• 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!

For this guide we are going to make a simple decision, in this case a formable for Sardinia if you play as one of the Nuragic tribes (the local population in Sardinia). When making this guide, we will take it for granted that you already understand the basic concepts of Scripting, like Scopes, Effects and Triggers, which are all explained in this guide.

We will start by opening up the folder ‘Imperator\game\decisions’. This is the directory for all the decisions in the game, and here we will enter the ‘tier_2_formables’ folder, as the decision we are making is going to be a Tier 2 formable. In this folder we will make a new .txt file called ‘form_sardinia”, and change it’s encoding to UTF-8 with Bom.

Our goal for the decision is to let a Nuragic tribe form a new nation called Sardinia, changing its color, flag, name, and giving them some rewards. We also want to make sure it is presented logically to a player when they look at the decision.

We will start by taking a look at the base syntax of a decisions file.

upload_2019-11-15_12-29-43.png

Code:
country_decisions = {
   
    # Form Sardinia
    form_sardinia = {
        potential = { # TRIGGER FIELD - Conditions for the decision to be shown

        }

        highlight = { # TRIGGER FIELD - PROVINCE SCOPE - Conditions for provinces to be highlighted

        }

        allow = { # TRIGGER FIELD - Conditions for the decision to completed

        }

        effect = { # EFFECT FIELD - What will happen when decision is completed

        }

        ai_will_do = { # TRIGGER FIELD - Modifiers to see how the AI will prioritize this decision
            base = 1
        }
    }
}
  • country_decisions - This is just necessary syntax at the start of every decisions file.
  • potential - Triggers to check if the decision will be shown to you or not. E.g. only showing formable nations in Greece to Greek cultured countries
  • highlight - Triggers to check if the provinces should be highlighted when you hover over the decision. Also used by the AI to plan how to complete the decision.
  • allow - Triggers to check if the decision can be completed or not. These will be shown if you hover over the decision.
  • effect - Effects that happen when the decision is completed.
  • ai_will_do - A section for modifying the priority the AI should give this particular decision.
 
Potential
Potential

We will start out by adding triggers to the potential to limit who can see the decision. We only want it to show up for the Nuragic tribes, and we will also add other common conditions we put in every formable (to make sure you do not grab several formables of the same tier etc.).

upload_2019-11-15_12-34-57.png

Code:
potential = { # TRIGGER FIELD - Conditions for the decision to be shown
    num_of_cities >= 1 # TRIGGER - Check that the country owns at least 1 territory
    country_culture = nuragic # TRIGGER - Check that the country has the Nuragic culture
    NOT = { # BOOLEAN OPERATOR - Check that the following is not true
        tag = SAR # TRIGGER - The country has the following tag
    } # END OF BOOLEAN OPERATOR
    NOR = { # BOOLEAN OPERATOR - Check that none of the following is true
        is_tier_2_formable_trigger = yes # SCRIPTED TRIGGER - List of tier 2 formables
        is_endgame_tag_trigger = yes # SCRIPTED TRIGGER - List of tier 3 formables
    } # END OF BOOLEAN OPERATOR
}

First we make sure that the nation owns land, as we only want the decision to show up for settled nations, with a simple check that the country has at least 1 territory (called cities in trigger, but the trigger predates our addition of territory ranks). We then check that the culture of the country is Nuragic. This way we make sure the decision only shows up for the Nuragic tribes, and not for anyone else.

With the first boolean operator, we make sure that the current tag is not SAR (Sardinia’s tag). We have not added the effect yet, but later on we will change the tag to SAR, so this is simply preparing what we are going to need later down the line.

The second boolean operator is a check we add to most of our formables, it makes sure that you cannot “reduce” your tier of formable. E.g. if you have formed the Pan-Hellenic League, we don’t want you to go back and form Achaea afterwards. Note that we only check for tier 2 and tier 3, and not tier 1. This is because the Sardinia formable is going to be tier 2, so it is fine if the country is already a tier 1 formable.

We check for tier formables by using “Scripted Triggers”, in other words, triggers we have written in Script. If we go to the file ‘Imperator\game\common\scripted_triggers\00_decisions.txt’, we will see ‘is_tier_2_formable_trigger’ almost all the way at the top. It is basically a list that checks if you have one of the formable tags. We are going to add our own entry in the tier 2 formable list, as we are making a new one and it should be accounted for.

upload_2019-11-15_12-40-58.png

