Planet S

Planet S

Not enough ratings
Scenario Modding
By Glimmerlight Games
   
Award
Favorite
Favorited
Unfavorite
Introduction
Welcome to the scenario modding guide!

This guide will cover everything to create custom scenarios, including how to setup a basic scenario, how to create quest & dialogs as well as events, parameters and custom scenario specific gameplay adjustments.
This guide will NOT cover asset creation (textures / models / sounds), custom content like buildings or spaceships (please refer to our more general modding guide: Creating mods for Planet S) or the process of setting up a workshop mod through the editor (please also refer to the general guide linked above).
Setup
Make sure that you have setup a mod using the editor before you continue!

To start we first have to create a scenario script. Scenario scripts have to be placed the scripts/scenarios folder. The full path world be {PlanetSInstallFolder}/editor/mods/{YourModsName}/scripts/scenarios. We would also recommend you to create a subfolder with the name of your mod to prevent conflicts (e.g. {PlanetSInstallFolder}/editor/mods/{YourModsName}/scripts/scenarios/testMod/). In that folder or any subfolder you need create a lua file, for example testScenario.lua. This script file will contain everything that is relevant for your scenario.

The Scenario Script:
Every scenario script starts of with a registerScenario function:
registerScenario = function() return { name = "Test Scenario", description = "A Scenario for testing purposes", } end
This function will be automatically called by the game on startup and it wants a lua table with information and the structure of the scenario. In this guide we will refer to this table as the Scenario Table. In this basic example we are defining two of the required fields: "name" and "description". These will be used in scenario menu and to identify the scenario. This should already be enough to get your scenario registered, but the game won't consider it playable yet. That also means it won't show up in the scenario menu yet. It will however show up if you go and create a new creative game. But before you go and check, you first have to either upload your current mod to the workshop and subscribe to it yourself (don't worry other won't see it unless you set it to public) or you can copy your mods folder from the editor/mods folder to the mods folder of the game ({PlanetSInstallFolder}/mods) just make sure that you don't work on those files as they will only be uploaded from the editor mods folder. After you have done that, start the game. In the create menu (creative mode only) under "Game Options" there is a scenario combo box. Your scenario should now show up in that combo box. Make sure that it does before you continue!

That brings us to our next step. To make a scenario playable you also have to specify a savegame and at least one chapter. The savegame can't be just any savegame, it has to one specifically for your scenario. To create one you can use the creative mode by selecting the scenario during world creation.
Then once you are loaded into the game, create a savegame and copy from the saves folder, directly next to your scenario script file.
After that we can specify the savegame in the script as follow:
registerScenario = function() return { name = "Test Scenario", description = "A Scenario for testing purposes", savefileName = "TestScenario.pss", } end
You can rename the savegame however you want but make sure that it ends with .pss!

