Need help with conditions

So basically, I am making a spirit that increases army experience, but I want to make it so that the nation needs to control it's colonies in order to be able to gain the experience. How is this done?

There's a few ways this could be done. (I'm just going to go with flat-rate increases, so +0.1 a day, instead of 10% boost)

Option 1:

You can do a lot of if checks on the spirit's modifier, this is very ugly in my opinion, but it will do what you want, and can be done in the tools on the site.

if = {

limit= {

TAG = {

controls_state = STATE_ID

}

}

experience_gain_army = 0.1

}

if = {

limit= {

TAG = {

controls_state = STATE_ID

controls_state = STATE_ID_2

}

}

experience_gain_army = 0.2

}

Option 2:

You can have a different spirit for each level of experience you want, and have the events which swap out the spirit whenever you gain/lose control of a colony. This should also be doable on the site, but you will still have a lot of checks, as you will need to check if the nation has spirit_level_x, if it does then replace/add/remove as needed.

Option 3:

Personally, the one I would go for. Add a variable to the country, which would would increase/decrease when states are taken/lost.

In your national spirit you would have the following as a modifier:

experience_gain_army = army_experience_gain_from_colonies

In this example "army_experience_gain_from_colonies" is the name of the variable we are going to use, you can rename to whatever you like, but just keep to ASCII characters and only use _ for spacing words.


Then you will need to actually add this variable to the country. If the country starts with this national spirit, you will need to add this to the country's history file manually:

set_variable = {

var = army_experience_gain_from_colonies

value = 0

}

(I'm assuming it will start with a bonus of 0, swap 0 for whatever bonus it should start with)

However, if it is added by a focus/event, you can use the above as a reward and not need to edit any files.


And then the last thing that is needed is to add/subtract from the variable when you conquer/lose your colonies. This can be done with:

add_to_variable = {

var = army_experience_gain_from_colonies

value = 0.1

}

subtract_from_variable = {

var = army_experience_gain_from_colonies

value = 0.1

}


You can either use events to fire the above code, e.g. "Australia breaks away from the crown" would give just 1 option for the UK to take which gave the reward:

subtract_from_variable = {

var = army_experience_gain_from_colonies

value = 0.1

}

Or you can delve into some files and have this done behind the scenes by using on_actions. You will need to create a new folder and file for your mod. In common, add a folder called "on_actions" and in that folder create a new file (filename doesn't matter).

Inside that you would have the following: https://pastebin.com/raw/fhyk7vcC (With this if you annex or puppet any country increase the xp gain, and on release reduce - replace TAG with your nation's tag)


There's a few ways this could be done. (I'm just going to go with flat-rate increases, so +0.1 a day, instead of 10% boost)

Option 1:

You can do a lot of if checks on the spirit's modifier, this is very ugly in my opinion, but it will do what you want, and can be done in the tools on the site.

if = {

limit= {

TAG = {

controls_state = STATE_ID

}

}

experience_gain_army = 0.1

}

if = {

limit= {

TAG = {

controls_state = STATE_ID

controls_state = STATE_ID_2

}

}

experience_gain_army = 0.2

}

Option 2:

You can have a different spirit for each level of experience you want, and have the events which swap out the spirit whenever you gain/lose control of a colony. This should also be doable on the site, but you will still have a lot of checks, as you will need to check if the nation has spirit_level_x, if it does then replace/add/remove as needed.

Option 3:

Personally, the one I would go for. Add a variable to the country, which would would increase/decrease when states are taken/lost.

In your national spirit you would have the following as a modifier:

experience_gain_army = army_experience_gain_from_colonies

In this example "army_experience_gain_from_colonies" is the name of the variable we are going to use, you can rename to whatever you like, but just keep to ASCII characters and only use _ for spacing words.


Then you will need to actually add this variable to the country. If the country starts with this national spirit, you will need to add this to the country's history file manually:

set_variable = {

var = army_experience_gain_from_colonies

value = 0

}

(I'm assuming it will start with a bonus of 0, swap 0 for whatever bonus it should start with)

However, if it is added by a focus/event, you can use the above as a reward and not need to edit any files.


And then the last thing that is needed is to add/subtract from the variable when you conquer/lose your colonies. This can be done with:

add_to_variable = {

var = army_experience_gain_from_colonies

value = 0.1

}

subtract_from_variable = {

var = army_experience_gain_from_colonies

value = 0.1

}


You can either use events to fire the above code, e.g. "Australia breaks away from the crown" would give just 1 option for the UK to take which gave the reward:

subtract_from_variable = {

var = army_experience_gain_from_colonies

value = 0.1

}

Or you can delve into some files and have this done behind the scenes by using on_actions. You will need to create a new folder and file for your mod. In common, add a folder called "on_actions" and in that folder create a new file (filename doesn't matter).

Inside that you would have the following: https://pastebin.com/raw/fhyk7vcC (With this if you annex or puppet any country increase the xp gain, and on release reduce - replace TAG with your nation's tag)


-jordsta95

 thanks thats exactly what i needed