I want some items in my map to be upgradeable. Since I was not able to find a decend data editor solution, I decided to write a small script for this. Basically, I am adding all upgradeable items to a database and replace them, when they are used.
Everything works fine so far, except one thing: I am not able to remove one item and fill its slot instantly with another item.
I have only one item slot for most item types; causing the upgraded version to never be created, when the slot is still filled with the old item. This forces me to add a wait to the function, which I really would like to see being removed.
The relevant function:
boolItemUpgrade(boola,boolb){//trigger reaction, needs the parameters and the boolean returnunitcaster=EventUnit();unitu=EventUnitInventoryItem();stringid=UnitGetType(u);strings;intslot;intcont;if(ItemIsUpgradeable(id)){slot=EventUnitInventoryItemSlot();cont=EventUnitInventoryItemContainer();i=StringLength(id);s=StringSub(id,1,i-1)+IntToString(StringToInt(StringSub(id,i,i))+1);//determines the id of my next item, //all upgradeable items have consecutive ids, like BootsOfSpeed1, BootsOfSpeed2 etc...UnitRemove(u);Wait(.5,0);//this sucksu=UnitInventoryCreate(caster,s);UnitInventoryMove(u,cont,slot);}returntrue;}
Everything works, the correct item is created, but without the wait, it does not show up. Note that the wait needs to be at least about 0.5 seconds, a 0 wait and even a 0.125 wait did not work.
Any solution for this? Data would be fine as well, as long as it works properly.
The trigger reaction works. Reaction time is fine (at least in singleplayer), but I cannot access the ID of the removed item in the hero loses item trigger. So I need to store it somehow; and I doubt I can simpy use a temp global for this, since there definitely still is some delay. Its never easy -.-
Does something like a "Drop item"- function exist? This would make things much easier.
€ will try moving the item, I guess.
€€ Manually dropping the item works just fine. But there seems to be no way of dropping an item out of an inventory other than killing the item. I tried so far:
UnitKill(u);//makes information unavailable in drop reaction triggerUnitRemove(u);//same hereUnitSetPosition(u,Point(0,0),false);//no effectlibNtve_gf_ShowHideUnit(u,false);//no effectUnitInventoryMove(u,0,0);//no effect
I even tried increasing the death time, but the Unit loses Item trigger does not trigger, when the item dies, but only, when it gets removed. I guess, I need to attach the data to the trigger then -.-
I have done items b4 and I still don't understand them very well. But, I do know that a possible solution could be that (if your item already has a model being used for it (I guess it doesn't matter but whatever)) if you take the item and actually put the old item in a spot where the player can't get to it on the map. All you'd have to do is set up a trigger that moves the item to the spot you chose. If there is no triggere for that then you have to do it the complicated way. You would have to make a trigger that registers what the item is, then it removes the item and creates a new one in that area. Hope that helps. :D
I have done items b4 and I still don't understand them very well. But, I do know that a possible solution could be that (if your item already has a model being used for it (I guess it doesn't matter but whatever)) if you take the item and actually put the old item in a spot where the player can't get to it on the map. All you'd have to do is set up a trigger that moves the item to the spot you chose. If there is no triggere for that then you have to do it the complicated way. You would have to make a trigger that registers what the item is, then it removes the item and creates a new one in that area. Hope that helps. :D
Not really, sorry. Moving the item has no effect, it stays in the inventory, and creating a new one would still have the same issue, how to transfer the data to the reaction trigger.
I used a global now for testing purposes to store the id of the killed item and it works just fine. Needs some more tests; I doubt it is foolproof, maybe it can be abused by upgrading multiple items at once, since there seems to be a slight delay between the removal of the item and the reaction of the trigger.
In case someone is interested, here my current function:
Well, in case it becomes an issue, I can always make a stack or attach the data to the trigger (in case that is possible, is there something like GetHandleId from Warcraft 3?)
Well, in case it becomes an issue, I can always make a stack or attach the data to the trigger (in case that is possible, is there something like GetHandleId from Warcraft 3?)
UnitGetPropertyInt(unit, 24);
Something like that ... UnitGetProperty only has 24 indexes (0..23) and the 24th index (and everything above) returns a unique unit ID (which is always a multiple of 64 I think). So you can kinda do it.
Also.. maybe you can dublicate the item you want dropped at the hero's feet and then remove the old item?
UnitGetPropertyInt(unit, 24);
Something like that ... UnitGetProperty only has 24 indexes (0..23) and the 24th index (and everything above) returns a unique unit ID (which is always a multiple of 64 I think). So you can kinda do it.
I need such an ID for a trigger, since multiple upgrades simultaneously would probably be possible on the same unit. Still, a stack would work as well; a unique trigger id would be easier, though.
Quote:
Also.. maybe you can dublicate the item you want dropped at the hero's feet and then remove the old item?
I do not want the item to be actually dropped, I just want it to trigger the drop event without destroying it instantly, so I have access to the dropped item's unit type in the drop reaction trigger without having to store it externally.
I didnt even look at the script, but I'm not sure if you know you can find items by searching for units of type "item" within 0.1 radius of the unit holding the items. OneTwo did a hero revive tutorial that included stuff about the items, and that might be helpful.
Rollback Post to RevisionRollBack
Feel free to Send me a PM if you have any questions/concerns!
Yes, you can (and should probably) even use 0.0, if the items are properly set up.
However this does not help me; I do not need to detect a normal dropped item, I need to either drop an item without killing it or detect the type of a killed item, after it was auto-dropped because of the kill.
Whatever, my current solution somewhat works anyway; these would be just improvements. Thanks for the help, though.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hey
I want some items in my map to be upgradeable. Since I was not able to find a decend data editor solution, I decided to write a small script for this. Basically, I am adding all upgradeable items to a database and replace them, when they are used.
Everything works fine so far, except one thing: I am not able to remove one item and fill its slot instantly with another item.
I have only one item slot for most item types; causing the upgraded version to never be created, when the slot is still filled with the old item. This forces me to add a wait to the function, which I really would like to see being removed.
The relevant function:
Everything works, the correct item is created, but without the wait, it does not show up. Note that the wait needs to be at least about 0.5 seconds, a 0 wait and even a 0.125 wait did not work.
Any solution for this? Data would be fine as well, as long as it works properly.
I've never worked with Blizzard's item system so I'm not much of a help here.
Just.. is there maybe an event that fires when your hero loses an item? If there is you can use that to circumvent the wait.
Worth a shot, I'll try this out later when I have some time.
The trigger reaction works. Reaction time is fine (at least in singleplayer), but I cannot access the ID of the removed item in the hero loses item trigger. So I need to store it somehow; and I doubt I can simpy use a temp global for this, since there definitely still is some delay. Its never easy -.-
Does something like a "Drop item"- function exist? This would make things much easier.
€ will try moving the item, I guess.
€€ Manually dropping the item works just fine. But there seems to be no way of dropping an item out of an inventory other than killing the item. I tried so far:
I even tried increasing the death time, but the Unit loses Item trigger does not trigger, when the item dies, but only, when it gets removed. I guess, I need to attach the data to the trigger then -.-
I have done items b4 and I still don't understand them very well. But, I do know that a possible solution could be that (if your item already has a model being used for it (I guess it doesn't matter but whatever)) if you take the item and actually put the old item in a spot where the player can't get to it on the map. All you'd have to do is set up a trigger that moves the item to the spot you chose. If there is no triggere for that then you have to do it the complicated way. You would have to make a trigger that registers what the item is, then it removes the item and creates a new one in that area. Hope that helps. :D
Not really, sorry. Moving the item has no effect, it stays in the inventory, and creating a new one would still have the same issue, how to transfer the data to the reaction trigger.
I used a global now for testing purposes to store the id of the killed item and it works just fine. Needs some more tests; I doubt it is foolproof, maybe it can be abused by upgrading multiple items at once, since there seems to be a slight delay between the removal of the item and the reaction of the trigger.
In case someone is interested, here my current function:
Well, in case it becomes an issue, I can always make a stack or attach the data to the trigger (in case that is possible, is there something like GetHandleId from Warcraft 3?)
UnitGetPropertyInt(unit, 24);
Something like that ... UnitGetProperty only has 24 indexes (0..23) and the 24th index (and everything above) returns a unique unit ID (which is always a multiple of 64 I think). So you can kinda do it.
Also.. maybe you can dublicate the item you want dropped at the hero's feet and then remove the old item?
I need such an ID for a trigger, since multiple upgrades simultaneously would probably be possible on the same unit. Still, a stack would work as well; a unique trigger id would be easier, though.
I do not want the item to be actually dropped, I just want it to trigger the drop event without destroying it instantly, so I have access to the dropped item's unit type in the drop reaction trigger without having to store it externally.
I didnt even look at the script, but I'm not sure if you know you can find items by searching for units of type "item" within 0.1 radius of the unit holding the items. OneTwo did a hero revive tutorial that included stuff about the items, and that might be helpful.
Yes, you can (and should probably) even use 0.0, if the items are properly set up.
However this does not help me; I do not need to detect a normal dropped item, I need to either drop an item without killing it or detect the type of a killed item, after it was auto-dropped because of the kill.
Whatever, my current solution somewhat works anyway; these would be just improvements. Thanks for the help, though.