Next we need to specify a chapter. We will dive into chapters in the next section so for now you can just copy & paste this minimal setup:
registerScenario = function() return { name = "Test Scenario", description = "A Scenario for testing purposes", savefileName = "TestScenario.pss", chapters = { { chapterName = "First Chapter", parameters = { }, }, }, } end
Now your first scenario should be good to go and the game should consider it playable. Check that by starting the game (don't forget to copy any changed files / reupload) and going into the scenario menu. Your scenario should now be listed there!
Chapters & Scenario Parameters
Every scenario in Planet S is divided into one or more chapters. A chapter is basically a section of the scenario with its own set of quests, dialogs and parameters. As you might have noticed before, chapters are also defined in the scenario table.
A chapter has to have a name and a set of parameters. The first chapter will also be the one that the scenario will start with. We will go into how to jump to a chapter in the Callbacks & Logic section of this guide.
Here is an example for a scenario with 4 chapters:
registerScenario = function() return { name = "Test Scenario", description = "A Scenario for testing purposes", savefileName = "TestScenario.pss", chapters = { { chapterName = "Chapter 1", parameters = { ScenarioParameter.DISABLE_TRADER, ScenarioParameter.DISABLE_PIRATES, }, }, { chapterName = "Chapter 2", parameters = { ScenarioParameter.DISABLE_TRADER, }, }, { chapterName = "Chapter 3", parameters = { ScenarioParameter.DISABLE_PIRATES, }, }, { chapterName = "Chapter 4", parameters = { }, }, }, } end
Every chapter has its own set of parameters, which brings us to the next subject: Scenario Parameters!

Scenario Parameters
Scenario parameters are a way to configure certain parts of the game or to change the behavior of existing game components. In the example above there are two distinct scenario parameters: DISABLE_TRADER and DISABLE_PIRATES. Both do pretty much exactly what you would expect: DISABLE_TRADER prevents the neutral trader from spawning while the flag is active (He won't spawn in chapter 1 & 2 in this case) and DISABLE_PIRATES prevents the pirates from attacking (Chapter 1 & 3). Keep in mind that you need to enable the pirates during world creation, otherwise this parameter won't make any difference anyways. A full list of all available parameters can be found in the Reference: Scenario Parameters section of this guide.
Quests
Quests are the main way to define player objectives on a per chapter basis. Each chapter can have its own list of quests. A quest in Planet S is made up of an ID, name, description and at least one task. The ID is required, the name and description can also be a language key if you want to translate your scenario into different languages but we won't cover that in this guide.
A task is a specific action or goal that the player has to complete and all tasks of a quest have to be completed to fulfill the quest.
Here is an example for a scenario with two quests in the first chapter:
registerScenario = function() return { name = "Test Scenario", description = "A Scenario for testing purposes", savefileName = "TestScenario.pss", chapters = { { chapterName = "Chapter 1", parameters = { ScenarioParameter.DISABLE_TRADER, ScenarioParameter.DISABLE_PIRATES, }, quests = { { id = "chapter_1_quest_1_build_city", name = "Build a city", description = "Build a first small city to attract new residents.", tasks = { { type = "BuildingPlacedTask", buildingTypeID = "b_residenceWorkers", count = 10, }, { type = "BuildingPlacedTask", buildingTypeID = "b_cityCenter_0", count = 1, } }, }, { id = "chapter_1_quest_2_build_wind_park", name = "Build a wind park", description = "Construct a wind park to generate energy.", tasks = { { type = "BuildingPlacedTask", buildingTypeID = "b_windPark", count = 3, }, }, }, }, }, { chapterName = "Chapter 2", parameters = { ScenarioParameter.DISABLE_TRADER, }, }, }, } end
Lets break down how this works:
The first quest requires the player to build 10 worker residences and a city center on any planet they own combined.
The second quest requires the player to build 3 wind parks on any planet they own combined.
Both quests use the task type BuildingPlacedTask which just tracks building placement.
The parameter buildingTypeID specifies which building type to place and the parameter count how many to place. You could leave out these parameters and the task would still work. It would then default to 1 building of any type.
The same goes for other parameters that are not specified here. For this task for example there are parameters to specify the factionID (numerical index of the faction starting at 0, default is also 0), planetID (numerical index of the planet starting at 1, default is undefined), planetTypeID (string ID of the planet type, default is undefined) and tileID (numerical index of the tile on a planet, default is undefined). These params let you specify for example on which planet or type of planet something should be placed, by which faction or even on which tile specifically.
There are a ton of different task types in the game that you can use or combine to create different types of quests. Check Reference: Tasks for more details and a list of all task types.
When starting this scenario you might notice that the quests don't actually start or appear. We will cover that and other progression stuff in the next section.
Quest Progression
This section will cover a few different progression related topics:
  • Starting a quest
  • Automatically or manually advancing to the next quest
  • Tracking progress for inactive quests

Lets start with how to start a quest. By default the game will not start any of the quests in the active chapter and there can also only be one active quest at a time. To show our first quest after starting the scenario we need to tell the game to do exactly that. For that we can use a callback function which will be automatically invoked by the game when the scenario starts: onScenarioStart:
--registerScenario goes here --... onScenarioStart = function(scenarioState, world) ScenarioManager.startQuest("chapter_1_quest_1_build_city") end
In this callback we are calling the ScenarioManager and telling him to start the quest with the given ID. The game will then start and display the quest.
Note: startQuest will not cancel the currently active quest and will fail instead.
There is also a function to complete a quest: ScenarioManager.completeQuest(questID) and one to cancel the currently active quest: ScenarioManager.cancelActiveQuest().
On top of that you might also want to create gameplay dependent quests which can be done using ScenarioManager.createAndStartQuest(questTable). In that case questTable refers to a lua table with the same structure as any quest in the quests section of a chapter.
There are various other callbacks that you can use to start or cancel quests in different situations then just the start of the scenario and we will go into more detail in Callbacks & Logic.

Next up is advancing to the next quest. By default the game will automatically advance to the next quest in the quests table of a chapter. This behavior can be overwritten:
--registerScenario & chapter setup --... quests = { { id = "quest_0", --... }, { id = "quest_1", autoProgress = false, --... }, { id = "quest_2", nextQuestID = "quest_4", --... }, { id = "quest_3", --... }, { id = "quest_4", --... }, }, --...
In this case the first quest (quest_0) will automatically progress to quest_1 on completion, quest_1 on the other hand will not. After quest_1 there will be no active quest so you will have to tigger the next one manually using startQuest or createAndStartQuest.
quest_2 will also automatically progress and start the next quest but in this case not the next in the list but quest_4 instead.

The last progression related topic would be tracking of progress for inactive quests. Why or when do you need that? Lets revisit our first quest example:
--... quests = { { id = "chapter_1_quest_1_build_city", name = "Build a city", description = "Build a first small city to attract new residents.", tasks = { { type = "BuildingPlacedTask", buildingTypeID = "b_residenceWorkers", count = 10, }, { type = "BuildingPlacedTask", buildingTypeID = "b_cityCenter_0", count = 1, } }, }, { id = "chapter_1_quest_2_build_wind_park", name = "Build a wind park", description = "Construct a wind park to generate energy.", tasks = { { type = "BuildingPlacedTask", buildingTypeID = "b_windPark", count = 3, earlyCompletePossible = true, }, }, }, }, --...
Those where the first two quests but with one key difference in the second quests task: earlyCompletePossible = true . What this does is for the task to be completed before the quest has actually started. The problem this solves is that the player might choose to first build wind parks and then the city to complete the first quest. Without this progression flag the player would then have to again build additional 3 wind parks. With this flag the second quest will either complete automatically if the player has already build 3 wind parks or track the progress correctly if the player had already build 1 or 2 wind parks.
Note: This will only work for quests in the active chapter. Tasks for quests in any other chapter will not track any progress.
Quest Descriptions
At the moment our quest descriptions are a bit boring as they only contain plain predefined text. Instead what we would like to have is task progress to be displayed in the description of the quest. For example like this:
This can be done using description elements.
This is definition of the quest from the example image:
{ id = "chapter_1_quest_1_build_city", name = "Build a city", description = "Build a first small city to attract new residents.\n - Build Worker Residences %0\n - Build a City Center %1", descriptionElements = { "task0.progress", "task1.progress", }, tasks = { { type = "BuildingPlacedTask", buildingTypeID = "b_residenceWorkers", count = 10, }, { type = "BuildingPlacedTask", buildingTypeID = "b_cityCenter_0", count = 1, } }, }
In our quest description we can use /n to insert a line break / make the text multi line and we can use % followed by any number between 0 and 9 to insert dynamic quest specific elements into our description. These markers will be replaced by content that is defined in descriptionElements in our quest definition. In this case we are replacing %0 with the progress of our first task and %1 with the progress of our second task.
There are various different description elements that you can use. Each task has a progress and completed element ("taskX.progress", "taskX.completed") but some tasks also have their own special elements. Check References: Tasks for which are available for specific tasks. On top of task elements there is also a quest progress ("quest.progress") and there are also variable set elements but we will cover those later in Saving Progress.
Callbacks & Logic #1
This section will cover more types of callbacks that the scenario system provides as well as how to implement your own scenario logic and how to utilize the event system.
To start of here is a list of available callbacks that you can add to your scenario script:
onScenarioStart = function(scenarioState, world)
Called as soon as the player starts the scenario. (Not called when loading a savegame of the scenario, only once at the start)
onUpdate = function(scenarioState, world, passedTime)
Called every frame. The game tick time that has passed in the meantime is available through the third parameter. Keep in mind that it can be 0.
onQuestEvent = function(scenarioState, eventID, event)
Called whenever a quest event is fired. You can find more info on this later in this section.
onQuestStarted = function(scenarioState, questID)
Called whenever a quest is either started through startQuest / createAndStartQuest or when a quest auto progresses to the next one.
onQuestCompleted = function(scenarioState, questID)
Called whenever a quest gets completed by the player or through completeQuest. Canceling a quest will not trigger this callback.
onTaskCompleted = function(scenarioState, questID, taskID)
Called whenever a task for a quest gets completed. The taskID can be set in any task definition. By default its an empty string.
onVictoryConditionCompleted = function(scenarioState, questID)
Called whenever a victory condition gets completed. More on that in Victory & Defeat
onDefeatConditionCompleted = function(scenarioState, questID)
Called whenever a defeat condition gets completed. More on that in Victory & Defeat
onChapterChanged = function(scenarioState, chapterIndex)
Called whenever a chapter is being changed. Also triggered before onScenarioStart when activating the first chapter.
onDialogFinished = function(scenarioState, dialogID, canceled)
Called whenever a dialog finished or was canceled. More on that in Dialogs
The callback onQuestEvent is a special one and can be very powerful as it allows you or your scenario to react on stuff based on various different things that can happen in Planet S. There are a ton of different events that are fired when playing the game with all kinds of information attachted to them. You can find a full list in Reference: Events.
Events all have a numerical ID with which you can easily identify which event was just fired. You can compare the incoming eventID parameter with the ID of the event type that you are looking for. You can access each event type ID by adding .ID to the type like this: BuildingPlacedQuestEvent.ID.
To access any data that the event carries you first have to cast the incoming event data to the specific event using the cast function like this: BuildingPlacedQuestEvent.cast(event).
Lets look at to examples for how you might use this system:
onQuestEvent = function(scenarioState, eventID, event) if eventID == PiratesSpawnedQuestEvent.ID then ScenarioManager.startQuest("defeat_incoming_pirates_quest") end end
This is fairly simple and self-explanatory. We wait for the PiratesSpawnedQuestEvent, which triggers whenever the pirates spawn, by checking the incoming eventID parameter for PiratesSpawnedQuestEvent.ID. Then when the event triggers we start a quest where the player has to defeat those pirates. Pretty simple, right?
Now lets look at a more complex example where we might want to use event data:
onQuestEvent = function(scenarioState, eventID, event) if eventID == ColonyEstablishedQuestEvent.ID then local colonyEventData = ColonyEstablishedQuestEvent.cast(event) --Check for the bots faction, assuming 1 is the bot faction if colonyEventData.factionID == 1 then if colonyEventData.planetTypeID == "pt_normal" then --This will most likely be the first or main colony of the bot ScenarioManager.createAndStartQuest({ id = "defeat_bot_colony_quest", name = "Defeat the Bot Colony", description = "Eliminate the bot colony that has established itself.", tasks = { { type = "ColonyTakeoverTask", planetID = colonyEventData.planetID, newFactionID = 0, -- Assuming 0 is the player's faction }, }, }) end end end end
In this example we are looking for a ColonyEstablishedQuestEvent which triggers whenever a faction colonizes a previously uncolonized planet. Then we use the event data to filter for a bot faction and a normal / grass planet to be the planet type. Then we trigger a dynamic quest which will ask for the player to take specifically this colony from the bot. We specify the planet by using the planetID of the event which is part of the event data.

Callbacks & Logic #2
So there are plenty of ways to get feedback from the game but what else can we do to react to player behavior or other events?
We have already used some function like startQuest, createAndStartQuest or finishedQuest which are all called on the ScenarioManager. This manager has quite a few more function you can use to perform different things. You can find a full list in Reference: Scenario Manager.
Again here are two more examples for what you can do using the ScenarioManager:
onQuestCompleted = function(scenarioState, questID, canceled) if questID == "defeat_bot_colony_quest" then local playerMainPlanetID = ScenarioManager.scenarioGetInterestingPlanetID(0, "pt_normal") --This should get the player's main planet ScenarioManager.scenarioAddItems(playerMainPlanetID, "i_guns", 50) --Add 50 guns to the player's main planet as a reward ScenarioManager.scenarioAddCredits(0, 100000) --Give the player 100k credits as a reward end end
In this example we are looking for the quest from a previous example to be completed. Then we look for the players main planet using ScenarioManager.scenarioGetInterestingPlanetID. This function returns the ID of the most interesting planet with the given constraints. The most interesting planet is the one with the highest economic score. We are looking for a planet owned by faction 0 (the player) and of type "pt_normal". If the player doesn't own a planet of that type the function will fallback to any planet type and then to any faction if the player doesn't own any planet at all.
With that info we grant that planet 50 guns using ScenarioManager.scenarioGiveItemsToPlanet as a reward. On top of that we also gift the player faction 100k credits using ScenarioManager.scenarioAddCredits.

Here is another more complex example:
onQuestEvent = function(scenarioState, eventID, event) if eventID == ColonyEstablishedQuestEvent.ID then local eventData = ColonyEstablishedQuestEvent.cast(event) if eventData.factionID == 0 then ScenarioManager.scenarioTriggerPiratesManuallyFaction(0, { { spaceshipTypeID = "s_battleCruiser", count = 3, }, }) end elseif eventID == PiratesRetreatedQuestEvent.ID then local eventData = PiratesRetreatedQuestEvent.cast(event) if eventData.defeated then local spaceshipID = ScenarioManager.scenarioCreateShipSpace("s_battleCruiser", 0, Vector2f.createValue(GameValues.SAFE_SPAWN_DISTANCE), true) local playerMainPlanetID = ScenarioManager.scenarioGetInterestingPlanetID(0, "pt_normal") ScenarioManager.scenarioShipSetTargetPlanet(spaceshipID, playerMainPlanetID) end end end
Here we wait for the player faction to establish any colony using the event system. As soon as that happens we manually trigger the pirates with a custom evil fleet of 3 battle cruisers which specifically target the player faction using ScenarioManager.scenarioTriggerPiratesManuallyFaction. Then we wait for the PiratesRetreatedQuestEvent and check if they were defeated or if they just left because they were successful with their raid. If they were defeated we grant the player a battle cruiser using ScenarioManager.scenarioCreateShipSpace which we spawn outside of the map. We then order it to fly to the players main planet using ScenarioManager.scenarioShipSetTargetPlanet.
Saving Progress
Since you can do quite a lot of different custom stuff in scenarios you might also want to store some data or custom progress in the savegame file as global or local variables in the scenario script will not survive a game restart and could even leak into other scenario runs.
As previously mentioned in Quest Descriptions there is something called a variable set which is attached to the scenario state object that is passed into all callbacks as a parameter.
This variable set will be stored into and loaded from the savegame file so its safe to use it as a way to store progress.
Since we have to handle this on the C++ side of the game, its a bit limited in what it can store. For example it can't store lua tables, arrays, maps or strings, just numbers and bools. It basically works like a map or dictionary with key-value pairs.
Again here is an example:
onQuestEvent = function(scenarioState, eventID, event) if eventID == TechnologyUnlockedQuestEvent.ID then local eventData = TechnologyUnlockedQuestEvent.cast(event) if eventData.factionID == 0 then if not scenarioState.variableSet:doesVariableExist("technologiesUnlocked") then scenarioState.variableSet:addUInt32_t("technologiesUnlocked", 1) else local newValue = scenarioState.variableSet:getUInt32_t("technologiesUnlocked") + 1 scenarioState.variableSet:setUInt32_t("technologiesUnlocked", newValue) if newValue == 5 then ScenarioManager.scenarioAddCredits(0, 50000) --Give the player 50k credits as a reward for unlocking 5 technologies scenarioState.variableSet:removeVariable("technologiesUnlocked") end end end end end
Here we count how many technologies the player has unlocked and give him 50k credits every time he unlocks 5 techologies. We store our progress in the variable set under the name "technologiesUnlocked" and we use an unsigned integer as the data type.
As you can see you can query the existance of a variable using doesVariableExist, add one using addUInt32_t (or addInt32_t, addFloat, addBool), set it using setUint32_t (same for the other three types) and remove it using removeVarible. You can also clear the entire set using clear.
The actual saving and loading will be taken care of by the game just like for the progress of quests, tasks and dialogs.
Also as mentioned before you can also display variable set values in quest descriptions using description elements. They need to be specified as follows: "variableSet.type.variableName", so for our example that would be as follows: "variableSet.uint32_t.technologiesUnlocked".
Victory & Defeat
Next we will cover how to put logic in place so that a scenario can be won or lost and specific victory & defeat conditions / quests.
You as the scenario creator decide when the scenario can be won and when a player might lose. To trigger either you again have to call the Scenario Manager.
Here is an example:
onQuestEvent = function(scenarioState, eventID, event) if eventID == SpaceshipConstructedQuestEvent.ID then local eventData = SpaceshipConstructedQuestEvent.cast(event) if eventData.factionID == 0 and eventData.spaceshipTypeID == "s_exoSpaceship" then ScenarioManager.finishScenarioWin("You have successfully constructed the Exo Spaceship! Congratulations!", true, false, false) end elseif eventID == SpaceshipDestroyedQuestEvent.ID then local eventData = SpaceshipDestroyedQuestEvent.cast(event) if eventData.factionID == 0 and eventData.spaceshipTypeID == "s_explorer" then ScenarioManager.finishScenarioLoss("Your Explorer spaceship has been destroyed! Game Over.", false, false, false) end end end
In this case the player will trigger a scenario victory when that faction will construct an exo spaceship. A scenario defeat will be triggered when any explorer of the player faction gets destroyed.
Both outcomes would look like this when triggered:
Victory:
Defeat:
In short: you can trigger a victory or defeat at any point using ScenarioManager.finishScenarioWin or ScenarioManager.finishScenarioLoss. The parameters are the same for both functions and work as follows: The first parameter is a message that will be displayed in the victory / defeat screen, the second parameter defines, if the player should be able to keep playing after the victory / defeat screen. The third and fourth parameter should usually always be set to false. The third one defines if the game should instantly just exit back to the main menu without displaying a victory or defeat screen and the fourth one is just for campaign scenarios and has no impact outside of that.

It would also be nice to have the option to display this information to the player so that its easy to see how to win or lose. Thats what victory and defeat conditions are for. Both are just like quests but you can have multiple active at the same time. This has the nice bonus that you can use the builtin quest tasks and description system to check for these conditions. They are also marked with a special icon in the quest UI:



These victory and defeat conditions can be added or removed using ScenarioManager.addVictoryCondition(questTable), ScenarioManager.addDefeatCondition(questTable), ScenarioManager.removeVictoryCondition(id) and ScenarioManager.removeDefeatCondition(id).
Note: When these get completed, they won't auto trigger a victory or defeat and they will also not trigger the regular onQuestCompleted but the onVictoryConditionCompleted or onDefeatConditionCompleted instead.
Both condition types can also be specified per chapter similar to quests but in a dedicated victoryConditions and defeatConditions table.
Here is the example from above turned into victory and defeat conditions:
registerScenario = function() return { name = "Test Scenario", description = "A Scenario for testing purposes", savefileName = "TestScenario.pss", chapters = { { chapterName = "Chapter 1", parameters = { ScenarioParameter.DISABLE_TRADER, ScenarioParameter.DISABLE_PIRATES, }, quests = { --.... }, victoryConditions = { { id = "construct_exo_spaceship", name = "Construct an Exo Spaceship", description = "Construct an Exo Spaceship to escape the solar system.", tasks = { { type = "SpaceshipConstructedTask", spaceshipTypeID = "s_exoSpaceship", }, }, }, }, defeatConditions = { { id = "explorer_destroyed", name = "Explorer Destroyed", description = "Your explorer has been destroyed.", tasks = { { type = "SpaceshipDestroyedTask", spaceshipTypeID = "s_explorer", }, }, }, }, }, }, } end


Dialogs
In your scenario you might want to tie things together by telling a story. This can be done through dialogs. Dialogs in Planet S are fairly simple as there is no player input or decisions, just characters and text lines. Example:

Dialogs are made up of pages with each page being made up of a character state and a text line. Dialogs are defined on a per chapter basis just like quests, victory and defeat conditions.
Here is an example for a simple dialog:
registerScenario = function() return { name = "Test Scenario", description = "A Scenario for testing purposes", savefileName = "TestScenario.pss", chapters = { { chapterName = "Chapter 1", parameters = { ScenarioParameter.DISABLE_TRADER, ScenarioParameter.DISABLE_PIRATES, }, dialogs = { { id = "simple_dialog", pages = { { textID = "Hi dad! How are you?", character = { characterID = "c_hazel", characterIdleAnimationID = "Idle", characterTalkAnimationID = "Talk", characterIdleExpressionID = "idle", characterTalkExpressionID = "talk", }, }, { textID = "I'm fine, thanks for asking!", character = { characterID = "c_theo", characterIdleAnimationID = "Idle", characterTalkAnimationID = "Talk", characterIdleExpressionID = "idle", characterTalkExpressionID = "talk", } }, { textID = "That's great to hear!", character = { characterID = "c_hazel", characterIdleAnimationID = "Idle", characterTalkAnimationID = "Talk", characterIdleExpressionID = "idle", characterTalkExpressionID = "talk", }, }, }, }, }, quests = { --... }, }, }, } end
This is a simple conversation between Hazel and Theo from the campaign. The dialog is made up of three pages. The character expressions are a bit tedious to define so here is a tip: The character expression setups are all predefined in "scripts/scenarioDialogs/character_animations.lua" you can include this using require in your scenario script and use the predefined tables from that.
This is the adjusted script setup:
require "scripts/scenarioDialogs/character_animations.lua" registerScenario = function() return { name = "Test Scenario", description = "A Scenario for testing purposes", savefileName = "TestScenario.pss", chapters = { { chapterName = "Chapter 1", parameters = { ScenarioParameter.DISABLE_TRADER, ScenarioParameter.DISABLE_PIRATES, }, dialogs = { { id = "simple_dialog", pages = { { textID = "Hi dad! How are you?", character = hazel_neutral, }, { textID = "I'm fine, thanks for asking!", character = theo_neutral, }, { textID = "That's great to hear!", character = hazel_neutral, }, }, }, }, quests = { --... }, }, }, } end
You can find a full list of predefined character expression setups in Reference: Characters.
Now we can show / start a dialog using ScenarioManager.showDialog(dialogID, cancelActive). You can also hide / cancel any an active dialog using ScenarioManager.hideDialog.
Scenario Specific Content
Another thing you might want to do in your scenario is to have custom buildings, spaceships or even planets or a fully custom world type. All of this is already possible with mods. Luckily scenarios scripts have the same capabilities as mod scripts so you can also have a registerSpaceships, registerBuildings or registerWorldTypes (or all other register functions that are available in mod scripts). You can also use your custom world type to create a savegame for your scenario. Just setup everything in the scenario script file, select your scenario in the creative create menu and then you should be able to select any world type from the scenario script.
Quick example:
registerSpaceships = function() ContentRegistry.registerSpaceship("s_interceptor", { spaceshipYard = "", }) end
This will remove the interceptor from the small spaceship yard in the scenario. For more info refer to our other modding guide.
Bot Profiles
The behavior of bots in scenarios can also be modified using bot profiles. Bot profiles can be set per bot per chapter. There are three different bot profiles: "STANDARD" (the default behavior), "NO_PROGRESS" (the bot will maintain its current setup but it won't build ships, upgrade or expand its cities or attack anyone) and "NO_OFFENSE" (the bot won't build military to attack other bots or players).
Here is an example for how to set a bot profile:
registerScenario = function() return { name = "Test Scenario", description = "A Scenario for testing purposes", savefileName = "TestScenario.pss", chapters = { { chapterName = "Chapter 1", parameters = { ScenarioParameter.DISABLE_TRADER, ScenarioParameter.DISABLE_PIRATES, }, botProfiles = { { factionID = 1, profileName = "NO_PROGRESS", }, }, dialogs = { --... }, quests = { --... }, }, }, } end
Tips & Tricks
This section covers a couple of tricks that might help you:
  • If you have already released your scenario and plan to fix or change something about it keep this in mind: Changing the quest structure / tasks or chapters can break existing scenario savegames. In those cases it makes more sense to copy & paste your existing scenario script and to make these fundamental changes to that script file. Don't forget to add something like a version suffix to the scenario ID and maybe also name. Changes in the logic like in the callbacks are usually fine but that depends on what you are changing.
  • When you make changes to quests or description elements or chapters during development then keep in mind that these changes might not show up in your testing savegame of your scenario (not the one you created in creative mode but any savegame after actually starting the scenario to test it). So if you don't see your change where you expect it, consider restarting the scenario from scratch though the scenario menu.
  • Since it can get tedious to replay all parts of your scenario every time you have to restart you can add a trick to skip quests or build your own cheats based on keyboard input. Keep in mind to remove this test code before uploading your scenario or otherwise people might accidentally run into issues or cheat when they don't want to. Here is an example for how to skip the active quest based on a key input (pressing F8 in this case):
    AEX:loadLibraries({ "AEX_Platform" }) --Should be at the top of your script file, first line --.... onUpdate = function(scenarioState, world, passedTime) if AEX_InputHandler:wasKeyPressed(InputHandler.KEY_F8) then ScenarioManager.scenarioSkipQuest() end end
    The active quest will be auto completed and trigger onQuestCompleted for that quest. Just know that this might mess with what you are doing in your logic since the player isn't actually completing the tasks.
Reference: Scenario Parameters
Parameter (Usage: ScenarioParameter.XXX)
Description
DISABLE_VICTORY_CONDITIONS
Disables all existing victory conditions in the game. This includes the science & the military victory
DISABLE_TRADER
Prevents the neutral trader from spawning.
DISABLE_PIRATES
Prevents pirates from spawning. Keep in mind that pirates have to be enabled in the world options for this to have any effect.
DISABLE_FAKE_TRADER
Prevents the pirates from using the fake trader spaceship.
SUPPRESS_BUILDING
Prevents the player from building, reparing or upgrading any buildings.
DISABLE_RESEARCH
Disables research entirely.
SUPPRESS_PLAYER_SCIENCE
Prevents the player from chosing or upgrading to science buildings.
SUPPRESS_PLAYER_MILITARY
Prevents the player from chosing or upgrading to military buildings.
SUPPRESS_BOT_SCIENCE
Prevents bots from chosing or upgrading to science buildings.
SUPPRESS_BOT_MILITARY
Prevents bots from chosing or upgrading to military buildings.
DISABLE_MILITARY_BUILDINGS
Disallows building, upgrading or reparing buildings with a military score > 0.
DISABLE_MILITARY_SPACESHIPS
Disables construction of spaceships with a military score > 0.
AT_LEAST_ONE_TRADE_ENTRY
Prevents the player from removing all trade entries in a spaceport.
DISABLE_DIPLOMACY
Disables the diplomacy menu.
BOTS_NO_WARP_GATES_CAP
Disables the warp gate capacity for bots.
DISABLE_PLAYER_AUTO_ATTACKS
Disables auto attacks for player ships. (Ships won't automatically shoot at nearby enemies)
TAKEOVER_PRESERVE_BUILDINGS
Colony takeovers will not destroy or ruin all buildings but will instead keep everything intact.
TRADER_PLAYER_TIER_4
The traders budget will be adjusted to the same level as if the player had reached tier 4.
DISABLE_BUILDING_WEAPONS
Buildings with a weapon will not shoot any target.
HIGH_EXO_EXPEDITION_DIFFICULTY
The exo spaceship expedition difficulty will be increased by decreasing the cone angle for any potential exit route. (Increase in average exit route length)
BLOCK_SCENARIO_LOSS
Blocks / Skips any scenario loss triggers.
HIDE_SUN_DYSON_UI
Hides the dyson swarm you that is usually displayed when you select the sun.
BLOCK_RESEARCH_PROGRESS
Prevents any research progress from happening.
SUPRESS_AUTO_SAVE
Disables the auto save system.
BOT_IDLE
Buts all bots into idle mode. Idling bots won't do anything.
BOT_UNLIMITED_CREDITS
Will give the bots an infinite amount of credits to work with.
BOT_DONT_ATTACK_FIRST
Prevents bots from striking first. They will only attack the players colonies if they were attacked before.
BOT_NO_DIPLOMACY
Prevents bots from using the diplomacy system.
BOT_DONT_FIX_OVERPRODUCTION
Prevents bots from fixing item overproduction (pausing or destroying buildings to reduce production).
BOT_NO_RESEARCH
Prevents the bot from using the research system.
BOT_FOCUS_GAS_PLANETS
Bots will only focus on overtaking gas planets.
BOT_NO_AUTO_ATTACKS
Bots won't automatically attack player ships or colonies.
BOT_FOCUS_PIRATES
Bots will focus on attacking targets.
BOT_DISABLE_TRADE_ROUTES
Bots won't update their trade routes.
BOT_DISABLE_TRADE_ROUTES_ESCORTS
Bots won't update any escorts for their trade routes.
BOT_PERMANENT_PLANET_ATTACKS
Bots will focus on attacking targeted planets constantly until they are captured. This will only work if bots are told to attack one or more planets.
BOT_ALLOW_MULTIPLE_OVERTAKES
Will allow bots to attack multiple planets at once.
BOT_UNLOCK_SPACESHIPS_SCIENCE
Automatically unlocks all science spaceships for bots.
BOT_UNLOCK_SPACESHIPS_MILITARY
Automatically unlocks all military spaceships for bots.
BOT_USE_ACTUAL_PRODUCTION_RATE
Will change the way how bots export items from a planet. Usually they use a custom heuristic to determine what to export from a planet but his will cause them to use the actual production rate of the planet.
Reference: Tasks #1
BuildingPlacedTask
Parameter
Type
Default
buildingTypeID
String
Undefined
factionID
Number
0
planetID
Number
Undefined
planetTypeID
String
Undefined
tileID
Number
Undefined
count
Number
1
Description Elements:
  • buildingTypeID
  • factionID
  • planetID
  • planetTypeID
  • count
  • maxCount

BuildingUpgradedTask
Parameter
Type
Default
newBuildingTypeID
String
Undefined
oldBuildingTypeID
String
Undefined
factionID
Number
0
planetID
Number
Undefined
planetTypeID
String
Undefined
tileID
Number
Undefined
count
Number
1
Description Elements:
  • newBuildingTypeID
  • oldBuildingTypeID
  • factionID
  • planetID
  • planetTypeID
  • count
  • maxCount

BuildingRuinedTask
Parameter
Type
Default
buildingTypeID
String
Undefined
factionID
Number
0
planetID
Number
Undefined
planetTypeID
String
Undefined
tileID
Number
Undefined
count
Number
1
Description Elements:
  • buildingTypeID
  • factionID
  • planetID
  • planetTypeID
  • count
  • maxCount

BuildingDestroyedTask
Parameter
Type
Default
buildingTypeID
String
Undefined
factionID
Number
0
planetID
Number
Undefined
planetTypeID
String
Undefined
tileID
Number
Undefined
count
Number
1
Description Elements:
  • buildingTypeID
  • factionID
  • planetID
  • planetTypeID
  • count
  • maxCount

SpaceshipConstructedTask
Parameter
Type
Default
spaceshipTypeID
String
Undefined
spaceshipID
Number
Undefined
factionID
Number
0
count
Number
1
Description Elements:
  • spaceshipTypeID
  • factionID
  • spaceshipID
  • count
  • maxCount

SpaceshipDestroyedTask
Parameter
Type
Default
spaceshipTypeID
String
Undefined
spaceshipID
Number
Undefined
factionID
Number
0
count
Number
1
Description Elements:
  • spaceshipTypeID
  • factionID
  • spaceshipID
  • count
  • maxCount

VictorySpaceshipEscapedTask
Parameter
Type
Default
spaceshipID
Number
Undefined
factionID
Number
0
Description Elements:
  • factionID
  • spaceshipID

ColonyEstablishedTask
Parameter
Type
Default
factionID
Number
0
planetID
Number
Undefined
planetTypeID
String
Undefined
Description Elements:
  • factionID
  • planetID
  • planetTypeID
Reference: Tasks #2
ColonyDestroyedTask
Parameter
Type
Default
factionID
Number
0
planetID
Number
Undefined
planetTypeID
String
Undefined
Description Elements:
  • factionID
  • planetID
  • planetTypeID

ColonyTakeoverTask
Parameter
Type
Default
newFactionID
Number
FACTION_ID_NONE
oldFactionID
Number
FACTION_ID_NONE
planetID
Number
Undefined
planetTypeID
String
Undefined
Description Elements:
  • newFactionID
  • oldFactionID
  • planetID
  • planetTypeID

FactionDefeatedTask
Parameter
Type
Default
factionID
Number
0
Description Elements:
  • factionID

TechnologyUnlockedTask
Parameter
Type
Default
technologyID
String
Undefined
factionID
Number
0
Description Elements:
  • technologyID
  • factionID

TradeRouteEstablishedTask
Parameter
Type
Default
factionID
Number
0
sourcePlanetID
Number
Undefined
destinationPlanetID
Number
Undefined
itemTypeID
String
Undefined
Description Elements:
  • factionID
  • sourcePlanetID
  • destinationPlanetID
  • itemID

PiratesDefeatedTask
Parameter
Type
Default
allowRegularRetreat
Boolean
false

TraderArrivedTask
Parameter
Type
Default

TraderLeftTask
Parameter
Type
Default

DysonProbeLaunchedTask
Parameter
Type
Default
factionID
Number
0
activeCount
Number
1
Description Elements:
  • factionID
  • activeCount
  • count

TradeEntryCreatedTask
Parameter
Type
Default
factionID
Number
0
planetID
Number
Undefined
itemTypeID
String
Undefined
buy
Boolean
false
Description Elements:
  • factionID
  • planetID
  • itemID

TradeEntryRemovedTask
Parameter
Type
Default
factionID
Number
0
planetID
Number
Undefined
itemTypeID
String
Undefined
Description Elements:
  • factionID
  • planetID
  • itemID

PopulationTask
Parameter
Type
Default
factionID
Number
0
planetID
Number
Undefined
planetTypeID
String
Undefined
populationID
Number
Undefined
populationCount
Number
1
Description Elements:
  • factionID
  • planetID
  • planetTypeID
  • populationID
  • populationCount

ItemTask
Parameter
Type
Default
factionID
Number
0
planetID
Number
Undefined
planetTypeID
String
Undefined
itemTypeID
String
Undefined
itemCount
Number
1
Description Elements:
  • factionID
  • planetID
  • planetTypeID
  • itemID
  • itemCount
Reference: Tasks #3
MoneyTask
Parameter
Type
Default
factionID
Number
0
moneyAmount
Number
0.0
Description Elements:
  • factionID
  • moneyAmount

UpkeepTask
Parameter
Type
Default
factionID
Number
0
upkeepAmount
Number
0.0
Description Elements:
  • factionID
  • upkeepAmount

PowerTask
Parameter
Type
Default
factionID
Number
0
planetID
Number
Undefined
planetTypeID
String
Undefined
powerAmount
Number
0
Description Elements:
  • factionID
  • planetID
  • planetTypeID
  • powerAmount

ItemProductionRateTask
Parameter
Type
Default
factionID
Number
0
planetID
Number
Undefined
planetTypeID
String
Undefined
itemTypeID
String
Undefined
productionRate
Number
0.0
Description Elements:
  • factionID
  • planetID
  • planetTypeID
  • itemID
  • productionRate

PopulationSupplyTask
Parameter
Type
Default
factionID
Number
0
planetID
Number
Undefined
planetTypeID
String
Undefined
itemTypeID
String
Undefined
Description Elements:
  • factionID
  • planetID
  • planetTypeID
  • itemID

PlanetLostTask
Parameter
Type
Default
factionID
Number
0
planetID
Number
Undefined
planetTypeID
String
Undefined
count
Number
1
Description Elements:
  • factionID
  • planetID
  • planetTypeID
  • count
  • maxCount

PlanetRepairTask
Parameter
Type
Default
factionID
Number
0
planetID
Number
Undefined
planetTypeID
String
Undefined
Description Elements:
  • factionID
  • planetID
  • planetTypeID

DysonSwarmBuildTask
Parameter
Type
Default
factionID
Number
0
Description Elements:
  • factionID
  • count

ScoreTask
Parameter
Type
Default
factionID
Number
0
planetID
Number
Undefined
score
Number
1
military
Boolean
false
Description Elements:
  • factionID
  • planetID
  • score

SpaceshipDamageTask
Parameter
Type
Default
factionID
Number
0
spaceshipID
Number
Undefined
damage
Number
0
Description Elements:
  • factionID
  • spaceshipID
  • damage
  • maxDamage

SpaceshipLocationTask
Parameter
Type
Default
factionID
Number
0
spaceshipID
Number
Undefined
planetID
Number
Undefined
planetTypeID
String
Undefined
tileID
Number
Undefined
position
Vector2f
Vector2f.createValues(0.0, 0.0)
distanceTolerance
Number
25.0
Description Elements:
  • factionID
  • spaceshipID
  • planetID
  • planetTypeID
  • timer
  • maxTimer
  • timerFormattedSeconds
  • timerFormattedMinutes
Reference: Tasks #4
DeliverItemsTask
Parameter
Type
Default
factionID
Number
0
spaceshipID
Number
Undefined
planetID
Number
Undefined
planetTypeID
String
Undefined
tileID
Number
Undefined
position
Vector2f
Vector2f.createValues(0.0, 0.0)
distanceTolerance
Number
25.0
itemTypeID
String
Undefined
itemCount
Number
1
justPickup
Boolean
false
Description Elements:
  • factionID
  • spaceshipID
  • planetID
  • planetTypeID
  • itemID
  • itemCount

TimerTask
Parameter
Type
Default
duration
Number
0.0
Description Elements:
  • duration
  • time
  • timeLeft
  • timeFormattedSeconds
  • timeFormattedMinutes

SpaceshipHealthTask
Parameter
Type
Default
factionID
Number
0
spaceshipID
Number
Undefined
healthPercentage
Number
0.5
below
Boolean
true
Description Elements:
  • factionID
  • spaceshipID
  • healthPercentage
  • currentHealthPercentage
  • healthPercentageTarget

SpaceshipWorldBorderTask
Parameter
Type
Default
factionID
Number
0
spaceshipID
Number
Undefined
distanceTolerance
Number
25.0

ColonyKeepTask
Parameter
Type
Default
factionID
Number
0
planetIDs
Table of Number
Undefined
Description Elements:
  • factionID
  • planetIDs
  • remainingPlanetIDs

TriggerTask
Parameter
Type
Default
remainingTriggers
Table of String
Undefined

TerraformingTask
Parameter
Type
Default
factionID
Number
0
planetID
Number
Undefined
tileID
Number
Undefined
count
Number
1
Description Elements:
  • factionID
  • planetID
  • count
  • maxCount

OpenStatisticsMenuTask
Parameter
Type
Default

OpenResearchMenuTask
Parameter
Type
Default

OpenTradeRouteMenuTask
Parameter
Type
Default

OpenDiplomacyMenuTask
Parameter
Type
Default

StartResearchTask
Parameter
Type
Default
factionID
Number
0
technologyTypeID
String
Undefined
Description Elements:
  • factionID
  • technologyTypeID

DiplomacyStatusTask
Parameter
Type
Default
factionID0
Number
0
factionID1
Number
0
newStatus
DIP_STATUS (can be either DIP_STATUS_WAR, DIP_STATUS_PEACE, DIP_STATUS_TRADE, DIP_STATUS_ALLIANCE)
Undefined
Description Elements:
  • factionID0
  • factionID1
Reference: Tasks #5
ColonySharePurchaseTask
Parameter
Type
Default
factionIDFrom
Number
0
factionIDTo
Number
0
planetID
Number
Undefined
planetTypeID
String
Undefined
Description Elements:
  • factionIDFrom
  • factionIDTo
  • planetID
  • planetTypeID

TradeTask
Parameter
Type
Default
initiatorFactionID
Number
0
targetFactionID
Number
0
spaceshipID
Number
Undefined
planetID
Number
Undefined
planetTypeID
String
Undefined
transactionAmount
Number
0.0
Description Elements:
  • initiatorFactionID
  • targetFactionID
  • spaceshipID
  • planetID
  • planetTypeID
  • transactionAmount

SpaceshipConvoyTask
Parameter
Type
Default
factionID
Number
0
spaceshipID
Number
Undefined
convoyTargetSpaceshipID
Number
Undefined
Description Elements:
  • factionID
  • spaceshipID
  • convoyTargetSpaceshipID
Reference: Events #1
BuildingPlacedQuestEvent
Parameter
Type
buildingTypeID
String
factionID
Number
planetID
Number
planetTypeID
String
tileID
Number

BuildingUpgradedQuestEvent
Parameter
Type
newBuildingTypeID
String
oldBuildingTypeID
String
factionID
Number
planetID
Number
planetTypeID
String
tileID
Number

BuildingRepairedQuestEvent
Parameter
Type
buildingTypeID
String
factionID
Number
planetID
Number
planetTypeID
String
tileID
Number

BuildingRuinedQuestEvent
Parameter
Type
buildingTypeID
String
factionID
Number
planetID
Number
planetTypeID
String
tileID
Number

BuildingDestroyedQuestEvent
Parameter
Type
buildingTypeID
String
factionID
Number
planetID
Number
planetTypeID
String
tileID
Number

SpaceshipConstructedQuestEvent
Parameter
Type
spaceshipTypeID
String
spaceshipID
Number
factionID
Number

SpaceshipDestroyedQuestEvent
Parameter
Type
spaceshipTypeID
String
spaceshipID
Number
factionID
Number

VictorySpaceshipEscapedQuestEvent
Parameter
Type
spaceshipID
Number
factionID
Number

ColonyEstablishedQuestEvent
Parameter
Type
factionID
Number
planetID
Number
planetTypeID
String

ColonyDestroyedQuestEvent
Parameter
Type
factionID
Number
planetID
Number
planetTypeID
String

ColonyTakeoverQuestEvent
Parameter
Type
newFactionID
Number
oldFactionID
Number
planetID
Number
planetTypeID
String

FactionDefeatedQuestEvent
Parameter
Type
factionID
Number

TechnologyUnlockedQuestEvent
Parameter
Type
technologyID
String
factionID
Number
Reference: Events #2
TradeRouteUpdatedQuestEvent
Parameter
Type
tradeRouteID
Number

TradeEntryUpdatedQuestEvent
Parameter
Type
factionID
Number
planetID
Number
isBuyEntry
Boolean
created
Boolean
updated
Boolean
removed
Boolean

TradeTransactionQuestEvent
Parameter
Type
initiatorFactionID
Number
targetFactionID
Number
spaceshipID
Number
planetID
Number
planetTypeID
String
transactionAmount
Number
transactionResources
Table of String
transactionResourceAmounts
Table of Number

TraderArrivedQuestEvent
Parameter
Type

TraderLeftQuestEvent
Parameter
Type

PiratesSpawnedQuestEvent
Parameter
Type
spaceshipIDs
Table of Number

PiratesRetreatedQuestEvent
Parameter
Type
defeated
Boolean

DysonProbeLaunchedQuestEvent
Parameter
Type
factionID
Number
oldFactionProbeCount
Number
newFactionProbeCount
Number
oldActiveProbeCount
Number
newActiveProbeCount
Number

ResourceDepletedQuestEvent
Parameter
Type
factionID
Number
planetID
Number
tileID
Number
resourceID
String
buildingTypeID
String

PopulationMilestoneQuestEvent
Parameter
Type
factionID
Number
populationTypeID
String
milestone
Number
population
Number

FactionBankruptQuestEvent
Parameter
Type
factionID
Number

PiratesRetreatingQuestEvent
Parameter
Type

TriggerQuestEvent
Parameter
Type
triggerID
String

SpaceshipWarpedQuestEvent
Parameter
Type
spaceshipID
Number

TerraformingQuestEvent
Parameter
Type
factionID
Number
planetID
Number
tileID
Number

StatisticsMenuOpenedQuestEvent
Parameter
Type

ResearchMenuOpenedQuestEvent
Parameter
Type

TradeRouteMenuOpenedQuestEvent
Parameter
Type

DiplomacyMenuOpenedQuestEvent
Parameter
Type

ResearchStartedQuestEvent
Parameter
Type
factionID
Number
technologyTypeID
String

DiplomacyStatusChangedQuestEvent
Parameter
Type
factionID0
Number
factionID1
Number
oldStatus
DIP_STATUS (can be either DIP_STATUS_WAR, DIP_STATUS_PEACE, DIP_STATUS_TRADE, DIP_STATUS_ALLIANCE)
newStatus
DIP_STATUS (can be either DIP_STATUS_WAR, DIP_STATUS_PEACE, DIP_STATUS_TRADE, DIP_STATUS_ALLIANCE)

ColonySharePurchasedQuestEvent
Parameter
Type
factionIDFrom
Number
factionIDTo
Number
planetID
Number
planetTypeID
String
sharePrice
Number

DiplomacyProposalCreatedQuestEvent
Parameter
Type
proposalID
Number
factionIDFrom
Number
factionIDTo
Number

DiplomacyProposalAnsweredQuestEvent
Parameter
Type
proposalID
Number
factionIDFrom
Number
factionIDTo
Number
accepted
Boolean

SpaceshipConvoyQuestEvent
Parameter
Type
factionID
Number
spaceshipID
Number
convoyTargetSpaceshipID
Number
Reference: Characters
Hazel
Animation Name / Character Setup
hazel_neutral
hazel_smug
hazel_shook
hazel_serious
hazel_crying
hazel_tears
hazel_desperate

Theo
Animation Name / Character Setup
theo_neutral
theo_exhausted
theo_pressured

Vincent
Animation Name / Character Setup
vincent_neutral
vincent_dreamy
vincent_pensive
vincent_unhappy

Kroger
Animation Name / Character Setup
kroger_neutral
kroger_grin
kroger_pensive

Myla
Animation Name / Character Setup
myla_captured
myla_neutral
myla_happy
myla_pensive
myla_angry

Mik
Animation Name / Character Setup
mik_neutral
mik_sad
mik_confident

Lucas
Animation Name / Character Setup
lucas_neutral
lucas_ashamed
lucas_worried

Dresher
Animation Name / Character Setup
dresher_neutral
dresher_grin

Soldier
Animation Name / Character Setup
soldier_neutral

Scientist
Animation Name / Character Setup
scientist_neutral

Mercenary
Animation Name / Character Setup
mercenary_neutral

Trader
Animation Name / Character Setup
trader_neutral
Reference: Scenario Manager #1
startQuest
Parameter
Type
questID
String
Return Type
void
Description: Starts a quest
createAndStartQuest
Parameter
Type
questTable
Table
Return Type
void
Description: Creates a dynamic quest and starts it
getCurrentQuestID
Parameter
Type
Return Type
String
Description: Returns the ID of the currently active quest
isQuestActive
Parameter
Type
Return Type
Boolean
Description: Returns whether any quest is currently active
completeQuest
Parameter
Type
questID
String
Return Type
void
Description: Completes the given quest instantly
cancelActiveQuest
Parameter
Type
Return Type
void
Description: Cancels the currently active quest
progressToChapter
Parameter
Type
newChapterIndex
Number
Return Type
Boolean
Description: Instantly progresses to the chapter with the given index
addVictoryCondition
Parameter
Type
questTable
Table
Return Type
void
Description: Adds the given victory condition
isVictoryConditionActive
Parameter
Type
id
String
Return Type
Boolean
Description: Returns whether the given victory condition is active
removeVictoryCondition
Parameter
Type
id
String
Return Type
void
Description: Removes the given victory condition
addDefeatCondition
Parameter
Type
questTable
Table
Return Type
void
Description: Adds the given defeat condition
isDefeatConditionActive
Parameter
Type
id
String
Return Type
Boolean
Description: Returns whether the given defeat condition is active
removeDefeatCondition
Parameter
Type
id
String
Return Type
void
Description: Removes the given defeat condition
showDialog
Parameter
Type
dialogID
String
cancelExisting
Boolean
Return Type
void
Description: Shows the given dialog
hideDialog
Parameter
Type
Return Type
void
Description: Hides the current dialog
isDialogActive
Parameter
Type
Return Type
Boolean
Description: Returns whether any dialog is active
getCurrentDialogID
Parameter
Type
Return Type
String
Description: Returns the current dialog
activateScenarioParameter
Parameter
Type
parameterName
String
Return Type
Boolean
Description: Activates the given scenario parameter (See: Reference: Scenario Parameter)
deactivateScenarioParameter
Parameter
Type
parameterName
String
Return Type
Boolean
Description: Deactivates the given scenario parameter (See: Reference: Scenario Parameter)
isScenarioParameterActive
Parameter
Type
parameterName
String
Return Type
Boolean
Description: Checks if the given scenario parameter is active or not
Reference: Scenario Manager #2
finishScenarioWin
Parameter
Type
message
String
allowContinue
Boolean
exit
Boolean
campaign
Boolean
Return Type
void
Description: Triggers a scenario victory with the given message and parameters. (Note: The parameter campaign can be ignored)
finishScenarioLoss
Parameter
Type
reason
String
allowContinue
Boolean
exit
Boolean
campaign
Boolean
Return Type
void
Description: Triggers a scenario defeat with the given message and parameters. (Note: The parameter campaign can be ignored)
setScenarioMessage
Parameter
Type
message
String
duration
Number
Return Type
void
Description: Shows a message banner in the top section of the screen with the given message for the given duration. (Only one possible at a time)
scenarioCreateShipSpace
Parameter
Type
spaceshipID
String
factionID
Number
spawnPosition
Vector2f
executeDirectly
Boolean
Return Type
Number
Description: Spawns a spaceship in space. The parameter 'executeDirectly' can be relevant if you want to access certain ship stats directly after creating the ship as ships take one game tick to be created with this flag set to false. Returns the ID of the created ship.
scenarioCreateShipPlanet
Parameter
Type
spaceshipID
String
factionID
Number
planetID
Number
tileID
Number
executeDirectly
Boolean
Return Type
Number
Description: Spawns a spaceship in space. The parameter 'executeDirectly' can be relevant if you want to access certain ship stats directly after creating the ship as ships take one game tick to be created with this flag set to false. Returns the ID of the created ship.
scenarioAddCredits
Parameter
Type
factionID
Number
credits
Number
Return Type
void
Description: Adds the given amount of credits to the bank of the given faction. (Negative values are possible)
scenarioAddItems
Parameter
Type
planetID
Number
itemTypeID
String
amount
Number
Return Type
void
Description: Adds the given items to the planet with the given planet ID.
scenarioShipSetHidden
Parameter
Type
shipID
Number
hidden
Boolean
Return Type
Boolean
Description: Hides or shows the given spaceship.
scenarioDisallowItemTrades
Parameter
Type
itemTypeID
String
Return Type
void
Description: Prevents the given item from being traded by blocking the creation of trade entries for that item type.
scenarioAllowItemTrades
Parameter
Type
itemTypeID
String
Return Type
void
Description: Reallows the given item from being traded.
Reference: Scenario Manager #3
scenarioGetPlanetItemAmount
Parameter
Type
planetID
Number
itemTypeID
String
Return Type
Number
Description: Returns the amount of items of the given type on the given planet
scenarioPurgeItemsOfTypeForFaction
Parameter
Type
itemTypeID
String
factionID
Number
Return Type
void
Description: Removes all items of the given type from the given planet
scenarioAddTradeEntry
Parameter
Type
planetID
Number
itemTypeID
String
pricePerUnit
Number
itemLimit
Number
sell
Boolean
Return Type
void
Description: Adds the given trade entry to the given planet
scenarioRemoveTradeEntry
Parameter
Type
planetID
Number
itemTypeID
String
sell
Boolean
Return Type
void
Description: Removes the given (matching) trade entry from the given planet
scenarioTeleportShipToPlanet
Parameter
Type
shipID
Number
planetID
Number
tileID
Number
cancelRoute
Boolean
Return Type
void
Description: Teleports the given ship to the given planet above the given tile
scenarioTeleportShipToPosition
Parameter
Type
shipID
Number
position
Vector2f
cancelRoute
Boolean
Return Type
void
Description:Teleports the given ship to the given position
scenarioShipSetTargetTile
Parameter
Type
shipID
Number
planetID
Number
tileID
Number
Return Type
void
Description: Sets the target of the given ship to the given planet tile
scenarioShipSetTargetPlanet
Parameter
Type
shipID
Number
planetID
Number
Return Type
void
Description: Sets the target of the given ship to the given planet
scenarioShipSetTargetWorld
Parameter
Type
shipID
Number
worldPosition
Vector2f
Return Type
void
Description: Sets the target of the given ship to the given position (in space)
scenarioShipSetMinHitpoints
Parameter
Type
shipID
Number
minHitpoints
Number
Return Type
void
Description: Set the minimum hitpoints of the given ship to the given amount
scenarioShipSetItems
Parameter
Type
shipID
Number
slot
Number
itemTypeID
String
amount
Number
Return Type
void
Description: Sets the items in the given slot of the given ship
scenarioShipAddItems
Parameter
Type
shipID
Number
itemTypeID
String
amount
Number
Return Type
Number
Description: Adds the given items to the inventory of the given ship
Reference: Scenario Manager #4
scenarioShipDrawItems
Parameter
Type
shipID
Number
itemTypeID
String
amount
Number
Return Type
Number
Description: Tries to remove the given amount of items from a spaceship. Returns the amount that was actually drawn (<= amount)
scenarioDestroySpaceship
Parameter
Type
shipID
Number
Return Type
void
Description: Destroys the given spaceship
scenarioDiplomacySet
Parameter
Type
factionIDA
Number
factionIDB
Number
status
DIP_STATUS (can be either DIP_STATUS_WAR, DIP_STATUS_PEACE, DIP_STATUS_TRADE, DIP_STATUS_ALLIANCE)
Return Type
void
Description: Sets the diplomatic status between two factions.
doesPositionCollideWithPlanet
Parameter
Type
position
Vector3f
Return Type
Boolean
Description: Checks if the given position collides with a planet. (Does not check the sun).
scenarioTriggerTraderManually
Parameter
Type
planetID
Number
Return Type
Boolean
Description: Force triggers the neutral trader. (Only works if the scenario parameter to disable the trader is NOT active)
scenarioTriggerPiratesManually
Parameter
Type
targetShipID
Number
spawnPosition
Vector2f
targetStrength
Number
Return Type
void
Description: Force triggers an immediate priate attack with the given parameters. (Only works if the scenario parameter to disable the pirates is NOT active and if pirates are enabled in the savegame)
scenarioTriggerPiratesManuallyFleet
Parameter
Type
targetShipID
Number
spawnPosition
Vector2f
fleetTable
Table
Return Type
void
Description: Force triggers an immediate priate attack with the given parameters. (Only works if the scenario parameter to disable the pirates is NOT active and if pirates are enabled in the savegame). 'fleetTable' is a list of spaceship type IDs with the amount to spawn. Example:
{ { spaceshipTypeID = "s_fighter", count = 4, }, { spaceshipTypeID = "s_falcon", count = 1, }, }
scenarioTriggerPiratesManuallyFaction
Parameter
Type
targetFactionID
Number
fleetTable
Table
Return Type
void
Description: Force triggers an immediate priate attack with the given parameters. (Only works if the scenario parameter to disable the pirates is NOT active and if pirates are enabled in the savegame). 'fleetTable' is a list of spaceship type IDs with the amount to spawn. Example:
{ { spaceshipTypeID = "s_fighter", count = 4, }, { spaceshipTypeID = "s_falcon", count = 1, }, }
scenarioRemoveShipFromPirateFleet
Parameter
Type
shipID
Number
Return Type
void
Description: Removes the given ship from any active pirate fleet. This will cause the ship to not receive any new tasks from the pirate controller.
scenarioSetShipControllable
Parameter
Type
shipID
Number
controllable
Boolean
Return Type
Boolean
Description: Changes if the ship is controllable by the player or any bot factions.
scenarioSetShipInvincible
Parameter
Type
shipID
Number
invincible
Boolean
Return Type
Boolean
Description: Changes if the ship should be invincible or not
scenarioSetColonyControllable
Parameter
Type
planetID
Number
controllable
Boolean
Return Type
Boolean
Description: Changes if the colony is controllable by the player or any bot factions.
scenarioSetColonyInvincible
Parameter
Type
planetID
Number
invincible
Boolean
Return Type
Boolean
Description: Changes if the colony is invincible or not. An invincible colony is the same as setting all buildings invincible manually.
Reference: Scenario Manager #5
scenarioRemoveInvincibilityFromMilitaryBuildings
Parameter
Type
planetID
Number
Return Type
void
Description: Removes the invincibility from the military buildings on the given planet
scenarioSetBuildingInvincible
Parameter
Type
planetID
Number
tileID
Number
invincible
Boolean
Return Type
Boolean
Description: Sets the invincibility of the given building
scenarioDetermineSpaceshipYardTileID
Parameter
Type
planetID
Number
Return Type
Number
Description: Returns the tile ID of the (first) spaceship yard on the given planet, if any
scenarioSetDysonProbesOfFaction
Parameter
Type
factionID
Number
amount
Number
Return Type
void
Description: Sets the amount of dyson probes for the given faction
scenarioGetDysonProbesOfFaction
Parameter
Type
factionID
Number
Return Type
Number
Description: Returns the amount of dyson probes of the given faction
scenarioGrantPlanetToFaction
Parameter
Type
factionID
Number
planetTypeID
String
Return Type
Number
Description: Instantly transfers the ownership of a planet to the given faction, if the planet is already colonized a takeover is performed, otherwise a spaceport is placed in order to colonize the planet
scenarioTriggerTrade
Parameter
Type
shipID
Number
planetID
Number
budget
Number
Return Type
void
Description: Instantly performs a trade between the given neutral trader ship and the given planet
scenarioShipSetName
Parameter
Type
shipID
Number
name
String
Return Type
void
Description: Sets the name of the given ship
scenarioShipSetSpecialMark
Parameter
Type
shipID
Number
specialMark
Boolean
Return Type
void
Description: Sets whether to show a special mark on the minimap for the given ship (exclamation mark)
scenarioShipSuppressAutoAttacks
Parameter
Type
shipID
Number
suppressAutoAttacks
Boolean
Return Type
void
Description: Sets whether the given ship should stop automatically attacking enemy ships and buildings
scenarioShipClearAttackTarget
Parameter
Type
shipID
Number
Return Type
void
Description: Resets the attack target of the given ship
scenarioOwnsPlanetType
Parameter
Type
factionID
Number
planetTypeID
String
Return Type
Boolean
Description: Returns whether the given faction owns a planet of the given type
scenarioGetInterestingPlanetID
Parameter
Type
factionID
Number
planetTypeID
String
Return Type
Number
Description: Returns the planet with the highest economic score, the search can be filtered by passing the faction ID or a specific planet type
scenarioGetSpaceportTileID
Parameter
Type
planetID
Number
Return Type
Number
Description: Returns the tile ID of the spaceport on the given planet, if any
Reference: Scenario Manager #6
scenarioGetTileIDWithBuilding
Parameter
Type
planetID
Number
buildingID
String
Return Type
Number
Description: Looks for a building of the given type on the given planet and returns its tile ID.
scenarioGetNearestPlanet
Parameter
Type
planetID
Number
Return Type
Number
Description: Returns the planet ID of the closest planet to the given one
scenarioIsBuildingOnPlanet
Parameter
Type
planetID
Number
buildingTypeID
String
Return Type
Boolean
Description: Checks if the given planet contains a building of the given type.
scenarioPlaceBuildingOnPlanet
Parameter
Type
factionID
Number
planetID
Number
buildingTypeID
String
Return Type
void
Description: Places a building of the given type on a planet.
scenarioPlaceBuildingOnTile
Parameter
Type
factionID
Number
planetID
Number
buildingTypeID
String
tileID
Number
Return Type
void
Description: Places a building of the given type on the tile with the given ID.
scenarioDestroyBuildingOnTile
Parameter
Type
planetID
Number
tileID
Number
Return Type
void
Description: Destroys the building on the given tile.
scenarioSetPlanetOwner
Parameter
Type
planetID
Number
factionID
Number
Return Type
void
Description: Transfers the ownership of a planet to another faction. This will trigger a takeover including its configured implications.
scenarioIsTraderActive
Parameter
Type
Return Type
Boolean
Description: Returns if the neutral trader is currently active.
scenarioRaiseDefenses
Parameter
Type
planetID
Number
targetMilitaryScore
Number
maxTier
Number
ignoreProgression
Boolean
Return Type
Boolean
Description: Automatically builds defense buildings on the given planet.
scenarioGetFakeTraderShipID
Parameter
Type
Return Type
Number
Description: Returns the ship ID of any active fake trader.
scenarioPiratesActive
Parameter
Type
Return Type
Boolean
Description: Returns if the pirates are currently active.
scenarioHideFactionInDysonMenu
Parameter
Type
factionID
Number
hidden
Boolean
Return Type
void
Description: Changes the visibility of the given faction in the dyson swarm menu.
scenarioShipBlockPush
Parameter
Type
shipID
Number
blockPush
Boolean
Return Type
void
Description: Changes the pushing behavior of the given ship (won't be pushed around by other ships if disabled)
scenarioApplyResearchBoost
Parameter
Type
factionID
Number
boost
Number
Return Type
void
Description: Applies a research boost to the given faction. This adds direct research progress to the currently researched technology.
Reference: Scenario Manager #7
scenarioDoesResearchTechnology
Parameter
Type
factionID
Number
Return Type
Boolean
Description: Returns whether the given faction currently researches a technology
scenarioRuinBuilding
Parameter
Type
planetID
Number
tileID
Number
Return Type
void
Description: Instantly sets the given building to the ruined state
scenarioAdjustMilitaryBuildingsInvinicibility
Parameter
Type
planetID
Number
invincible
Boolean
Return Type
void
Description: Sets whether the military buildings on the given planet are invincible
scenarioResetColonyWarTimer
Parameter
Type
planetID
Number
Return Type
void
Description: Resets the colony war timer of the given planet back to its maximum (30 seconds)
scenarioTriggerBotBuildup
Parameter
Type
factionID
Number
targetTier
Number
Return Type
void
Description: Triggers a bot buildup for the given faction, where the bot quickly (and without respecing construction costs) advances up to the givent target tier
scenarioBotDestroyGoalsForAllPirateShips
Parameter
Type
factionID
Number
Return Type
void
Description: Causes the bot with the given faction ID to wanting to destroy all currently present pirate ships
scenarioBotSetParamMilitaryFleetFactor
Parameter
Type
factionID
Number
militaryFleetFactor
Number
Return Type
void
Description: Sets the bot parameter "militaryFleetFactor" for the given faction, influencing the amount of ships it wants to own (mutliplier, easiest 1.0, harder above)
scenarioBotSetParamColonyOvertakeFleetMultiplier
Parameter
Type
factionID
Number
colonyOvertageFleetMultiplier
Number
Return Type
void
Description: Sets the bot parameter "colonyOvertakeFleetMultiplier" for the given faction, influencing how many ships the bot requires before daring to attack an enemy planet
scenarioShipSetBotClass
Parameter
Type
shipID
Number
botClass
Number
Return Type
void
Description: Sets the "bot class" of the given ship, determining whether the owning bot uses this ship for attacks
scenarioBotResetShipBotClasses
Parameter
Type
Return Type
void
Description: Resets the "bot class" of all ships in the world
scenarioSetBotName
Parameter
Type
factionID
Number
name
String
Return Type
void
Description: Sets the name of the bot with the given faction ID
scenarioBotTriggerEscort
Parameter
Type
factionID
Number
shipID
Number
Return Type
void
Description: Causes the bot with the given faction ID to escort the given ship
scenarioBotAbortEscort
Parameter
Type
factionID
Number
shipID
Number
Return Type
void
Description: Causes the bot with the given faction ID to stop escorting the given ship
scenarioBotTriggerAttackShip
Parameter
Type
factionID
Number
shipID
Number
neverBackOff
Boolean
allIn
Boolean
Return Type
void
Description: Causes the bot with the given faction ID to attack the given ship, "allIn" causes the bot to use all its available ships
Reference: Scenario Manager #8
scenarioBotAbortAttack
Parameter
Type
factionID
Number
shipID
Number
Return Type
void
Description: Aborts any attack by the bot that is currently planned for the given ship
scenarioBotTriggerAttackPlanet
Parameter
Type
factionID
Number
planetID
Number
instant
Boolean
Return Type
void
Description: Schedules an the given planet for attack by the bot. The parameter 'instant' will force an instant attack (high priority)
scenarioBotAnswerProposal
Parameter
Type
factionIDBot
Number
factionIDOther
Number
accept
Boolean
Return Type
void
Description: Answers any active proposal between the bot and the given other faction
scenarioTriggerNotification
Parameter
Type
iconID
Number
notificationColor
EnumNotificationColor (can be either DEFAULT_NOTIFICATION_COLOR_PLANS, RED_NOTIFICATION_COLOR_PLANS, GREEN_NOTIFICATION_COLOR_PLANS, ORANGE_NOTIFICATION_COLOR_PLANS)
title
String
content
String
dismissable
Boolean
Return Type
void
Description: Creates a notification
scenarioTriggerNotificationShip
Parameter
Type
iconID
Number
notificationColor
EnumNotificationColor (can be either DEFAULT_NOTIFICATION_COLOR_PLANS, RED_NOTIFICATION_COLOR_PLANS, GREEN_NOTIFICATION_COLOR_PLANS, ORANGE_NOTIFICATION_COLOR_PLANS)
title
String
content
String
dismissable
Boolean
spaceshipID
Number
Return Type
void
Description: Creates a notification with a ship as the target (clicking on the notification will take the player to that ship)
scenarioTriggerNotificationPlanet
Parameter
Type
iconID
Number
notificationColor
EnumNotificationColor (can be either DEFAULT_NOTIFICATION_COLOR_PLANS, RED_NOTIFICATION_COLOR_PLANS, GREEN_NOTIFICATION_COLOR_PLANS, ORANGE_NOTIFICATION_COLOR_PLANS)
title
String
content
String
dismissable
Boolean
planetID
Number
Return Type
void
Description: Creates a notification with a planet as the target (clicking on the notification will take the player to that planet)
scenarioTriggerNotificationBuilding
Parameter
Type
iconID
Number
notificationColor
EnumNotificationColor (can be either DEFAULT_NOTIFICATION_COLOR_PLANS, RED_NOTIFICATION_COLOR_PLANS, GREEN_NOTIFICATION_COLOR_PLANS, ORANGE_NOTIFICATION_COLOR_PLANS)
title
String
content
String
dismissable
Boolean
planetID
Number
tileID
Number
Return Type
void
Description: Creates a notification with a building / tile as the target (clicking on the notification will take the player to that tile)
scenarioTriggerColonyWar
Parameter
Type
planetID
Number
tileID
Number
attackerFactionID
Number
Return Type
void
Description: Forces the given colony to enter war mode by performing an attack on the given tile
trigger
Parameter
Type
triggerID
String
Return Type
void
Description: Performs a trigger action with the given ID. Triggers can be used in conjunction with TriggerQuestEvent or TriggerTask to track custom actions.
Reference: Scenario Manager #9
triggerQuickSave
Parameter
Type
Return Type
void
Description: Triggers a quick save
setBotAttackClass
Parameter
Type
attackClass
Number
Return Type
void
Description: Sets the active bot class to use for attacks or other ship actions
getBotAttackClass
Parameter
Type
Return Type
Number
Description: Returns the current attack class of the bot
scenarioAddCustomTileMarker
Parameter
Type
planetID
Number
tileID
Number
markerType
EnumMarkerType (can be either WHITE_TILE_MARKER, RED_TILE_MARKER, GREEN_TILE_MARKER, BLUE_TILE_MARKER)
Return Type
void
Description: Spawns a custom tile marker on the given tile
scenarioRemoveCustomTileMarker
Parameter
Type
planetID
Number
tileID
Number
Return Type
void
Description: Removes any custom tile marker from the given tile
scenarioClearCustomTileMarkers
Parameter
Type
planetID
Number
Return Type
void
Description: Clears all custom tile markers from the given planet
scenarioClearAllCustomTileMarkers
Parameter
Type
Return Type
void
Description: Clears all custom tile markers
createDipStatusImproveProposal
Parameter
Type
factionIDFrom
Number
factionIDTo
Number
Return Type
void
Description: Creates a diplomatic proposal to improve the diplomatic status between the given two factions
scenarioShipIsTraveling
Parameter
Type
shipID
Number
Return Type
Boolean
Description: Returns if the given ship is currently traveling
scenarioShipGetHitpoints
Parameter
Type
shipID
Number
Return Type
Number
Description: Returns the current hitpoints of the given ship
scenarioShipGetMaxHitpoints
Parameter
Type
shipID
Number
Return Type
Number
Description: Returns the max hitpoints of the given ship
scenarioShipGetShieldpoints
Parameter
Type
shipID
Number
Return Type
Number
Description: Returns the current shieldpoints of the given ship
scenarioShipGetMaxShieldpoints
Parameter
Type
shipID
Number
Return Type
Number
Description: Returns the max shieldpoints of the given ship
scenarioGetPlanetPosition
Parameter
Type
planetID
Number
Return Type
Vector2f
Description: Returns the position of the given planet
scenarioGetPlanetTypeID
Parameter
Type
planetID
Number
Return Type
String
Description: Returns the planet type ID of the given planet
scenarioShipIsInWorldBounds
Parameter
Type
shipID
Number
Return Type
Boolean
Description: Returns if the given ship is within world bounds