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

Is there a way to "PREVENT" ai controlled heroes casting spells?

Status
Not open for further replies.
Level 17
Joined
Jun 2, 2009
Messages
1,141
Hello everyone. I was spent 1 year for the create AI system for my map and finally people started to appreciate me for their current conditions. But i have a huge flaw. They are casting spells with triggers BUT they are casting spells randomly. Can i prevent it somehow?

Feel free to suggest anything.
 
Level 28
Joined
Feb 18, 2014
Messages
3,580
You cannot change the AI spell casting behaviour because it's hardcoded. The AI will cast spells randomly under some circumstances as explained in this tutorial.
The only workaround I can think off is to temporary disable those spells and enable them when needed or manually order the AI to cast them when they meet your conditions.
 
Level 17
Joined
Jun 2, 2009
Messages
1,141
You cannot change the AI spell casting behaviour because it's hardcoded. The AI will cast spells randomly under some circumstances as explained in this tutorial.
The only workaround I can think off is to temporary disable those spells and enable them when needed or manually order the AI to cast them when they meet your conditions.
Hmmm. What happens when i add them to the unit group temporary when they will cast spells via triggers and create another trigger when they try to cast spells check if they are not in this temporary group and order them as stop? It will gonna work?

Trigger 1: Unit starts to effect and ability, casting unit is within X group equal to FALSE
Order > stop

Trigger 2: I will add units temporarily within unit group, then order them and remove them from this group after 1 seconds.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,558
Something like this would probably work:
  • Events
    • Run this trigger once for each computer Hero
  • Actions
    • Unit - Disable Ability1 for AIHero
    • Unit - Disable Ability2 for AIHero
    • Unit - Disable Ability3 for AIHero
    • Unit - Disable Ability4 for AIHero
Then whenever your AI triggers Order a Hero to cast an Ability simply Enable it before doing so:
  • Unit - Enable Ability1 for AIHero
  • Unit - Order AIHero to cast Ability1
Then whenever your AI heroes are done casting an ability you can disable it again:
  • Events
    • Unit - A unit Stops casting an ability
  • Conditions
    • (Triggering unit) is an AI Hero Equal to True
  • Actions
    • Unit - Disable (Ability being cast) for (Triggering unit)
I don't really like the idea of ordering the unit to Stop since it will interrupt it's orders and most likely produce scenarios where the Hero constantly tries and fails to cast the ability. That being said, you can easily test your suggested method and see if it works for you.
 
Level 17
Joined
Jun 2, 2009
Messages
1,141
Something like this would probably work:
  • Events
    • Run this trigger once for each computer Hero
  • Actions
    • Unit - Disable Ability1 for AIHero
    • Unit - Disable Ability2 for AIHero
    • Unit - Disable Ability3 for AIHero
    • Unit - Disable Ability4 for AIHero
Then whenever your AI triggers Order a Hero to cast an Ability simply Enable it before doing so:
  • Unit - Enable Ability1 for AIHero
  • Unit - Order AIHero to cast Ability1
Then whenever your AI heroes are done casting an ability you can disable it again:
  • Events
    • Unit - A unit Stops casting an ability
  • Conditions
    • (Triggering unit) is an AI Hero Equal to True
  • Actions
    • Unit - Disable (Ability being cast) for (Triggering unit)
I don't really like the idea of ordering the unit to Stop since it will interrupt it's orders and most likely produce scenarios where the Hero constantly tries and fails to cast the ability. That being said, you can easily test your suggested method and see if it works for you.
Uhm, i don't get it clearly but let me show you this

  • SpellDetect
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Player - Disable (Ability being cast) for (Owner of (Triggering unit))
This trigger disables ability but still ability can be cast, then disables.

  • SpellDetect Copy
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Unit - Order (Casting unit) to Stop
This trigger not disables the ability and stops them from casting spells

But as you mentioned i am not a fan of using stop order. But it looks better solution. Because it is annoying to see your ally hero casting ultimate ability with 120 cooldown on single non-player unit..
 
Status
Not open for further replies.
Top