• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.
Index
  • Snow Crystal

    Design Lead - Crusader Kings 3
    Paradox Staff
    63 Badges
    Jan 22, 2018
    1.378
    5.853
    • Crusader Kings II
    • Hearts of Iron IV: Death or Dishonor
    • Hearts of Iron IV: Expansion Pass
    • Crusader Kings II: Holy Fury
    • Imperator: Rome
    • Imperator: Rome - Magna Graecia
    • Stellaris
    • Crusader Kings III: Royal Edition
    Intro
  • Intro

    Hello there!

    In this guide we are going to showcase how missions in Imperator work, and how you can make your own. It is expected that readers will already have taken a look at our basic Scripting guide. It should be mentioned that missions are more complicated than e.g. events, so we don’t recommend people who have never touched on our Script language to start their modding career with the mission system.

    For this specific mission guide we are going to make a very simplified mission for Carthage where they get tasks to annex ports in southern Gaul.

    We will start by opening the folder ‘Imperator\game\common\missions’, creating a new text file called ‘00_carthaginian_missions_11_gaul.txt’, and saving it with the encoding UTF-8 with BOM.

    Now to take a look at the syntax for missions, and what tools are available for them:

    upload_2019-11-22_12-34-7.png

    Code:
    carthaginian_mission_11_gaul = {
        header = "mission_image_carthage" # SPECIAL FIELD - Sets top picture for the mission
        icon = "carthage_1" # SPECIAL FIELD - Sets icon for the mission
    
        repeatable = no # SPECIAL FIELD - Sets if a mission can be done once or several times
    
        chance = {} # SPECIAL FIELD - Sets the chances of a mission appearing in your list of available missions
    
        potential = {} # TRIGGER FIELD - Sets the conditions for the mission to appear in your list
    
        abort = {} # TRIGGER FIELD - Sets conditions for the mission to be automatically aborted
    
        on_potential = {} # EFFECT FIELD - These effects are run when the mission becomes available
    
        on_start = {} # EFFECT FIELD - These effects are run when the mission is started
    
        on_abort = {} # EFFECT FIELD - These effects are run when the mission is aborted
    
        on_completion = {} # EFFECT FIELD - These effects are run when the mission is completed
    
        carthaginian_mission_11_gaul_task_final = { # MISSION TASK
            icon = "task_political" # SPECIAL FIELD - Sets picture for mission task
    
            duration = 180 # SPECIAL FIELD - Sets the duration of the mission task (instant mission task if no duration is defined)
    
            monthly_on_action = carthaginian_mission_11_gaul_task_final_pulse # SPECIAL FIELD - Monthly on_action that can be used to trigger events (for timed mission tasks)
    
            requires = {} # SPECIAL FIELD - Missions tasks required for this task to be available
    
            prevented_by = {} # SPECIAL FIELD - Sets exclusivity for this mission task
    
            final = yes # SPECIAL FIELD - Final mission task of the mission
    
            potential = {} # TRIGGER FIELD - Conditions for the mission task to be available
    
            highlight = {} # TRIGGER FIELD - Conditions for provinces to be highlighted when hovering over the mission task
    
            allow = {} # TRIGGER FIELD - Conditions for the mission task to be completed
    
            bypass = {} # TRIGGER FIELD - Conditions for the mission task to be bypassed
    
            ai_chance = {} # SPECIAL FIELD - Set AI chance modifiers, to decide how the AI prioritizes mission tasks
    
            on_start = {} # EFFECT FIELD - These effects are run when the mission task is started (timed mission tasks only)
    
            on_completion = {} # EFFECT FIELD - These effects are run when the mission task is completed
    
            on_bypass = {} # EFFECT FIELD - These effects are run when the mission task is bypassed
        }
    }
    • header - Sets the banner image shown at the top of the mission screen when selected. The default folder for these files are ‘Imperator\game\gfx\interface\missions’.
    • icon - Sets the mission’s picture shown when you choose in the mission list. The default folder for these files are ‘Imperator\game\gfx\interface\icons\missions’
    • repeatable - Sets whether the mission can be completed several times by a tag or not. If not specified, the default is no.
    • chance - Sets the probability for the mission to be one of the three available to you when choosing a mission (potential must still be met).
    • potential - Sets the conditions for a mission to be available at all.
    • abort - Sets conditions for a mission to be automatically cancelled.
    • on_potential - Effects run when the mission becomes available to you.
    • on_start - Effects run when the mission is started.
    • on_abort - Effects run when the mission is aborted.
    • on_completion - Effects run when the mission is completed.
    • mission_task - The mission tasks that will be generated in the mission when you start it. These can be named anything, though a descriptive or otherwise easy to remember name is preferrable.
      • icon - Sets the mission task’s icon. The default folder for these files are ‘Imperator\game\gfx\interface\icons\mission_tasks’.
      • duration - Sets the duration of the mission. If defined, it will be a timed mission task, if not the mission task will be completed instantly on selection.
      • monthly_on_action - Sets a monthly_on_action that can be used to call events while the mission task is running. For timed mission tasks only.
      • requires - Defines mission tasks that this mission task requires to have been completed to become available for the player. This is the main way we define how the mission tree is generated.
      • prevented_by - Makes a mission task exclusive with the specified mission task/s.
      • final - Sets which mission tasks allow the mission tree to be finished when completed.
      • potential - Sets the conditions for the mission task to appear at all.
      • highlight - Defines territories to highlight when hovering over the mission task.
      • allow - Sets the required conditions to complete the mission task.
      • bypass - Sets the conditions under which the mission task will be bypassed.
      • ai_chance - Defines modifiers for ai prioritization of the mission task.
      • on_start - Effects run when the mission task is started. For timed mission tasks only.
      • on_completion - Effects run when the mission task is completed.
      • on_bypass - Effects run when the mission task is bypassed.
     
    • 1Like
    Reactions:
    Mission Essentials
  • Mission Essentials

    So before we start working on the mission tasks (where we are going to spend most of our time) we will set up the essentials for the mission tree itself, like the conditions for the mission to appear, its graphics, localization, related tasks, and what will happen when we start/abort/complete the mission.

    upload_2019-11-22_12-37-51.png

    Code:
    carthaginian_mission_11_gaul = {
        header = "mission_image_carthage" # SPECIAL FIELD - Sets top picture for the mission
        icon = "carthage_1" # SPECIAL FIELD - Sets icon for the mission
    
        repeatable = no # SPECIAL FIELD - Sets if a mission can be done once or several times
    
        chance = { # SPECIAL FIELD - Sets the chances of a mission appearing in your list of available missions
            factor = 3 # MODIFIER - Higher chance for story missions to appear than other missions
        }
    
        potential = { # TRIGGER FIELD - Sets the conditions for the mission to appear in your list
            NOT = { has_variable = carthaginian_mission_11_gaul } # VARIABLE - Cooldown if mission has been aborted
            country_culture = carthaginian # TRIGGER - Check if the nation is of Punic culture
            OR = { # BOOLEAN OPERATOR - Check if any of the following conditions are true
                has_completed_mission = carthaginian_iberia_expansion_mission # TRIGGER - Have completed the first Carthaginian mission in Iberia
                has_completed_mission = carthaginian_rome_expansion_mission # TRIGGER - Have completed the Carthaginian mission against Rome
                any_owned_province = { # TRIGGER SCRIPT LIST - Own any province with the following conditions
                    OR = { # BOOLEAN OPERATOR - Check if any of the following conditions are true
                        is_in_region = tarraconensis_region # TRIGGER - Has any province in the region of Tarraconensis
                        is_in_region = cisalpine_gaul_region # TRIGGER - Has any province in the region of Cisalpine Gaul
                        is_in_region = transalpine_gaul_region # TRIGGER - Has any province in the region of Transalpine Gaul
                        is_in_area = corsica_area # TRIGGER - Has any province in the area of Corsica
                    } # END OF BOOLEAN OPERATOR
                } # END OF TRIGGER SCRIPT LIST
            } # END OF BOOLEAN OPERATOR
            NOT = { # BOOLEAN OPERATOR - Check if the following condition is not true
                any_owned_province = { # TRIGGER SCRIPT LIST - Own any province with the following conditions
                    count >= 5 # COUNT - At least 5 provinces with the following conditions
                    is_in_region = transalpine_gaul_region # TRIGGER - Has any province in the region of Transalpine Gaul
                } # END OF TRIGGER SCRIPT LIST
            } # END OF BOOLEAN OPERATOR
            is_subject = no # TRIGGER - Is not a subject of another nation
        }
    
        on_start = { # EFFECT FIELD - These effects are run when the mission is started
            save_scope_as = mission_country # EFFECT - Save Scope
        }
    
        on_abort = { # EFFECT FIELD - These effects are run when the mission is aborted
            custom_tooltip = general_mission_cooldown_tt # EFFECT - CUSTOM TOOLTIP - Explains the player that they will receive a cooldown when aborting the mission
            set_variable = { # EFFECT - VARIABLE - Set a variable to check cooldown
                name = carthaginian_mission_11_gaul # SPECIAL FIELD - Name of variable
                days = 7300 # SPECIAL FIELD - Duration of variable
            } # END OF VARIABLE EFFECT
        }
    
        on_completion = { # EFFECT FIELD - These effects are run when the mission is completed
            complete_mission_effect = yes # SCRIPTED EFFECT - Sets up a variable to count how many missions we have completed
        }
    
        carthaginian_mission_11_gaul_task_final = { # MISSION TASK
            icon = "task_political" # SPECIAL FIELD - Sets picture for mission task
    
            duration = 180 # SPECIAL FIELD - Sets the duration of the mission task (instant mission task if no duration is defined)
    
            monthly_on_action = carthaginian_mission_11_gaul_task_final_pulse # SPECIAL FIELD - Monthly on_action that can be used to trigger events (for timed mission tasks)
    
            requires = {} # SPECIAL FIELD - Missions tasks required for this task to be available
    
            final = yes # SPECIAL FIELD - Final mission task of the mission
    
            potential = {} # TRIGGER FIELD - Conditions for the mission task to be available
    
            highlight = {} # TRIGGER FIELD - Conditions for provinces to be highlighted when hovering over the mission task - PROVINCE SCOPE
    
            allow = {} # TRIGGER FIELD - Conditions for the mission task to be completed
    
            bypass = {} # TRIGGER FIELD - Conditions for the mission task to be bypassed
    
            ai_chance = {} # SPECIAL FIELD - Set AI chance modifiers, to decide how the AI prioritizes mission tasks
    
            on_start = {} # EFFECT FIELD - These effects are run when the mission task is started (timed mission tasks only)
    
            on_completion = {} # EFFECT FIELD - These effects are run when the mission task is completed
    
            on_bypass = {} # EFFECT FIELD - These effects are run when the mission task is bypassed
        }
    }

    Starting from the top, we define the header and icon used for the mission, these files are found in ‘Imperator\game\gfx\interface\missions’ and ‘Imperator\game\gfx\interface\icons\missions’ respectively. We simply grab the name of the header and icon images we want.

    As this is going to be a story mission, it is not something we want to pop up repeatedly, so we’ll add ‘repeatable = no’. As mentioned in the syntax explanations, you don’t have to define if the mission is repeatable in this case as the default is no, but I find it a lot more readable to be able to see it.

    For chance, we will keep it simple and just add a slightly higher chance than normal as it is a story mission. If we look at other Carthaginian and Roman missions, we did the same thing there.

    upload_2019-11-22_12-39-3.png

    Code:
    potential = { # TRIGGER FIELD - Sets the conditions for the mission to appear in your list
        NOT = { has_variable = carthaginian_mission_11_gaul } # VARIABLE - Cooldown if mission has been aborted
        country_culture = carthaginian # TRIGGER - Check if the nation is of Punic culture
        OR = { # BOOLEAN OPERATOR - Check if any of the following conditions are true
            has_completed_mission = carthaginian_iberia_expansion_mission # TRIGGER - Have completed the first Carthaginian mission in Iberia
            has_completed_mission = carthaginian_rome_expansion_mission # TRIGGER - Have completed the Carthaginian mission against Rome
            any_owned_province = { # TRIGGER SCRIPT LIST - Own any province with the following conditions
                OR = { # BOOLEAN OPERATOR - Check if any of the following conditions are true
                    is_in_region = tarraconensis_region # TRIGGER - Has any province in the region of Tarraconensis
                    is_in_region = cisalpine_gaul_region # TRIGGER - Has any province in the region of Cisalpine Gaul
                    is_in_region = transalpine_gaul_region # TRIGGER - Has any province in the region of Transalpine Gaul
                    is_in_area = corsica_area # TRIGGER - Has any province in the area of Corsica
                } # END OF BOOLEAN OPERATOR
            } # END OF TRIGGER SCRIPT LIST
        } # END OF BOOLEAN OPERATOR
        NOT = { # BOOLEAN OPERATOR - Check if the following condition is not true
            any_owned_province = { # TRIGGER SCRIPT LIST - Own any province with the following conditions
                count >= 5 # COUNT - At least 5 provinces with the following conditions
                is_in_region = transalpine_gaul_region # TRIGGER - Has any province in the region of Transalpine Gaul
            } # END OF TRIGGER SCRIPT LIST
        } # END OF BOOLEAN OPERATOR
        is_subject = no # TRIGGER - Is not a subject of another nation
    }

    For the potential, we have quite a mouthful of triggers, so we’ll go through them one by one.

    Starting at the top, we have one that checks that you don’t have a specific variable. This is a variable we will add when you abort the mission with a duration of 20 years, so you will be unable to choose the mission again for a while.

    Next, we are checking if the nation has the right culture by doing a simple culture check. This will be useful, as it means any other Punic nations that might rise to glory will be able to pick the mission as well, instead of limiting it to just Carthage in particular.

    Following that, we have a large OR trigger, checking if we have completed the Carthaginian Iberia mission OR the Carthaginian Rome mission OR own a province in one of several regions/areas. This is to check it makes sense to get access to the mission, as we make sure territories are held near the place we want to write the mission about. Alternatively, we also allow them to have completed a mission nearby which would make sense to follow up with one in Gaul.

    After that we have a check that does almost the opposite. It checks that we don’t hold too many territories in Transalpine Gaul already, as we don’t want the player to start with a lot of the tasks already completed before they have even started the mission. We do this by adding a count check to the script list, ensuring that no more than 4 territories are held in the Transalpine Gaul region.

    At the end of the potential triggers, we have made sure that the nation isn’t a subject. Subjects usually cannot initiate a war, so granting them missions which involve taking areas or expanding is fairly pointless.

    upload_2019-11-22_12-39-9.png

    Code:
    on_start = { # EFFECT FIELD - These effects are run when the mission is started
        save_scope_as = mission_country # EFFECT - Save Scope
    }
    
    on_abort = { # EFFECT FIELD - These effects are run when the mission is aborted
        custom_tooltip = general_mission_cooldown_tt # EFFECT - CUSTOM TOOLTIP - Explains the player that they will receive a cooldown when aborting the mission
        set_variable = { # EFFECT - VARIABLE - Set a variable to check cooldown
            name = carthaginian_mission_11_gaul # SPECIAL FIELD - Name of variable
            days = 7300 # SPECIAL FIELD - Duration of variable
        } # END OF VARIABLE EFFECT
    }
    
    on_completion = { # EFFECT FIELD - These effects are run when the mission is completed
        complete_mission_effect = yes # SCRIPTED EFFECT - Sets up a variable to count how many missions we have completed
    }

    Moving on to the effects, we have mostly generic effects that are used in many missions. First we save a scope in the on_start. This is not necessary, but I find it very helpful to know that I can always use scope:mission_country in any mission task or event that has been spawned from the mission, to refer back to the original country who started the mission.

    For the on_abort, we have a custom tooltip explaining to the player that it will have a 20 year cooldown, and then we set the variable that we checked for in the potential conditions. This is something we do in all story missions, so the player cannot start and abort a mission repeatedly.

    Finally in the on_completion we have a Scripted Effect that we use in all missions which sets a variable to count how many missions a country has completed. We use this counter in a couple of the Carthaginian missions to decide when a mission will be available to a player.

    Moving on, we are going to add the four localization keys that we can see on the entry mission screen.

    upload_2019-11-22_12-39-17.png


    So the four loc keys we have are:
    • <mission name> - Name of mission
    • <mission name>_DESCRIPTION - Description of mission
    • <mission name>_CRITERIA_DESCRIPTION - Completion Criteria of mission
    • <mission name>_BUTTON_TOOLTIP - Shorter description given when hovering the mission.
    upload_2019-11-22_12-39-22.png

    Code:
    ### Gaul ###
    carthaginian_mission_11_gaul:0 "Controlling Rhodanus"
    carthaginian_mission_11_gaul_DESCRIPTION:0 "This is a descriptive description describing the mission about taking control of the territories around the Rhodanus."
    carthaginian_mission_11_gaul_CRITERIA_DESCRIPTION:0 "This mission will be considered complete when we have taken control of the territories around the Rhodanus."
    carthaginian_mission_11_gaul_BUTTON_TOOLTIP:0 "Rhodanus will be our entrance into the rich trade of Gaul."

    We add these four loc keys to the file ‘Imperator\game\localization\english\carthaginian_mission_l_english.yml’.

    As this mission is one that is primarily made for this guide, we are not going to spend too much time adding small details like a long description. With these loc keys added, our mission now looks like this:

    upload_2019-11-22_12-39-27.png
     
    • 1Like
    Reactions:
    Setting up our Mission Tasks
  • Setting up our Mission Tasks

    With the framework of the mission completed, we are going to move to the core of the mission system, the tasks themselves. We simply add the names we want to use for them, and then start putting in their potential fields etc. We’ll start by adding 7 tasks, including the final task.

    upload_2019-11-22_12-48-17.png

    Code:
    carthaginian_mission_11_gaul = {
        header = "mission_image_carthage" # SPECIAL FIELD - Sets top picture for the mission
        icon = "carthage_1" # SPECIAL FIELD - Sets icon for the mission
    
        repeatable = no # SPECIAL FIELD - Sets if a mission can be done once or several times
    
        chance = { # SPECIAL FIELD - Sets the chances of a mission appearing in your list of available missions
            factor = 3 # MODIFIER - Higher chance for story missions to appear than other missions
        }
    
        potential = { # TRIGGER FIELD - Sets the conditions for the mission to appear in your list
            NOT = { has_variable = carthaginian_mission_11_gaul } # VARIABLE - Cooldown if mission has been aborted
            country_culture = carthaginian # TRIGGER - Check if the nation is of Punic culture
            OR = { # BOOLEAN OPERATOR - Check if any of the following conditions are true
                has_completed_mission = carthaginian_iberia_expansion_mission # TRIGGER - Have completed the first Carthaginian mission in Iberia
                has_completed_mission = carthaginian_rome_expansion_mission # TRIGGER - Have completed the Carthaginian mission against Rome
                any_owned_province = { # TRIGGER SCRIPT LIST - Own any province with the following conditions
                    OR = { # BOOLEAN OPERATOR - Check if any of the following conditions are true
                        is_in_region = tarraconensis_region # TRIGGER - Has any province in the region of Tarraconensis
                        is_in_region = cisalpine_gaul_region # TRIGGER - Has any province in the region of Cisalpine Gaul
                        is_in_region = transalpine_gaul_region # TRIGGER - Has any province in the region of Transalpine Gaul
                        is_in_area = corsica_area # TRIGGER - Has any province in the area of Corsica
                    } # END OF BOOLEAN OPERATOR
                } # END OF TRIGGER SCRIPT LIST
            } # END OF BOOLEAN OPERATOR
            NOT = { # BOOLEAN OPERATOR - Check if the following condition is not true
                any_owned_province = { # TRIGGER SCRIPT LIST - Own any province with the following conditions
                    count >= 5 # COUNT - At least 5 provinces with the following conditions
                    is_in_region = transalpine_gaul_region # TRIGGER - Has any province in the region of Transalpine Gaul
                } # END OF TRIGGER SCRIPT LIST
            } # END OF BOOLEAN OPERATOR
            is_subject = no # TRIGGER - Is not a subject of another nation
        }
    
        on_start = { # EFFECT FIELD - These effects are run when the mission is started
            save_scope_as = mission_country # EFFECT - Save Scope
        }
    
        on_abort = { # EFFECT FIELD - These effects are run when the mission is aborted
            custom_tooltip = general_mission_cooldown_tt # EFFECT - CUSTOM TOOLTIP - Explains the player that they will receive a cooldown when aborting the mission
            set_variable = { # EFFECT - VARIABLE - Set a variable to check cooldown
                name = carthaginian_mission_11_gaul # SPECIAL FIELD - Name of variable
                days = 7300 # SPECIAL FIELD - Duration of variable
            } # END OF VARIABLE EFFECT
        }
    
        on_completion = { # EFFECT FIELD - These effects are run when the mission is completed
            complete_mission_effect = yes # SCRIPTED EFFECT - Sets up a variable to count how many missions we have completed
        }
    
        carthaginian_mission_11_gaul_task_1 = { # Ports of Gaul
            icon = "task_political"
    
            potential = {}
    
            allow = {}
    
            on_completion = {}
        }
    
        carthaginian_mission_11_gaul_task_2 = { # Managing Massalia
            icon = "task_political"
    
            requires = { carthaginian_mission_11_gaul_task_1 }
    
            potential = {}
    
            allow = {}
    
            on_completion = {}
        }
    
        carthaginian_mission_11_gaul_task_3 = { # Annex Arelatis
            icon = "task_political"
    
            requires = { carthaginian_mission_11_gaul_task_1 }
    
            potential = {}
    
            allow = {}
    
            on_completion = {}
        }
    
        carthaginian_mission_11_gaul_task_4 = { # Navigating Narbo
            icon = "task_political"
    
            requires = { carthaginian_mission_11_gaul_task_1 }
    
            potential = {}
    
            allow = {}
    
            on_completion = {}
        }
    
        carthaginian_mission_11_gaul_task_5 = { # Ousting the Greeks
            icon = "task_political"
    
            requires = { carthaginian_mission_11_gaul_task_2 carthaginian_mission_11_gaul_task_3 }
    
            potential = {}
    
            allow = {}
    
            on_completion = {}
        }
    
        carthaginian_mission_11_gaul_task_6 = { # Gallic Markets
            icon = "task_political"
    
            requires = { carthaginian_mission_11_gaul_task_3 carthaginian_mission_11_gaul_task_4 }
    
            potential = {}
    
            allow = {}
    
            on_completion = {}
        }
    
        carthaginian_mission_11_gaul_task_final = { # Rhodanian Trade
            icon = "task_political" # SPECIAL FIELD - Sets picture for mission task
    
            requires = { carthaginian_mission_11_gaul_task_5 carthaginian_mission_11_gaul_task_6 } # SPECIAL FIELD - Missions tasks required for this task to be available
    
            final = yes # SPECIAL FIELD - Final mission task of the mission
        }
    }

    We will simply add a handful of near duplicate titles. Personally, I prefer just using the base name and a task number like this, then a comment with the name of the task. Others prefer using the name of the task itself (e.g ports_of_gaul = { }), but either will work just fine.

    upload_2019-11-22_12-48-29.png

    Code:
    carthaginian_mission_11_gaul_task_2 = { # Managing Massalia
        icon = "task_political"
    
        requires = { carthaginian_mission_11_gaul_task_1 }
    
        potential = {}
    
        allow = {}
    
        on_completion = {}
    }
    
    carthaginian_mission_11_gaul_task_3 = { # Annex Arelatis
        icon = "task_political"
    
        requires = { carthaginian_mission_11_gaul_task_1 }
    
        potential = {}
    
        allow = {}
    
        on_completion = {}
    }
    
    carthaginian_mission_11_gaul_task_4 = { # Navigating Narbo
        icon = "task_political"
    
        requires = { carthaginian_mission_11_gaul_task_1 }
    
        potential = {}
    
        allow = {}
    
        on_completion = {}
    }
    
    carthaginian_mission_11_gaul_task_5 = { # Ousting the Greeks
        icon = "task_political"
    
        requires = { carthaginian_mission_11_gaul_task_2 carthaginian_mission_11_gaul_task_3 }
    
        potential = {}
    
        allow = {}
    
        on_completion = {}
    }
    
    carthaginian_mission_11_gaul_task_6 = { # Gallic Markets
        icon = "task_political"
    
        requires = { carthaginian_mission_11_gaul_task_3 carthaginian_mission_11_gaul_task_4 }
    
        potential = {}
    
        allow = {}
    
        on_completion = {}
    }
    
    carthaginian_mission_11_gaul_task_final = { # Rhodanian Trade
        icon = "task_political" # SPECIAL FIELD - Sets picture for mission task
    
        requires = { carthaginian_mission_11_gaul_task_5 carthaginian_mission_11_gaul_task_6 } # SPECIAL FIELD - Missions tasks required for this task to be available
    
        final = yes # SPECIAL FIELD - Final mission task of the mission
    }

    Inside each mission task, we will fill in the “requires” field referring to previous tasks by name. This will allow the game to generate a working mission tree.

    Next we will add the localization for each mission task, so it is easier to keep track of things when the tree is generated.

    upload_2019-11-22_13-1-43.png

    Code:
    ### Gaul ###
    carthaginian_mission_11_gaul:0 "Controlling Rhodanus"
    carthaginian_mission_11_gaul_DESCRIPTION:0 "This is a descriptive description describing the mission about taking control of the territories around the Rhodanus."
    carthaginian_mission_11_gaul_CRITERIA_DESCRIPTION:0 "This mission will be considered complete when we have taken control of the territories around the Rhodanus."
    carthaginian_mission_11_gaul_BUTTON_TOOLTIP:0 "Rhodanus will be our entrance into the rich trade of Gaul."
    carthaginian_mission_11_gaul_task_1:0 "Ports of Gaul"
    carthaginian_mission_11_gaul_task_1_DESC:0 "Long have the Greeks been the only foreign traders in Gaul, it is time for a change."
    carthaginian_mission_11_gaul_task_2:0 "Managing Massalia"
    carthaginian_mission_11_gaul_task_2_DESC:0 "Massalia has a long and rich history."
    carthaginian_mission_11_gaul_task_3:0 "Annex Arelatis"
    carthaginian_mission_11_gaul_task_3_DESC:0 "Arelatis is a natural harbor up the Rhodanus, connecting the river trade of Gaul with the Mediterranean."
    carthaginian_mission_11_gaul_task_4:0 "Navigating Narbo"
    carthaginian_mission_11_gaul_task_4_DESC:0 "One of the richer Gallic cities along the Mediterranean coast."
    carthaginian_mission_11_gaul_task_5:0 "Ousting the Greeks"
    carthaginian_mission_11_gaul_task_5_DESC:0 "Down with the Greeks!"
    carthaginian_mission_11_gaul_task_6:0 "Gallic Markets"
    carthaginian_mission_11_gaul_task_6_DESC:0 "The rich Gallic markets are ours for the taking."
    carthaginian_mission_11_gaul_task_final:0 "Rhodanian Trade"
    carthaginian_mission_11_gaul_task_final_DESC:0 "We have finally completed our goal of entering the rich river trade of Gaul."

    Localization keys for mission tasks are pretty similar to what we saw earlier, and easy enough to add as well. We simply use:
    • <mission task name> - Name of the mission task
    • <mission task name>_DESC - Description of the mission task that is shown when it is hovered
    upload_2019-11-22_12-54-49.png


    And this is the result. We have a working mission tree (though one that doesn’t do much), with all the names and descriptions we want.
     
    Timed Task
  • Timed Task

    To start, our first task will be timed. All we need to do to change an instant task to a timed one is add a duration to it. This first task will be about forging claims on the ports of Gaul, and potentially getting some other events while doing so.

    upload_2019-11-22_13-3-39.png

    upload_2019-11-22_13-3-47.png

    Code:
    carthaginian_mission_11_gaul_task_1 = { # Ports of Gaul
        icon = "task_diplomatic"# SPECIAL FIELD - Sets picture for mission task
    
        duration = 180 # SPECIAL FIELD - Sets duration for the mission task
    
        monthly_on_action = carthaginian_mission_11_gaul_task_1_pulse # SPECIAL FIELD - Monthly on action pulse
    
        highlight = { # TRIGGER FIELD - Conditions for the provinces to be highlighted
            scope:province = { # SPECIAL SCOPE - A special saved scope to check conditions on all provinces
                OR = { # BOOLEAN OPERATOR - Checks if any of the following conditions are true
                    province_id = 2325 # TRIGGER - Checks for Massalia's province ID
                    province_id = 2319 # TRIGGER - Checks for Arelatis' province ID
                    province_id = 2256 # TRIGGER - Checks for Narbo's province ID
                }
                trigger_if = { # TRIGGER IF - Checks if the following condition is true, and if it is we apply the extra trigger
                    limit = {
                        has_owner = yes # TRIGGER - Checks if the province has any owner
                    }
                    NOT = { # BOOLEAN OPERATOR - Checks if the following condition is NOT true
                        owner = root  # EVENT TARGET COMPARISON - Owner is ROOT
                    }
                }
            }
        }
    
        allow = { # TRIGGER FIELD - Conditions for the mission task to be completed
            treasury >= 150 # TRIGGER - Check if you have 150 or more gold in your treasury
        }
    
        bypass = { # TRIGGER FIELD - COnditions for the mission task to be bypassed
            any_owned_province = { # TRIGGER SCRIPT LIST - Check if you own any provinces that fits the following conditions
                count = 3 # COUNT - Count if you hold 3 provinces that fits the following conditions
                OR = { # BOOLEAN OPERATOR - Checks if any of the following conditions are true
                    province_id = 2325 # TRIGGER - Checks for Massalia's province ID
                    province_id = 2319 # TRIGGER - Checks for Arelatis' province ID
                    province_id = 2256 # TRIGGER - Checks for Narbo's province ID
                }
            }
        }
    
        on_start = { # EFFECT FIELD - These effects are run when the mission task is started
            add_treasury = -150 # EFFECT - Remove 150 gold from your treasury
        }
    
        on_completion = { # EFFECT FIELD - These effects are run when the mission task is completed
            p:2325 = { # SPECIFIC PROVINCE SCOPE - Massalia
                if = { # If Clause - Check if the following condition is true, then give you a claim if it is
                    limit = { # LIMIT - Initiates a trigger field
                        has_owner = yes # TRIGGER - Checks if the province has any owner
                        NOT = { owner = root } # BOOLEAN OPERATOR - EVENT TARGET COMPARISON - Checks that we don't own the province
                    }
                    add_claim = root # EFFECT - Add claim to the province to ROOT
                }
            }
            p:2319 = { # SPECIFIC PROVINCE SCOPE - Arelatis
                if = { # If Clause - Check if the following condition is true, then give you a claim if it is
                    limit = { # LIMIT - Initiates a trigger field
                        has_owner = yes # TRIGGER - Checks if the province has any owner
                        NOT = { owner = root } # BOOLEAN OPERATOR - EVENT TARGET COMPARISON - Checks that we don't own the province
                    }
                    add_claim = root # EFFECT - Add claim to the province to ROOT
                }
            }
            p:2256 = { # SPECIFIC PROVINCE SCOPE - Narbo
                if = { # If Clause - Check if the following condition is true, then give you a claim if it is
                    limit = { # LIMIT - Initiates a trigger field
                        has_owner = yes # TRIGGER - Checks if the province has any owner
                        NOT = { owner = root } # BOOLEAN OPERATOR - EVENT TARGET COMPARISON - Checks that we don't own the province
                    }
                    add_claim = root # EFFECT - Add claim to the province to ROOT
                }
            }
        }
    }

    Starting from the top, we set the icon and a duration of 180 days, meaning it will be approximately half a year from the task starting until completion. We also set a monthly_on_action, meaning we will have an on_action pulse that runs every month while this task is active.

    Jumping over to the file ‘Imperator\game\common\on_action\00_mission_pulse.txt’, we add a new entry at the bottom of the list.

    upload_2019-11-22_13-3-57.png

    Code:
    carthaginian_mission_11_gaul_task_1_pulse = {
        random_events = {
            5 = 0
        }
    }

    Here, we can add random events that can potentially fire each month.

    Moving back to the mission task, the next on our list is the highlight section. We have a special scope inside it, saved by automatically by Code, that let’s us target all provinces (territories) for checking conditions against them (similar to how we do it in decisions, see this guide).

    In this case, we highlight the three territories we want you to gain a claim on (targets of later mission tasks, Narbo, Arelatis and Massalia). We also make sure that you do not gain a claim on a province you already own.

    For the allow section, we add a simple check that you have at least 150 gold in your treasury, as that is the price we will set for the claims.

    As for the bypass, as that is something we haven’t touched upon before, we add conditions that will skip the task. In this case we check if the nation taking the task already owns all three territories. It doesn’t make sense to make claims on your own territories after all, so we will simply bypass the mission if that is the case. This will make this task uncompletable, but allow the player to move on to any tasks following it.

    NOTE: If the task in question requires any other tasks to be completed first, those tasks will be required before being able to move on past the bypassed mission (e.g. if task 3 requires tasks 1 and 2, and is required by task 4, you won’t be able to complete task 4 until both 1 and 2 have been completed, even if 3 has been bypassed).

    When we get to the on_start, we follow up on our check from the allow section. We remove 150 gold from the treasury of the nation who is doing the mission, and it happens when the mission is started rather than completed as it makes sense that you invest in creating the claims before the forging actually begins.

    Finally, in the on_completion we go to the specific territory scopes we are looking for (Narbo, Arelatis, and Massalia) and check that they are not already owned by us. If they are not, we grant a claim on the territory. The way we do this is through a trigger_if inside the limit of a normal if clause. If the province does not have an owner, we will always get a claim on it (as the trigger if clause won’t apply, and there will be no triggers in the if), and if there is an owner we make sure it isn’t us.


    upload_2019-11-22_13-4-5.png


    And this is the result of our hard work. In this test case, we already hold Massalia, and you can see that we only gain a claim on the other two territories.

    Considering it’s 3 territories we are talking about, and it costs 150 gold, it is easy to see the correlation between price and land. 50 gold per province. To make a final adjustment to the price, we will scale it down if we already any of the provinces, using a Script Value.

    We will open the file ‘Imperator\game\common\script_values\00_mission.txt’, and add a new entry to the list.

    upload_2019-11-22_13-4-9.png

    Code:
    carthaginian_mission_11_gaul_task_1_svalue = {
        value = 150
        every_owned_province = {
            limit = {
                OR = {
                    province_id = 2325
                    province_id = 2319
                    province_id = 2256
                }
            }
            subtract = 50
        }
    }

    We set up a starting value, in this case 150 as that is the value we used earlier, then subtract 50 for every territory we own that fits the conditions (checking for the province ID of Arelatis, Narbo and Massalia). Now that we have the Script Value prepared, we can simply put it into the treasury trigger and effect.

    upload_2019-11-22_13-4-15.png

    Code:
    allow = { # TRIGGER FIELD - Conditions for the mission task to be completed
        treasury >= carthaginian_mission_11_gaul_task_1_svalue # TRIGGER - Check if you have enough gold in your treasury
    }
    
    bypass = { # TRIGGER FIELD - COnditions for the mission task to be bypassed
        any_owned_province = { # TRIGGER SCRIPT LIST - Check if you own any provinces that fits the following conditions
            count = 3 # COUNT - Count if you hold 3 provinces that fits the following conditions
            OR = { # BOOLEAN OPERATOR - Checks if any of the following conditions are true
                province_id = 2325 # TRIGGER - Checks for Massalia's province ID
                province_id = 2319 # TRIGGER - Checks for Arelatis' province ID
                province_id = 2256 # TRIGGER - Checks for Narbo's province ID
            }
        }
    }
    
    on_start = { # EFFECT FIELD - These effects are run when the mission task is started
        add_treasury = { # EFFECT - Remove a logical amount of gold from your treasury
            subtract = carthaginian_mission_11_gaul_task_1_svalue
        }
    }

    Now the task will check for the scaled cost in allow, and similarly it will subtract a scaled cost in the effect. This is a quick and easy way to scale costs easily, without having to do a lot of complicated math in Script. Looking over at our tooltip again, we can see that the cost has scaled properly as we already own Massalia.

    upload_2019-11-22_13-4-23.png
     
    Instant Task
  • Instant Task

    For the next part of our guide, we will make three similar instant tasks, where you have to hold a territory (Narbo, Massalia and Arelatis respectively), and are given a reward.

    upload_2019-11-22_13-9-27.png

    Code:
    carthaginian_mission_11_gaul_task_2 = { # Managing Massalia
        icon = "task_conquest" # ICON - Set icon for the task
    
        requires = { carthaginian_mission_11_gaul_task_1 } # SPECIAL FIELD - Set tasks that needs to be completed to be able to complete this task
    
        highlight = { # TRIGGER FIELD - Conditions for provinces to be highlighted
            scope:province = { # SPECIAL SCOPE - A special saved scope to check conditions on all provinces
                province_id = 2325 # TRIGGER - Checks for Massalia's province ID
            }
        }
    
        allow = { # TRIGGER FIELD - Conditions for the mission task to be completed
            owns = 2325 # TRIGGER - Checks for Massalia's province ID
        }
    
        on_completion = { # EFFECT FIELD - These effects are run when the mission task is completed
            p:2325 = { # SPECIFIC PROVINCE SCOPE - Massalia
                while = { # WHILE LOOP - Run the following effects as many times as the count, as long as the condition in limit is true
                    count = 5 # COUNT - How many times should it run if conditions are true
                    limit = { # LIMIT - Conditions for while to run
                        total_population < population_cap # TRIGGER - Checks if total population is lower than population capacity in the province
                    }
                    define_pop = { # EFFECT - Add defined pop to the province
                        type = freemen # TYPE - Sets type of pop
                        culture = root.culture # CULTURE - Sets culture of pop
                        religion = root.religion # RELIGION - Sets religion of pop
                    }
                }
            }
        }
    }
    
    carthaginian_mission_11_gaul_task_3 = { # Annex Arelatis
        icon = "task_political"
    
        requires = { carthaginian_mission_11_gaul_task_1 }
    
        highlight = {
            scope:province = {
                province_id = 2319
            }
        }
    
        allow = {
            owns = 2319
        }
    
        on_completion = {
            p:2319 = {
                while = {
                    count = 5
                    limit = {
                        total_population > population_cap
                    }
                    define_pop = {
                        type = freemen
                        culture = root.culture
                        religion = root.religion
                    }
                }
            }
        }
    }
    
    carthaginian_mission_11_gaul_task_4 = { # Navigating Narbo
        icon = "task_expansion"
    
        requires = { carthaginian_mission_11_gaul_task_1 }
    
        highlight = {
            scope:province = {
                province_id = 2256
            }
        }
    
        allow = {
            owns = 2256
        }
    
        on_completion = {
            p:2256 = {
                while = {
                    count = 5
                    limit = {
                        total_population > population_cap
                    }
                    define_pop = {
                        type = freemen
                        culture = root.culture
                        religion = root.religion
                    }
                }
            }
        }
    }

    As the three tasks will be entirely similar (besides linking to different provinces), we will only showcase one of them. We add an icon to the top, as we did in the previous task. Unlike the previous task, however, we do not have a duration as it is an instant task.

    In the requires field, we simply add the name of the mission task we want to link it up to. In this case, we want these tasks to be available after the first task has been completed, so add that task’s name.

    Moving on to highlight, we did something along the same lines as we did last time. In this case we only want one specific territory to highlight, so we check for its province id. Similarly, we check we don’t already own the territory in allow.

    In the on_completion we find the specific province scope, and make a while loop which adds some pops to the province.

    upload_2019-11-22_13-9-32.png


    This is what the final tooltip looks like. Hardly the most exciting mission task, but it is fully functional and does what we want for this guide.
     
    Exclusive Tasks
  • Exclusive Tasks

    Next on our list are two exclusive tasks, task 5 and 6. One will be about getting rid of the Greeks in the area and taking control of their old markets, and the other will be focused on just building up the new territories. As they are exclusive, if you complete one of them, the other one will be automatically bypassed.

    upload_2019-11-22_13-12-3.png

    Code:
    carthaginian_mission_11_gaul_task_5 = { # Ousting the Greeks
        icon = "task_political" # ICON - Set icon for the task
    
        prevented_by = { carthaginian_mission_11_gaul_task_6 } # EXCLUSIVITY - If you complete this other task, this task will become unavailable
    
        requires = { carthaginian_mission_11_gaul_task_2 carthaginian_mission_11_gaul_task_3 } # SPECIAL FIELD - Set tasks that needs to be completed to be able to complete this task
    
        bypass = { # TRIGGER FIELD - Conditions for the mission task to be bypassed
            has_completed_mission_task = carthaginian_mission_11_gaul_task_6 # TRIGGER - Check if this mission task has been completed
        }
    
        allow = { # TRIGGER FIELD - Conditions for the mission task to be completed
            trigger_if = { # TRIGGER IF - Checks if the following condition is true, and if it is we apply the extra trigger
                limit = { # LIMIT - Sets condition for trigger if to be true or not
                    NOT = { owns = 2325 } # BOOLEAN OPERATOR - TRIGGER - Check if the nation does not own Massalia
                }
                owns = 2325 # TRIGGER - Check if the nation owns Massalia
            }
            p:2325 = { # SPECIAL PROVINCE SCOPE - Massalia
                has_city_status = yes # TRIGGER - Checks if the province has city status
                dominant_province_culture = root.culture # TRIGGER - Checks if the province is dominantly punic culture
            }
            trigger_if = { # TRIGGER IF - Checks if the following condition is true, and if it is we apply the extra trigger
                limit = { # LIMIT - Sets condition for trigger if to be true or not
                    NOT = { owns = 2319 } # BOOLEAN OPERATOR - TRIGGER - Check if the nation does not own Arelatis
                }
                owns = 2319 # TRIGGER - Check if the nation owns Arelatis
            }
            p:2319 = { # SPECIAL PROVINCE SCOPE - Arelatis
                has_city_status = yes # TRIGGER - Checks if the province has city status
                dominant_province_culture = root.culture # TRIGGER - Checks if the province is dominantly punic culture
            }
        }
    
        on_completion = {
            p:2325 = { # SPECIAL PROVINCE SCOPE - Massalia
                add_province_modifier = { # EFFECT - Add province modifier
                    name = punic_mission_punic_port_modifier # SPECIAL FIELD - Name of modifier
                    duration = -1 # SPECIAL FIELD - Duration of modifier
                }
            }
            p:2319 = { # SPECIAL PROVINCE SCOPE - Arelatis
                add_province_modifier = { # EFFECT - Add province modifier
                    name = punic_mission_punic_port_modifier # SPECIAL FIELD - Name of modifier
                    duration = -1 # SPECIAL FIELD - Duration of modifier
                }
            }
        }
    }

    So let us take a look at the ‘Ousting the Greeks’ task first.

    We have added a new field we haven’t used so far, called ‘prevented_by’, this means the task cannot be completed if you have completed the named task. This is what will lock down the mission task, and give the player a warning before finishing the other task. For both mission tasks to be exclusive, we will have to do the same when we move over to the other mission task as well.

    In the bypass section of this task, we have added a check if you have completed the other mission task, as well. This way, the other task will be locked down but still allow continuing to the final mission task.

    As for allow, we add trigger_if clauses to check if the nation already owns the two territories. They should, as the previous tasks require them, but it is possible that the nation has lost them before finishing the next task.

    We use a trigger_if, as we only want to enable the trigger and its tooltip if the trigger_ifs conditions are met, as generally they will still hold the territory and we do not want our tooltips to grow unnecessarily large. Besides that, we check that the two territories are established cities and of our culture.

    Finally, we add province modifiers to the two territories on completion. We use two province modifiers that already appear fairly regularly in the original Carthaginian missions, so in this case avoid the need for an entirely new one. We are going to use the same modifier for the other exclusive task as well.

    upload_2019-11-22_13-12-10.png

    Code:
    carthaginian_mission_11_gaul_task_6 = { # Gallic Markets
        icon = "task_economical" # ICON - Set icon for the task
    
        prevented_by = { carthaginian_mission_11_gaul_task_5 } # EXCLUSIVITY - If you complete this other task, this task will become unavailable
    
        requires = { carthaginian_mission_11_gaul_task_3 carthaginian_mission_11_gaul_task_4 } # SPECIAL FIELD - Set tasks that needs to be completed to be able to complete this task
    
        bypass = { # TRIGGER FIELD - Conditions for the mission task to be bypassed
            has_completed_mission_task = carthaginian_mission_11_gaul_task_5 # TRIGGER - Check if this mission task has been completed
        }
    
        allow = { # TRIGGER FIELD - Conditions for the mission task to be completed
            trigger_if = { # TRIGGER IF - Checks if the following condition is true, and if it is we apply the extra trigger
                limit = { # LIMIT - Sets condition for trigger if to be true or not
                    NOT = { owns = 2256 } # BOOLEAN OPERATOR - TRIGGER - Check if the nation does not own Narbo
                }
                owns = 2256 # TRIGGER - Check if the nation owns Narbo
            }
            p:2256 = { # SPECIAL PROVINCE SCOPE - Narbo
                has_city_status = yes # TRIGGER - Checks if the province has city status
                free_building_slots = 0 # TRIGGER - Check that the province has no free building slots
                has_construction = no # TRIGGER - Check that there is nothing being constructed right now
            }
            trigger_if = { # TRIGGER IF - Checks if the following condition is true, and if it is we apply the extra trigger
                limit = { # LIMIT - Sets condition for trigger if to be true or not
                    NOT = { owns = 2319 } # BOOLEAN OPERATOR - TRIGGER - Check if the nation does not own Arelatis
                }
                owns = 2319 # TRIGGER - Check if the nation owns Arelatis
            }
            p:2319 = { # SPECIAL PROVINCE SCOPE - Arelatis
                has_city_status = yes # TRIGGER - Checks if the province has city status
                free_building_slots = 0 # TRIGGER - Check that the province has no free building slots
                has_construction = no # TRIGGER - Check that there is nothing being constructed right now
            }
        }
    
        on_completion = {
            p:2256 = { # SPECIAL PROVINCE SCOPE - Narbo
                add_province_modifier = { # EFFECT - Add province modifier
                    name = punic_mission_punic_port_modifier # SPECIAL FIELD - Name of modifier
                    duration = -1 # SPECIAL FIELD - Duration of modifier
                }
            }
            p:2319 = { # SPECIAL PROVINCE SCOPE - Arelatis
                add_province_modifier = { # EFFECT - Add province modifier
                    name = punic_mission_punic_port_modifier # SPECIAL FIELD - Name of modifier
                    duration = -1 # SPECIAL FIELD - Duration of modifier
                }
            }
        }
    }

    This task is fairly similar to the one it is exclusive with, except we have changed the task it is prevented by (as it wouldn’t make sense to be exclusive with itself, after all), as well as a targeted territory. So instead of Massalia and Arelatis, it targets Narbo and Arelatis.

    In addition, we have changed the dominant culture check to one that checks there are no free building slots in the city. We also added a check to make sure they aren’t currently constructing anything, as it would otherwise be possible to just queue up 3-4 buildings and that would fill up the quota for buildings in the province, fulfilling the conditions of the no free building slots check.

    upload_2019-11-22_13-12-17.png



    When we hover over the two tooltips, we can see that the exclusivity works by the red border and destroyed statue of the other task. However, as mentioned earlier when we explained the syntax of a mission, a bypass cannot take effect if you haven’t completed all mission tasks up to that point.

    In this case, that means we will not be able to move on to the final mission, if we complete ‘Ousting the Greeks’ (then make ‘Gallic Markets’ uncompletable), and ‘Navigating Narbo’ has not been completed. So what we will do, is to introduce exclusivity to ‘Navigating Narbo’ and ‘Managing Massalia’ as well, but only from one way.

    Meaning that if we complete ‘Ousting the Greeks’ and have not already completed ‘Navigating Narbo’, we will lock and bypass ‘Navigating Narbo’ as well as ‘Gallic Markets’, and vice versa for the other side.

    upload_2019-11-22_13-12-22.png

    Code:
    carthaginian_mission_11_gaul_task_2 = { # Managing Massalia
        icon = "task_conquest" # ICON - Set icon for the task
    
        requires = { carthaginian_mission_11_gaul_task_1 } # SPECIAL FIELD - Set tasks that needs to be completed to be able to complete this task
    
        prevented_by = { carthaginian_mission_11_gaul_task_6 }
    
        highlight = { # TRIGGER FIELD - Conditions for provinces to be highlighted
            scope:province = { # SPECIAL SCOPE - A special saved scope to check conditions on all provinces
                province_id = 2325 # TRIGGER - Checks for Massalia's province ID
            }
        }
    
        bypass = { # TRIGGER FIELD - Conditions for the mission task to be bypassed
            has_completed_mission_task = carthaginian_mission_11_gaul_task_6 # TRIGGER - Check if this mission task has been completed
        }
    
        allow = { # TRIGGER FIELD - Conditions for the mission task to be completed
            owns = 2325 # TRIGGER - Checks for Massalia's province ID
        }
    
        on_completion = { # EFFECT FIELD - These effects are run when the mission task is completed
            p:2325 = { # SPECIFIC PROVINCE SCOPE - Massalia
                while = { # WHILE LOOP - Run the following effects as many times as the count, as long as the condition in limit is true
                    count = 5 # COUNT - How many times should it run if conditions are true
                    limit = { # LIMIT - Conditions for while to run
                        total_population < population_cap # TRIGGER - Checks if total population is lower than population capacity in the province
                    }
                    define_pop = { # EFFECT - Add defined pop to the province
                        type = freemen # TYPE - Sets type of pop
                        culture = root.culture # CULTURE - Sets culture of pop
                        religion = root.religion # RELIGION - Sets religion of pop
                    }
                }
            }
        }
    }

    Here we can see the changes we are making to ‘Managing Massalia’. By taking the same prevented_by and bypass as ‘Ousting the Greeks’, we can easily make sure that everything is bypassed properly. We do the same for ‘Navigating Narbo’, taking the prevented_by and bypass from ‘Gallic Markets’ to have the same effect there.

    upload_2019-11-22_13-12-30.png



    Here we can see it in effect, with both mission tasks on the left-hand side being bypassed when we complete ‘Ousting the Greeks’. The same will happen on the other side if we complete ‘Gallic Markets’, with the right-hand side being bypassed and locked.
     
    Final Task
  • Final Task

    The final task of the mission, or the final tasks if you want to add several of them, allow a mission to be finished. In the missions we made for Rome and Carthage, these usually provide the largest rewards in the mission.

    For our final mission task, we are going to give our nation a sizeable modifier if they still fulfill the requirements we originally set (holding Arelatis, and either Narbo or Massalia based on what route they took).

    upload_2019-11-22_13-16-32.png

    Code:
    carthaginian_mission_11_gaul_task_final = { # Rhodanian Trade
        icon = "task_political" # SPECIAL FIELD - Sets picture for mission task
    
        requires = { carthaginian_mission_11_gaul_task_5 carthaginian_mission_11_gaul_task_6 } # SPECIAL FIELD - Missions tasks required for this task to be available
    
        final = yes # SPECIAL FIELD - Final mission task of the mission
    
        allow = { # TRIGGER FIELD - Conditions for the mission task to be completed
            trigger_if = { # TRIGGER IF - Checks if the following condition is true, and if it is we apply the extra trigger
                limit = { # LIMIT - Sets condition for trigger if to be true or not
                    has_completed_mission_task = carthaginian_mission_11_gaul_task_5 # TRIGGER - Has completed the task Ousting the Greeks
                    NOT = { owns = 2325 } # BOOLEAN OPERATOR - TRIGGER - Check if we do not hold Massalia
                }
                owns = 2325 # TRIGGER - Check that we hold Massalia
            }
            trigger_if = { # TRIGGER IF - Checks if the following condition is true, and if it is we apply the extra trigger
                limit = { # LIMIT - Sets condition for trigger if to be true or not
                    has_completed_mission_task = carthaginian_mission_11_gaul_task_6 # TRIGGER - Has completed the task Gallic Markets
                    NOT = { owns = 2256 } # BOOLEAN OPERATOR - TRIGGER - Check if we do not hold Narbo
                }
                owns = 2256 # TRIGGER - Check that we hold Narbo
            }
            trigger_if = { # TRIGGER IF - Checks if the following condition is true, and if it is we apply the extra trigger
                limit = { # LIMIT - Sets condition for trigger if to be true or not
                    NOT = { owns = 2319 } # BOOLEAN OPERATOR - TRIGGER - Check if we do not hold Arelatis
                }
                owns = 2319 # TRIGGER - Check that we hold Arelatis
            }
        }
    
        on_completion = { # EFFECT FIELD - Run these effects when we complete the task
            add_country_modifier = { # EFFECT - Add country modifier
                name = carthaginian_mission_11_gaul_task_final_modifier # SPECIAL FIELD - Name of modifier
                duration = -1 # SPECIAL FIELD - Duration of modifier
            }
        }
    }

    We added a ‘final = yes’ almost all the way at the top, to make this one of the final tasks in this mission.

    Besides that, we are simply checking that the nation still holds the land they needed to get to this point, based on which route they took. We use trigger_ifs, as we have many times in this mission already, to check if they have completed specific mission tasks and own the territories needed.

    For the completion effect, we have added a country modifier with a duration of -1, meaning it will last until the end of the game.

    upload_2019-11-22_13-16-37.png

    Code:
    carthaginian_mission_11_gaul_task_final_modifier = {
        light_infantry_discipline = 0.1
        global_commerce_modifier = 0.05
        global_capital_trade_routes = 1
    }

    Here is the country modifier we have added. It provides you with light infantry (an influx of Gallic mercs and settlers in Punic lands is the idea), more commerce income, and a new capital trade route.

    upload_2019-11-22_13-16-41.png


    And here is the tooltip for the final mission task, so we can see what it looks like in-game.
     
    Optional Paths/Tasks
  • Optional Paths/Tasks

    Throughout the whole guide, we have had a pretty strict line of tasks, all related to one another. But that does not necessarily have to be the case. We could easily add paths unrelated to the main path as optional tasks along the way. For this part of the guide, we will not add a lot of triggers, effects, nor comments, but simply add new mission tasks to show what it would look like.

    We will try adding two new optional tasks that branch out of ‘Gallic Markets’ and ‘Ousting the Greeks’. As these branch from exclusive tasks, we will make these exclusive to the branching tasks as well (e.g a task branching out of ‘Gallic Markets’ cannot be completed if you complete ‘Ousting the Greeks’).

    upload_2019-11-22_13-18-33.png

    Code:
    carthaginian_mission_11_gaul_task_7 = { # Rebuilding Massalia
        icon = "task_economical"
    
        requires = { carthaginian_mission_11_gaul_task_5 }
    
        prevented_by = { carthaginian_mission_11_gaul_task_6 }
    }
    
    carthaginian_mission_11_gaul_task_8 = { # Carthago Narbo
        icon = "task_economical"
    
        requires = { carthaginian_mission_11_gaul_task_6 }
    
        prevented_by = { carthaginian_mission_11_gaul_task_5 }
    }

    So this is all we add, Script-wise. Two new tasks, exclusive with the opposite side of the one they branch from, and requiring their side to have been completed.

    upload_2019-11-22_13-18-36.png


    And this is what it looks like in-game. If we choose the left path with ‘Gallic Markets’, we will allow ‘Carthago Narbo’ as well, and on the other side, we will allow ‘Rebuilding Massalia’ after ‘Ousting the Greeks’. One thing to note here, is that a task that has only been locked and isn’t bypassed will not get the golden frame, as you can see with ‘Carthago Narbo’.

    Next, we are going to add a new optional path that does not interact with the main tasks at all. This will simply be a set of optional tasks that the nation can choose to do if they so wish.

    upload_2019-11-22_13-18-40.png

    Code:
    carthaginian_mission_11_gaul_task_9 = { # Gallic Embassy
        icon = "task_diplomatic"
    }
    
    carthaginian_mission_11_gaul_task_10 = { # Allies in Gaul
        icon = "task_diplomatic"
    
        requires = { carthaginian_mission_11_gaul_task_9 }
    }
    
    carthaginian_mission_11_gaul_task_11 = { # Civilizing the Gallic Hinterlands
        icon = "task_conquest"
    
        requires = { carthaginian_mission_11_gaul_task_10 }
    }

    Once again we add the absolute minimum just to get the tasks to appear, without any triggers or effects.

    upload_2019-11-22_13-18-46.png


    And here is the result. A whole new optional path one can take on the left hand side, independent of the main path.

    Of course, you can start making the two paths interact with one another as well, if you so wish. For example can we make ‘Allies in Gaul’ a requirement of ‘Gallic Markets’, by adding task 10 to the requires of task 6.

    upload_2019-11-22_13-18-50.png


    Now we’ve seen a few examples of the many interesting things we can do with the mission system. An important thing to keep in mind with the last change though, is that we have to rethink bypasses, and if we want to bypass the optional path on the left, so the player can get past ‘Gallic Markets’.
     
    Randomized Tasks
  • Randomized Tasks

    One of the things that makes this system so powerful is its ability to find optimal ways of generating a tree, meaning we can add tasks that only appear under specific circumstances, or tasks that appear randomly. For example, a mission with a main path, and one of three possible optional paths. This way, the mission can vary every time you it is played.

    For this example, we are going to randomly generate a variable when we start the mission, and then get one of three different tasks based on the result. If we abort or complete the mission, we will remove said variable.

    upload_2019-11-22_13-21-20.png

    Code:
    on_start = { # EFFECT FIELD - These effects are run when the mission is started
        save_scope_as = mission_country # EFFECT - Save Scope
        random_list = { # RANDOM LIST - Gets one of the following effects
            1 = { # CHANCE - 1/3
                set_variable = carthaginian_mission_gaul_1 # VARIABLE - Set variable
            }
            1 = { # CHANCE - 1/3
                set_variable = carthaginian_mission_gaul_2 # VARIABLE - Set variable
            }
            1 = { # CHANCE - 1/3
                set_variable = carthaginian_mission_gaul_3 # VARIABLE - Set variable
            }
        }
    }
    
    on_abort = { # EFFECT FIELD - These effects are run when the mission is aborted
        custom_tooltip = general_mission_cooldown_tt # EFFECT - CUSTOM TOOLTIP - Explains the player that they will receive a cooldown when aborting the mission
        set_variable = { # EFFECT - VARIABLE - Set a variable to check cooldown
            name = carthaginian_mission_11_gaul # SPECIAL FIELD - Name of variable
            days = 7300 # SPECIAL FIELD - Duration of variable
        } # END OF VARIABLE EFFECT
        switch = { # SWITCH - Check if we have any of the following conditions
            trigger = has_variable # TRIGGER - Condition that will be used
            carthaginian_mission_gaul_1 = { remove_variable = carthaginian_mission_gaul_1 } # If we have this variable, remove it
            carthaginian_mission_gaul_2 = { remove_variable = carthaginian_mission_gaul_2 } # If we have this variable, remove it
            carthaginian_mission_gaul_3 = { remove_variable = carthaginian_mission_gaul_3 } # If we have this variable, remove it
        }
    }
    
    on_completion = { # EFFECT FIELD - These effects are run when the mission is completed
        complete_mission_effect = yes # SCRIPTED EFFECT - Sets up a variable to count how many missions we have completed
        switch = { # SWITCH - Check if we have any of the following conditions
            trigger = has_variable # TRIGGER - Condition that will be used
            carthaginian_mission_gaul_1 = { remove_variable = carthaginian_mission_gaul_1 } # If we have this variable, remove it
            carthaginian_mission_gaul_2 = { remove_variable = carthaginian_mission_gaul_2 } # If we have this variable, remove it
            carthaginian_mission_gaul_3 = { remove_variable = carthaginian_mission_gaul_3 } # If we have this variable, remove it
        }
    }

    As we can see here, we have now expanded a bit upon our mission essentials, adding new effects to on_start, on_abort and on_completion.

    In on start we have simply added a random_list that gives us one of three variables, without anything affecting the chances (i.e. they are all equally likely). It is also possible to make this a lot more complicated by checking for different things, but we are keeping it simple for the sake of this guide.

    In the on_abort and on_completion, we have added a trigger switch to remove the variables that we have received. It is basically a simplified and more compact version of an if - else_if effect, meaning that it checks for a specific trigger (in this case ‘has_variable’), and if it returns true it will complete that lines effect and move on (e.g if we had the variable ‘carthaginian_mission_gaul_2’, it would return false on the first check, return true on the second check and remove the variable, and never get to the third check).

    With three possible variables given to us as we start the mission, we will now add three new (very simplified) tasks that will spawn based on the variable we are given.

    upload_2019-11-22_13-21-25.png

    Code:
    carthaginian_mission_11_gaul_task_12 = { # The Lands of the Aquitani
        icon = "task_political"
    
        potential = {
            has_variable = carthaginian_mission_gaul_1
        }
    }
    
    carthaginian_mission_11_gaul_task_13 = { # Fighting the Arverni
        icon = "task_political"
    
        potential = {
            has_variable = carthaginian_mission_gaul_2
        }
    }
    
    carthaginian_mission_11_gaul_task_14 = { # Finding Lugdunum
        icon = "task_political"
    
        potential = {
            has_variable = carthaginian_mission_gaul_3
        }
    }

    Here we can see what it would look like, checking for the three variables that we set up earlier in three different task’s potential fields.

    upload_2019-11-22_13-21-29.png


    And here we see one possible outcome in game, after starting the mission again. In this case we got the third variable, ‘Finding Lugdunum’. If we had wanted to expand on this, like we do in the generic missions we added for the Livy Update, we could start checking many different factors before deciding what paths should open up for us, and how things should be linked together.

    Whole paths filled with mission tasks can be locked behind one of these variables, and it can generate wildly different results every time if we add enough things that can potentially happen.