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

How can i make AI Controlled Heroes cast their skills on enemy heroes?

Status
Not open for further replies.
Level 17
Joined
Jun 2, 2009
Messages
1,141
Foreword: Hello. Before i get into details let me tell you about something important. This is not an easy as you think. I have already created post about it and i have requested it's closing.
Now we will go step by step. I have already created AI system for my AoS/MOBA map and created trigger about AI Controlled Heroes cast spells on enemy units.
I don't want to change skills target to heroes only because they have to be casted on non-hero units as well.

_______________________________________
I will update this section as we proceed.


_______________________________________


Step 1: Please share your suggestion first. I will share my system with you as we proceed.
@Antares A We can start with targeted spells.
 
Last edited:
Level 17
Joined
Jun 2, 2009
Messages
1,141
Do you want to make a trigger that makes the hero cast the spell on a hero or have the Blizzard AI cast the spell on a hero by itself?
Updated.
No no i don't want to use their default behaviour. Here is the quick example.
You and MR X fighting together agains your friend (enemy hero)
Your ally BOT MR X have 3 targeted skills and additionally there are creeps around you and enemy.
You are expecting your BOT friend cast those skills to your enemy hero (AI or your enemy friend)
You don't want to see your BOT casting spells on non-hero units.

This is my system but it has huge flaws. I do not suggest you to work on this because my system not reliable and not works properly.
First trigger picks random enemy hero and order your heroes cast spells on them
Second trigger is order them to stop if they will target on enemy non hero units.
This trigger causes too many lags. They are stopping their moves, attacks, casting spells and looks like they are lagging and additionally they are able to cast trigger spells more than once in 1 seconds (casting ultimates 3 times within 2 seconds) and much more and they are not properly casting their skills on enemy heroes. Sometimes they are doing nothing for few seconds etc etc.
Click to the spoiler if you still want to see. But still i prefer new, reliable, good trigger. My trigger have a huge flaws.
Still if you want to fix this trigger, please use this topic How can i prevent unit not to take order while cooldown


  • SkillsTarget
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in HerolarBotALL and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is in zUG_RegenALL) Equal to False
              • zBool_AIFallBackCREEP[(Player number of (Owner of (Picked unit)))] Equal to False
              • zBool_AIFallBackHERO[(Player number of (Owner of (Picked unit)))] Equal to False
              • zBool_AIFallBackTOWER[(Player number of (Owner of (Picked unit)))] Equal to False
            • Then - Actions
              • Set TempGroupT = (Units within 1000.00 of (Position of (Picked unit)) matching ((((Matching unit) is in HerolarALL) Equal to True) and ((((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True) and (((Matching unit) is alive) Equal to True))))
              • Set TempUnit = (Random unit from TempGroupT)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in TempGroupT) Greater than or equal to 1
                • Then - Actions
                  • Unit Group - Add (Picked unit) to TempCastGroup
                  • Unit - Order (Picked unit) to Human Sorceress - Polymorph TempUnit
                  • Unit - Order (Picked unit) to Orc Shadow Hunter - Hex TempUnit
                  • Unit - Order (Picked unit) to Orc Far Seer - Chain Lightning TempUnit
                  • Unit - Order (Picked unit) to Neutral - Firebolt TempUnit
                  • Unit - Order (Picked unit) to Undead Lich - Frost Nova TempUnit
                  • Unit - Order (Picked unit) to Undead Necromancer - Cripple TempUnit
                  • Unit - Order (Picked unit) to Neutral Naga Sea Witch - Forked Lightning TempUnit
                  • Unit - Order (Picked unit) to Special Archimonde - Finger Of Death TempUnit
                  • Unit - Order (Picked unit) to Neutral Fire Lord - Soul Burn TempUnit
                  • Unit - Order (Picked unit) to Neutral Naga Sea Witch - Forked Lightning TempUnit
                  • Unit - Order (Picked unit) to Special Archimonde - Finger Of Death TempUnit
                  • Unit - Order (Picked unit) to Neutral - Firebolt TempUnit
                  • Unit - Order (Picked unit) to Human Sorceress - Polymorph TempUnit
                  • Unit - Order (Picked unit) to Orc Raider - Ensnare TempUnit
                  • Game - Display to DebugBotSkills for 1.00 seconds the text: ((Name of (Owner of (Picked unit))) + ( >>> + (Name of (Owner of TempUnit))))
                  • -------- This trigger picks CreepsDevil around the Hero. Because after it casts spells, it has go to next or previous target --------
                  • -------- If player number lesser than or equal to 6 that means CreepsDevil are allies. (Player 1 red ally with 2-3-4-5-6) --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Player number of (Owner of (Picked unit))) Less than or equal to 6
                    • Then - Actions
                      • -------- I am creating TempGroup2 that includes CreepsDevil (allies of picked unit) --------
                      • Set TempGroup2 = (Units within 500.00 of (Position of (Picked unit)) matching (((Matching unit) is in zUG_CreepsDevil) Equal to True))
                      • -------- Don't worry, i am removing dying CreepsDevil from CreepsDevil unit group --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Number of units in TempGroup2) Greater than or equal to 1
                        • Then - Actions
                          • -------- There are still 1 or more creeps available around the picked unit. Go for the NextTarget --------
                          • Unit - Order TempBotTargetCaster to Attack-Move To (Center of CurrentTarget[(Player number of (Owner of TempBotTargetCaster))])
                        • Else - Actions
                          • -------- There are no creeps. Fall back to the previous target. --------
                          • Unit - Order TempBotTargetCaster to Attack-Move To (Center of PreviousTarget[(Player number of (Owner of TempBotTargetCaster))])
                      • Custom script: call DestroyGroup (udg_TempGroup2)
                    • Else - Actions
                      • Set TempGroup2 = (Units within 500.00 of (Position of (Picked unit)) matching (((Matching unit) is in zUG_CreepsReaper) Equal to True))
                      • -------- Else. That means player number of picked player NOT lesser or equal to 6. That means picked unit ally with CreepsReaper (player 7 allied with 8-9-10-11-12) --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Number of units in TempGroup2) Greater than or equal to 1
                        • Then - Actions
                          • Unit - Order TempBotTargetCaster to Attack-Move To (Center of CurrentTarget[(Player number of (Owner of TempBotTargetCaster))])
                        • Else - Actions
                          • Unit - Order TempBotTargetCaster to Attack-Move To (Center of PreviousTarget[(Player number of (Owner of TempBotTargetCaster))])
                      • Custom script: call DestroyGroup (udg_TempGroup2)
                • Else - Actions
                  • Custom script: call RemoveLocation (udg_TempPointCasterTarget)
                  • Custom script: call DestroyGroup (udg_TempGroupT)
                  • Set TempBotTargetCaster = No unit
                  • Set TempUnit = No unit
              • Set TempBotTargetCaster = No unit
              • Set TempUnit = No unit
              • Unit Group - Remove all units from TempCastGroup
            • Else - Actions
      • Unit Group - Remove all units from TempCastGroup
  • SpellDetectVer2
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Casting unit) is in HerolarBotALL) Equal to True
      • ((Unit-type of (Target unit of ability being cast)) is A Hero) Equal to False
      • ((Casting unit) belongs to an ally of (Owner of (Target unit of ability being cast))) Equal to False
      • (Melee AI of (Owner of (Casting unit))) Not equal to Insane AI
    • Actions
      • Unit - Order (Casting unit) to Stop
      • Wait 0.10 seconds
      • Set TempPoint = (Center of CurrentTarget[(Player number of (Owner of (Casting unit)))])
      • Custom script: call RemoveLocation(udg_TempPoint)
      • Unit - Order (Casting unit) to Attack-Move To TempPoint
      • Unit - Set mana of (Casting unit) to ((Mana of (Casting unit)) + 100.00)
 

