• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Giving items to units from array

Status
Not open for further replies.
Level 1
Joined
Jan 26, 2010
Messages
2
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.
Top