Crusader Kings III

Crusader Kings III

Lifestyle XP from Skills patch
Dradka 20 Oct, 2023 @ 10:04pm
Additional Lifestyle support
Using nested if statements along with else_if statements when only 1 condition can be true will help drastically cut down on the number or if statements being processed every time the code is fired.

if = {
limit = { has_trait = education_diplomacy}
if = {
limit = { has_trait = education_diplomacy_1 }
add = 0.1
}
else_if = {
limit = { has_trait = education_diplomacy_2 }
add = 0.2
}
else_if = {
limit = { has_trait = education_diplomacy_3 }
add = 0.3
}
else_if = {
limit = { has_trait = education_diplomacy_4 }
add = 0.4
}
else = {
add = 0.5
}
}
else_if = {
limit = { has_trait = education_intrigue_5 }
add = 0.25
}

Like in the case here if the character doesn't have any level of diplomacy education it will completely bypass checking each and every single one of those diplomacy education traits. Then in the case of if the character were to have one it would process each statement until the first true condition. With the fact that the code is also already looking for the diplomacy education trait should they have 5 star diplomacy there isn't a problem with not having a conditional check for that trait as as it would first have to trigger true with having a diplomacy trait and false each level.