Drowning

makakai

New Member
Reaction score
1
What is the best way to add a drowning effect to the game. So if a unit enters region water I want him to die after 60 seconds but if he leaves the area I don't want him to die. At the moment I've done this via expiration timer but I can only pause the timer and hence when you go back into the water area you will die quicker which I don't want to happen I just want the timer to reset

Any Ideas?

Below are my current triggers

Trigger:
  • Unit - A unit enters Water <gen>
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Drowning Equal to 1
      • Then - Actions
        • Unit - Unpause the expiration timer for (Entering unit)
      • Else - Actions
    • Unit - Add a 60.00 second Generic expiration timer to (Entering unit)


Trigger:
  • Unit - A unit leaves Water <gen>
    • Unit - Pause the expiration timer for (Leaving unit)
    • Set Drowning = 1


(I'm pretty new at World Editor :p)
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
if you add a new expiration timer to the unit the old one will be overwritten and thus it will start from its beginning again.
 

makakai

New Member
Reaction score
1
Trigger:
  • Enter Water
    • Events
      • Unit - A unit enters Water <gen>
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Drowning Equal to 1
        • Then - Actions
          • Unit - Add a 60.00 second Generic expiration timer to (Entering unit)
        • Else - Actions
      • Unit - Add a 60.00 second Generic expiration timer to (Entering unit)


Like that? Cause that doesn't work (assuming I still pause it when I leave the region) That keeps the timer paused as I enter but as I leave the expiration timer disappears (There is no blue left in the bar as if the timer has run out but nothing happens)
 

sylvannis mb

New Member
Reaction score
6
ok so ive made a set of triggers that work, but it may be more complicated than you want.
here they are:

first create a hashtable and save it
Trigger:
  • hash
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set hashtable = (Last created hashtable)


Then set the trigger for when the unit enters the water
Trigger:
  • drowning
    • Events
      • Unit - A unit enters Region 000 <gen>
    • Conditions
    • Actions
      • Unit Group - Add (Triggering unit) to drowning
      • Hashtable - Save 60 as (Key (Triggering unit)) of 1 in hashtable


Then create a trigger for if the unit leaves the water
Trigger:
  • not drowning
    • Events
      • Unit - A unit leaves Region 000 <gen>
    • Conditions
    • Actions
      • Unit Group - Remove (Triggering unit) from drowning


Finally, create a trigger to lower the timer, and kill the unit when the timer reaches 0
Trigger:
  • drowning 2
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in drowning and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load (Key (Picked unit)) of 1 from hashtable) Greater than 0
            • Then - Actions
              • Hashtable - Save ((Load (Key (Picked unit)) of 1 from hashtable) - 1) as (Key (Picked unit)) of 1 in hashtable
            • Else - Actions
              • Unit - Kill (Picked unit)


hope this helps :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top