1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Base abilities for custom spells cast by melee-game AI units

Discussion in 'JASS/AI Scripts Tutorials' started by Boris_Spider, Apr 11, 2011.

  1. Boris_Spider

    Boris_Spider

    Joined:
    Dec 12, 2009
    Messages:
    728
    Resources:
    6
    Icons:
    3
    Maps:
    2
    Tutorials:
    1
    Resources:
    6
    Base Abilities for Custom Spells used by AI Casters

    For getting the AI to cast custom spells, appropriate base spells must be used. Many users will argue that all custom spells should be based off of Channel-Special. While this is recommended for human users, the AI will never cast spells based on Channel-Special. It's also true that you can trigger the AI casting. This makes sense for Boss Fights in arena or RPG style formats, but it's not as useful for melee-like AI. It makes no sense to have additional code to try and determine when, where, and how randomly the AI should cast it's spells when there's already code 'running in the background' to do this. There is some information throughout the internet on this matter, but it's a pain to find and very spotty at best. So I decided to assemble this list to help make life easier for any searching for this information.

    This tutorial/list is intended to provide a list of abilities AI casters can use and when they'll use them. The regular melee game will use all abilities on the standard Blizzard maps (except for transform abilities like Destroyer Form/Bear Form/Crow Form). This tutorial focuses on custom maps with custom units casting custom abilities when desired via using ideal base abilities.

    -=|Base spells and when the AI decides to cast them|=-

    ~Acid Bomb -

    ~Aerial Shackles - Spammed immediately if allies are nearby. Casts if caster is under attack.

    ~Anti-magic Shell -

    ~Banish - Prefers casting on summoned units.

    ~Bladestorm - Used at random, appears to use immediately if many enemies nearby.

    ~Black Arrow & Parasite - The AI normally uses it when the target is dying, perhaps to spawn the unit faster giving that the target is almost dead. Parasite is always cast on the furthest target inside the range.

    ~Berserk - Used in combat, will not cast if outnumbered.

    ~Big Bad Voodoo -

    ~Blizzard/Rain of Fire - Will cast if there are at least 2 to 3 units in a group. Monsoon however never seems to cast.

    ~Bloodlust -

    ~Cannibalize - Spammed when a unit is injured, usually around 50% HP or less.

    ~Chain Lightning - Spammed at every cool down, appears to ignore stunned/disabled enemies.

    ~Charm - Spammed on anything that can be targeted; will not target things that can't attack (Though may target workers making buildings that attack)

    ~Cloud - Spams any defensive building (ranged and/or melee), usually when attacking towns

    ~Cold Arrows - PREFERRED over Searing Arrows in the case the hero/unit has both spells.

    ~Cripple -

    ~Curse - Spammed on engaged enemy units

    ~Dark Portal (Archimonde) - Uses whenever is available.

    ~Death Pact - Never

    ~Devour - Spammed on anything that can be targeted, may prefer units with higher levels.

    ~Defend - Activated in the same manner as Divine Shield, but only if the caster is being attacked by a unit with Piercing damage or Magic damage (If ability is set to shield against Magic damage as well).

    ~Dispel -

    ~Divine Shield - Casts when attacked, often just before the caster is dealt damage or hit by a non-friendly spell to avoid taking any damage. The health of the unit isn't a factor for it's casting.

    ~Drunken Haze -

    ~Finger of Death - Uses whenever is available

    ~Fan of Knives - Spams randomly if 2 to 3 enemies around, occasionally also uses on single targets if attacked.

    ~Faerie Fire - Spammed randomly on enemy units

    ~Farsight - Unused

    ~Fire Breath/Shockwave/Carrion Swarm/Impale - Will cast if there are at least 2 to 3 units in a cone.

    ~Flamestrike - May be cast if there are 2+ enemies standing in the AoE

    ~Forked Lightning - Spammed on enemy heroes and/or clusters of 2+ enemy units.

    ~Frost Nova - Spammed at every cool down

    ~Healing Wave/Heal/Rejuvenation - Used when caster or any nearby allies take significant/any/moderate damage.

    ~Holy Light/Death Coil - Spam on any nearby Undead units or friendly non-Undead units, prefers heroes. /Death Coil is same function as Holy Light but with opposite targets. It's been noticed while doing some Tank/Spank boss fights that if the hero is taken a LOT more damage then the heal, the healer or himself(if he has this spell) he STOPS casting it

    ~Hex - Spammed on non-heroes, may target a lone hero

    ~Immolation - Activates only if Immolation deals damage and there are viable targets present; it may favor use after losing hitpoints

    ~Inner Fire - Spammed randomly? May be a preference for high level units (e.g. Frost Wyrm or Tauren)

    ~Invisibility - Occasionally casts on retreating friendly heroes with moderate to low health

    ~Life Drain - Spammed at every cool down.

    ~Locust Swarm / Voodoo Spirits -

    ~Mana Burn - Spammed on anything with mana

    ~Mana Drain -

    ~Mana Flare -

    ~Mirror Image - Cast if the caster is attacked a certain number of times. Used immediately if the caster is about to be hit by a spell.

    ~Parasite - Always casts on the furthest target inside the range.

    ~Phase Shift -

    ~Purge -

    ~Raise Dead - Spammed at every cool down if nearby corpses are available; but only in combat

    ~Resurrection - Cast if there are friendly dead units nearby.

    ~Roar/Howl of Terror - Used when engaging enemies

    ~Searing Arrows - Uses it whenever the CD is off.

    ~Serpent Ward - Plants near enemies every cool down.

    ~Silence - Appears to spam on anything that has mana. [May target all units if it reduces the damage dealt of those targeted - needs confirmation.] Preference for units with at least 75 mana as well as player units and non-heroes over heroes.

    ~Sleep - Cast while in combat, seems to prefer non heroes.

    ~Slow - Spammed randomly? May be a preference for high level units (e.g. Frost Wyrm or Tauren)

    ~Soul Burn - Only activates on heroes.

    ~Shadow Strike - Spammed at every cool down unless victim is already afflicted with Shadow Strike (may prefer target that has less then 100% of his health. Never studied to determine the threshold, but a user has never seen it used on a 100% target)

    ~Spirit-Link - Casts on friendly units that are engaged

    ~Stasis Trap -

    ~Storm Bolt/Fire Bolt/Frost Bolt - Spammed at every cool down, has preference to target heroes.

    ~Starfall - Uses when there is 2 or more enemy units close.

    ~Thunderclap/Warstomp - Will cast if there are 2 to 3 units around the caster. May not be used if air units are present (despite being allowed to hit them to).

    ~Unholy Frenzy -

    ~Vengeance -

    ~Water Elemental - Casts when caster or nearby allies are engaging enemies.

    ~Wind Walk - Used when the AI-controlled units are near death

    -=|Important things to note|=-

    ~When the AI casts customs spells, it may rapidly cast them and cause the SFX to display incorrectly - if at all. Some spells with lightning effects don't display properly, what causes this is still unknown.

    ~The AI only casts Forked Lightning/Chain Lightning if the damage dealt is greater than 0. When using this as a base spell set the damage dealt to 0.01 to ensure use. If it's set to 0, the AI will NOT cast it. This also applies to Immolation.

    ~Shockwave may lag due to its terrain deformation, use Carrionswarm or Breath of Fire instead.

    If abilities aren't mentioned it's because none of the contributors have submitted the casting trends of the AI. Please submit your experiences working with custom AI base abilities. The more information I have the more useful others may find this tutorial.

    Future Plans:
    ~See if AI has preference for casting certain spells over others. (e.g. I've noticed that the AI will spam Charm before it casts Forked Lightning)
    ~Determine if setting a damage spell's damage to zero 'prevents' casting (Confirmed with Forked Lightning and Chain Lightning).

    Test Map
    Attached is the current AI test map. Open it up in-game and watch which spells are used. There are a few MUI problems with the custom spells I'm using, but they don't interfere with the map. You can control red's units to see which spells are where and get an idea of what you can do. I'll be adding additional base spells (and IDing them) as I have time.
    ~Lightning Strike is based off of Blizzard
    ~Thunderwrath is based off of CarrionSwarm
    ~Lightning Speed is based off of Silence

    Contributors:
    ~Boris_Spider
    ~kino
    ~mckill2009
    ~myronbeg
    ~Shyrony
    ~gjpaixao13
    ~Teuncreemers
    ~watermelon_1234
    ~Sephalo
    ~ngkn92
    ~Dark Axl

    Last Updated: 8/16/2014

    Related Tutorial:
    http://www.hiveworkshop.com/forums/general-mapping-tutorials-278/ai-editor-162687/ by VeljkoM
     

    Attached Files:

    Last edited: Sep 27, 2014
  2. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,426
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    This stuff is solid information. I like it. :thumbs_up:

    However:
    I've had breath of fire casted when I was fighting 1 unit vs 1 unit, against a computer player. Maybe my memory is off, but I think you might want to check that out.
     
  3. Boris_Spider

    Boris_Spider

    Joined:
    Dec 12, 2009
    Messages:
    728
    Resources:
    6
    Icons:
    3
    Maps:
    2
    Tutorials:
    1
    Resources:
    6
    Thanks, will check it out soon.

    //\\oo//\\
     
  4. mckill2009

    mckill2009

    Joined:
    Mar 10, 2009
    Messages:
    4,696
    Resources:
    34
    Maps:
    5
    Spells:
    27
    JASS:
    2
    Resources:
    34
    That's true, channel base type ability for AI is useless since they will not cast it except when you change the base order ID and order string, I use this before but now no more...

    I'd also like to add that the ORDER of casting a custom spell by the AI dummy is this...


    • Untitled Trigger 001
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equal to Storm Bolt
      • Actions
        • Set pt = (Position of (Triggering unit))
        • Unit - Create 1 Dummy for (Triggering player) at pt facing Default building facing degrees
        • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
        • Unit - Add Chain Lightning (Neutral Hostile) to (Last created unit)
        • Unit - Set level of Chain Lightning (Neutral Hostile) for (Last created unit) to (Level of Chain Lightning for (Triggering unit))
        • Unit - Order (Last created unit) to Orc Far Seer - Chain Lightning (Target unit of ability being cast)
        • Custom script: call RemoveLocation(udg_pt)


    Not this...


    • Untitled Trigger 001
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equal to Storm Bolt
      • Actions
        • Set pt = (Position of (Triggering unit))
        • Unit - Create 1 Dummy for (Triggering player) at pt facing Default building facing degrees
        • Unit - Add Chain Lightning (Neutral Hostile) to (Last created unit)
        • Unit - Set level of Chain Lightning (Neutral Hostile) for (Last created unit) to (Level of Chain Lightning for (Triggering unit))
        • Unit - Order (Last created unit) to Orc Far Seer - Chain Lightning (Target unit of ability being cast)
        • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
        • Custom script: call RemoveLocation(udg_pt)



    In all, these are useful information +rep...
     
  5. Kino

    Kino

    Joined:
    Oct 12, 2008
    Messages:
    1,677
    Resources:
    19
    Models:
    5
    Maps:
    14
    Resources:
    19
    I can confirm that Flamestrike is used if there at least 2 enemies standing within AOE.

    Also, nice to see you finally finished it.
     
  6. VeljkoM

    VeljkoM

    Joined:
    Jul 27, 2008
    Messages:
    2,553
    Resources:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    2
    I linked this to my AI Editor Tutorial if that is ok. I have given you credits.
     
  7. Boris_Spider

    Boris_Spider

    Joined:
    Dec 12, 2009
    Messages:
    728
    Resources:
    6
    Icons:
    3
    Maps:
    2
    Tutorials:
    1
    Resources:
    6
    Thanks! Although I don't plan on adding the trigger que to the tutorial since the melee-game AI is determining when to cast. It's still interesting though and sheds some light on why custom spells are triggerd as they are.

    ~Interesting, when I tried using it as a base the AI never seemed to cast it. Of course I had the damage set to 0, which may matter. I'll check into it this weekend, I don't have much time during the week.

    ~ //\\^^//\\

    Cool! I'm glad you found it useful.

    //\\^^//\\
     
  8. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,426
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    I'm going to go ahead and approve this. However, feel free to update it whenever you want, and I'll probably check it out.

    ~Approved.
     
  9. Boris_Spider

    Boris_Spider

    Joined:
    Dec 12, 2009
    Messages:
    728
    Resources:
    6
    Icons:
    3
    Maps:
    2
    Tutorials:
    1
    Resources:
    6
    Cool! I'll update as I figure out the AI's capabilities.

    //\\oo//\\
     
  10. Boris_Spider

    Boris_Spider

    Joined:
    Dec 12, 2009
    Messages:
    728
    Resources:
    6
    Icons:
    3
    Maps:
    2
    Tutorials:
    1
    Resources:
    6
    Update:

    I haven't forgotten about this tut. The test map is nearly complete. I'll start verifying in a couple weeks probably. The test map will be attached and will have instructions on how to test other base abilities.

    //\\oo//\\
     
  11. puggsoy

    puggsoy

    Joined:
    May 13, 2011
    Messages:
    213
    Resources:
    0
    Resources:
    0
    This is extremely helpful. Personally I'm kinda surprised that somebody only got round to making this after so many years of WC3 modding, it really is something a lot of people would want/need. It's what I need, anyway.

    +rep
     
  12. myronbeg

    myronbeg

    Joined:
    May 1, 2011
    Messages:
    81
    Resources:
    0
    Resources:
    0
    It's good to share info with other people, but I'm not suprised with all these AI casting spells. No matter what custom spells the user will put on the units, eventually the AI controlled units will try to use the spells based on the rawcode data of the ability. However, they will never LEARN skills, like Heroes.

    How about putting Wind Walk when the AI-controlled units are almost dying?

    How about Cloud when the enemy approaches to attack enemy's tower defense building?

    Holy Light will spam on any nearby Undead units but at the same time also concern about bleeding units.

    To be honest, Curse doesn't just apply on AI-controlled units, but we Users will also do the same thing. That's because they are auto-caster.

    Cannibalize will happen when a unit is injured.

    EDIT: I have discovered many more AI using spells cuz I was play with AIs
     
  13. Boris_Spider

    Boris_Spider

    Joined:
    Dec 12, 2009
    Messages:
    728
    Resources:
    6
    Icons:
    3
    Maps:
    2
    Tutorials:
    1
    Resources:
    6
    Thanks for the additional info!

    Update: The test map has finally been set up. I'm working on balancing a spell's damage, then I can upload the map and start demonstrating base abilities.

    //\\^^//\\
     
  14. Boris_Spider

    Boris_Spider

    Joined:
    Dec 12, 2009
    Messages:
    728
    Resources:
    6
    Icons:
    3
    Maps:
    2
    Tutorials:
    1
    Resources:
    6
    Update:

    Current test map has finally been added. I'll diversify the base spells as possible.

    //\\oo//\\
     
  15. Kino

    Kino

    Joined:
    Oct 12, 2008
    Messages:
    1,677
    Resources:
    19
    Models:
    5
    Maps:
    14
    Resources:
    19
    That test map is seriously entertaining just to watch, Im serious.
     
  16. watermelon_1234

    watermelon_1234

    Joined:
    Nov 18, 2007
    Messages:
    1,066
    Resources:
    10
    Spells:
    9
    JASS:
    1
    Resources:
    10
    Wow, I didn't expect you to make such an interesting test-map. XD

    Anyway, the tutorial is really nice. It would help though if you categorized your abilities (like how they target stuff) or at least make them alphabetized.
     
  17. Boris_Spider

    Boris_Spider

    Joined:
    Dec 12, 2009
    Messages:
    728
    Resources:
    6
    Icons:
    3
    Maps:
    2
    Tutorials:
    1
    Resources:
    6
    I've lost about 3 hours making it (everything's from scratch, except the imported spells) and around 10 Hrs watching it. That's why it took me so long to upload it. ::/

    //\\^^//\\

    That's what I plan to do next. A list of recommended base abilities will be present too. Thanks for the suggestion!

    //\\^^//\\
     
  18. VeljkoM

    VeljkoM

    Joined:
    Jul 27, 2008
    Messages:
    2,553
    Resources:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    2
    Fun little map indeed and will serve great purpose in further testing.

    By the way I was wondering when you tested abilities like Sleep or Hex did you set it to last equally on heroes and units or left it to default to last longer on units? Perhaps AI prefers to cast these spells on units because they last longer?
     
  19. Boris_Spider

    Boris_Spider

    Joined:
    Dec 12, 2009
    Messages:
    728
    Resources:
    6
    Icons:
    3
    Maps:
    2
    Tutorials:
    1
    Resources:
    6
    No, but I will. Thanks for suggesting that.

    //\\^^//\\
     
  20. Tirlititi

    Tirlititi

    Joined:
    Jul 11, 2010
    Messages:
    396
    Resources:
    12
    Models:
    6
    Maps:
    2
    Spells:
    3
    JASS:
    1
    Resources:
    12
    I think that, indeed, autocast spells have the same "event for firing" for their autocast and for their IA use (which means their autocast doesn't have to be enabled for IAs).

    This is not true. I use Frost Nova as a base ability for occasionnaly casts. It may be casted when the unit is damaged or when the fight begins (ie. when the caster sees an enemy and goes toward him). It seems to depend on the number of allies/ennemies around, though. Anyway, it is much less used than Chain Lightning, for instance.

    For my experience, it depends on the target's damages compared with the caster's current HP (and maybe its allies' around). I think it's the same IA than the autocast's one but I'm not sure for Curse.

    Inner Fire is, like Frost Nova, casted when the caster or its allies are damaged and not even always at the first shot. I also use it as an occasionnaly spell. If I remember well, I compared the autocast and the IA use of this spell and concluded it was the same. I'm maybe mistaken, it was some times ago.

    This topic is really a good idea. I wish you good luck because it's hard to fullfill and I rarely saw any information about it on the internet.