| 06-17-2006, 03:36 AM | #1 |
This is a short question, but is there a way to check what slot an item is in? |
| 06-17-2006, 03:45 AM | #2 |
oddly there isn't a built in function for it, but you can use my getitemslot function JASS:function GetItemSlot unit hero,item it returns integer local integer i=0 loop exitwhen i==6 if(UnitItemInSlot(hero,i)==it)then return i endif set i=i+1 endloop return -1 endfunction Set Hero=The Triggering Unit Set it=The manipulated item custom script: set udg_slot=GetItemSlot(udg_Hero,udg_it) if the number you get back is -1 then the unit doesn't have the item. |
| 06-17-2006, 03:55 AM | #3 |
Okay, I'm not good at JASS. How does this run? And also this checks for a specific item? So I would changew it to the item (for example ratf) and then it would check if it has it in any slot? I dont quite understand this, as it is beyond my limited scope of JASS knowledge (which I am working on, and should speed up now that school is out). EDIT: Let me ask a real question. How would I make something that checks what slot an item is in when a unit manipulates one and then puts that item in a variable for that hero. What I'm atempting to do is make Set Items (Have 1 item: no extra effect Have 2 items: +3 whatever Have 3 items: +7 something Have all 4: +9 blabla). What my idea was I would check all the slots when a hero gets an item and check if the hero has all the items. Looking back, this doesnt make much sense. Is there a better way to do that? |
| 06-17-2006, 11:12 AM | #4 |
Yes there actually is: Whenever the hero/unit picks up an item check if it is one of your defined ones, store the number (how many items of that) somewhere and update depending on that number which/how many boni the hero gets. The same when dropped. |
| 06-17-2006, 11:47 AM | #5 |
It appears that you are actually looking for item types, not specific instances of an item. JASS:function UnitHasItemType unit hero, integer id returns boolean local integer i = 0 local boolean b = false loop exitwhen i == 6 or b set b = GetUnitTypeId(UnitItemInSlot(hero,i)) == id set i = i + 1 endloop return b endfunction |
