Planetfall has a simple scripting system that enables to create custom game behavior inside a normal generated planet. The game also uses this for custom behavior to add flavor at certain events, or in campaigns.
The scripting follows the “Event condition action model” (https://en.wikipedia.org/wiki/Event_condition_action) In short this means upon certain game events, if certain conditions are met, it’s possible to do certain actions. For example: When a new turn starts (event), and the new turn is turn 2 (condition), spawn a new unit at the position of the leader of the player whose turn started (action).
Creating a script:
- As described in the modding basics, create a new mod and add a new resource pack file: https://aowplanetfall.paradoxwikis.com/Modding
- Make sure your new resource pack file is added in the package manager in the following menu: Content > Resource Packs
- Edit your new resource pack with the Resource Editor: Add a new Settings category
- Create a new resource of the type ‘Trigger (Script)’
- Set the Type to ‘Automatic’, then click the small orange box in the ‘Trigger Script’ field
- In the Trigger Editor Create a new Event (Right click > New), then choose ‘Time - Turn Started’, then click ‘Ok’
- Now create a new Condition (Right click > New), then choose ‘Type - Integer Comparison’
- Then click the first number (0) and change it to ‘Integer Current Round’, click ‘Ok’
- Then click the second number (0) and leave it to ‘Integer - Preset’, but change the 0 to 2.
- Now create a new Action (Right click > New), then choose ‘Unit - Create (Unit Resource)’
- Click ‘Side with Alias ’ and change it to ‘Core - Player’, then click ‘Player 1’ and change it to ‘Event Response - Triggering’. This will make sure we are talking about the player who triggered the event, in this case the player whose turn started. Click ‘Ok’.
- Click ‘Empty Position’ and change it to ‘Hex Pos - Unit Position’, then change ‘Unit with Alias ’ to ‘Core -Leader’, and change ‘Player 1’ to ‘Event Response - Triggering’.
- At this point what you have should look like the following image:
- Notice that we did not yet specify which unit should spawn. This is the [NULL] field. If you click that, then notice that there are no units to select from. Let’s fix this:
- Click the top menu ‘Content’ > ‘Resource Packs’ > ‘Add’ > Navigate to the steam install folder and select ‘Units_SpeciesPenguins.rpk’ (e.g. C:\Program Files (x86)\Steam\steamapps\common\Age of Wonders Planetfall\Content\Title\Packs\Species_Penguins\Units_SpeciesPenguins.rpk)
- Back to the script, click the [NULL] field and select Penguin.
- Don’t forget to save the pack! ‘File’ > ‘Save’
- Time for a test run! Make sure your mod is ‘Published’ (In Package Manager: ‘File’ > ‘Publish’, then enable the mod in the launcher. Now start the game, start any scenario, end your turn and you should have a Penguin! Yay~!
- If you follow all steps, then the script should work. However, it is very understandable that something can go wrong. So let’s enable debugging for scripts. Create a new file:
- C:\Users\<username>\Documents\Paradox Interactive\Age of Wonders Planetfall\Config\Game.cfg
- Edit this file with notepad, and add paste the following in there:
- Now try out the script again, but this time start the game Debug Mode. To do so: Scroll down in the Launcher and select the Launch button for ‘Open game in debug mode’
- Check your Logs folder for a new file ‘GameTriggers####_####.txt’
- C:\Users\<username>\Documents\Paradox Interactive\Age of Wonders Planetfall\Log\GameTriggers####_####.txt
- This file has a lot of text, so you’ll have to use the search feature of your text browser. Search for the name you assigned to your script in Resource Editor.
- The text there should be relatively straightforward to understand if there is an error with your script.