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

Losing HP

Status
Not open for further replies.
Level 1
Joined
Jan 15, 2013
Messages
61
Hi guys i'm making a map right now and i got some diffculties. How to make for example a unit lose 10 hp/sec if he enters a lava tileset and if he leaves it to stop losing hp. Thx in advance + rep for help
 
Level 23
Joined
Oct 20, 2012
Messages
3,075
There's a terrain type condition. You can use that.

  • DPS
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain type at (Position of (Picked unit))) Equal to Underground - Lava
            • Then - Actions
              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - 100.00)
            • Else - Actions
BTW, I didn't remove the leaks there coz I assume you know how to do that already. (But here's a tut to clear leaks just in case: Things That Leak)
 
I think the leak is the group, use this to clear them :

Before the pick every unit :
  • Set Temp_Group = unit in playable map area
And end them after the damage with :
  • Custom Script : call DestroyGroup(udg_Temp_Group)
Also, I notice point leaks as well.
After the group picked, use this before If/Then/Else action :
  • Set Temp_Point = position of Pocked Unit
After the damage and group removed via the custom script, remove the point with this :
  • Custom Script : call RemoveLocation(udg_Temp_Point)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I would rather make a region with all the lava places in it, and detect when a unit enters, add to a group and start the loop. Detect when leaves, and remove from group, check the units in group, if 0, stop the loop.
 
Status
Not open for further replies.
Top