• Check out the results of the Techtree Contest #19!
  • 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!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Giving items to units from array

Status
Not open for further replies.

jozelino

J

jozelino

Hey
I made a small test map with 2 peasants. I gave them inventory and added 1 small shop with 1 item in it. I wanted that each time a unit picks an item or drops 1, all of its items will be added to an item array. It did a lot of problems so i changed it to save the item's type.
When I pick 1 item it does save it and gives it back to my peasant but when I have 2 items it sometimes doesn't. Before I added a small wait between each time I set an item in the array, it never saved 2 items. (Why?)
Anyway, there are many weird problems like items spawning on a corpse or disappearing / duplicating.
I tried solving this for 3 hours and had no success.

This is what supposed to set the item types in the array:


ItemsActions
Events
Unit - A unit owned by Player 1 (Red) Acquires an item
Unit - A unit owned by Player 1 (Red) Loses an item
Conditions
Actions
Set redItems[0] = (Item-type of (Item carried by (Triggering unit) in slot 1))
Wait 0.10 seconds
Set redItems[1] = (Item-type of (Item carried by (Triggering unit) in slot 2))
Wait 0.10 seconds
Set redItems[2] = (Item-type of (Item carried by (Triggering unit) in slot 3))
Wait 0.10 seconds
Set redItems[3] = (Item-type of (Item carried by (Triggering unit) in slot 4))
Wait 0.10 seconds
Set redItems[4] = (Item-type of (Item carried by (Triggering unit) in slot 5))
Wait 0.10 seconds
Set redItems[5] = (Item-type of (Item carried by (Triggering unit) in slot 6))



this is the respawn trigger:


Respawn
Events
Unit - A unit Dies
Conditions
((Triggering unit) is in (Units of type Weak Peasant)) Equal to True
Actions
Player - Set (Owner of (Killing unit)) Current gold to (((Owner of (Killing unit)) Current gold) + 1)
Wait 2.00 seconds
Unit - Create 1 (Unit-type of (Triggering unit)) for (Owner of (Triggering unit)) at ((Owner of (Triggering unit)) start location) facing Default building facing degrees
Camera - Pan camera for (Owner of (Triggering unit)) to ((Owner of (Triggering unit)) start location) over 1.00 seconds
Special Effect - Create a special effect at ((Owner of (Triggering unit)) start location) using Objects\Spawnmodels\Undead\UDeathMedium\UDeath.mdl
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Triggering unit)) Equal to Player 1 (Red)
Then - Actions
Hero - Create redItems[0] and give it to (Random unit from (Units owned by Player 1 (Red) matching (((Matching unit) is alive) Equal to True)))
Hero - Create redItems[1] and give it to (Random unit from (Units owned by Player 1 (Red) matching (((Matching unit) is alive) Equal to True)))
Hero - Create redItems[2] and give it to (Random unit from (Units owned by Player 1 (Red) matching (((Matching unit) is alive) Equal to True)))
Hero - Create redItems[3] and give it to (Random unit from (Units owned by Player 1 (Red) matching (((Matching unit) is alive) Equal to True)))
Hero - Create redItems[4] and give it to (Random unit from (Units owned by Player 1 (Red) matching (((Matching unit) is alive) Equal to True)))
Hero - Create redItems[5] and give it to (Random unit from (Units owned by Player 1 (Red) matching (((Matching unit) is alive) Equal to True)))
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Triggering unit)) Equal to Player 2 (Blue)
Then - Actions
Do nothing
Else - Actions
Do nothing



Note: Only done for red player by now.


It's really hard to explain all of the weird stuff happening so I'll also add the map - try to drop items, buy items, get killed, change items slots and such.



Thanks very much to anyone who would help.


PS. The 1 gold bounty I set on the peasant didn't work so I had to make a trigger...

http://www.2shared.com/file/10917957/f62a9843/respawntest.html

I just noticed that I shouldn't have put a prefix.. How do I remove it?
 
Status
Not open for further replies.
Back
Top