A lot of updating, making republics work

This commit is contained in:
Thakia 2026-11-24 16:18:56 -03:00
parent 09fb57c091
commit 4d6f569e96
99 changed files with 9792 additions and 9342 deletions

View file

@ -21,6 +21,7 @@
# flag:faction_demand
# flag:swear_fealty
# flag:stepped_down
# flag:term_end
# flag:appointment
# flag:appointment_succession
# flag:migration
@ -61,6 +62,7 @@ on_title_destroyed = {
if = {
limit = {
is_ruler = yes
government_has_mechanic = administrative
top_liege = this
administrative_counts_can_be_independent = no
@ -88,6 +90,19 @@ on_title_destroyed = {
target = scope:landed_title
}
}
# Adjust the size of the merchants tally.
else_if = {
limit = {
# Pre-filter out anything higher or lower.
scope:landed_title = { tier = tier_county }
has_global_variable_list = merchants_tally
}
# We don't need to check the list twice, since if they're not in it then removing them from it won't do anything.
remove_list_global_variable = {
name = merchants_tally
target = scope:landed_title
}
}
# Empire Faith Gate: remove holder from empire-holders list when they lose their last empire.
else_if = {
limit = {
@ -232,6 +247,20 @@ on_title_destroyed = {
}
}
if = {
limit = { scope:landed_title = { is_noble_family_title = yes } }
hanseatic_sync_family_head_benefits_effect = { CHARACTER = root }
}
if = {
limit = {
scope:landed_title = {
tier = tier_county
is_noble_family_title = no
}
}
hanseatic_sync_county_benefits_effect = { COUNTY = scope:landed_title }
}
#########
# PAM #
#########
@ -249,6 +278,76 @@ on_title_destroyed = {
}
}
# A realm ruler's term has ended and the ruler for the next term has been decided (e.g. a republican election at term end)
# Fired from code later the same day. If the realm changed hands, on_title_gain has already fired with scope:transfer_type = flag:term_end
# root = the realm ruler for the next term
# scope:title = the primary title of the realm
# scope:previous_holder = the ruler whose term ended
# scope:new_holder = the realm ruler for the next term. Same as scope:previous_holder if they kept the realm (e.g. were re-elected)
# Does *not* provide scope:transfer_type
on_term_ended = {
on_actions = { on_term_ended_events }
effect = {
if = {
limit = { scope:previous_holder = scope:new_holder }
every_player = {
limit = {
OR = {
this = root
is_vassal_or_below_of = root
}
}
if = {
limit = { this = root }
send_interface_toast = {
type = event_toast_effect_good
title = term_ended_reelected_toast_self
left_icon = scope:title
custom_tooltip = term_ended_reelected_toast_self.desc
}
}
else = {
send_interface_toast = {
type = event_toast_effect_neutral
title = term_ended_reelected_toast
left_icon = scope:new_holder
right_icon = scope:title
custom_tooltip = term_ended_reelected_toast.desc
}
}
}
}
}
}
on_term_ended_events = {
effect = {
if = {
limit = { scope:previous_holder = scope:new_holder }
# Re-elected (root)
scope:title ?= {
every_full_assembly_member = {
limit = {
is_ai = no
}
trigger_event = republic_event.0051
}
}
}
else = {
# Elected (root = winner)
scope:title ?= {
every_full_assembly_member = {
limit = {
is_ai = no
}
trigger_event = republic_event.0050
}
}
}
}
}
# A title is transferred to a new character
# root = the new holder
# scope:title = the title that changes hands
@ -310,19 +409,44 @@ on_title_gain = {
if = {
limit = { clerical_elector_title ?= scope:title }
pam_strip_illegal_cardinalate_effect = yes
if = {
limit = { clerical_elector_title ?= scope:title }
add_character_flag = cardinal_flag
situation:the_christian_church ?= {
add_manual_participant = prev
}
}
# Also catches a sitting Head of Faith who is handed a cardinalate
pam_vacate_head_of_faith_cardinalate_effect = yes
}
# A cardinal handed the Church seat must vacate the cardinalate
else_if = {
limit = {
scope:title = {
OR = {
is_head_of_faith = yes
this = title:k_papal_state
}
}
}
pam_vacate_head_of_faith_cardinalate_effect = yes
}
if = {
limit = {
exists = clerical_elector_title
scope:title = clerical_elector_title
}
add_character_flag = cardinal_flag
situation:the_christian_church ?= {
add_manual_participant = prev
}
}
# Unconditional: also catches a sitting Head of Faith who is handed a cardinalate
pam_vacate_head_of_faith_cardinalate_effect = yes
limit = {
scope:transfer_type = flag:election
government_has_flag = government_is_republic
}
scope:title = {
every_full_assembly_member = {
if = {
limit = {
has_character_modifier = gdp_popular_mandate_modifier
}
remove_character_modifier = gdp_popular_mandate_modifier
}
}
}
}
if = {
limit = {
scope:transfer_type = flag:election
@ -402,10 +526,19 @@ on_title_gain = {
add_realm_law_skip_effects = theocratic_elective_succession_law
}
}
if = {
limit = {
scope:title = { is_head_of_faith = yes }
should_use_theocratic_elective_succession_law_trigger = yes
NOT = { has_realm_law = theocratic_elective_succession_law }
}
add_realm_law_skip_effects = theocratic_elective_succession_law
}
# Move a county+ Realm Priest Puppet to Clerical Ruler while the puppeteer slot is still free
if = {
limit = {
is_clergy = yes
government_has_flag = government_is_theocracy
scope:title.tier >= tier_county
highest_held_title_tier = scope:title.tier
exists = puppeteer
@ -416,27 +549,32 @@ on_title_gain = {
scope:previous_holder ?= {
if = {
limit = {
NOT = { exists = clerical_elector_title }
is_alive = yes
}
remove_character_flag = cardinal_flag
}
if = {
limit = {
is_alive = yes
OR = {
scope:title = { has_clerical_region = yes }
root.clerical_elector_title ?= scope:title
}
NOR = {
exists = clerical_elector_title
any_held_title = { has_clerical_region = yes }
if = {
limit = {
NOT = {
exists = clerical_elector_title
}
}
remove_character_flag = cardinal_flag
}
situation:the_christian_church ?= {
if = {
limit = { is_manual_participant = prev }
remove_manual_participant = prev
if = {
limit = {
OR = {
scope:title = { has_clerical_region = yes }
root.clerical_elector_title ?= scope:title
}
NOR = {
exists = clerical_elector_title
any_held_title = { has_clerical_region = yes }
}
}
situation:the_christian_church ?= {
if = {
limit = { is_manual_participant = prev }
remove_manual_participant = prev
}
}
}
}
@ -488,7 +626,6 @@ on_title_gain = {
KIND = flag:archbishop
}
}
# PAM - a Christian prelate takes a landed title outside the clerical regions
pam_the_christian_church_clergy_gained_landed_title_catalyst_effect = yes
#if = {
@ -1092,6 +1229,7 @@ on_title_gain = {
if = {
limit = {
scope:title = { is_landless_type_title = no }
highest_held_title_tier >= tier_duchy
any_held_title = {
title_tier = duchy
has_variable = adventurer_creation_reason
@ -1152,6 +1290,16 @@ on_title_gain = {
change_government = top_liege.government_type
}
}
if = {
limit = {
is_landed = no
exists = scope:title.title_domicile
location != default_location
should_in_default_location_trigger = yes
}
set_location_to_default = yes
}
}
#####################
# DUCHY-TIER TITLES #
@ -1191,53 +1339,41 @@ on_title_gain = {
}
# Transfer title-bound artifacts with the title it's associated with (This is present in two places in this on_action)
if = {
limit = {
scope:previous_holder ?= {
any_character_artifact = {
has_variable = artifact_succession_title #Is this an artifact that should follow a title?
var:artifact_succession_title = { is_title_created = yes } #Does the title the artifact should follow exist?
var:artifact_succession_title = scope:title #Scope title is the artifact title
scope:previous_holder ?= {
every_character_artifact = {
limit = {
var:artifact_succession_title ?= scope:title
scope:title = { is_title_created = yes }
}
if = {
limit = {
OR = {
scope:transfer_type = flag:conquest
scope:transfer_type = flag:conquest_holy_war
scope:transfer_type = flag:conquest_claim
scope:transfer_type = flag:conquest_populist
scope:transfer_type = flag:abdication
scope:transfer_type = flag:usurped
scope:transfer_type = flag:revoked
scope:transfer_type = flag:faction_demand
}
}
set_owner = {
target = root
history = {
type = conquest
actor = scope:previous_holder
recipient = root
location = scope:previous_holder.location
}
}
}
}
scope:previous_holder = {
every_character_artifact = {
limit = {
has_variable = artifact_succession_title #Is this an artifact that should follow a title?
var:artifact_succession_title = { is_title_created = yes } #Does the title the artifact should follow exist?
var:artifact_succession_title = scope:title #Scope title is the artifact title
}
if = {
limit = {
OR = {
scope:transfer_type = flag:conquest
scope:transfer_type = flag:conquest_holy_war
scope:transfer_type = flag:conquest_claim
scope:transfer_type = flag:conquest_populist
scope:transfer_type = flag:abdication
scope:transfer_type = flag:usurped
scope:transfer_type = flag:revoked
scope:transfer_type = flag:faction_demand
}
}
set_owner = {
target = root
history = {
type = conquest
actor = scope:previous_holder
recipient = root
location = scope:previous_holder.location
}
}
}
else = {
set_owner = {
target = root
history = {
type = inherited
recipient = root
}
else = {
set_owner = {
target = root
history = {
type = inherited
recipient = root
}
}
}
@ -1416,7 +1552,10 @@ on_title_gain = {
#####################
# KING+ TIER TITLES #
#####################
else = {
else_if = {
limit = {
scope:title.tier >= tier_kingdom
}
# Newly formed Hegemon of China should spruce up their council
# if = {
# limit = {
@ -1448,7 +1587,7 @@ on_title_gain = {
limit = {
OR = {
exists = scope:title.var:ceremonial_title
top_liege.primary_title.var:administrative_ui_special_title ?= scope:title
ceremonial_liege_title ?= scope:title
}
}
if = {
@ -1513,53 +1652,41 @@ on_title_gain = {
}
}
# Transfer title-bound artifacts with the title it's associated with (This is present in two places in this on_action)
if = {
limit = {
scope:previous_holder ?= {
any_character_artifact = {
has_variable = artifact_succession_title #Is this an artifact that should follow a title?
var:artifact_succession_title = { is_title_created = yes } #Does the title the artifact should follow exist?
var:artifact_succession_title = scope:title #Scope title is the artifact title
scope:previous_holder ?= {
every_character_artifact = {
limit = {
var:artifact_succession_title ?= scope:title
scope:title = { is_title_created = yes }
}
if = {
limit = {
OR = {
scope:transfer_type = flag:conquest
scope:transfer_type = flag:conquest_holy_war
scope:transfer_type = flag:conquest_claim
scope:transfer_type = flag:conquest_populist
scope:transfer_type = flag:abdication
scope:transfer_type = flag:usurped
scope:transfer_type = flag:revoked
scope:transfer_type = flag:faction_demand
}
}
set_owner = {
target = root
history = {
type = conquest
actor = scope:previous_holder
recipient = root
location = scope:previous_holder.location
}
}
}
}
scope:previous_holder = {
every_character_artifact = {
limit = {
has_variable = artifact_succession_title #Is this an artifact that should follow a title?
var:artifact_succession_title = { is_title_created = yes } #Does the title the artifact should follow exist?
var:artifact_succession_title = scope:title #Scope title is the artifact title
}
if = {
limit = {
OR = {
scope:transfer_type = flag:conquest
scope:transfer_type = flag:conquest_holy_war
scope:transfer_type = flag:conquest_claim
scope:transfer_type = flag:conquest_populist
scope:transfer_type = flag:abdication
scope:transfer_type = flag:usurped
scope:transfer_type = flag:revoked
scope:transfer_type = flag:faction_demand
}
}
set_owner = {
target = root
history = {
type = conquest
actor = scope:previous_holder
recipient = root
location = scope:previous_holder.location
}
}
}
else = {
set_owner = {
target = root
history = {
type = inherited
recipient = root
}
else = {
set_owner = {
target = root
history = {
type = inherited
recipient = root
}
}
}
@ -2033,14 +2160,14 @@ on_title_gain = {
remove_character_flag = ceremonial_liege_flag
remove_character_flag = ceremonial_regent_flag
}
top_liege.primary_title.var:administrative_ui_special_title.holder ?= {
ceremonial_liege ?= {
remove_character_flag = ceremonial_liege_flag
remove_character_flag = ceremonial_regent_flag
}
if = {
limit = { tgp_is_ceremonial_regent_trigger = yes } # Not 'actual' ruler
add_character_flag = ceremonial_regent_flag
top_liege.primary_title.var:administrative_ui_special_title.holder ?= { add_character_flag = ceremonial_liege_flag }
ceremonial_liege ?= { add_character_flag = ceremonial_liege_flag }
}
}
# West Francia becomes France when no longer controlled by a Karling
@ -2380,6 +2507,7 @@ on_title_gain = {
is_house_head = no
NOT = { exists = confederation }
exists = house.house_head.confederation
house.house_head.confederation = { is_house_based = no }
liege = house.house_head.liege
is_at_war = no
}
@ -2391,6 +2519,7 @@ on_title_gain = {
limit = {
government_is_japanese_trigger = yes
is_house_head = yes
scope:title = primary_title
}
trigger_event = {
weeks = { 2 4 }
@ -2456,6 +2585,11 @@ on_title_gain = {
if = {
limit = {
government_allows = noble_families
NOT = { scope:title.tier = tier_barony }
trigger_if = {
limit = { government_has_mechanic = administrative }
scope:title.tier >= min_appointment_tier
}
}
government_type = { save_scope_as = nf_gov_type }
# Note: anything that should be run after creation can go in on_noble_family_title_created
@ -2559,13 +2693,24 @@ on_title_gain = {
}
every_vassal_or_below = {
limit = {
is_playable_character = yes
OR = {
highest_held_title_tier >= main_administrative_tier # All governors
liege = root
exists = root.house
}
#normal triggering
every_vassal_or_below = {
limit = {
is_playable_character = yes
exists = scope:previous_holder
government_has_mechanic = administrative
OR = {
highest_held_title_tier >= main_administrative_tier # All governors
liege = root
}
}
trigger_event = {
id = ep3_governor_yearly.3060
days = 1
}
}
trigger_event = ep3_governor_yearly.3060
}
}
}
@ -2769,41 +2914,22 @@ on_title_gain = {
}
# Did I conquer a place with holy order leases not of my faith?
if = {
limit = {
scope:title = {
any_in_de_jure_hierarchy = {
tier = tier_barony
is_under_holy_order_lease = yes
county.holder = {
any_liege_or_above = { this = root }
}
lessee = {
NAND = { # Only for leases of people who are not of your faith or the holder's faith
faith = root.faith
faith = prev.county.holder.faith
}
scope:title = {
every_in_de_jure_hierarchy = {
limit = {
tier = tier_barony
is_under_holy_order_lease = yes
county.holder = {
any_liege_or_above = { this = root }
}
lessee = {
NAND = { # Only for leases of people who are not of your faith or the holder's faith
faith = root.faith
faith = prev.county.holder.faith
}
}
}
}
scope:title = {
every_in_de_jure_hierarchy = {
limit = {
tier = tier_barony
is_under_holy_order_lease = yes
county.holder = {
any_liege_or_above = { this = root }
}
lessee = {
NAND = { # Only for leases of people who are not of your faith or the holder's faith
faith = root.faith
faith = prev.county.holder.faith
}
}
}
revoke_lease = yes
}
revoke_lease = yes
}
}
@ -2894,7 +3020,12 @@ on_title_gain = {
}
# Natural Disaster Recovery project invalidation
great_projects_ensure_unique_disaster_recovery_projects_effect = yes
if = {
limit = {
this = top_liege
}
great_projects_ensure_unique_disaster_recovery_projects_effect = yes
}
###########
# Nomads/Tribals leaving confederacies
@ -2904,6 +3035,7 @@ on_title_gain = {
is_confederation_member = yes
scope:title.tier >= tier_kingdom
government_is_japanese_trigger = no
confederation ?= { is_title_based = no }
}
confederation = {
remove_confederation_member = root
@ -2985,6 +3117,7 @@ on_title_gain = {
is_ruler = no
highest_held_title_tier <= scope:title.tier
government_has_flag = government_is_landless_adventurer
government_has_flag = government_is_merchant
government_has_mechanic = administrative
}
}
@ -3289,13 +3422,7 @@ on_title_gain = {
every_courtier = {
limit = {
location != root.capital_province
is_imprisoned = no
is_travelling = no
is_commanding_army = no
NOR = {
exists = involved_activity
exists = knight_army
}
should_in_default_location_trigger = yes
}
set_location_to_default = yes
}
@ -3307,13 +3434,7 @@ on_title_gain = {
every_courtier = {
limit = {
location != root.domicile.domicile_location
is_imprisoned = no
is_travelling = no
is_commanding_army = no
NOR = {
exists = involved_activity
exists = knight_army
}
should_in_default_location_trigger = yes
}
set_location_to_default = yes
}
@ -3769,6 +3890,10 @@ on_title_lost = {
gdp_league_focus_on_title_lost
}
on_actions = {
gdp_league_focus_on_title_lost
}
effect = {
################ N3OW Dynamic Titles ##################
@ -4201,13 +4326,7 @@ on_title_lost = {
owner = {
if = {
limit = {
is_alive = yes
is_imprisoned = no
is_travelling = no
NOT = {
exists = involved_activity
}
is_commanding_army = no
should_in_default_location_trigger = yes
}
set_location_to_default = yes
}
@ -4457,13 +4576,7 @@ on_title_lost = {
every_courtier = {
limit = {
location != root.capital_province
is_imprisoned = no
is_travelling = no
is_commanding_army = no
NOR = {
exists = involved_activity
exists = knight_army
}
should_in_default_location_trigger = yes
}
set_location_to_default = yes
}
@ -4476,13 +4589,7 @@ on_title_lost = {
every_courtier = {
limit = {
location != root.domicile.domicile_location
is_imprisoned = no
is_travelling = no
is_commanding_army = no
NOR = {
exists = involved_activity
exists = knight_army
}
should_in_default_location_trigger = yes
}
set_location_to_default = yes
}
@ -4504,6 +4611,16 @@ on_title_lost = {
# Move or destroy estates without a liege
if = {
limit = {
trigger_if = {
limit = {
government_has_flag = government_is_republic
liege != root
}
# ...only do this if your liege is not ~also~ a republic, else vassal republics may fall into this
NOT = {
has_same_government = liege
}
}
# Has an NF title
any_held_title = {
NOT = { this = scope:title }
@ -4518,6 +4635,10 @@ on_title_lost = {
}
if = {
limit = {
NOR = {
government_has_flag = government_is_republic
government_has_flag = government_is_merchant
}
OR = {
exists = scope:new_holder.var:laamp_invasion_flag
trigger_if = {
@ -4597,8 +4718,7 @@ on_title_lost = {
limit = {
is_house_head = no
# Has an NF title
exists = house
house.house_head = {
house.house_head ?= {
any_held_title = { is_noble_family_title = yes }
}
# Only remaining title is NF title
@ -5226,7 +5346,10 @@ on_vassal_gained = {
limit = {
scope:vassal = {
is_confederation_member = yes
scope:vassal.confederation = { has_leading_house = no }
scope:vassal.confederation ?= {
has_leading_house = no
is_title_based = no
}
}
}
scope:vassal.confederation = {
@ -5315,6 +5438,28 @@ on_vassal_gained = {
}
}
}
### If a republic family becomes independent or part of a non-republic...
if = {
limit = {
scope:vassal = {
government_has_flag = government_is_republic
is_landed = no
any_held_title = { is_noble_family_title = yes }
}
NOT = { government_has_flag = government_is_republic }
}
# Create Merchant - this will trigger on_vassal_change and make them a Merchant
scope:vassal = {
create_title_and_vassal_change = {
type = conquest
save_scope_as = change
add_claim_on_loss = no
}
becomes_independent = { change = scope:change }
resolve_title_and_vassal_change = scope:change
}
}
}
}
@ -5329,14 +5474,11 @@ on_vassal_change = {
### If a admin duke-tier character becomes the top-liege's direct vassal, ensure that they have a noble family title
if = {
limit = {
# This trigger is intentionally different from the similar effect in on_title_gain up above. We want all direct vassals of the top liege to have a family title if they can
government_has_mechanic = administrative
government_allows = noble_families
is_house_head = yes
trigger_if = {
# This trigger is intentionally different from the similar effect in on_title_gain up above. We want all direct vassals of the top liege to have a family title if they can
limit = { government_has_flag = government_has_county_tier_noble_families }
highest_held_title_tier >= tier_county
}
trigger_else = { highest_held_title_tier >= tier_duchy }
highest_held_title_tier >= min_appointment_tier
liege = {
top_liege = this
government_allows = noble_families
@ -5355,19 +5497,13 @@ on_vassal_change = {
}
### If an admin ruler becomes independent...
if = {
limit = {
government_has_mechanic = administrative
}
limit = { government_has_mechanic = administrative }
if = {
limit = {
liege = root # I.e. root is independent
}
limit = { liege = root } # I.e. root is independent
if = {
limit = {
is_landed = no
any_held_title = {
is_noble_family_title = yes
}
any_held_title = { is_noble_family_title = yes }
}
if = {
limit = {
@ -5403,19 +5539,19 @@ on_vassal_change = {
limit = {
government_allows = noble_families
NOT = {
exists = house.noble_family
any_held_title = { is_noble_family_title = yes }
}
}
create_noble_family_effect = { GOVERNMENT_GIVER = this }
domicile ?= { set_up_domicile_estate_effect = yes }
}
}
# Byz admin landless NF should always be direct vassal of top liege
# Admin landless NF should always be direct vassal of top liege
else_if = {
limit = {
government_has_flag = government_is_administrative
government_allows = noble_families
liege != top_liege
primary_title = {
primary_title ?= {
is_noble_family_title = yes
}
is_landed = no
@ -5602,6 +5738,7 @@ on_vassal_change = {
liege != root
primary_title ?= {
has_custom_title_name = yes
is_landless_type_title = no
}
}
primary_title = {
@ -5825,7 +5962,6 @@ on_realm_capital_change = {
domicile ?= {
move_domicile = scope:capital_province
}
# don't move them in such cases
if = {
limit = {
is_landed = no