## Thailand: recurring variable systems. Game-start state lives in the history file. Party ## indices: 1 Democrats, 3 Move Forward, 18 Pheu Thai, 22 NCPO, 23 House of Mahidol. on_actions = { on_weekly_SIA = { effect = { if = { limit = { date > 2016.1.1 has_completed_focus = SIA_fta_decade NOT = { has_completed_focus = SIA_ignite_thailand } NOT = { has_country_flag = SIA_ignite_strategy_forced } } set_country_flag = SIA_ignite_strategy_forced country_event = { id = thailand.432 days = 5 } } # Communist entry gate: 52 consecutive weeks under 35% stability. if = { limit = { has_stability < 0.35 } add_to_variable = { SIA_misery_weeks = 1 } clamp_variable = { var = SIA_misery_weeks min = 0 max = 999 } } else = { set_variable = { SIA_misery_weeks = 0 } } if = { limit = { check_variable = { SIA_misery_weeks > 51 } } if = { limit = { NOT = { has_country_flag = SIA_misery_gate } } set_country_flag = SIA_misery_gate } } else = { if = { limit = { has_country_flag = SIA_misery_gate } clr_country_flag = SIA_misery_gate } } if = { limit = { has_completed_focus = SIA_treaty_ally NOT = { has_completed_focus = SIA_bamboo_bends_east } NOT = { has_country_flag = SIA_treaty_ally_reaction_done } } set_country_flag = SIA_treaty_ally_reaction_done country_event = { id = thailand.217 days = 120 random_days = 60 } } if = { limit = { has_completed_focus = SIA_bamboo_bends_east NOT = { has_completed_focus = SIA_treaty_ally } NOT = { has_country_flag = SIA_bamboo_east_reaction_done } } set_country_flag = SIA_bamboo_east_reaction_done country_event = { id = thailand.218 days = 120 random_days = 60 } } if = { limit = { has_completed_focus = SIA_perpetual_guardianship NOT = { has_country_flag = SIA_guardianship_reaction_done } } set_country_flag = SIA_guardianship_reaction_done country_event = { id = thailand.219 days = 90 random_days = 90 } } # Momentum 100 capitulates at once; the 180-day timeout is thailand.259. if = { limit = { has_country_flag = SIA_strike_active } add_stability = -0.01 if = { limit = { check_variable = { SIA_strike_momentum > 99 } } country_event = { id = thailand.250 days = 1 } # Clear the flag now so the day-180 thailand.259 deadline no-ops. clr_country_flag = SIA_strike_active } } if = { limit = { SIA_ds_conflict_live = yes } SIA_ds_update_tier = yes # Pre-twin-meter saves carry SIA_ds_active with no grievance variable, which would read 0 and # leave the crisis trivially resolvable. if = { limit = { NOT = { has_variable = SIA_ds_grievance } } set_variable = { SIA_ds_grievance = 40 } SIA_ds_recompute_floor = yes } # Left to burn the grievance creeps up and raises the floor; only concessions lower it. if = { limit = { check_variable = { SIA_insurgency_intensity > 59 } } random = { chance = 15 set_temp_variable = { ds_grievance_delta = 1 } SIA_ds_set_grievance = yes } } # Routed through SIA_ds_set_intensity so the tooltip surfaces and the floor holds. if = { limit = { has_completed_focus = SIA_iron_fist_doctrine } random = { chance = 30 set_temp_variable = { ds_delta = 1 } SIA_ds_set_intensity = yes } } else_if = { limit = { has_completed_focus = SIA_peace_dialogue_initiative } random = { chance = 12 set_temp_variable = { ds_delta = 1 } SIA_ds_set_intensity = yes } } else = { random = { chance = 20 set_temp_variable = { ds_delta = 1 } SIA_ds_set_intensity = yes } } if = { limit = { check_variable = { SIA_insurgency_intensity > 59 } } random = { chance = 15 country_event = { id = thailand.151 days = 1 } } } else_if = { limit = { check_variable = { SIA_insurgency_intensity > 29 } } random = { chance = 10 country_event = { id = thailand.151 days = 1 } } } else = { random = { chance = 5 country_event = { id = thailand.151 days = 1 } } } if = { limit = { check_variable = { SIA_insurgency_intensity > 59 } NOT = { has_country_flag = SIA_ds_crisis_fired } } set_country_flag = SIA_ds_crisis_fired country_event = { id = thailand.155 days = 3 } } if = { limit = { check_variable = { SIA_insurgency_intensity < 11 } date > 2010.1.1 NOT = { has_country_flag = SIA_ds_quiet_fired } } set_country_flag = SIA_ds_quiet_fired country_event = { id = thailand.156 days = 3 } } } # Outside the SIA_ds_active block on purpose: cleanup clears that flag, and this is the # standing cost of a force-resolved peace. if = { limit = { has_idea = SIA_pacified_but_smoldering } random = { chance = 2 country_event = { id = thailand.151 days = 1 } } } # Capped so the drift cannot snowball the palace into a permanent supermajority. if = { limit = { has_completed_focus = SIA_yellow_shirts check_variable = { party_pop_array^23 < 0.35 } } set_temp_variable = { party_index = 23 } set_temp_variable = { party_popularity_increase = 0.005 } change_relative_party_popularity = yes recalculate_party = yes } # See SIA_political_drift_update. Skipped on the communist path and after a republic. if = { limit = { date > 2002.1.1 NOT = { has_country_flag = SIA_path_communist } NOT = { has_country_flag = SIA_republic_declared } } SIA_political_drift_update = yes if = { limit = { check_variable = { SIA_reform_pressure > 60 } date > 2012.1.1 NOT = { has_country_flag = SIA_drift_protest_cooldown } } random = { chance = 20 set_country_flag = { flag = SIA_drift_protest_cooldown days = 365 value = 1 } country_event = { id = thailand.363 days = 3 } } } if = { limit = { check_variable = { SIA_reform_pressure > 40 } check_variable = { party_pop_array^18 > 0.25 } date > 2013.1.1 NOT = { has_country_flag = SIA_two_thailands_done } } set_country_flag = SIA_two_thailands_done country_event = { id = thailand.364 days = 3 } } if = { limit = { has_country_flag = SIA_misery_gate check_variable = { SIA_reform_pressure > 50 } NOT = { has_country_flag = SIA_red_dawn_done } } set_country_flag = SIA_red_dawn_done country_event = { id = thailand.418 days = 3 } } } set_party_index_to_ruling_party = yes if = { limit = { has_country_flag = SIA_path_populist check_variable = { party_index = 18 } NOT = { has_idea = SIA_junta_government } NOT = { has_completed_focus = SIA_civilian_control } has_variable = SIA_coup_risk } clamp_variable = { var = SIA_coup_risk min = 0 max = 100 } # The meter never bleeds off on its own. Only the coup-watch decisions and the # SIA_reassure_high_command mission bring it down. if = { limit = { has_stability > 0.5 } add_to_variable = { SIA_coup_risk = 0.5 } } else = { add_to_variable = { SIA_coup_risk = 1 } } clamp_variable = { var = SIA_coup_risk min = 0 max = 100 } SIA_coup_update_tier = yes if = { limit = { check_variable = { SIA_coup_risk > 40 } check_variable = { SIA_coup_risk < 85 } NOT = { has_country_flag = SIA_coup_event_cooldown } } random = { chance = 3 set_country_flag = { flag = SIA_coup_event_cooldown days = 180 value = 1 } country_event = { id = thailand.69 days = 2 } } } } # Without this the tier spirit lingers after a coup or the civilian-control focus, because the # populist gate above stops updating it. if = { limit = { OR = { has_idea = SIA_junta_government has_completed_focus = SIA_civilian_control NOT = { has_country_flag = SIA_path_populist } NOT = { check_variable = { party_index = 18 } } } OR = { has_idea = SIA_coup_tier_watchful has_idea = SIA_coup_tier_restless has_idea = SIA_coup_tier_plotting has_idea = SIA_coup_tier_tanks } } SIA_coup_cleanup_effect = yes } # Arms only once the Democrats commit to their trunk, and never bleeds off. set_party_index_to_ruling_party = yes if = { limit = { has_country_flag = SIA_path_democrat check_variable = { party_index = 1 } NOT = { has_country_flag = SIA_path_populist } NOT = { has_country_flag = SIA_path_royalist } NOT = { has_country_flag = SIA_path_reform } NOT = { has_country_flag = SIA_path_communist } NOT = { has_idea = SIA_junta_government } } # The focus reward seeds this too; belt and braces. SIA_pt_pressure_seed = yes set_temp_variable = { pt_delta = 1 } if = { limit = { has_idea = depression } add_to_temp_variable = { pt_delta = 1 } } else_if = { limit = { has_idea = recession } add_to_temp_variable = { pt_delta = 0.5 } } else_if = { limit = { has_idea = stagnation } add_to_temp_variable = { pt_delta = 0.25 } } else_if = { limit = { has_idea = fast_growth } subtract_from_temp_variable = { pt_delta = 0.25 } } else_if = { limit = { has_idea = economic_boom } subtract_from_temp_variable = { pt_delta = 0.5 } } if = { limit = { has_stability < 0.35 } add_to_temp_variable = { pt_delta = 0.5 } } else_if = { limit = { has_stability < 0.5 } add_to_temp_variable = { pt_delta = 0.25 } } else_if = { limit = { has_stability > 0.7 } subtract_from_temp_variable = { pt_delta = 0.5 } } # The Isan beachhead (SIA_break_into_isan) slows the tide at its source. if = { limit = { has_completed_focus = SIA_break_into_isan } subtract_from_temp_variable = { pt_delta = 0.5 } } if = { limit = { has_idea = SIA_rural_package_active } subtract_from_temp_variable = { pt_delta = 0.5 } } SIA_pt_pressure_set = yes } if = { limit = { has_country_flag = SIA_path_democrat check_variable = { SIA_pheu_thai_pressure > 99 } NOT = { has_idea = SIA_junta_government } NOT = { has_country_flag = SIA_pt_landslide_fired } NOT = { has_idea = SIA_red_shirt_encampment } NOT = { has_idea = SIA_red_shirt_crackdown } } set_country_flag = { flag = SIA_pt_landslide_fired days = 365 value = 1 } country_event = { id = thailand.260 days = 7 } } # party_index is still the ruling value here, before the boost below. if = { limit = { OR = { NOT = { check_variable = { party_index = 1 } } has_country_flag = SIA_path_populist has_country_flag = SIA_path_royalist has_country_flag = SIA_path_reform has_country_flag = SIA_path_communist has_idea = SIA_junta_government } OR = { has_idea = SIA_pt_tier_dormant has_idea = SIA_pt_tier_rising has_idea = SIA_pt_tier_surge } } SIA_pt_cleanup_effect = yes } # Also catches coup installs, which SIA_realign_to_royalist does not. if = { limit = { OR = { has_country_flag = SIA_path_royalist check_variable = { party_index = 22 } check_variable = { party_index = 23 } } OR = { AND = { has_variable = SIA_pheu_thai_pressure check_variable = { SIA_pheu_thai_pressure > 0 } } has_idea = SIA_pt_tier_dormant has_idea = SIA_pt_tier_rising has_idea = SIA_pt_tier_surge } } SIA_pt_quiet_effect = yes } # Political realignment detector. Watches the ruling party and swaps the player onto the # matching trunk. if = { limit = { NOT = { has_country_flag = SIA_path_communist } NOT = { has_country_flag = SIA_republic_declared } } set_party_index_to_ruling_party = yes # Seed once so we react to changes only, not to the initial party-vs-trunk gap. if = { limit = { NOT = { has_variable = SIA_last_ruling_party } } set_variable = { SIA_last_ruling_party = party_index } } if = { limit = { NOT = { check_variable = { SIA_last_ruling_party = party_index } } } if = { limit = { check_variable = { party_index = 18 } NOT = { has_country_flag = SIA_path_populist } } country_event = { id = thailand.420 days = 2 } } else_if = { limit = { OR = { check_variable = { party_index = 22 } check_variable = { party_index = 23 } } NOT = { has_country_flag = SIA_path_royalist } } country_event = { id = thailand.421 days = 2 } } else_if = { limit = { check_variable = { party_index = 3 } NOT = { has_country_flag = SIA_path_reform } } country_event = { id = thailand.422 days = 2 } } else_if = { limit = { check_variable = { party_index = 1 } NOT = { has_country_flag = SIA_path_democrat } } country_event = { id = thailand.424 days = 2 } } else_if = { limit = { # Fail-open: an unmodelled ruling party must clear the path flags, or the is_in_array entry # gates match nothing and no trunk can reopen. NOT = { check_variable = { party_index = 18 } } NOT = { check_variable = { party_index = 22 } } NOT = { check_variable = { party_index = 23 } } NOT = { check_variable = { party_index = 3 } } NOT = { check_variable = { party_index = 1 } } } SIA_clear_path_flags = yes SIA_strip_populist_ideas = yes SIA_strip_royalist_ideas = yes SIA_strip_reform_ideas = yes SIA_strip_democrat_ideas = yes SIA_coup_cleanup_effect = yes SIA_pt_cleanup_effect = yes } set_variable = { SIA_last_ruling_party = party_index } } } if = { limit = { date > 2022.6.1 has_completed_focus = SIA_gripen_deal NOT = { has_country_flag = SIA_f35_rejected_done } } set_country_flag = SIA_f35_rejected_done country_event = { id = thailand.319 days = 1 } } set_party_index_to_ruling_party = yes if = { limit = { has_country_flag = SIA_path_populist check_variable = { party_index = 18 } check_variable = { GLOBAL.preah_vihear_tension > 60 } NOT = { has_country_flag = SIA_yellow_shirts_border_done } } set_country_flag = SIA_yellow_shirts_border_done country_event = { id = preah_vihear.112 days = 1 } } if = { limit = { date > 2011.2.1 date < 2012.6.1 check_variable = { GLOBAL.preah_vihear_tension > 40 } NOT = { has_country_flag = SIA_preah_vihear_observers_done } } set_country_flag = SIA_preah_vihear_observers_done country_event = { id = preah_vihear.121 days = 1 } } # thailand.19 clears this on the 6 Jan 2001 vote, but on_new_term_election never fires for a # country that has lost its elections, which would strand the flag. if = { limit = { date > 2001.2.1 has_country_flag = generic_election_killswitch } clr_country_flag = generic_election_killswitch } # Counted weekly because the decisions ran any_owned_state in available, which the engine re- # evaluates every tick while the category is open. if = { limit = { has_country_flag = SIA_reconstruction_unlocked } set_variable = { SIA_reclaimed_count = 0 } set_variable = { SIA_reclaimed_unpacified_count = 0 } set_variable = { SIA_reclaimed_ready_count = 0 } every_owned_state = { limit = { SIA_is_reclaimed_state = yes } add_to_variable = { ROOT.SIA_reclaimed_count = 1 } if = { limit = { compliance < 90 } add_to_variable = { ROOT.SIA_reclaimed_unpacified_count = 1 } } if = { limit = { compliance > 80 } add_to_variable = { ROOT.SIA_reclaimed_ready_count = 1 } } } } } } # Weekly, not daily: the boost ends in recalculate_party, which re-sorts the whole 24-party # array. Every comparable MD political tick runs at weekly cadence or slower. on_weekly_SIA = { effect = { if = { limit = { has_country_flag = SIA_path_democrat NOT = { has_idea = SIA_junta_government } check_variable = { party_pop_array^18 < 0.45 } OR = { has_idea = SIA_pt_tier_rising has_idea = SIA_pt_tier_surge } } set_party_index_to_ruling_party = yes if = { limit = { check_variable = { party_index = 1 } } SIA_pt_wave_popularity_boost = yes } } } } on_monthly_SIA = { effect = { # Cached here because the Preah Vihear decision category re-evaluates its visible every # frame the decision tab is open, for both claimants, from 2008 to game end. if = { limit = { country_exists = CBD OR = { is_subject_of = CBD is_in_faction_with = CBD CBD = { is_subject_of = SIA } AND = { is_subject = yes CBD = { is_subject = yes } OVERLORD = { has_subject = CBD } } } } set_global_flag = GLOBAL_preah_vihear_suspended } else = { clr_global_flag = GLOBAL_preah_vihear_suspended } # Closes after a year, a path commitment, or a change of government. if = { limit = { has_idea = SIA_thaksin_ascendant } set_party_index_to_ruling_party = yes if = { limit = { check_variable = { party_index = 1 } check_variable = { SIA_thaksin_rise_months < 12 } NOT = { has_country_flag = SIA_path_populist } NOT = { has_country_flag = SIA_path_royalist } NOT = { has_country_flag = SIA_path_reform } NOT = { has_country_flag = SIA_path_democrat } NOT = { has_country_flag = SIA_path_communist } } SIA_thaksin_rise_update = yes } else = { remove_ideas = SIA_thaksin_ascendant } } if = { limit = { has_country_flag = SIA_trade_income_active } # Both capped in SIA_thailand_effects.txt so a big FTA web cannot snowball. SIA_recalculate_trade_diplomacy = yes SIA_collect_trade_dividend = yes } # Must hit GLOBAL.preah_vihear_tension itself or it never comes down (99_RAJ_on_actions.txt # Kashmir bug). if = { limit = { date > 2008.7.1 NOT = { has_global_flag = GLOBAL_preah_vihear_resolved } OR = { check_variable = { GLOBAL.preah_vihear_tension > 0 } check_variable = { preah_vihear_readiness > 0 } } } subtract_from_variable = { GLOBAL.preah_vihear_tension = 3 } clamp_variable = { var = GLOBAL.preah_vihear_tension min = 0 max = 100 } subtract_from_variable = { preah_vihear_readiness = 5 } clamp_variable = { var = preah_vihear_readiness min = 0 max = 100 } if = { limit = { country_exists = CBD } CBD = { subtract_from_variable = { preah_vihear_readiness = 5 } clamp_variable = { var = preah_vihear_readiness min = 0 max = 100 } } } set_party_index_to_ruling_party = yes if = { limit = { has_country_flag = SIA_path_populist check_variable = { party_index = 18 } check_variable = { GLOBAL.preah_vihear_tension > 50 } } add_stability = -0.01 } } } } }