###GRACE INTERACTION DECISIONS FOR CHINA - WORLD OF IDEOLOGIES ADD ###

#Add the decisions in a nice order which will make sense in the menu! For example, ranked by cost/reward.


#HOSTILE DECISIONS (ESTABLISHING THE CO-PROSPERITY SPHERE IN CHINA)
offmap_decisions = {

	china_establish_prosperity_sphere = {
		only_playable = yes
		button_name = offmap_hostility
		ai_check_interval = 120
	
		from_potential = {
			has_dlc = "Jade Dragon"
			has_landed_title = k_guandong
		}

		potential = {
			is_offmap_tag = offmap_china
		}

		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				independent = yes
				in_revolt = no
				NOT = {
					is_tributary = {
						type = offmap
						suzerain = ROOT
					}
				}
				NOT = { has_character_modifier = peace_deal_with_china }
				OR = {
					custom_tooltip = { #Borders the Western Governate
						text = chinese_grace_become_tributary_allow_governor_neighbor_tt
						any_neighbor_independent_ruler = {
							has_landed_title = e_china_west_governor
						}
					}
					custom_tooltip = { #Borders the eastern edge of the map
						text = china_invade_dragon_throne_eastern_edge_tt
						any_realm_province = {
							region = custom_eastern_edge_of_map
						}
					}
				}
				custom_tooltip = {
					text = chinese_grace_supply_horses_not_already_supplying_tt
					NOT = {
						has_character_modifier = china_supply_horses
					}
				}
				custom_tooltip = { #Borders the eastern edge of the map
					text = chinese_grace_become_tributary_allow_chinese_influence_tt
					any_realm_province = {
						region = custom_chinese_invasion_target_region
					}
				}
				custom_tooltip = {
					text = china_offmap_boon_decisions_enabled_trigger_raiding_tt
					NOT = {
						has_character_modifier = china_raid_grace_cd
					}
				}
				custom_tooltip = {
					text = china_invade_dragon_throne_failed_tt
					NOT = { has_character_modifier = failed_invasion_of_china }
				}
				NOT = { has_raised_levies = THIS }
				custom_tooltip = {
					text = china_invade_dragon_throne_levies_tt
					NOT = { any_vassal = { ROOT_FROM = { has_raised_levies = PREV } } }
				}
				NOT = { has_truce = ROOT }
				prisoner = no
				NOT = { trait = incapable }
				is_inaccessible_trigger = no
			}
			NOT = { offmap_ruler = { religion = FROM } }
			china_offmap_hostile_decisions_enabled_trigger = yes
			offmap_china = {
				ROOT = {
					show_scope_change = no
					custom_tooltip = {
						text = china_invade_dragon_throne_war_tt
						NOT = { any_war = { using_cb = invasion_of_china_cb } }
					}
				}
			}
		}

		effect = {
			hidden_effect = {
				ROOT = { #Set amount of troops
					set_offmap_tmp_flag = china_war_variables_set
					set_variable = {
						which = china_war_troop_quantity
						value = 15
						# 15 regiments of ~500 units
					}
					set_variable = {
						which = china_war_target_match_mult
						value = 2
					}
					set_variable = {
						which = china_war_troop_quality
						value = 6
						# Value between 1-7
					}
					set_variable = {
						which = china_war_minimum_commander_martial
						value = 16
					}
					set_variable = { #Minimum 80k
						which = china_war_troop_quantity_override
						value = 160
					}
					save_event_target_as = invasion_of_china_govenor
				}
			}
			FROM = {
				show_scope_change = no
				sound_effect = china_angered_emperor
				save_event_target_as = invasion_of_china_attacker
				custom_tooltip = {
					text = china_invade_dragon_throne_modifiers_tt
					hidden_effect = {
						set_offmap_currency = { offmap = offmap_china value = 0 }
						remove_character_modifier = peace_deal_with_china
						remove_character_modifier = chinese_grace_send_gift_timer
						remove_character_modifier = chinese_grace_send_eunuch_timer
						remove_character_modifier = chinese_grace_send_concubine_timer
						remove_character_modifier = chinese_grace_tributary_timer
						remove_character_modifier = jd_china_boon_cd
						remove_character_modifier = china_force_open_cooldown
						remove_character_modifier = angered_china_modifier
						remove_character_modifier = chinese_imperial_trade_contract
					}
				}
				hidden_effect = {
					add_character_modifier = {
						name = war_with_china_modifier
						inherit = yes
						duration = -1
					}
					war = {
						target = ROOT
						casus_belli = invasion_of_china_hakko_ichiu_cb
					}
				}
				hidden_effect = {
					add_character_modifier = {
						inherit = yes
						name = china_raid_active
						duration = -1
					}
				}
			}
			hidden_effect = {
				any_player = {
					limit = {
						has_offmap_news_enabled = offmap_china
						is_within_diplo_range = ROOT
					}
					narrative_event = { id = 270923 }
				}
			}
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 0.3
			modifier = {
				factor = 0
				FROM = {
					has_grace_medium_trigger = yes
				}
			}
			modifier = {
				factor = 0
				FROM = {
					OR = {
						trait = shy
						trait = content
						trait = craven
					}
				}
			}
			modifier = {
				factor = 0.5
				FROM = {
					OR = {
						trait = zealous
						trait = proud
					}
				}
			}
			modifier = {
				factor = 0.5
				FROM = {
					OR = {
						trait = zealous
						trait = proud
					}
				}
			}
		}
	}
}