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

Low hp skill cast

Status
Not open for further replies.
Level 2
Joined
Aug 8, 2022
Messages
20
How to make computer unit cast spell with triger? For example i have unit that has Divine Shield, he supposed to soak some dmg and when HP is low - turn on the shield, but he cast it as soon as he he gets the first hit.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,558
Computers have hardcoded AI that will dictate how they use abilities. You can't really control this but sometimes you can find workarounds.

Add your Paladin(s) to a Unit Group:
  • Paladin Group
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet PaladinUnit = Paladin 0001 <gen>
      • Unit Group - Add PaladinUnit to PaladinGroup
      • Hero - Learn skill for PaladinUnit: Divine Shield
      • Player - Disable Divine Shield for (Owner of PaladinUnit)
      • Trigger - Turn on Paladin Loop <gen>
Then periodically check on these Paladins to see if they should cast Divine Shield:
  • Paladin Loop
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in PaladinGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet PaladinUnit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (PaladinUnit is alive) Equal to True
              • (Percentage life of PaladinUnit) Less than or equal to 25.00
              • (Ability Cooldown Remaining of PaladinUnit for ability Divine Shield..) Less than or equal to 0.00
            • Then - Actions
              • Player - Enable Divine Shield for (Owner of PaladinUnit)
              • Unit - Order PaladinUnit to Human Paladin - Activate Divine Shield.
              • Player - Disable Divine Shield for (Owner of PaladinUnit)
            • Else - Actions
Paladin Loop should be initially OFF.

You can customize this to work specifically for your map. The important thing to note is that the Paladin cannot Learn Divine Shield while it's Disabled, so you need to make sure you Enable it before doing so.
 

Attachments

  • Divine Shield.w3m
    17.4 KB · Views: 7
Status
Not open for further replies.
Top