Attachments

  • annen.png
    annen.png
    63.1 KB · Views: 15
Last edited:

Antares

Spell Reviewer
Level 22
Joined
Dec 13, 2009
Messages
520
I don't fully understand what's going on in your trigger, but if the problem is that your trigger doesn't discriminate between heroes and nonhero units, that should be an easy fix to add
  • ((Matching unit) is A Hero) Equal to True
in your "TempGroupT" Condition.

However, you might run into the problem that the Blizzard AI casts the spell by itself without being prompted by the trigger. That is why I recommend using a base spell for your spell that works well with the Blizzard AI and just leave the spellcasting handled by it completely. If you choose a good base spell with the help of Pyrogasm's link, you should get a behavior that's close to what you want it to be.

If the AI keeps casting the spell on nonhero units, you have the option of creating a copy of the hero spells for your bots that don't have nonhero units as allowed targets. Players would have a different version of those spells, so it wouldn't affect them.

If you want the trigger to only fire when the bot can actually cast the spell, you can check both if the cooldown is ready and if the bot has enough mana with
  • (Ability Cooldown Remaining of tempUnit for ability yourAbility..) Equal to 0.0
  • (Integer((Mana of tempUnit))) Greater than or equal to (Mana cost of yourAbility, Level ((Level of yourAbility for tempUnit) - 1).)
