Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
Like the title says. Trying to make it so that if someone picks up an item, no one else can pick that item up if they drop it or try to give it to someone else.
A hashtable storing the owner of the item will be simplest here. You read from the table and if it doesn't match the player stored there make the unit drop the item.
Hashtable - Create a new hashtable
Set ItemHash = (Last created hashtable)
-------- do that in an init trigger --------
Events
Unit - A unit acquires an item
Conditions
((Item-type of (Item being manipulated)) is A powerup) Equal to False //tomes don't matter since they get used when picked up
Actions
Set TempItem = (Item being manipulated)
Set OwnPlayer = (Load Key("owner") of Key(TempItem) in ItemHash)
If (All conditions are true) then do (Then actions) else do (Else actions)
If - Conditions
OwnPlayer equal to (Picked Player)
-------- a note about the above line: Picked Player does NOT exist here and I'm not using it to mean "Picked Player". The hashtable load function will return a null player if the item has no owner, but for some godforsaken reason Blizzard doesn't allow us to compare if a player variable is = no player (null) like you can with units or items. --------
-------- By using Picked Player in this way it will return null and we can compare to it. There is no player being picked. You could instead create a player variable and set it = null on map init and compare vs that. --------
Then - Actions
Hashtable - Save Handle of (Owner of (Triggering Unit)) as Key("owner") of Key(TempItem) in ItemHash
Skip remaining actions
Else - Actions
If (All conditions are true) then do (Then actions) else do (Else actions)
If - Conditions
OwnPlayer not equal to (Owner of (Triggering Unit)
Then - Actions
Hero - Drop TempItem from (Triggering Unit)
Else - Actions
It's not strictly necessary but it's probably nice to clear the hashtable of unnecessary data when items are destroyed/pawned/removed, so you can do that too:
Events
Unit - A unit pawns an item
-------- there are no generic item death events or remove events, but if you are doing these yourself then you know when it happens and can do what this trigger does then --------
Conditions
Actions
Hashtable - Flush all child hashtables of Key(Item being manipulated)
Had to change the hero - drop line to 'item being manipulated' rather than the TempItem variable, but other than that seems to work perfectly. Thanks +rep'd
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.