﻿# Rota Fortunae — decisions.

rf_appease_powers_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_spend_money.dds" }
	desc = rf_appease_powers_decision_desc
	selection_tooltip = rf_appease_powers_decision_tooltip
	ai_check_interval = 36
	cooldown = { years = 5 }

	is_shown = {
		rf_is_realm_trigger = yes
		rf_menace_value >= 25
	}

	is_valid = {
		gold >= rf_appease_gold_value
		prestige >= rf_appease_prestige_value
	}

	cost = {
		gold = rf_appease_gold_value
		prestige = rf_appease_prestige_value
	}

	effect = {
		primary_title = { rf_change_menace_effect = { AMOUNT = -20 } }
		custom_tooltip = rf_appease_powers_decision.tt
	}

	ai_potential = {
		rf_menace_value >= 60
		rf_has_coalition_against_trigger = yes
	}
	ai_will_do = {
		base = 20
		modifier = { add = 30 has_trait = craven }
		modifier = { add = 20 diplomacy >= 14 }
		modifier = { add = -20 has_trait = arrogant }
	}
}

rf_renovatio_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_realm.dds" }
	desc = rf_renovatio_decision_desc
	selection_tooltip = rf_renovatio_decision_tooltip
	ai_check_interval = 60
	cooldown = { years = 15 }

	is_shown = {
		rf_wheel_enabled_trigger = yes
		rf_is_realm_trigger = yes
		OR = {
			rf_phase_value = 3
			rf_phase_value = 4
		}
	}

	is_valid = {
		gold >= rf_renovatio_gold_value
		is_at_war = no
	}

	cost = {
		gold = rf_renovatio_gold_value
	}

	effect = {
		custom_tooltip = rf_renovatio_decision.tt
		random = {
			chance = {
				value = 30
				add = stewardship
				add = diplomacy
				max = 85
			}
			add_character_flag = rf_renovatio_success
		}
		trigger_event = rf_wheel.200
	}

	ai_potential = { gold >= 300 }
	ai_will_do = {
		base = 25
		modifier = { add = 25 stewardship >= 14 }
		modifier = { add = 15 has_trait = diligent }
	}
}

rf_leave_coalition_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_misc.dds" }
	desc = rf_leave_coalition_decision_desc
	selection_tooltip = rf_leave_coalition_decision_tooltip
	ai_check_interval = 0

	is_shown = {
		is_ai = no
		rf_is_coalition_member_trigger = yes
	}

	is_valid = {
		custom_description = {
			text = rf_coalition_at_war_tt
			NOT = {
				exists = primary_title.var:rf_coalition_against.var:rf_coalition_war
			}
		}
	}

	effect = {
		save_scope_as = rf_turncoat
		primary_title.var:rf_coalition_against ?= {
			every_in_list = {
				variable = rf_coalition
				limit = { exists = holder holder != scope:rf_turncoat }
				holder = { add_opinion = { target = scope:rf_turncoat modifier = rf_betrayed_coalition_opinion } }
			}
		}
		rf_leave_coalition_effect = yes
	}

	ai_potential = { always = no }
	ai_will_do = { base = 0 }
}

# Testing aid, only visible when the game runs in debug mode.
rf_debug_turn_wheel_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_misc.dds" }
	desc = rf_debug_turn_wheel_decision_desc
	selection_tooltip = rf_debug_turn_wheel_decision_tooltip
	ai_check_interval = 0
	is_shown = {
		debug_only = yes
		rf_is_realm_trigger = yes
	}
	effect = {
		custom_tooltip = rf_debug_turn_wheel_decision_tooltip
		hidden_effect = {
			rf_ensure_state_effect = yes
			if = { limit = { rf_phase_value = 1 } rf_enter_phase_effect = { PHASE = 2 } }
			else_if = { limit = { rf_phase_value = 2 } rf_enter_phase_effect = { PHASE = 3 } }
			else_if = { limit = { rf_phase_value = 3 } rf_enter_phase_effect = { PHASE = 4 } }
			else = { rf_enter_phase_effect = { PHASE = 1 } }
		}
	}
	ai_potential = { always = no }
	ai_will_do = { base = 0 }
}

rf_debug_provoke_coalition_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_misc.dds" }
	desc = rf_debug_provoke_coalition_decision_desc
	selection_tooltip = rf_debug_provoke_coalition_decision_tooltip
	ai_check_interval = 0
	is_shown = {
		debug_only = yes
		rf_is_realm_trigger = yes
	}
	effect = {
		custom_tooltip = rf_debug_provoke_coalition_decision_tooltip
		hidden_effect = {
			rf_ensure_state_effect = yes
			primary_title = { set_variable = { name = rf_menace value = 80 } }
			save_scope_as = rf_threat
			every_independent_ruler = {
				limit = {
					rf_can_join_coalition_against_trigger = { THREAT = scope:rf_threat }
					rf_in_coalition_range_trigger = { THREAT = scope:rf_threat }
				}
				rf_join_coalition_effect = { THREAT = scope:rf_threat }
			}
			rf_coalition_war_check_effect = yes
			rf_refresh_threat_lists_effect = yes
		}
	}
	ai_potential = { always = no }
	ai_will_do = { base = 0 }
}

rf_debug_simulate_year_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_misc.dds" }
	desc = rf_debug_simulate_year_decision_desc
	selection_tooltip = rf_debug_simulate_year_decision_tooltip
	ai_check_interval = 0
	is_shown = {
		debug_only = yes
		rf_is_realm_trigger = yes
	}
	effect = {
		custom_tooltip = rf_debug_simulate_year_decision_tooltip
		hidden_effect = {
			if = {
				limit = { NOT = { exists = global_var:rf_initialized } }
				rf_game_start_effect = yes
			}
			rf_yearly_realm_effect = yes
			rf_refresh_great_powers_effect = yes
			rf_refresh_threat_lists_effect = yes
		}
	}
	ai_potential = { always = no }
	ai_will_do = { base = 0 }
}
