
I don't know if this will help any modders, if there are anyone left.
Introduction: One of the game's "conditions" isn't working as intended, or at least not as the Wiki states. It's the "poor_strata_life_needs" condition, and probably its variants. Let's see what the Wiki says:
>"Returns true if the country's poor strata are getting X% of their life needs, with X being a value between 0 and 1."
Victoria 2 Wiki | List of conditions
I was creating an event in a mod I play for widespread famine in countries where the population couldn't obtain essential goods for life. I put the condition along with the "NOT" operator to check if 50% of the population wasn't receiving their "life needs":
trigger = { NOT = { poor_strata_life_needs = 0.50 } }
Problem: My country was receiving the event, and I was sure that my population had more than 50% of their "life needs" met, even in the colonies. The event, however, seemed to work well for most of the countries I expected wouldn't be able to sustain themselves, but somehow the trigger condition returned as true for me.
The Theory: "What was happening?" I discovered that my country received the event because the condition checked if X% of the "poor strata" was in the "Life Needs" category, and not that it was "getting X% of their life needs".
In the end there are four categories, I will name them as follows:
- (1) Life Needs Partially Fulfilled;
- (2) Life Needs Fully Fulfilled;
- (3) Everyday Needs Fully Fulfilled;
- (4) Luxury Fully Needs Fulfilled.
Explanation: The categories are what you can see in the statistical pie chart in the "Budget" tab. It turns out that most of my "poor strata" was in category (3) "Everyday Needs Fully Fulfilled", over 60%, and only 34% in category (2) "Life Needs Fully Fulfilled", validating the widespread famine event, even though everyone was receiving their life need goods at 100%. To test if the game identified the composition of category (3) "Everyday Needs Fully Fulfilled", I used condition "NOT = { poor_strata_everyday_needs = 0.60 }" to test if the trigger returned as false, and "NOT = { poor_strata_everyday_needs = 0.70 }" to see if the trigger returned as true, and they returned as I intended in this test, respectively.
Category (3) over 60% and Category (2) at 34% only.
Solution: I added the conditions "poor_strata_everyday_needs = 0.01" and "poor_strata_luxury_needs = 0.01" inside a "NOT = { OR = {" (...) operator, in addition to the original condition separately. Now the event no longer triggers for my situation, but continues to trigger normally in others.
Importance: I noticed that all disease events in the game, some unrest events and many others use this condition; if your population is doing very well, you will still receive these unwanted events, hindering your population growth or other things. There are other events with this condition and its variations, and other mods probably use it as well, and it doesn't work in a way that seems to be the code's intention.
NOTE: I tested extensively with several savegames, and the results were consistent with my theory, except for one savegame that was on the last year of the game. I hope someone can test this in their game with the console, to verify that it's not just happening in mine. I'll leave the event code below (I changed the country_modifier to one that exists in vanilla):
#
country_event = {
id = 99999270 # General Famine
title = "Famine in our land!"
desc = "EVTDESC99999270"
picture = starving
major = yes
trigger = {
NOT = { has_country_modifier = potato_blight }
NOT = {
poor_strata_life_needs = 0.50
}
NOT = {
OR = {
poor_strata_everyday_needs = 0.01
poor_strata_luxury_needs = 0.01
}
}
any_owned_province = {
any_pop = {
NOT = { type = soldiers }
strata = poor
NOT = { life_needs = 0.50 }
}
}
}
mean_time_to_happen = {
months = 12
}
option = {
name = "What can I do?!"
add_country_modifier = {
name = potato_blight
duration = 365
}
any_owned = {
limit = {
any_pop = {
NOT = { type = soldiers }
strata = poor
NOT = { life_needs = 0.50 }
}
}
any_pop = {
limit = {
NOT = { life_needs = 0.01 }
}
reduce_pop = 0.01
}
any_pop = {
limit = {
life_needs = 0.01
NOT = { life_needs = 0.05 }
}
reduce_pop = 0.10
}
any_pop = {
limit = {
life_needs = 0.05
NOT = { life_needs = 0.10 }
}
reduce_pop = 0.25
}
any_pop = {
limit = {
life_needs = 0.10
NOT = { life_needs = 0.20 }
}
reduce_pop = 0.50
}
any_pop = {
limit = {
life_needs = 0.20
NOT = { life_needs = 0.30 }
}
reduce_pop = 0.75
}
any_pop = {
limit = {
life_needs = 0.30
NOT = { life_needs = 0.40 }
}
reduce_pop = 0.90
}
any_pop = {
limit = {
life_needs = 0.40
NOT = { life_needs = 0.50 }
}
reduce_pop = 0.99
}
}
any_owned = {
limit = {
NOT = { has_province_modifier = baby_boom }
OR = {
life_rating = 35
is_capital = yes
}
OR = {
terrain = farmlands
trade_goods = grain
trade_goods = fish
trade_goods = fruit
is_capital = yes
}
any_pop = {
NOT = { type = soldiers }
strata = poor
life_needs = 0.50
}
}
add_province_modifier = {
name = baby_boom
duration = 3650
}
}
}
}
#
Minor note: I hope all of you understood, English is not my native language.
Post Scriptum: I don't know if this was already known, but since I couldn't find it anywhere else, I decided to post it.