Over Time Item Removal

Level 6
Joined
May 1, 2009
Messages
156
Request: Add on to current trigger to make it so if the item is picked back up before the expiration timer runs out the timer stops and the trigger starts over once the meat is dropped again.

I've had problems before with this trigger and now I'm seeing if you drop the item "Meat" and pick it up again, the item will still disappear after the generic timer runs out.

The idea behind this trigger is 'meat becoming moldy'... if you set it down for over, in this case, 30 seconds it disappears as in becomes moldy and inedible. So if you pick the meat back up before 30 seconds it does not get removed.

  • ID Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set IDhashtable = (Last created hashtable)
  • ID A
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Meat
    • Actions
      • Set IDpoint1 = (Position of (Item being manipulated))
      • Unit - Create 1 Dummy for Neutral Passive at IDpoint1 facing Default building facing degrees
      • Unit - Add a 5.00 second Generic expiration timer to (Last created unit)
      • Hashtable - Save Handle Of(Item being manipulated) as (Key item) of (Key (Last created unit)) in IDhashtable
      • Hashtable - Save Handle Of(Last created unit) as (Key unit) of (Key (Item being manipulated)) in IDhashtable
      • Custom script: call RemoveLocation (udg_IDpoint1)
  • ID B
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Dummy
      • ((Key item) is stored as a Handle of (Key (Triggering unit)) in IDhashtable) Equal to True
    • Actions
      • Hashtable - Clear all child hashtables of child (Key (Load (Key item) of (Key (Triggering unit)) in IDhashtable)) in IDhashtable
      • Item - Remove (Load (Key item) of (Key (Triggering unit)) in IDhashtable)
      • Hashtable - Clear all child hashtables of child (Key (Triggering unit)) in IDhashtable
 
Level 6
Joined
May 1, 2009
Messages
156
But its not just for one single item, there are multiple items, "Meat" that are dropped and picked up that must be accounted for.
 
Yes, AlienAtSystem made his point. You need this:
  • Trigger
  • Events
    • Unit - A unit acquires an item
  • Conditions
    • (Load Key(unit) is stored as a Handle of (Key(Item being manipulated)) from IDHashtable) Equal to True
  • Actions
    • Unit - Remove (Load (Key(unit)) of (Key(Item being manipulated)) from IDHashtable)
DO NOT use Unit - Kill unit, because the timer is based on that unit's death, so, if you kill the unit, the item will eventually disappear, by the time you pick it up back. Unit - Remove unit will help you avoid this issue.
 
Level 6
Joined
May 1, 2009
Messages
156
Thank you all three, I would like to try your trigger Pharaoh but I don't use hashtables, I can't imitate your condition. Also, '(load (Key(unit)'... is it a string 'Unit' or something else? I just don't see why it's a string if it is.
 
Level 6
Joined
May 1, 2009
Messages
156
Ok Pharaoh you get helper of the year for requests, since I have you here and since you made every part of this trigger what's wrong with this added part that is supposed to remove the item "Meat" after the item is created at the position of the dying unit of the animals you're hunting.

  • ID Ab Implementing
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Dying unit)) Equal to Neutral Passive
    • Actions
      • Set IDpoint2 = (Position of (Last created item))
      • Unit - Create 1 Dummy for Neutral Passive at IDpoint2 facing Default building facing degrees
      • Unit - Add a 30.00 second Generic expiration timer to (Last created unit)
      • Hashtable - Save Handle Of(Item being manipulated) as (Key item) of (Key (Last created unit)) in IDhashtable
      • Hashtable - Save Handle Of(Last created unit) as (Key unit) of (Key (Item being manipulated)) in IDhashtable
      • Custom script: call RemoveLocation (udg_IDpoint2)
 
  • Set IDpoint2 = (Position of (Last created item))
That line should be in a trigger that has the action Item - Create Item or Hero - Create Item and give it to Hero. Did you mean (Position of (Triggering unit))?

  • Hashtable - Save Handle Of(Item being manipulated) as (Key item) of (Key (Last created unit)) in IDhashtable
That line should be in a trigger with an event "Unit - A unit uses/acquires/loses an item". Since you have no event like this, the reference will return null. What do you need this trigger for? I thought this part was done.
 
Level 6
Joined
May 1, 2009
Messages
156
I told you when i brought this up earlier it did funky things, if you read 'the idea' behind this trigger in the first post you see what I'm trying to do. Basically meat rots on the ground after 60 seconds so it doesn't matter if you drop it and its on the ground for 60 seconds or if it's on the ground after being created from a dead animal.

Remove meat if its dropped and on ground after 60 seconds... done.

Remove meat created at spot of dying animal on ground after 60 seconds... problem.
 
Top