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

Unit's hp regen per second?

Status
Not open for further replies.
Level 16
Joined
Mar 27, 2011
Messages
1,349
I don't think so. You'd need to do the maths yourself I suppose. Something like this:

Base HP regen + (Strength Amount x (HP regen per strength stat)) + Items + Abilities

This could be complicated to work out depending on items and abilities/aura that affect HP regen.

There is an easy but dodgy way of automatically calculating Hp regen, but it wouldn't work under most circumstances. Here's the code:

  • Regen Amount
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Life of HpRegenTestUnit) Equal to (Max life of HpRegenTestUnit)
        • Then - Actions
          • Game - Display to (All players) for 1.00 seconds the text: Cannot caluclate HP...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • HasInitialHpBeenSet Equal to False
            • Then - Actions
              • Set HpRegenAmount = (Life of HpRegenTestUnit)
              • Set HasInitialHpBeenSet = True
            • Else - Actions
              • Set HpRegenAmount = ((Life of HpRegenTestUnit) - HpRegenAmount)
              • Game - Display to (All players) for 1.00 seconds the text: (HpRegenAmount: + (String(HpRegenAmount)))
              • -------- reset --------
              • Set HpRegenAmount = (Life of HpRegenTestUnit)
HpRegenTestUnit - The unit your testing
HpRegenAmount - A real. This value calculates Hp Regen Rate. You'd need to save this into a separate variable before it's reset
HasInititalHpBeenSet - A boolean.

This would only work if the unit has lost more life than what he regenerates per second and the value takes 1 second to update meaning it wouldn't work in real time scenarios. Maybe someone else could suggest a better way. Why do you need to know a unit's HP regenation rate?
 
Level 14
Joined
Nov 30, 2013
Messages
926
I don't think so. You'd need to do the maths yourself I suppose. Something like this:

Base HP regen + (Strength Amount x (HP regen per strength stat)) + Items + Abilities

This could be complicated to work out depending on items and abilities/aura that affect HP regen.

There is an easy but dodgy way of automatically calculating Hp regen, but it wouldn't work under most circumstances. Here's the code:

  • Regen Amount
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Life of HpRegenTestUnit) Equal to (Max life of HpRegenTestUnit)
        • Then - Actions
          • Game - Display to (All players) for 1.00 seconds the text: Cannot caluclate HP...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • HasInitialHpBeenSet Equal to False
            • Then - Actions
              • Set HpRegenAmount = (Life of HpRegenTestUnit)
              • Set HasInitialHpBeenSet = True
            • Else - Actions
              • Set HpRegenAmount = ((Life of HpRegenTestUnit) - HpRegenAmount)
              • Game - Display to (All players) for 1.00 seconds the text: (HpRegenAmount: + (String(HpRegenAmount)))
              • -------- reset --------
              • Set HpRegenAmount = (Life of HpRegenTestUnit)
HpRegenTestUnit - The unit your testing
HpRegenAmount - A real. This value calculates Hp Regen Rate. You'd need to save this into a separate variable before it's reset
HasInititalHpBeenSet - A boolean.

This would only work if the unit has lost more life than what he regenerates per second and the value takes 1 second to update meaning it wouldn't work in real time scenarios. Maybe someone else could suggest a better way. Why do you need to know a unit's HP regenation rate?

Just using it for testing purposes. Thanks for helping me btw. :smile:
 
Status
Not open for further replies.
Top