• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Is there a way to see the code behind default abilities?

Chaosy

Tutorial Reviewer
Level 41
Joined
Jun 9, 2011
Messages
13,239
No.

I'll admit this is a bit of an educated guess but I am pretty sure there is no "code" for the default abilities because they function purely through the object editor. But regardless if that's true you cannot see the code behind the scenes unless you manage to reverse engineer the game.

However there is probably a thread from the past that asks how to make a custom Thunder Clap, also check the spell section if you want to see how it would likely be done in practive.

edit: for the AI part, I think you got it backwards. The ability is not hardcoded for AI, the AI knows how to use aoe abilities.
 
edit: for the AI part, I think you got it backwards. The ability is not hardcoded for AI, the AI knows how to use aoe abilities.
But there must be some kind of priority the AI uses. Granted it's been a long time since I played any War3, but to my recollection the Mountain King AI would never use Thunderclap unless X enemies were in range. Saying that if he only faces one enemy, the AI would never use clap.
That logic must be written somewhere.

Edit: But I bet you're right that reverse engineering is probably the way to go. I was thinking people would have found a way of doing so by this time
 
Last edited:
Yes.

I have been trying to attack this problem by seeing about rewriting all the code in the game for fun:


However, as in the above video, since I wrote my own game engine for that, there is no AI code for Thunder Clap because there is no AI code at all.

Or, if you want to go the other route and sail the seven seas, I'm pretty sure there's a file in War3/Source/Unit/Ability/CAbilityThunderClap.h that defines the header for the class, and War3/Source/Unit/Ability/CAbilityThunderClap.cpp defines the implementation of the original. I didn't know any of that when I made the video above, though, since it was only recently that Microsoft published the leaks.
 
Level 2
Joined
Jul 26, 2014
Messages
2
You can find a big deal of info about ability quirks and AI usage in this document where people made tests so you don't have to
I think you meant to link to the Ability Insight Document? Your link doesn't seem to work for me (but it is pretty easy to find with a search).

But there must be some kind of priority the AI uses. Granted it's been a long time since I played any War3, but to my recollection the Mountain King AI would never use Thunderclap unless X enemies were in range. Saying that if he only faces one enemy, the AI would never use clap.
That logic must be written somewhere.

Edit: But I bet you're right that reverse engineering is probably the way to go. I was thinking people would have found a way of doing so by this time
You're right that it's now possible to reverse engineer the abilities using the leaked debug symbols. If you dig down into the Thunder Clap ability, it has a function named "CompAI" that determines when the AI chooses to use Thunder Clap. However, this function is only called in two different cases: when the Hero takes damage, or when a nearby ally takes damage. So it appears the hero would not use Thunder Clap when attacking a passive enemy.

Once it gets into the CompAI function, Thunder Clap's logic works out like this:
  1. Check the "Allow Time" timer for the ability. This timer appears to prevent the AI from using the same ability again within 0.5 seconds, even if it has no cooldown.
  2. Check the cooldown of the ability, doing nothing if the ability is on cooldown.
  3. Count the number of units in the AOE of the ability and store them.
  4. If the Hero is under attack (basically, if CompAI was called from the hero itself taking damage):
    1. If the Hero's life is under the "DYING_HERO" threshold (which appears to be a constant of some sort, but doesn't seem to be used by any other abilities)
      1. If there are 2 or more ground enemies in the area (including buildings)
        1. CAST
  5. If there are 3 or more ground enemies in the area (not including buildings) AND there are more attacking enemies than there are allies in the area (not including enemy buildings)
    1. CAST
 
Level 28
Joined
Dec 3, 2020
Messages
970
I think you meant to link to the Ability Insight Document? Your link doesn't seem to work for me (but it is pretty easy to find with a search).


You're right that it's now possible to reverse engineer the abilities using the leaked debug symbols. If you dig down into the Thunder Clap ability, it has a function named "CompAI" that determines when the AI chooses to use Thunder Clap. However, this function is only called in two different cases: when the Hero takes damage, or when a nearby ally takes damage. So it appears the hero would not use Thunder Clap when attacking a passive enemy.

Once it gets into the CompAI function, Thunder Clap's logic works out like this:
  1. Check the "Allow Time" timer for the ability. This timer appears to prevent the AI from using the same ability again within 0.5 seconds, even if it has no cooldown.
  2. Check the cooldown of the ability, doing nothing if the ability is on cooldown.
  3. Count the number of units in the AOE of the ability and store them.
  4. If the Hero is under attack (basically, if CompAI was called from the hero itself taking damage):
    1. If the Hero's life is under the "DYING_HERO" threshold (which appears to be a constant of some sort, but doesn't seem to be used by any other abilities)
      1. If there are 2 or more ground enemies in the area (including buildings)
        1. CAST
  5. If there are 3 or more ground enemies in the area (not including buildings) AND there are more attacking enemies than there are allies in the area (not including enemy buildings)
    1. CAST
Wait what how?
Leaked debug symbols?
Extremely useful! Need this for all abilities!
 
Level 2
Joined
Jul 26, 2014
Messages
2
Wait what how?
Leaked debug symbols?
Extremely useful! Need this for all abilities!
Yeah, Blizz leaked a debug build of the whole game back in December, which included versions of all the exes built with the debug symbols included. As well as utility tools and plugins. Taking the debug exes apart can get you readable C or C++ code for the game. There's no legit method to get the leak now (they took it down quickly, of course), but there are some less trustworthy methods to try to acquire it.

As for the process of how to extract the code from the debug exes, I'm afraid I'm not an expert and don't feel qualified to give much advice there. I had help getting the code I'm looking at. You can try looking up C++ decompliers, which might head you in the right direction.
 
Top