• 🏆 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!

Make units drop random items upon death using trigger?

Status
Not open for further replies.
Level 3
Joined
Jan 29, 2017
Messages
29
So I created a respawn spots for neutral hostiles units in my map for every 1 minute using trigger, but after 30 minutes of game time I want them to start dropping random items (Tome of Strength, or Agility or Intelligence)

Does anyone can help me how to do that?

EDIT: I can figured out how to drop the items randomly, the thing is I can't make the trigger to only drop the items after 30 minutes. I tried to set events like "Elapsed game time is 1800 seconds" (30 minutes), and then I add "a unit dies" events. But it doesn't works
 
Last edited:
Level 20
Joined
Feb 23, 2014
Messages
1,264
First you set your desired item types at map initialization:

  • Actions
    • Set ItemType[0] = <your item type> <- variable: Item Type, array
    • Set ItemType[1] = <your item type>
    • Set ItemType[2] = <your item type>
    • Set ItemType[3] = <your item type>
    • Set ItemType[4] = <your item type>

Then you do this to drop the items; this trigger should have the box "Initially On" ticked off (should be turned off):

  • Item Dropping Trigger
    • Events
      • Unit - A unit Dies
    • Conditions
      • <any unit conditions that you might have>
    • Actions
      • Set TempPoint = (Position of (Triggering unit))
      • Item - Create ItemType[(Random integer number between 0 and 4)] at TempPoint <- the maximum integer value must be equal to your highest array index (4 in my example above)
      • Custom script: call RemoveLocation(udg_TempPoint)

You enable the trigger above with this:

  • Timer Trigger
    • Events
      • Time - Elapsed game time is 1800.00 seconds
    • Conditions
    • Actions
      • Trigger - Turn on Item Dropping Trigger <gen>

I didn't see your triggers, but I think the most likely reason why it didn't work for you is that you put the time elapsed event in the trigger that drops the items. The problem with that is that a trigger doesn't need all of its events to be true in order to fire - if you have a trigger that has 10 events, any of them will run the trigger. Thus, if you put the time elapsed event inside the item dropping trigger then that's the reason it didn't work.
 
Last edited:
Level 3
Joined
Jan 29, 2017
Messages
29
First you set your desired item types at map initialization:

  • Actions
    • Set ItemType[0] = <your item type> <- variable: Item Type, array
    • Set ItemType[1] = <your item type>
    • Set ItemType[2] = <your item type>
    • Set ItemType[3] = <your item type>
    • Set ItemType[4] = <your item type>

Then you do this to drop the items; this trigger should have the box "Initially On" ticked off (should be turned off):

  • Item Dropping Trigger
    • Events
      • Unit - A unit Dies
    • Conditions
      • <any unit conditions that you might have>
    • Actions
      • Set TempPoint = (Position of (Triggering unit))
      • Item - Create ItemType[(Random integer number between 0 and 4)] at TempPoint <- the maximum integer value must be equal to your highest array index (4 in my example above)
      • Custom script: call RemoveLocation(udg_TempPoint)

You enable the trigger above with this:

  • Timer Trigger
    • Events
      • Time - Elapsed game time is 1800.00 seconds
    • Conditions
    • Actions
      • Trigger - Turn on Item Dropping Trigger <gen>

I didn't see your triggers, but I think the most likely reason why it didn't work for you is that you put the time elapsed event in the trigger that drops the items. The problem with that is that a trigger doesn't need all of its events to be true in order to fire - if you have a trigger that has 10 events, any of them will run the trigger. Thus, if you put the time elapsed event inside the item dropping trigger then that's the reason it didn't work.
Thanks dude! it worked like a charm :)
 
Status
Not open for further replies.
Top