Code:
is_tier_2_formable_trigger = {
    OR = {
        tag = ARI #armenia formable
        tag = ARM #armenia
        tag = ASR #Assyria
        tag = BBY #Babylon
        tag = BGG #Belgia
        tag = BRA #Pretania
        tag = CCC #Caledonian Confederacy
        tag = CCI #Cilicia
        tag = 1KR #Crete
        tag = DRA #Dravidia
        tag = EGY #Egypt
        tag = EGT #Egypt Formable
        tag = GLT #Galatia
        tag = HVL #Helvetia
        tag = ILL #Illyria
        tag = MAC #Macedon
        tag = MCD #Macedon Formable
        tag = MEE #Media
        tag = NRM #Noricum
        tag = NUM #Numidia
        tag = PRY #Phrygia
        tag = PRG #Phrygia Formable
        tag = PTU #Pontus Formable
        tag = PON #Pontus
        tag = SAR #Sardinia
        tag = SII #Sicily
        tag = SYA #Syria
        tag = YMN #Yamnat
        tag = SEL #Seleucids
        tag = TRE #Thrace
        tag = XXS #Saxonia
        tag = HIB #Hibernia
        tag = YZI #Yuezhi
    }
}

As we can see here, we have simply added it to the list (alphabetically, so it is easier to keep track of things). References like these are very handy, as it means it will automatically be applied to every other decision using this Scripted Trigger, rather than having to add it for every decision each time we add a new formable to the list.
 
Highlight
Highlight

Next we’ll go down to the “highlight” section. This section has a double purpose, in that it both shows the selected provinces to the player when they hover over the decision, and informs the AI which provinces it should focus on to complete the decision.

The decision will require you to hold all of Sardinia, so we’ll add triggers for the whole island.

upload_2019-11-15_12-45-10.png

Code:
highlight = { # TRIGGER FIELD - PROVINCE SCOPE - Conditions for provinces to be highlighted
    OR = { # BOOLEAN OPERATOR - Check if either of the following is true
        is_in_area = sardinia_septentrionalis # TRIGGER - Northern Sardinia Area
        is_in_area = sardinia_meridionalis # TRIGGER - Southern Sardinia Area
    } # END OF BOOLEAN OPERATOR
}

The highlighter is a bit of a weird case, as the Scope used is not the same as any other Scope. It will basically go through every province Scope, checking the trigger conditions to see if it is a valid province to highlight or not.

In this case we check if the province in question is in either ‘sardinia_septentrionalis’ (the area that covers the northern half of Sardinia) or ‘sardinia_meridionalis’ (the area that covers the southern half of Sardinia).

As every ownable province is in an area, and we usually have a logical area setup for islands and places like these (e.g. Corsica is an area, Sardinia is two areas, Sicily is three areas, Cyprus is an area, etc.), we can use these triggers to quickly check what we want.

upload_2019-11-15_12-46-26.png


This is what it will look like in-game. As we can see, it does not highlight the impassable mountain-range in eastern Sardinia, but does highlight the rest of the island.
 
Allow
Allow

With the decision’s highlights and potentials set, we can move on to the conditions for completing the decision. For this we want three different things: that Sardinia doesn’t already exist, that you fulfill the base criteria for forming a new nation (a scripted trigger checking that you aren’t at war or have an active civil war), and that you hold all of Sardinia.

upload_2019-11-15_12-49-6.png

Code:
allow = { # TRIGGER FIELD - Conditions for the decision to completed
    custom_tooltip = { # CUSTOM TOOLTIP
        text = formable_not_sardinia_exists # LOCALIZATION KEY
        NOT = { # BOOLEAN OPERATOR - Check that the following is not true
            any_country = { # TRIGGER SCRIPT LIST - Checks if there is any country
                tag = SAR # TRIGGER - With the Sardinian tag
            }
        } # END OF BOOLEAN OPERATOR
    }
    can_form_nation_trigger = yes # SCRIPTED TRIGGER - Checks if you are at war or in a civil war
    owns_area = sardinia_septentrionalis # TRIGGER - Check that you own all of Northern Sardinia
    owns_area = sardinia_meridionalis # TRIGGER - Check that you own all of Southern Sardinia
}

For the trigger that checks Sardinia does not already exist, we’ll use a custom tooltip as the trigger tooltip in this case is rather ugly. To make a custom tooltip for a trigger, we use a text field and add a key that we’ll write ourselves, and then put the triggers inside it. This is a great way to make sure a trigger both looks nice, and checks for something complex or specific in one tooltip line (or tick).

For the localization key of the custom tooltip, we will go to the file ‘nation_formation_l_english.yml’,scroll all the way to the bottom, and add a new entry.

upload_2019-11-15_12-49-42.png

Code:
# Sardinia
formable_not_sardinia_exists:0 "#Y Sardinia#! must NOT exist."

The second thing on the list is the scripted trigger ‘can_form_nation_trigger’, simply making sure you are not in a war or in a civil war. This Scripted Trigger is just below the Scripted Trigger formable lists we looked at earlier (the file ‘imperator\game\common\scripted_triggers\00_decisions.txt’).

