Code:
namespace = cit_trade
##################################################################
# state_improvement
##################################################################
cit_trade.1 = {
type = province_event
hidden = yes
trigger = {
is_state_capital = yes
num_of_citizen > 0
}
immediate = {
set_variable = {
name = cit_in_state
value = 0
}
state = {
ordered_state_province = {
limit = { num_of_citizen > 0 }
order_by = num_of_citizen
ordered_pops_in_province = {
limit = { pop_type = citizen }
order_by = pop_happiness
change_variable = {
name = cit_in_state
add = 1
}
}
}
}
trigger_event = {
id = cit_trade.2
}
}
}
cit_trade.2 = { #Citizen Trade bonus
type = province_event
hidden = yes
trigger = {
is_state_capital = yes
cit_in_state >= 20
}
immediate = {
if = {
limit = {
cit_in_state >= 20
cit_in_state < 40
}
state = {
add_state_modifier = {
name = cit_trade_1
duration = duration = 366
mode = add
}
}
}
else_if = {
limit = {
cit_in_state >= 40
cit_in_state < 60
}
state = {
add_state_modifier = {
name = cit_trade_2
duration = duration = 366
mode = add
}
}
}
else_if = {
limit = {
cit_in_state >= 60
cit_in_state < 80
}
state = {
add_state_modifier = {
name = cit_trade_3
duration = duration = 366
mode = add
}
}
}
else = {
limit = { }
}
}
}
Ok, I think I might have something that would work, but it's hard to be sure.
I defined 3 state modifiers here, but you may have to make much more.
Code:
cit__trade_1 = {
local_state_trade_routes = 1
}
cit__trade_2 = {
local_state_trade_routes = 2
}
cit__trade_3 = {
local_state_trade_routes = 3
}
Then I put the first event in the yearly pulse.
Code:
yearly_province_pulse = {
random_events = {
25 = 0
75 = slave_revolts.1
}
events = {
cit_trade.1
}
}
Now how this is supposed to work is that the first event fires for every state capital, which then goes to the state scope, and systematically goes through provinces, and systematically goes through pops in each province adding a point to the variable defined in the first event. Then the second event fires as a result of the first event, and it checks to see if the variable which should equal the number of citizens in the state and should be saved in the state capital, is greater than 20, then there's an If, else_if, else progression to see which tier of citizen number the state has and give the correct state modifier accordingly.
There's so much that can go wrong here, but this is my best attempt.
I also tried to cut corners a bit, so that it doesn't fire when it's unnceccessary, like I assumed if there's no citizen in the state capital, that there are no citizens in the state.