Skip to content

Commit

Permalink
population optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
DudeChris33 committed Mar 16, 2024
1 parent 7741bba commit b677d4b
Show file tree
Hide file tree
Showing 5 changed files with 967 additions and 742 deletions.
13 changes: 13 additions & 0 deletions common/on_actions/01_pop_on_actions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#When adding effects directly in on_actions always consider if it would be best to do so through a scripted effect. on_actions with a lot of script in them are harder to get an overview of.

This comment has been minimized.

Copy link
@billiamwill

billiamwill Mar 16, 2024

Collaborator

Let's put it in common/on_actions/00_pop_on_actions.txt

on_yearly_pulse is already defined there, creating it twice might cause a conflict

This comment has been minimized.

Copy link
@DudeChris33

DudeChris33 Mar 16, 2024

Author Collaborator

it wont. 1.36 made on_actions additive

This comment has been minimized.

Copy link
@billiamwill

billiamwill Mar 17, 2024

Collaborator

ok. Still no reason to create an entirely new file just for that imho


# country random events
on_yearly_pulse = {
events = {
migrations.101
migrations.102
population_grow.101
population_grow.104
population_upgrade.101
population_upgrade.104
}
}
107 changes: 79 additions & 28 deletions events/migrations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,59 @@ namespace = migrations
# MIGRATIONS, what keeps the world moving
########################################################################################