Lastly we’ll add in triggers to check all the provinces in the areas of Sardinia Septentrionalis (Northern Sardinia) and Sardinia Meridionalis (Southern Sardinia) are owned, so that it properly reflects the highlights we made earlier.

After all that, we get the following tooltip on mouseover:

upload_2019-11-15_12-52-49.png
 
Effect
Effect

For the effects, we want to change the decision taking country’s name, map color, tag, and flag, as well as giving them a nice reward. As we have a lot of formables already in the game, we have a lot of scripted effects (like scripted triggers, but effects instead) that we already use.

upload_2019-11-15_12-53-32.png

Code:
effect = { # EFFECT FIELD - What will happen when decision is completed
    custom_tooltip = "tier_2_formable_tooltip" # CUSTOM TOOLTIP - Explains what tier formable it is
    change_country_name = "SARDINIA_NAME" # EFFECT - Change country name
    tribal_formable_government_change_effect = yes # SCRIPTED EFFECT - If they are tribal and not a tribal federation, they will become one
    hidden_effect = { # EFFECT - Everything inside this clause will become hidden
        change_country_adjective = "SARDINIA_ADJECTIVE" # EFFECT - Change adjective
        change_country_tag = SAR # EFFECT - Change tag
        change_country_color = sardinia_color # EFFECT - Change country color
        change_country_flag = SARDINIA_FLAG # EFFECT - Change country flag
    } # END OF HIDDEN EFFECT
    capital_scope = { # EVENT TARGET - Find capital province of nation
        capital_formable_tribal_effect = yes # SCRIPTED EFFECT - Add 4 tribesmen to capital
        formable_capital_modifier_tribal_effect = yes # SCRIPTED EFFECT - Province modifier to capital
    } # END OF CAPITAL PROVINCE SCOPE
    add_3_free_province_investments = yes # SCRIPTED EFFECT - Add 3 free province investments
}

This is a bit of a mouthful, so we will try and make sense of one thing at a time. The top is simple enough, we just add a custom tooltip explaining that it is a tier 2 formable. Note that unlike custom tooltips used in trigger, it is common not to have anything inside effect custom tooltips.

After explaining that this is a tier 2 formable, we change the name of your country from whatever it is to Sardinia. Usually we would have to add an entry to beneath our previous localization entry about Sardinia existing (which we did when we made triggers), but in this particular case the name and adjective for Sardinia have been used before (in a Roman Mission). If we were to add it though, this is what it looks like in the localization:

upload_2019-11-15_12-55-24.png

Code:
SARDINIA_NAME:0 "Sardinia"
SARDINIA_ADJECTIVE:0 "Sardinian"

You notice we have already put in the adjective as well to save us the time, as we are using that further down.

Next we have a scripted effect called ‘tribal_formable_government_change_effect’. If we make a quick search for it, we’ll find out it looks like this:

upload_2019-11-15_12-55-50.png

Code:
tribal_formable_government_change_effect = {
    if = {
        limit = {
            is_tribal = yes
            NOT = { government = tribal_federation }
        }
        change_government = tribal_federation
    }
    else = {
        add_political_influence = 150
    }
}

A simple if/else, changing the government to tribal federation if you are a tribal who isn’t already one, and otherwise giving you political influence. Most of the “tribal formables” (i.e, formables in areas with mostly tribes) have this scripted effect, as it signifies their change from a single tribe to a larger federation of tribes coexisting (i.e. you are not just one Sardinian tribe, but a conglomeration of all the Sardinian tribes).

Moving on to the hidden effect section, we will start by explaining how hidden effects work. It is pretty self-explanatory, everything that is inside that section is not shown to the player, but still done. E.g. the player does not need to know that they are getting a new color, flag and adjective, as they are all things that are not important enough to need their own line, are implied by other effects, or will immediately be noticed (the tag for a country is mostly something that Script works with, and the player does not need to know what it is).

The adjective and tag are pretty straight forward. This will be set as your new tag (the very same we checked for earlier, and added into the Scripted Trigger list), and we have seen how the name and adjective localization looks already.

For the color change, we are going to add a new entry into the file ‘Imperator\game\common\named_colors\default_colors.txt’. This is where we put all the colors that are being used by Script in some way. Personally I have always associated Sardinia with a orange/yellow-ish color, so I make a quick google search for an RGB color chart and find a color that I like.

upload_2019-11-15_12-56-42.png

Code:
dravida_color = rgb { 31 198 35 }
armenia_color = rgb { 172  58  52 }
pontus_color = rgb { 149 101 186  }
bharatavarsha_orange_color = rgb { 232 151 23 }
galatia_light_blue_color = rgb { 23 232 204 }
achaea_color = rgb { 240 0 9 }
argolis_color = rgb { 190 51 190 }
sardinia_color = rgb { 223 180 78 }