Note the -1.

However, you have to do your trigger for each spell individually now, but this might be a good idea anyway.

Finally, in the second trigger you showed, it seems like you want to use the event
  • Unit - A unit Begins casting an ability
event instead of the event you're using. This way, it will stop the unit from casting before the spell is successfully cast and you also won't have to refill the bots mana.
 
Level 17
Joined
Jun 2, 2009
Messages
1,141
@Antares A Replacing bot ability with non-hero sound good but i am the guy who don't like hundreds of abilities and it was my final solution. Still i want to believe to power of the triggers.

About the casting ability i have noticed you already know why i am giving them to mana :) now i will try to do with A unit Begins casting an ability.

Now can you tell me what kind of suggestion you have unless you haven't saw my trigger within spoiler tag? I am curious. Because still i don't think my trigger is works good. Because bots still trying to do something and stopping their moves every seconds.
Or probably i am going to give them non-hero targeted versions of all spells they will going to use..

I don't fully understand what's going on in your trigger, but if the problem is that your trigger doesn't discriminate between heroes and nonhero units, that should be an easy fix to add
  • ((Matching unit) is A Hero) Equal to True
in your "TempGroupT" Condition.
By the way all heroes adding to HerolarALL group already.

  • Set TempGroupT = (Units within 1000.00 of (Position of (Picked unit)) matching ((((Matching unit) is in HerolarALL) Equal to True) and ((((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True) and (((Matching unit) is alive) Equal to True))))
  • Set TempUnit = (Random unit from TempGroupT)
Another quick question. I am picking random 1 enemy hero within the group. What will happens if i will not pick random 1 unit from the group?
In other words, what will happens if everytime i will pick every enemy heroes within 1000 range? Is it causes problem?

Old version: Picking random unit from unitgrop and cast spells to this unit
New version (my question): Not picking random unit and cast spells to these units

Edit: I am also thinking about channel. As i understand ai will NEVER cast spells based on Channel UNLESS they have ordered by triggers.
That means i can create firebolt based on Channel and default AI never casts it. Is is right?
 
Last edited:

Antares

Spell Reviewer
Level 22
Joined
Dec 13, 2009
Messages
520
I can't tell from the stuff you've posted here why your bots behave like that. Try disabling parts of your triggers and see when the bug stops. The variable TempBotTargetCaster isn't set anywhere. Is that intended?

Another quick question. I am picking random 1 enemy hero within the group. What will happens if i will not pick random 1 unit from the group?
In other words, what will happens if everytime i will pick every enemy heroes within 1000 range? Is it causes problem?

Old version: Picking random unit from unitgrop and cast spells to this unit
New version (my question): Not picking random unit and cast spells to these units
If you order it to be cast on all units in the unit group, it will loop through each unit in the unit group and give the command to cast the spell on that unit. The last command given will override all other commands and the spell will be cast on the last unit in the unit group.
Edit: I am also thinking about channel. As i understand ai will NEVER cast spells based on Channel UNLESS they have ordered by triggers.
That means i can create firebolt based on Channel and default AI never casts it. Is is right?
Correct.
 
Last edited:
Status
Not open for further replies.
Top