This section will explain about debugging the AI's expansive amout of possible errors.
AI-related errors
Definitions, Scenerios, and Solutions for the three types of AI-related errors:
1) Stagnant AI
Stagnant AI (AI that at game start does nothing)
Files that could cause problem:
All .ai files are suspect
Solution(s):
Drop down console, observe error in which .ai file at which line and correct.
Script logic needs revising (ie. trying to call a function which has a global 'nil' value)
Simple script revision – add or subtract an end (ie. if its an <eof> error then remove an extra end at the line specified!)
Invalid paths to non-existent files (AI cannot find a link to a file the AI needs to operate with)
If error is not apparent check the following:
Basic script syntax error (ie. mistypes/misspellings, CAPs used on text somewhere like _race names, etc)
AI doesn't exist for faction (as simple as that sounds, check that the game actually can use the faction by properly ensuring all functions point to it especially in cpu_manager.ai).
As above, check the following files to ensure your faction is present and correctly set:
attackstrategyinfo.ai
buildbasestrategyinfo.ai
buildorderstrategyinfo.ai
2) AI Execution Error
AI Execution Error (when playing game, all of a sudden game abruptly pauses with the text AI Execution Error – game can be unpaused at this point but AI will cease preforming any new operations apart from ones executed before error took place).
Possible scenarios:
a) AI builds a unit and when unit is created from building, AI Execution error occurs. Files that could cause problem:
infantrytactic.ai
vehicletactic.ai
<specific unit>tactic.ai
Solution(s):
Drop down console, observe error in which .ai file at which line and correct.
Check unit's script logic to ensure the unit's abilities are correct and can preform that operation. Chances are its a simple flaw in how the ability is asked to be executed.
b) Near gamestart, AI Execution error occurs. Files that could cause problem:
cpu_manager.ai
<race_name>buildbasestragy.ai
Solution(s):
Drop down console, observe error in which .ai file at which line and correct.
Check for invalid game states or logic not being set correctly in cpu_manager.ai.
There may be build logic errors in your <race_name>buildbasestragy.ai file – ensure they are corrected.
c) Sometimes during the game, an AI Execution error abruptly occurs. There is no indication from the console what the error is. Files that could cause problem:
All .ai files are suspect
Solution(s):
Since its not apparent what file the error occurred in, take note of what happened on-screen the exact moment the error occurred. Since the game is paused, look around and see, visually, if something doesn't look right.
However, chances are it has something to do with a ..tactic.ai file!
3) Crash-To-Desktop
Crash-To-Desktop (when playing game, all of a sudden it abruptly drops to desktop with an error. Due to the fact the game dropped to desktop, it may be less apparent what happened.)
Possible scenarios:
a) AI builds a unit and when unit is created from building, game immediately crashes. Files that could cause problem:
unitstats.ai
infantrytactic.ai
vehicletactic.ai
<specific unit>tactic.ai
Solution(s):
Check the above files for any scripts which contain any invalid syntax or mistypes/misspellings related to the unit in question.
Always ensure the script logic looks sound for all your units that use abilities!
Ensure the unit has the proper weapons delegated to it – watch for misspellings!
If you're having problems trying to determine what unit is crashing the game, go to the file: 'buildbasestrategyinfo.ai" and under the «squadlimits = section, place 0s at the end of either the infantry or vehicle units and then slowly figure out which one is the culprit.
b) AI builds a unit and when unit engages in combat or activates its own script during combat the game immediately crashes. Files that could cause problem:
unitstats.ai
infantrytactic.ai
vehicletactic.ai
<specific unit>tactic.ai
Solution(s):
Check the above files for any scripts which contain any invalid syntax or mistypes related to the unit in question.
Ensure the unit can use the abilities you've give it to use and that those abilities actually exist.
Ensure the unit has the proper weapons delegated to it – watch for misspellings!
If you're having problems trying to determine what unit is crashing the game, go to the file: 'buildbasestrategyinfo.ai» and under the «squadlimits = section place 0s at the end of either the infantry or vehicle units and then slowly figure out which one is the culprit.
If this is a multi-mod Skirmish AI integration, and one of the mods is missing from the list, then any associated unit or commander abilities/scripts must also be omitted/commented out from the files infantrytactic.ai and vehicletactic.ai.
c) AI builds an upgrade or addon that isn't one and game immediately crashes. Files that could cause problem:
<race_name>buildbasestragy.ai
Solution(s):
This errror is not as apparent when it occurs since it happens in the background.
Watch your faction's buildorder and ensure all structures and addons are what they are intended for.
d) Game crashes even before you get to play. Files that could cause problem:
cpu_manager.ai
infantrytactic.ai
Solution(s):
Likely an invalid call to a important missing file or object occurred as the game was loading.
Check to ensure something the AI needed was not accidentially excluded.
Or, check to ensure something that was removed from the mod, is not called for in cpu_manager.ai.
Check under infantrytactic.ai near the beginning under "InfantryTactic.TargetAbilities = " that no abilities are present that don't exist. This will also crash the game before you get to play!
e) Game crashes but only after the first 1–10 seconds of play. Files that could cause problem:
<race_name>buildbasestragy.ai
Solution(s):
Probably an invalid building name is present so when the AI switches from its static buildorder to the dynamic one stored in your <race_name>buildbasestragy.ai file the game will crash.
Check spelling and validity of all buildings your faction is told to build in the <race_name>buildbasestragy.ai file.