AI and Script Editing (SEV)
One of the most anticipated changes in SE5 versus previous versions was the ability to create scriptable AI. The following files can be edited and then re-compiled to modify the behavior of the AI in SE5. The effects of events and intelligence projects can also be modified via the same scripting language.
The Utilities folder is found in your Space Empires folder and contains sub-folders with useful programs that can be used to create new content for SE5. The ScriptParser folder contains the SE:V Script Parser, which is used to create compiled (.csf) AI files. Contained within the ScriptParser folder is two other folders that contain the source scripts for SE5:
The SE5EmpireScripts folder contains all the source script files that are compiled to make AI scripts.
The SE5MainScripts folder contains all the source script files that are compiled to make the scripts that control the execution of random events and intelligence events.
Before editing script files, it's always a good idea to make a duplicate set of scripts for your work rather than edit the default source scripts. It's not a problem to have them contained in a separate folder from the stock script files.
Main and Setup AI Files
These files by default are contained in the SE5EmpireScripts folder. They are the primary script files that get compiled to make the script files used by SE5 for an AI empire.
When compiled, these files are placed in a matching Empires\Racename folder. Racename_AI_Main.txt contains two entries that refer to these files by name. This tells the game which AI scripts to use for that empire. In the case that the scripts are missing, the default AI scripts will be used during the AI's turn.
Additional AI files
These files are included when an Empire's script file is compiled and are never compiled individually. They contain script functions that are common to all AI races.
A Racename_Main_Script calls all the files below as includes with the exception of Script_AI_GlobalResearch.txt, which is the only included file during compiling of a Racename_Setup_Script file.
- Script_AI_ColonyType.txt (SEV)
- Script_AI_Construction.txt (SEV)
- Script_AI_DesignCreation.txt (SEV)
- Script_AI_EnemyAnalysis.txt (SEV)
- Script_AI_GlobalConstants.txt (SEV)
- Script_AI_GlobalConstants_XXXXXX.txt (SEV)
- Script_AI_GlobalResearch.txt (SEV)
- Script_AI_GlobalSettings.txt (SEV)
- Script_AI_GlobalVariables.txt (SEV)
- Script_AI_Intelligence.txt (SEV)
- Script_AI_Lists.txt (SEV)
- Script_AI_Orders_Planets.txt (SEV)
- Script_AI_Orders_Ships.txt (SEV)
- Script_AI_Politics.txt (SEV)
- Script_AI_Research.txt (SEV)
- Script_AI_Restricted_SolarSystems.txt (SEV)
- Script_AI_StateChange.txt (SEV)
Event and Intel Script Files
The compiled versions of these files are placed in the data folder and are accessed by the game during the end turn processing phase. They are responsible for the Events and Intel Events that occur in the game.
To compile a single script file:
- With the SE:V Script Parser, open the source script file you wish to compile.
- Press the Compile button.
- If there are no errors, the compiled script file will be created in the same folder as the source file.
A handy feature is that the Script Parser can read a text file containing a list of files to compile - such as All Races Makefile.txt - and compiles them sequentially.
- Press the MakeFile button.
- Select the file that contains the list of scripts to compile.
- If there are no errors, the compiled script files will be created in the same folder as the source file.
Note: There is no way to break this operation once started. Any files with script errors will not be compiled.
Note: On systems that use "," for decimal places, you'll need to switch to "." when compiling files due to a quirk with SE:V's script parser. Otherwise, the compiled scripts will not work correctly.
Getting your new AI into the game
To add script files for a specific empire:
- The compiled Racename_Main_Script and Race_Setup_Script files are placed in the matching Empires\Racename folder.
- Make sure the reference in Racename_AI_Main.txt refers to the intended compiled files.
- The compiled script files will be automatically used by SE5 when that race is selected as an AI opponent.
Note: The Data\Ministers folder contains text files for each of the Minister styles that a player's race can select during game setup. These files are similar to a Racename_AI_Main.txt file and contain a reference to a set of AI script files. The reference scripts will be used by that player's ministers if they are turned on.
Additional Information On Functions
As some modders have found, not every function is described with as much detail, in the modding and scripting manuals, as might be desired. The following are functions that have additional information posted about them by other modders, gleaned through conversations with Aaron and their own trial and error.
- For more info see AI Reference
Custom AIs for Download or those in Development
The following link lists publicly released custom AIs: