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

Item Remove Trigger after create

Status
Not open for further replies.
Level 7
Joined
May 21, 2009
Messages
289
I'm Using the following trigger in my map, but I need the item to dissapear after a set amount of time (Example: 120 seconds (2 minutes)), but when I add "wait- 120 seconds" and then "remove- last created item" items that are created eventually disappear as soon as they are created:thumbs_down:!
Any ideas?

  • Item Drop low levels
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set itemdrop[1] = (1) Healing Vial
      • Set itemdrop[2] = (1) Mana Vial
      • Set itemdrop[3] = Wooden Sword
      • Set itemdrop[4] = Wooden Shield
  • Low Levels
    • Events
      • Unit - A unit owned by Neutral Hostile Dies
    • Conditions
      • (Level of (Dying unit)) Less than or equal to 6
    • Actions
      • Set point = (Position of (Dying unit))
      • Item - Create itemdrop[(Random integer number between 1 and 10)] at point
      • Custom script: call RemoveLocation(udg_point)
      • Item - Set the custom value of (Last created item) to 0
This is the simpliest form of the item drop triggers I have
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
I was thinking you could do it like this:

  • Untitled Trigger 010
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Item - Create Tome of Experience at (Random point in Region 004 <gen>)
      • Item - Set the custom value of (Last created item) to 1
  • Untitled Trigger 011
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Item - Pick every item in (Playable map area) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Custom value of (Picked item)) Greater than 0
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Custom value of (Picked item)) Less than 6
                • Then - Actions
                  • Item - Set the custom value of (Picked item) to ((Custom value of (Picked item)) + 1)
                • Else - Actions
                  • Item - Remove (Picked item)
            • Else - Actions
The first trigger creates items when you press ESC, it's just for testing purposes. What's important there is that you set the custom value to 1. All items that are created, or exist from the beginning have custom value of 0.

In the second trigger, we check the custom value. If it's greater than 0, then it's an item that is supposed to be removed after certain time.

In that example trigger, items get removed after 5 seconds.
 
Level 14
Joined
Aug 31, 2009
Messages
775
And of course, you can add onto that the Custom Value is changed when the item is picked up, and put back again when the item is dropped.

However, that would periodically remove every item on the map, so if you say wanted each item to have its own individual timer, then Hash Tables would need to be used.
 
Status
Not open for further replies.
Top