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

[General] How to make damage and healing detection system?

Status
Not open for further replies.
I wondered how to do this and I invented a way, but I'm not sure what complications might happen. Now it's just a theory, that's why I'm asking you, if you know what would be the most intuative way to do this. Opinions?


every 0.10 secs set cur_Hp[1] of hero_units[1] to Current HP
every 0.10 secs set cur_Hp[2] of hero_units[2] to Current HP
every 0.10 secs set cur_Hp[3] of hero_units[3] to Current HP
every 0.10 secs set cur_Hp[4] of hero_units[4] to Current HP

unit is attacked

attacked unit equal to hero units[1]
attacked unit equal to hero units[2]
attacked unit equal to hero units[3]
attacked unit equal to hero units[4]
--------------------------------------------------
if current hp of hero_units[owner of attacked unit] < cur_hp[owner of attacked unit] then
set resultHP = cur_hp[owner of attacked unit] - current hp of hero_units[owner of attacked unit]
display floating text above attacked unit "-resulthp[owner of attacked unit]"
--------------------------------------------------
if crrent hp of hero_units[owner of attacked unit] > cur_hp[owner of attacked unit] then
set resultHP = cur_hp[owner of attacked unit] - current hp of hero_units[owner of attacked unit]
display floating text above attacked unit "+resulthp[owner of attacked unit]"

--------------------------------------------------
 
I know there is such sytems, but I want to invent my own before looking at them :D

  • Floating Text
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Life of Hero_units[(Integer A)]) Less than CurHP[(Integer A)]
            • Then - Actions
              • Set CurHP[(Integer A)] = (CurHP[(Integer A)] - (Life of Hero_units[(Integer A)]))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CurHP[(Integer A)] Not equal to 0.00
                • Then - Actions
                  • Set CurHPConverted[(Integer A)] = (Integer(CurHP[(Integer A)]))
                  • Floating Text - Create floating text that reads (- + (String(CurHPConverted[(Integer A)]))) above Hero_units[(Integer A)] with Z offset 50.00, using font size 10.00, color (0.00%, 100.00%, 100.00%), and 0.00% transparency
                  • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
                  • Floating Text - Change the fading age of (Last created floating text) to 0.00 seconds
                  • Floating Text - Change the lifespan of (Last created floating text) to 1.00 seconds
                  • Floating Text - Change (Last created floating text): Disable permanence
                  • Set CurHP[(Integer A)] = (Life of Hero_units[(Integer A)])
                • Else - Actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Life of Hero_units[(Integer A)]) Greater than CurHP[(Integer A)]
            • Then - Actions
              • Set CurHP[(Integer A)] = (CurHP[(Integer A)] - (Life of Hero_units[(Integer A)]))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CurHP[(Integer A)] Not equal to 0.00
                • Then - Actions
                  • Set CurHPConverted[(Integer A)] = (Integer(CurHP[(Integer A)]))
                  • Floating Text - Create floating text that reads (+ + (String(CurHPConverted[(Integer A)]))) above Hero_units[(Integer A)] with Z offset 50.00, using font size 10.00, color (32.00%, 100.00%, 0.00%), and 0.00% transparency
                  • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
                  • Floating Text - Change the fading age of (Last created floating text) to 0.00 seconds
                  • Floating Text - Change the lifespan of (Last created floating text) to 1.00 seconds
                  • Floating Text - Change (Last created floating text): Disable permanence
                  • Set CurHP[(Integer A)] = (Life of Hero_units[(Integer A)])
                • Else - Actions
            • Else - Actions
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
First of all, don't base it on a periodic event. Don't loop through units.

The best known way is to detect when damage is done to any unit of interest or when a healing ability is cast.
If you really desperately need to detect healing done by object editor abilities, then you can run a periodic trigger for a little time whenever a chain heal spell is cast.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
You can use "units life event", ->"unit life becomes greater than equal to 0" etc.It doesn't have "Any units life becomes" event just like damage event.
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
Almost all kinds of damage can be detected with the "Unit takes damage" event. This doesn't require a loop.
I think the only exception was disease cloud.

I guess me or someone else should trigger all the normal object editor spells. This would get people to use proper damage detection systems, instead of trying to mess around with object editor and hoping it works.
 
Status
Not open for further replies.
Top