province_event = {
id = migrations.1
country_event = {
id = migrations.101
title = "migrations.1.t"
desc = "migrations.1.d"
picture = peasant_woman
hidden = yes

is_triggered_only = yes

trigger = {
base_manpower = 2 # does not let the last rural pop to leave, obviously
has_global_flag = popgrowth_running # to only affect if the popgrowth mechanic is active
NOT = { check_variable = { PG_trb_grow = 100 } } # negative growth, anything under 1.00 (100%)
NOT = { has_province_modifier = rural_pause } # condition that initial values are kept for 100 years

}

option = {
name = "migrations.1.1"

every_owned_province = {
limit = {
base_manpower = 2 # does not let the last rural pop to leave, obviously
NOT = { check_variable = { PG_trb_grow = 100 } } # negative growth, anything under 1.00 (100%)
NOT = { has_province_modifier = rural_pause } # condition that initial values are kept for 100 years
}
random_list = {
19 = {
# Reasons to leave. Devastation will NOT appear here, since it already influences growth.
modifier = { factor = 5.0 check_variable = { PG_com_grow = 110 } } # not if there's work in the city, same province
modifier = { factor = 0.65 check_variable = { PG_trb_grow = 60 } NOT = { check_variable = { PG_trb_grow = 80 } } }
modifier = { factor = 0.40 check_variable = { PG_trb_grow = 50 } NOT = { check_variable = { PG_trb_grow = 60 } } }
modifier = { factor = 0.25 check_variable = { PG_trb_grow = 40 } NOT = { check_variable = { PG_trb_grow = 50 } } }
modifier = { factor = 0.05 NOT = { check_variable = { PG_trb_grow = 40 } } } # they must be really miserable...
}
1 = {
province_event = { id = migrations.1 }
}
}
}
}
}

mean_time_to_happen = {
months = 240 # twenty years to move for a stabilized population, will be affected by modifiers
province_event = {
id = migrations.1
title = "migrations.1.t"
desc = "migrations.1.d"
picture = peasant_woman
hidden = yes

# Reasons to leave. Devastation will NOT appear here, since it already influences growth.
modifier = { factor = 5.0 check_variable = { PG_com_grow = 110 } } # not if there's work in the city, same province
modifier = { factor = 0.65 check_variable = { PG_trb_grow = 60 } NOT = { check_variable = { PG_trb_grow = 80 } } }
modifier = { factor = 0.40 check_variable = { PG_trb_grow = 50 } NOT = { check_variable = { PG_trb_grow = 60 } } }
modifier = { factor = 0.25 check_variable = { PG_trb_grow = 40 } NOT = { check_variable = { PG_trb_grow = 50 } } }
modifier = { factor = 0.05 NOT = { check_variable = { PG_trb_grow = 40 } } } # they must be really miserable...
is_triggered_only = yes

trigger = {
base_manpower = 2 # does not let the last rural pop to leave, obviously
has_global_flag = popgrowth_running # to only affect if the popgrowth mechanic is active
NOT = { check_variable = { PG_trb_grow = 100 } } # negative growth, anything under 1.00 (100%)
NOT = { has_province_modifier = rural_pause } # condition that initial values are kept for 100 years

This comment was marked as resolved.

Copy link
@billiamwill

billiamwill Mar 16, 2024

Collaborator

Let's empty this trigger, all of this is already known to be true from the event being called by migrations.101

}

immediate = {
Expand Down Expand Up @@ -115,33 +142,57 @@ province_event = {

}

country_event = { # 1st Country Event: tribal population want to leave. The country decides at a regional level
id = migrations.2
country_event = {
id = migrations.102
title = "migrations.2.t"
desc = "migrations.2.d"
picture = peasant_woman
#hidden = no
# hidden = yes

is_triggered_only = yes

trigger = {
has_global_flag = popgrowth_running # Only if popgrowth running
any_owned_province = {
has_province_flag = PG_trib_migr_start

}

}

mean_time_to_happen = {
months = 48 # remember, this is a country event. Won't fire that much anyway
modifier = {
factor = 0.65
calc_true_if = { any_owned_province = { base_manpower = 2 has_province_flag = PG_trib_migr_start } amount = 5 }
}
modifier = {
factor = 0.65 # added to the prior one
calc_true_if = { any_owned_province = { base_manpower = 2 has_province_flag = PG_trib_migr_start } amount = 10 }
option = {
name = "migrations.2.1"

random_list = {
3 = {
modifier = {
factor = 0.65
calc_true_if = { any_owned_province = { base_manpower = 2 has_province_flag = PG_trib_migr_start } amount = 5 }
}
modifier = {
factor = 0.65 # added to the prior one
calc_true_if = { any_owned_province = { base_manpower = 2 has_province_flag = PG_trib_migr_start } amount = 10 }
}
}
1 = {
country_event = { id = migrations.2 }
}
}
}
}

country_event = { # 1st Country Event: tribal population want to leave. The country decides at a regional level
id = migrations.2
title = "migrations.2.t"
desc = "migrations.2.d"
picture = peasant_woman
#hidden = no

is_triggered_only = yes

trigger = {
has_global_flag = popgrowth_running # Only if popgrowth running
any_owned_province = {
has_province_flag = PG_trib_migr_start
}

This comment has been minimized.

Copy link
@billiamwill

billiamwill Mar 16, 2024

Collaborator

Same, we can empty this trigger

}

immediate = {
Expand Down
25 changes: 6 additions & 19 deletions events/population_capacity.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace = population_capacity
########################################################################################
# population_capacity.X is empty. It will contain the "simplified" pop capacity calculation, for horde countries once it is back to the mod.


country_event = { # BI-YEARLY EVENT, UPDATES ESSENTIAL POPGROWTH VALUES
id = population_capacity.1
title = "population_capacity.1.t"
Expand All @@ -15,12 +16,13 @@ country_event = { # BI-YEARLY EVENT, UPDATES ESSENTIAL POPGROWTH VALUES
is_triggered_only = yes # Happens ALWAYS, either having Popgrowth turned or on off. It does many other things

trigger = { # Changed: affects only the human player. This trigger forces this
ai = no
# ai = no
}

immediate = {
hidden_effect = {
every_province = { # careful, now it's every province
# every_province = { # careful, now it's every province
every_owned_province = {
limit = { is_city = yes }
if = {
limit = { has_global_flag = popgrowth_running }
Expand All @@ -33,19 +35,13 @@ country_event = { # BI-YEARLY EVENT, UPDATES ESSENTIAL POPGROWTH VALUES
# Trade limits, update province economic output
DE_update_goods = yes
DE_update_value = yes



}
}


}

option = {
name = "population_capacity.1.a"

}

}

# SUBMOD Menu
Expand Down Expand Up @@ -111,14 +107,9 @@ country_event = {
NOT = { has_global_flag = popgrowth_vanilla }

}

}

}




province_event = { # PROVINCE INTERACTION MENU
id = population_capacity.3
title = "population_capacity.3.t"
Expand Down Expand Up @@ -182,6 +173,7 @@ province_event = { # PROVINCE INTERACTION MENU
}

}

######
# POPULATION CAPACITY, MAIN EVENT
######
Expand Down Expand Up @@ -718,11 +710,8 @@ province_event = {
divide_variable = { PG_trb_grow = 10 } multiply_variable = { PG_trb_grow = 1000 }
divide_variable = { PG_com_grow = 10 } multiply_variable = { PG_com_grow = 1000 }
divide_variable = { PG_upp_grow = 10 } multiply_variable = { PG_upp_grow = 1000 }


}


option = {
name = "population_capacity.4.a"
# ok, all done inside the immediate
Expand All @@ -732,7 +721,6 @@ province_event = {
clr_province_flag = PG_move_all
clr_province_flag = PG_move_upp_com
}

}

##################################################
Expand All @@ -742,7 +730,6 @@ province_event = {
# Most code comments from the main event are gone, but I've added some numerical examples.
##################################################


province_event = {
id = population_capacity.5 # Population capacity v4 (March 2022); detailed view
title = "population_capacity.5.t"
Expand Down
Loading

0 comments on commit b677d4b

Please sign in to comment.