﻿### Apply some impact to the relation between two houses.
#
debug_impact_house_relation_interaction = {
	category = interaction_debug_tgp
	desc = debug_impact_house_relation_interaction_desc
	use_diplomatic_range = no
	ignores_pending_interaction_block = yes
	icon = debug_chars
	common_interaction = yes

	is_shown = {
		debug_only = yes
		exists = scope:recipient.house
		scope:recipient.house ?= {
			NOT = { this = scope:actor.house }
		}
	}
	is_valid_showing_failures_only = {
		house_relation_is_valid_to_start_trigger = {
			HOUSE = scope:actor.house
			OTHER_HOUSE = scope:recipient.house
		}
	}

	send_option = {
		localization = debug_impact_house_relation_for_the_significantly_better
		flag = impact_for_the_significantly_better
	}
	send_option = {
		localization = debug_impact_house_relation_for_the_noticeably_better
		flag = impact_for_the_noticeably_better
	}
	send_option = {
		localization = debug_impact_house_relation_for_the_slightly_better
		flag = impact_for_the_slightly_better
	}
	send_option = {
		localization = debug_impact_house_relation_by_setting_to_neutral
		flag = set_to_neutral
	}
	send_option = {
		localization = debug_impact_house_relation_for_the_slightly_worse
		flag = impact_for_the_slightly_worse
	}
	send_option = {
		localization = debug_impact_house_relation_for_the_noticeably_worse
		flag = impact_for_the_noticeably_worse
	}
	send_option = {
		localization = debug_impact_house_relation_for_the_significantly_worse
		flag = impact_for_the_significantly_worse
	}
	send_option = {
		localization = debug_impact_house_relation_by_clearing_it
		flag = clear_relation
		is_valid = {
			scope:actor.house = {
				has_house_relation_with = scope:recipient.house
			}
		}
	}
	send_option = {
		localization = debug_impact_house_relation_by_starting_a_feud
		flag = start_feud
		is_shown = {
			has_bp1_dlc_trigger = yes
		}
		is_valid = {
			custom_tooltip = {
				text = action_in_debt_click
				NOT = {
					house_has_feud_relation_with_trigger = { TARGET = scope:recipient }
				}
			}
		}
	}

	can_send = {
	house_relation_is_valid_to_start_trigger = {
		HOUSE = scope:actor.house
		OTHER_HOUSE = scope:recipient.house
	}
}
	on_accept = {
		if = {
			limit = { scope:clear_relation = yes }
			scope:actor.house = {
				random_house_relation = {
					limit = {
						any_relation_house = { scope:recipient.house = this }
					}
					clear_house_relation = yes
				}
			}
		}
		else_if = {
			limit = { scope:set_to_neutral = yes }
			scope:actor.house = {
				set_house_relation = {
					target = scope:recipient.house
					description = debug_impact_house_relation_change_description
				}
			}
		}
		else_if = {
			limit = { scope:start_feud = yes }

			house_feud_start_effect = {
				# Feuding House Head
				ACTOR = scope:actor
				# Target House Head
				TARGET = scope:recipient
				# Feud Reason
				REASON = head_cuckolded
				# House Member attacker if relevant
				ATTACKER = scope:actor
				# House Member victim if relevant
				VICTIM = scope:recipient
			}
		}
		else = {
			scope:recipient = {
				scope:actor.house = {
					impact_house_relation = {
						target = scope:recipient.house
						steps = {
							value = 0

							if = {
								limit = { scope:impact_for_the_significantly_better = yes}
								add = 3
							}
							if = {
								limit = { scope:impact_for_the_noticeably_better = yes }
								add = 1
							}
							if = {
								limit = { scope:impact_for_the_slightly_better = yes }
								add = 0.3
							}
							if = {
								limit = { scope:impact_for_the_slightly_worse = yes }
								add = -0.3
							}
							if = {
								limit = { scope:impact_for_the_noticeably_worse = yes }
								add = -1
							}
							if = {
								limit = { scope:impact_for_the_significantly_worse = yes }
								add = -3
							}
						}
						description = debug_impact_house_relation_change_description
					}
				}
			}
		}
	}
	auto_accept = yes
}


debug_spawn_natural_disaster = {
	category = interaction_debug_tgp
	use_diplomatic_range = no
	ignores_pending_interaction_block = yes
	common_interaction = yes
	icon = debug_bad
	auto_accept = yes
	is_shown = {
		debug_only = yes
		scope:recipient ?= {
			is_landed = yes
			highest_held_title_tier >= tier_county
		}
	}
	send_option = {
		flag = sub_realm_earthquake
		localization = debug_sub_realm_earthquake
	}
	send_option = {
		flag = random_earthquake
		localization = debug_random_earthquake
	}
	send_option = {
		flag = sub_realm_flood
		localization = debug_sub_realm_flood
		is_valid = {
			custom_tooltip = {
				text = debug_sub_realm_flood_tt
				scope:recipient = {
					any_sub_realm_county = {
						title_province = { geographical_region = global_flood_region }
						NOT = {
							any_county_situation = { situation_type = natural_disaster_flood }
						}
					}
				}
			}
		}
	}
	send_option = {
		flag = random_flood
		localization = debug_random_flood
	}
	on_accept = {
		hidden_effect = {
			scope:recipient = {
				switch = {
					trigger = yes
					scope:sub_realm_earthquake = {
						scope:recipient = {
							random_sub_realm_county = {
								limit = {
									save_temporary_scope_as = county_temp
									NOT = {
										any_in_global_list = {
											variable = ongoing_earthquakes
											var:epicenter_county ?= scope:county_temp.kingdom
										}
									}
								}
								spawn_earthquake_in_county_effect = { COUNTY = this }
							}
						}
					}
					scope:random_earthquake = { trigger_event = natural_disaster.9901 }
					scope:sub_realm_flood = {
						scope:recipient = {
							random_sub_realm_county = {
								limit = {
									title_province = { geographical_region = global_flood_region }
									NOT = {
										any_county_situation = { situation_type = natural_disaster_flood }
									}
								}
								spawn_flood_in_county_effect = { COUNTY = this }
							}
						}
					}
					scope:random_flood = { trigger_event = natural_disaster.9902 }
				}
			}
		}
	}
}


debug_change_bloc_cohesion = {
	category = interaction_debug_tgp
	use_diplomatic_range = no
	ignores_pending_interaction_block = yes
	common_interaction = yes
	icon = icon_leave_bloc
	auto_accept = yes
	is_shown = {
		debug_only = yes
		scope:recipient.house.house_confederation ?= { has_cohesion = yes }
	}
	send_option = {
		flag = max
		localization = Max
	}
	send_option = {
		flag = improve
		localization = debug_improve_block_cohesion
	}
	send_option = {
		flag = damage
		localization = debug_damage_block_cohesion
	}
	send_option = {
		flag = destroy
		localization = DESTROY_ACCOLADE
	}
	on_accept = {
		scope:recipient.house.house_confederation = {
			switch = {
				trigger = yes
				scope:max = { change_cohesion = 100 }
				scope:improve = { change_cohesion = 20 }
				scope:damage = { change_cohesion = -20 }
				scope:destroy = { change_cohesion = -100 }
			}
		}
	}
}