Adding a new entry to the list under Argolis (the previous formable made), it looks like this. We simply put in the key we are using in Script, tell the Script we want to use RGB, and then set the numbers given by the color chart.

Moving on to the final part of the hidden effects, we have the flag change. For this, we are going to move into the file ‘game\common\coat_of_arms\coat_of_arms\00_pre_scripted_countries.txt’, the file where we have all specially made flags in the game. Looking for iconography that might fit ancient Sardinia, we find some coins from the era. Three recurring subjects are people’s faces (most areas have these), grain, and horses.So all the way at the bottom of the list in the file, we will make a new entry for our new flag, which will be a horse’s head.

upload_2019-11-15_12-58-22.png

Code:
SARDINIA_FLAG = {
    pattern = "pattern_solid.tga"
    color1 = "sardinia_color"

    colored_emblem = {
        texture = "ce_border_simple_02.tga"
        color1 = "offwhite"
        color2 = "pitch_black"
        instance = {
            rotation = 0
        }
        instance = {
            rotation = 180
        }
    }

    colored_emblem = {
        texture = "ce_horse_03.dds"
        color1 = "offwhite"
        instance = {
            scale = { 0.75 0.75 }
        }
    }
}

Flags are pretty straight forward. At the start you decide what kind of base pattern you want, you can find all of these in the folder ‘Imperator\game\gfx\coat_of_arms\patterns’. Then you add the required colors, grabbing colors from the list we saw earlier. In our case, we are going with one solid color, so we are just going to grab the color we made for Sardinia earlier.

On top of that solid color, we are adding some different colored emblems, these can be found in the folder ‘Imperator\game\gfx\coat_of_arms\colored_emblems’. First we grab a simple border texture, coloring it black and white, and make two instances of them, one for the top and one for the bottom of the flag. Then we grab a horse’s head emblem, and reduce its size slightly so it won’t interfere with the border.

upload_2019-11-15_12-59-5.png


Here’s the end result we are rolling with. I chose a black and white border because the emblem has such a strong black outline, so it comes together nicely. Also, with the yellow/orange background, it emphasizes the nations color, which seems fitting.

Moving back to our effects from earlier, we have these three Scripted Effects left, two of them affecting our capital and one of them affecting our nation.

upload_2019-11-15_12-59-19.png

Code:
capital_scope = { # EVENT TARGET - Find capital province of nation
    capital_formable_tribal_effect = yes # SCRIPTED EFFECT - Add 4 tribesmen to capital
    formable_capital_modifier_tribal_effect = yes # SCRIPTED EFFECT - Province modifier to capital
} # END OF CAPITAL PROVINCE SCOPE
add_3_free_province_investments = yes # SCRIPTED EFFECT - Add 3 free province investments

The first one, ‘capital_formable_tribal_effect’ is pretty straight forward, it simply adds 4 tribesmen pops to our capital city. Similarly, ‘formable_capital_modifier_tribal_effect’, simply adds a province modifier to our capital city that is used for most of our tribal formables.

The last effect adds 3 free province investments to our nation. These are used to get some nice state modifiers, and pretty handy for a player. We occasionally give out these free province investments at the end of decisions, special event chains, and in some missions.

upload_2019-11-15_12-59-58.png


Here we have it all put together, this is what the tooltip now looks like when mousing over the decision.
 
Final Touches
Final Touches


For this particular decision, we will leave the ai_will_do section blank besides the base = 1. All that remains is to make sure that the decision has some localization.

upload_2019-11-15_13-1-35.png

Code:
# Sardinia
formable_not_sardinia_exists:0 "#Y Sardinia#! must NOT exist."
form_sardinia:0 "Form Sardinia"
form_sardinia_desc:0 "The tribes of Sardinia have often been controlled by warlords from the south or east, controlling the most fertile pieces of the island while forcing the locals up in the highlands. Under our rule the people of Sardinia shall fend for themselves without the interference of foreign hostile forces."
SAR:0 "Sardinia"
SAR_ADJ:0 "Sardinian"

For the decision title, we simply use the name of the decision, in this case ‘form_sardinia’. For the description text ,we use the very same name with a ‘_desc’ added to the end of it. In addition to these two, we will add extra loc for the new tag, just in-case it is ever needed for anything, similar to the SARDINIAN_NAME and SARDINIAN_ADJECTIVE that we looked at earlier.

upload_2019-11-15_13-2-11.png


And there we are, a Sardinia tag with a new color and flag. In this case we made a formable nation, but decisions can be used for a lot of things, be it starting event chains (like the Pharos Lighthouse), making specific changes to your nation (religious conversions, or government reform) or really whatever else you can think of that would fit the system.