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

Enchantress "Nature Attendants" spell doesn't heal.

Level 14
Joined
Jul 19, 2007
Messages
772
I have imported Enchantress "Nature Attendants" spell from a Dota Spellpack and yes I have imported everything that is required for it and checked everything in the triggers but it seems like the spell doesn't work like it should even in the spellpack because the spirits doesn't heal anyone which it's supposed to do... What could be wrong?
  • Constantes Habilidades Enchantress
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet HealingWisp_Ability = Healing Spirits
  • Healing Wisps
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to HealingWisp_Ability
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HW_Enteros[1] Equal to 0
        • Then - Actions
          • Trigger - Turn on Healing Wisps Loop <gen>
        • Else - Actions
      • Set VariableSet HW_Enteros[1] = (HW_Enteros[1] + 1)
      • Set VariableSet HW_Enteros[2] = (HW_Enteros[2] + 1)
      • Set VariableSet HW_Caster[HW_Enteros[2]] = (Triggering unit)
      • Set VariableSet HW_Numero[HW_Enteros[2]] = (2 + (2 x (Level of (Ability being cast) for (Triggering unit))))
      • Set VariableSet HW_Duracion[HW_Enteros[2]] = 10.00
  • Healing Wisps Loop
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • For each (Integer HW_Enteros[3]) from 1 to HW_Enteros[2], do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • HW_Caster[HW_Enteros[3]] Not equal to No unit
            • Then - Actions
              • Set VariableSet HW_Duracion[HW_Enteros[3]] = (HW_Duracion[HW_Enteros[3]] - 0.04)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (HW_Duracion[HW_Enteros[3]] mod 1.00) Equal to 0.00
                • Then - Actions
                  • Set VariableSet Punto = (Position of HW_Caster[HW_Enteros[3]])
                  • For each (Integer A) from 1 to HW_Numero[HW_Enteros[3]], do (Actions)
                    • Loop - Actions
                      • Set VariableSet Grupo = (Units within 300.00 of Punto matching (((((Matching unit) is A structure) Equal to False) and ((Life of (Matching unit)) Less than (Max life of (Matching unit)))) and ((((Matching unit) is Mechanical) Equal to False) and (((Matching unit) belongs to an enemy
                      • Set VariableSet DummyHS = (Random unit from Grupo)
                      • Unit - Set life of DummyHS to ((Life of DummyHS) + 10.00)
                      • Custom script: call DestroyGroup(udg_Grupo)
                  • Custom script: call RemoveLocation(udg_Punto)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • HW_Duracion[HW_Enteros[3]] Less than or equal to 0.00
                • Then - Actions
                  • Set VariableSet HW_Caster[HW_Enteros[3]] = No unit
                  • Set VariableSet HW_Enteros[1] = (HW_Enteros[1] - 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • HW_Enteros[1] Equal to 0
                    • Then - Actions
                      • Set VariableSet HW_Enteros[2] = 0
                      • Trigger - Turn off (This trigger)
                    • Else - Actions
                • Else - Actions
            • Else - Actions
 
Level 20
Joined
Feb 27, 2019
Messages
593
I dont have enough math knowledge to comment on the problem but I was very confused with the math here. I was expecting that 2.00 modulo 1.0 would equal 0.00. That doesnt seem to be true in this case.

In Healing Wisps Loop change
  • (HW_Duracion[HW_Enteros[3]] mod 1.00) Equal to 0.00
to
  • (HW_Duracion[HW_Enteros[3]] mod 1.00) Equal to 0.04
 
Level 14
Joined
Jul 19, 2007
Messages
772
I dont have enough math knowledge to comment on the problem but I was very confused with the math here. I was expecting that 2.00 modulo 1.0 would equal 0.00. That doesnt seem to be true in this case.

In Healing Wisps Loop change
  • (HW_Duracion[HW_Enteros[3]] mod 1.00) Equal to 0.00
to
  • (HW_Duracion[HW_Enteros[3]] mod 1.00) Equal to 0.04
And that solved the problem. Thank you!
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,567
Checking for the exact value of a Real is just asking for trouble. There's an issue when applying Arithmetic to these Reals which causes them to lose an extremely small fraction of precision. It doesn't always happen right away but it seems like after a few times the problem starts to occur. For example, a Real that you'd expect to be equal to 10.00 could actually be equal to 9.99999. So when you check "is my variable equal to 0.04" it'll return False even though the calculations seem to all check out.

In this case, Duration should be an Integer variable so that you're guaranteed 100% precision.
 
Last edited:
Top