• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece!🔗 Click here to enter!

AI for ability usage

Status
Not open for further replies.
Level 13
Joined
Oct 16, 2010
Messages
731
I'm working on a zombie survival type map (were one player would be on the zombie team and one team would be defending as humans).
I have made it so that the undead attacking player team is controlled by a computer player if they aren't in the game.
I have managed to make the computer buy heroes, upgrades and send them into the battlefield.
My problem is that I want the computer to use the heroes abilities which are things like Death Pact, Rain of Chaos, Carrion Swarm and Doom. I have managed to make them learn the abilities but now i want them to actually use them. Here are my ideas for the abilities:
Death Pact - Hero is attacked and has 10% HP
- Order attacked unit to use Death Pact on random unit controlled
by player purple within range of attacked unit.

Rain of Chaos - Hero is attacked by unit.
- Order attacked unit to use Rain of Chaos on attacking unit.

My problem is that there is no condition for HP, and when ordering the unit to use the ability there is only normal abilities, not custom ones. Help?
 
Level 15
Joined
Oct 16, 2010
Messages
941
My problem is that there is no condition for HP,

It's under real comparisons.

and when ordering the unit to use the ability there is only normal abilities, not custom ones. Help?

Abilities have something called an Order String ID. The Order String ID is unique to each type of ability and not each ability itself. So if you make a custom Chain Lightning spell and base if off the original Chain Lightning spell, then they will both have the same Order String. So if you want the hero to cast a custom chain lightning ability you gave him, then just order him to cast Far Seer - Chain Lightning and he will cast the custom one you made.
 
Level 8
Joined
Dec 12, 2010
Messages
280
Maybe this will give you some ideas. This is a trigger that I used on a map.
It uses a random number in condition so they don't always try to cast ability.

  • Anubarak
    • Events
      • Unit - Anub'arak 0106 <gen> Takes damage
    • Conditions
    • Actions
      • Set DS_Unit = (Damage source)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 4) Equal to 1
          • (DS_Unit is Magic Immune) Equal to False
          • (DS_Unit is A ground unit) Equal to True
          • (Mana of Anub'arak 0106 <gen>) Greater than or equal to 150.00
        • Then - Actions
          • Unit - Order Anub'arak 0106 <gen> to Undead Crypt Lord - Impale DS_Unit
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Percentage life of Anub'arak 0106 <gen>) Less than 50.00
              • (Random integer number between 1 and 2) Equal to 2
              • (Hero level of Anub'arak 0106 <gen>) Greater than 5
              • (Mana of Anub'arak 0106 <gen>) Greater than or equal to 150.00
            • Then - Actions
              • Unit - Order Anub'arak 0106 <gen> to Undead Crypt Lord - Locust Swarm
            • Else - Actions
              • Unit - Order Anub'arak 0106 <gen> to Attack DS_Unit
      • Set DS_Unit = No unit
But I like this one better it uses damage taken as a condition and a boolean with a wait so it doesn't repeatedly try to cast the spell.

  • Archimonde
    • Events
      • Unit - Archimonde 0107 <gen> Takes damage
    • Conditions
      • (Damage taken) Greater than or equal to 25.00
      • A1Castspell Equal to True
    • Actions
      • Set A1Castspell = False
      • Set SourceLoc = (Position of (Damage source))
      • Set DS_Unit = (Damage source)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Dark Portal (Archimonde) for Archimonde 0107 <gen>) Greater than or equal to 1
          • (Damage taken) Less than or equal to 75.00
        • Then - Actions
          • Unit - Order Archimonde 0107 <gen> to Special Archimonde - Dark Portal SourceLoc
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Rain of Chaos (Archimonde) for Archimonde 0107 <gen>) Greater than or equal to 1
              • (Damage taken) Greater than 125.00
            • Then - Actions
              • Unit - Order Archimonde 0107 <gen> to Special Archimonde - Rain Of Chaos SourceLoc
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Finger of Death (Archimonde) for Archimonde 0107 <gen>) Greater than or equal to 1
                • Then - Actions
                  • Unit - Order Archimonde 0107 <gen> to Special Archimonde - Finger Of Death DS_Unit
                • Else - Actions
                  • Unit - Order Archimonde 0107 <gen> to Attack DS_Unit
              • Set DS_Unit = No unit
      • Custom script: call RemoveLocation(udg_SourceLoc)
      • Wait 30.00 seconds
      • Set A1Castspell = True
BTW its probably a bad idea to order a unit to attack an attacking unit as I did in this trigger as it will sometimes get the unit spinning back and forth when getting attacked simultaneously by two different units :)
 
Status
Not open for further replies.
Top