• 🏆 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 Rot?

Status
Not open for further replies.
Level 8
Joined
Dec 9, 2009
Messages
397
I would like items that are left on the field to rot after 5 mins after it dropped or was last touched by a player. I know there are item rot systems out there, but I can't find any triggers that would let me count time on a per item basis that sill lets me cancel it if it's touched.

I am using triggers and don't know Jass.

Any info would be great.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Something like this:

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Item_Hash = (Last created hashtable)
This trigger creates hashtable for item data.

  • Untitled Trigger 025
    • Events
      • Unit - A unit Loses an item
    • Conditions
    • Actions
      • Hashtable - Save 10 as (Key timer) of (Key (Item being manipulated)) in Item_Hash
      • Hashtable - Save True as (Key decaying) of (Key (Item being manipulated)) in Item_Hash
This trigger enables decaying when item is dropped by a hero and saves 10 (time in seconds) that it takes for the items to "decay". If you create items, save the values for created items.

  • Untitled Trigger 026
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Hashtable - Save False as (Key decaying) of (Key (Item being manipulated)) in Item_Hash
Item is picked up, save "false" so it can't get removed.

  • Untitled Trigger 028
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Item - Pick every item in (Playable map area) and do (Actions)
        • Loop - Actions
          • Set Temp_Integer_1 = (Load (Key timer) of (Key (Picked item)) from Item_Hash)
          • Set Temp_Boolean_1 = (Load (Key decaying) of (Key (Picked item)) from Item_Hash)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Temp_Integer_1 Equal to 0
              • Temp_Boolean_1 Equal to True
            • Then - Actions
              • Hashtable - Clear all child hashtables of child (Key (Picked item)) in Item_Hash
              • Item - Remove (Picked item)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Temp_Integer_1 Greater than 0
                  • Temp_Boolean_1 Equal to True
                • Then - Actions
                  • Hashtable - Save (Temp_Integer_1 - 1) as (Key timer) of (Key (Picked item)) in Item_Hash
                • Else - Actions
This trigger runs the timer for items and removes them if the timer hits zero.
 
Level 8
Joined
Dec 9, 2009
Messages
397
I'm trying to test it out, but I can't figure out how to get the
(Key (Item being manipulated))
into my trigger out of
  • Hashtable - Save 10 as (Key timer) of (Key (Item being manipulated)) in Item_Hash
This is the closest I can get.
  • Hashtable - Save 10.00 as (Key timer) of (Key (Name of (Item being manipulated))) in (Last created hashtable)
But this would reset the timer for all items of that name.

Did you use Save intiger? real? or something else?

With your triggers will the hashtable have 1 value for each item even if 2 items have the same name?

Thanks for helping.
 
Level 3
Joined
Apr 29, 2009
Messages
32
It's at Handle ID ' Event Response - Item being Manipulated ' Note: It's below the other Event Response's.
 
I'm trying to test it out, but I can't figure out how to get the
(Key (Item being manipulated))
into my trigger out of
  • Hashtable - Save 10 as (Key timer) of (Key (Item being manipulated)) in Item_Hash
This is the closest I can get.
  • Hashtable - Save 10.00 as (Key timer) of (Key (Name of (Item being manipulated))) in (Last created hashtable)
But this would reset the timer for all items of that name.

Did you use Save intiger? real? or something else?

With your triggers will the hashtable have 1 value for each item even if 2 items have the same name?

Thanks for helping.

if you're using JNGP I don't think you can set Key(Item being manipulated) in GUI... but if you're using normal WE you shouldn't have any problems with that part....
 
Level 8
Joined
Dec 9, 2009
Messages
397
I am using JNGP.... I thought that was better.

I also noticed other triggers on here that I couldn't make exactly the same, should I go back to just WE?
 
Level 8
Joined
Dec 9, 2009
Messages
397
Well I'm using JNGP because I want to use this system in my map and it requires JNGP :/

Though I did figure out a way to make it work without hashtables.


  • Item Rot Run
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • Item - Pick every item in (Entire map) and do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Custom value of (Picked item)) Greater than (>) 1
            • Then - Actions
              • Item - Set the custom value of (Picked item) to ((Custom value of (Picked item)) - 1)
            • Else - Actions
              • Do nothing
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Custom value of (Picked item)) Equal to (==) 1
            • Then - Actions
              • Item - Remove (Picked item)
            • Else - Actions
              • Do nothing
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Custom value of (Picked item)) Equal to (==) 0
            • Then - Actions
              • Item - Set the custom value of (Picked item) to 10
            • Else - Actions
              • Do nothing
  • Pickup
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Item - Set the custom value of (Item being manipulated) to 10
Thanks for the info guys.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
I always try to avoid using custom values. Using them may clash with other systems.

Anyway, your first trigger should be like this:

  • Untitled Trigger 026
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • Item - Pick every item in (Entire map) 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 1
            • Then - Actions
              • Item - Set the custom value of (Picked item) to ((Custom value of (Picked item)) - 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Custom value of (Picked item)) Equal to 1
                • Then - Actions
                  • Item - Remove (Picked item)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Custom value of (Picked item)) Equal to 0
                    • Then - Actions
                      • Item - Set the custom value of (Picked item) to 10
                    • Else - Actions
 
Status
Not open for further replies.
Top