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

[Solved] Movement type comparison issue in spell

Level 6
Joined
Sep 10, 2022
Messages
86
Hi, I have another stupid question. I have an ability that must target all ground units, but it does not work on turtles (I don't know why, I have ground type classification check, but maybe turtles are not ground units because they have movement type "amphibious").
So I decided to add an additional check, that compares target unit type movement. The problem is that I do not know what integer field corresponds to "amphibious", "foot" etc...
I assumed that 0 corresponds to None, 1 to Foot, etc., so amphibious is 6. Did not work.
Then I assumed that numeration starts with 1, so None is, and amphibious is 7. Did not work. (Then I found out in a forum that numeration starts with zero).

I checked with hydras targets - it is all the same. So the checks do not work on all amphibious. At the same time, it works well for trolls, ogres etc..

The conditions:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (strike_target is invulnerable) Equal to Нет
      • (strike_target is alive) Equal to Да
      • (strike_target belongs to an enemy of strike_cause_player.) Equal to Да
      • Or - Any (Conditions) are true
        • Conditions
          • (strike_target is A ground unit) Equal to Да
          • (Unit: strike_target's Integer Field: Type ('umvt')) Equal to 1
          • (Unit: strike_target's Integer Field: Type ('umvt')) Equal to 2
          • (Unit: strike_target's Integer Field: Type ('umvt')) Equal to 5
          • (Unit: strike_target's Integer Field: Type ('umvt')) Equal to 6
      • unit_mana Greater than 0.00

What should I do?
 
Level 6
Joined
Sep 10, 2022
Messages
86
Can you not just check if it's a Flying/Ground unit:
  • Conditions
    • (strike_target is a Ground unit) equal to True
  • Conditions
    • (strike_target is a Flying unit) equal to False
Ohhh well, I deleted all movement type comparisons, deleted ground comparison and instead of ground comparison added flying. Now it works, but I wonder what was wrong.
Maybe just the Ground condition is buggy... or "OR - Any Condition" did bad.
 
Level 25
Joined
Sep 26, 2009
Messages
2,381
This is a strange numeration
This is an often used pattern in programming called Bit Flags. Except for "None = 0", all those numbers are of power of two. The base remains same (2) but the exponent is increasing (i.e. 2^0, 2^1, 2^2, ... 2^5). It's often used to have a single variable represent multiple states. In this case, it seems that Blizz originally intended to allow units to have multiple movement types (e.g. choosing both "Foot" and "Float" would act as "Amphibious"), but ultimately dropped the idea.
 
Level 6
Joined
Sep 10, 2022
Messages
86
This is an often used pattern in programming called Bit Flags. Except for "None = 0", all those numbers are of power of two. The base remains same (2) but the exponent is increasing (i.e. 2^0, 2^1, 2^2, ... 2^5). It's often used to have a single variable represent multiple states. In this case, it seems that Blizz originally intended to allow units to have multiple movement types (e.g. choosing both "Foot" and "Float" would act as "Amphibious"), but ultimately dropped the idea.
Wow, haven't noticed it uses the power of two.
 
Top