﻿#Written by hiddengearz

add_namespace = war
add_namespace = anti_bully
add_namespace = Def_Spending_Warning

news_event = {
	id = war.0
	title = war.0.t
	desc = war.0.d
	
	picture = GFX_news_event_war
	major = yes
	is_triggered_only = yes


	option = {
		name = war.0.a
		log = "[GetDateText]: [This.GetName]: war.0.a executed"
	
	}
}
news_event = {
	id = war.1
	title = war.1.t
	desc = war.1.d
	
	picture = GFX_news_event_war
	major = yes
	is_triggered_only = yes


	option = {
		name = war.1.a
		log = "[GetDateText]: [This.GetName]: war.1.a executed"
	
	}
}

################### WAR 1 ############################
#Used just to trigger event 2, event 1 doesnt seem to work imediately via on action
country_event = {
	id = anti_bully.1
	title = anti_bully.1.t
	desc = anti_bully.1.d
	
	hidden = yes
	#fire_only_once = yes
	
	is_triggered_only = yes
	
	immediate = {
		country_event = { id = anti_bully.2 days = 1 }
	}
	option = {
		name = anti_bully.1.a
		log = "[GetDateText]: [This.GetName]: anti_bully.1.a executed"
		#this = { gearz_test = yes }
	}
	
	
}

#starts Anti Bully system - sent to attacker
country_event = {
	id = anti_bully.2
	title = anti_bully.2.t
	desc = anti_bully.2.d
	
	#hidden = yes
	#fire_only_once = yes
	
	is_triggered_only = yes
	
	trigger = {
		this = {
			has_offensive_war_with = event_target:AB_DEFF
		}
	}
	
	immediate = {
		
		if = {
			limit = { has_country_flag = { flag = total_AB_wars value = 0 } } #Has 0 AB wars
			event_target:AB_ATT = {
				modify_country_flag = { flag = total_AB_wars value = 1 }
				AB_war_main = yes
			}
			else = {
				event_target:AB_ATT = {
					modify_country_flag = { flag = total_AB_wars value = 1 }
				}
			}
		}
		event_target:AB_ATT = {
			AB_war_second = yes
		}
		
	}
		
	option = {
		name = anti_bully.2.a
		log = "[GetDateText]: [This.GetName]: anti_bully.2.a executed"
	}
	
	
}

#
country_event = {
	id = anti_bully.3
	title = anti_bully.3.t
	desc = anti_bully.3.d
	
	hidden = yes
	#fire_only_once = yes
	
	is_triggered_only = yes
	
	
	immediate = {
		AB_war_main = yes
	}
		
	option = {
		name = anti_bully.3.a
		log = "[GetDateText]: [This.GetName]: anti_bully.3.a executed" #We have lost national unity
		
	}
	
	
}

#Attacker offers white peace
country_event = {
	id = anti_bully.4
	title = anti_bully.4.t
	desc = anti_bully.4.d
	
	hidden = yes
	#fire_only_once = yes
	
	is_triggered_only = yes
	
	immediate = {
		AB_war_second = yes
	}
	
	option = { #attacker offers white peace
		name = anti_bully.4.a
		log = "[GetDateText]: [This.GetName]: anti_bully.4.a executed"
		
	}
	
}

#Deffender accepts/declines white peace
country_event = {
	id = anti_bully.5
	title = anti_bully.5.t
	desc = anti_bully.5.d
	
	#hidden = yes
	#fire_only_once = yes
	
	is_triggered_only = yes

	option = {
		name = anti_bully.5.a
		log = "[GetDateText]: [This.GetName]: anti_bully.5.a executed" #Accept & war ends
		every_state = {
			limit = {
				is_owned_by = This
				is_controlled_by = FROM
			}
			FROM = { transfer_state = PREV }
		}
		white_peace = FROM
		#hidden_effect = { clr_country_flag = stalemate@FROM }
		
		if = {
			limit = { #If you're in a faction, not a major and not the leader
				event_target:AB_event_target = {
					is_in_faction = yes
					is_faction_leader = no
				}
				any_country = { #Faction leader must have capitulated for me to see this decision
					is_in_faction_with = event_target:AB_event_target
					has_war_together_with = event_target:AB_event_target
					is_faction_leader = yes
					has_capitulated = no
				}
			}
			event_target:AB_event_target = { leave_faction = yes }
			if = {
				limit = { event_target:AB_event_target = { has_idea = NATO_member } }
				event_target:AB_event_target = { remove_ideas = NATO_member }
			}
		}
		
		ai_chance = {
			factor = 10			
			modifier = {
				factor = 10
				or = {
					strength_ratio = { tag = FROM ratio > 1.5 }
					has_stability > 0.35
				}
			}		
		}
	}
	
	option = {
		name = anti_bully.5.b
		log = "[GetDateText]: [This.GetName]: anti_bully.5.b executed" #nothing
		ai_chance = {
			factor = 10			
			modifier = {
				factor = 10
				or = {
					not = { strength_ratio = { tag = FROM ratio > 1.5 } }
					not = { has_stability > 0.35 }
				}
			}		
		}
	}
	
}


country_event = {
	id = Def_Spending_Warning.0
	title = Def_Spending_Warning.0.t
	desc = Def_Spending_Warning.0.d
	
	#hidden = yes
	#fire_only_once = yes
	
	is_triggered_only = yes
	major = yes
		
	option = {
		name = Def_Spending_Warning.0.a
		log = "[GetDateText]: [This.GetName]: Def_Spending_Warning.0.a executed"
		
	}
	
}
#For testing
country_event = {
	id = Def_Spending_Warning.1
	title = Def_Spending_Warning.1.t
	desc = Def_Spending_Warning.1.d
	
	#hidden = yes
	#fire_only_once = yes
	
	trigger = {
		neighbor_has_higher_mil_spending_by_2 = yes
	}
	
	is_triggered_only = yes
	
		
	option = {
		name = Def_Spending_Warning.1.a
		log = "[GetDateText]: [This.GetName]: Def_Spending_Warning.1.a executed"
		
	}
	
}
#For testing
country_event = {
	id = Def_Spending_Warning.2
	title = Def_Spending_Warning.2.t
	desc = Def_Spending_Warning.2.d
	
	#hidden = yes
	#fire_only_once = yes
	
	is_triggered_only = yes
	
		
	option = {
		name = Def_Spending_Warning.2.a
		log = "[GetDateText]: [This.GetName]: Def_Spending_Warning.2.a executed"
		GUA = {
			swap_ideas = { remove_idea = defence_01 add_idea = defence_06 }
		}
		
	}
	
}
