AI and Script Editing (SEV)

From SEWiki
Jump to: navigation, search

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.

Language Information

The scripting language SE5 uses is heavily based on the Pascal and BASIC languages. For information on functionality of the language, refer to the Scripting Language FAQ article.

Utilities Folder

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

  1. Racename_Main_Script.txt (SEV)
  2. Racename_Setup_Script.txt (SEV)

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.

  1. Script_AI_ColonyType.txt (SEV)
  2. Script_AI_Construction.txt (SEV)
  3. Script_AI_DesignCreation.txt (SEV)
  4. Script_AI_EnemyAnalysis.txt (SEV)
  5. Script_AI_GlobalConstants.txt (SEV)
  6. Script_AI_GlobalConstants_XXXXXX.txt (SEV)
  7. Script_AI_GlobalResearch.txt (SEV)
  8. Script_AI_GlobalSettings.txt (SEV)
  9. Script_AI_GlobalVariables.txt (SEV)
  10. Script_AI_Intelligence.txt (SEV)
  11. Script_AI_Lists.txt (SEV)
  12. Script_AI_Orders_Planets.txt (SEV)
  13. Script_AI_Orders_Ships.txt (SEV)
  14. Script_AI_Politics.txt (SEV)
  15. Script_AI_Research.txt (SEV)
  16. Script_AI_Restricted_SolarSystems.txt (SEV)
  17. 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.

  1. Script_Main_ExternalEvents.txt (SEV)
  2. Script_Main_Intelligence.txt (SEV)

Compiling Scripts

To compile a single script file:

  1. With the SE:V Script Parser, open the source script file you wish to compile.
  2. Press the Compile button.
  3. 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.

  1. Press the MakeFile button.
  2. Select the file that contains the list of scripts to compile.
  3. 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:

  1. The compiled Racename_Main_Script and Race_Setup_Script files are placed in the matching Empires\Racename folder.
  2. Make sure the reference in Racename_AI_Main.txt refers to the intended compiled files.
  3. 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.

  1. Sys_Get_Number_Of_Ships_With_Order
  2. Space_Object_Type_XXXX

Custom AIs for Download or those in Development

The following link lists publicly released custom AIs:

  1. Custom AIs for Download or Development (SEV)

External Links