GEN_subdue_usa_category = {
	GEN_subdue_usa = {
		state_target = yes
		on_map_mode = map_and_decisions_view
		icon = generic_form_nation
		highlight_states = {
			highlight_states_trigger = {
				is_owned_by = USA
			}
		}
		target_trigger = {
			FROM = {
				is_owned_by = USA
			}
		}
		cost = 15
		days_remove = 3
		ai_will_do = {
			base = 100
		}
		visible = {
			has_completed_focus = GEN_reach_out_to_trump
			FROM = {
				NOT = {
					has_state_flag = ACW_3
				}
			}
		}
		#fire_only_once = yes ### we may buy states after USA bought them back.
		remove_effect = {
			if = {
				limit = {
					NOT = {
						USA = {
							has_country_flag = ACW_prepared
						}
					}
				}
				USA = {
					country_event = {
						id = unrest.999
						days = 3
					}
					set_country_flag = ACW_prepared
				}
			}
			FROM = {
				set_state_flag = ACW_3
				USA = {
					add_to_variable = {
						var = GEN_ACW_force
						value = 1
					}
				}
			}
		}
	}
	GEN_ignite_a_civil_war = {
		icon = generic_form_nation
		cost = 150
		ai_will_do = {
			base = 300
		}
		visible = {
			has_completed_focus = GEN_reach_out_to_trump
		}
		available = {
			USA = {
				check_variable = {
					GEN_ACW_force > 10
				}
			}
			OR = {
				AND = {
					country_exists = SOV
					SOV = {has_capitulated = no}
				}
				AND = {
					country_exists = PRC
					PRC = {has_capitulated = no}
				}
			}
		}
		fire_only_once = yes
		complete_effect = {
			USA = {
				every_owned_state = {
					limit = {
						has_state_flag = ACW_3
					}
					clr_state_flag = ACW_3
					transfer_state_to = CSA
					create_unit = {
						division = "name = \"Republican Militia\" division_template = \"Infantry Division\" start_experience_factor = 0.3 start_equipment_factor = 1"
						owner = CSA
						count = 2
						allow_spawning_on_enemy_provs = yes
					}
				}
				every_controlled_state = {
					limit = {
						has_state_flag = ACW_3
					}
					clr_state_flag = ACW_3
				}
				every_core_state = {
					add_core_of = CSA
				}
			}
			PRC = {
				give_guarantee = CSA
			}
			USA = {
				declare_war_on = {
					target = CSA
					type = annex_everything
				}
			}
			CSA = {
				set_country_flag = polit_china_ally
			}
			if = {
				limit = {
					USA = {
						exists = no
					}
				}
				set_country_flag = CRI_fair_and_square
			}
		}
	}
}
GEN_protect_usa_category = {
	GEN_protect_usa = {
		state_target = yes
		on_map_mode = map_and_decisions_view
		icon = generic_form_nation
		highlight_states = {
			highlight_states_trigger = {
				is_owned_by = USA
			}
		}
		target_trigger = {
			FROM = {
				is_owned_by = USA
			}
		}
		cost = 15
		ai_will_do = {
			base = 300
		}
		#days_remove = 3 #is literally a gacha, so no restrictions here or you will be bonked anyways.
		visible = {
			check_variable = {
				GEN_ACW_force > 0 # was China/NATO Defence but it is so lackluster
			}
		}
		fire_only_once = no
		complete_effect = {
			FROM = {
				if = {
					limit = {
						has_state_flag = ACW_3
					}
					clr_state_flag = ACW_3
					USA = {
						if = {
							limit = {
								check_variable = {
									GEN_ACW_force > 0
								}
							}
							add_to_variable = {
								var = GEN_ACW_force
								value = -1
							}
						}
					}
				}
			}
		}
	}
}
GEN_subdue_china_category = {
	GEN_subdue_china = {
		state_target = yes
		on_map_mode = map_and_decisions_view
		icon = generic_form_nation
		days_remove = 3
		highlight_states = {
			highlight_states_trigger = {
				is_owned_by = PRC
				NOT = {
					state = 714
					state = 761
					state = 610
					state = 328
					state = 715
					state = 716
					state = 717
					state = 612
					state = 611 #All of the above being manchu and mongol states
					is_core_of = SHX
					is_core_of = SIK
					is_core_of = XSM
					state = 609 #East Hebei
					state = 745 #Dairen
					state = 743 #Qingtao
					state = 597 #Shandong
					state = 607 #Henan
					state = 622 #Yan'an base area
					state = 744 #Xi'an
					state = 614 #hebei south
					state = 608 # beijing-tianjin
				}
			}
		}
		target_trigger = {
			FROM = {
				is_owned_by = PRC
				NOT = {
					state = 714
					state = 761
					state = 610
					state = 328
					state = 715
					state = 716
					state = 717
					state = 612
					state = 611 #All of the above being manchu and mongol states
					is_core_of = SHX
					is_core_of = SIK
					is_core_of = XSM
					state = 609 #East Hebei
					state = 745 #Dairen
					state = 743 #Qingtao
					state = 597 #Shandong
					state = 607 #Henan
					state = 622 #Yan'an base area
					state = 744 #Xi'an
					state = 614 #hebei south
					state = 608 # beijing-tianjin
				}
			}
		}
		cost = 15
		ai_will_do = {
			base = 100
		}
		visible = {
			has_completed_focus = GEN_reach_out_to_taiwan
			FROM = {
				NOT = {
					has_state_flag = CCW_3
				}
			}
		}
		#fire_only_once = yes ### We may buy provinces after China bought them back
		remove_effect = {
			if = {
				limit = {
					NOT = {
						PRC = {
							has_country_flag = CCW_prepared
						}
					}
				}
				PRC = {
					country_event = {
						id = unrest.666
						days = 3
					}
					set_country_flag = CCW_prepared
				}
			}
			FROM = {
				set_state_flag = CCW_3
				PRC = {
					add_to_variable = {
						var = GEN_CCW_force
						value = 1
					}
				}
			}
		}
	}
	GEN_ignite_c_civil_war = {
		icon = generic_form_nation
		cost = 150
		ai_will_do = {
			base = 300
		}
		visible = {
			has_completed_focus = GEN_reach_out_to_taiwan
		}
		available = {
			PRC = {
				check_variable = {
					GEN_CCW_force > 10
				}
			}
			OR = {
				AND = {
					country_exists = GER
					GER = {has_capitulated = no}
				}
				AND = {
					country_exists = USA
					USA = {has_capitulated = no}
				}
			}
		}
		fire_only_once = yes
		complete_effect = {
			PRC = {
				every_owned_state = {
					limit = {
						has_state_flag = CCW_3
					}
					clr_state_flag = CCW_3
					transfer_state_to = CHI
					create_unit = {
						division = "name = \"Kuomintang Underground Supporters\" division_template = \"Sanjiao Jun\" start_experience_factor = 0.3 start_equipment_factor = 1"
						owner = CHI
						count = 2
						allow_spawning_on_enemy_provs = yes
					}
				}
				every_controlled_state = {
					limit = {
						has_state_flag = CCW_3
					}
					clr_state_flag = CCW_3
				}
			}
			USA = {
				give_guarantee = CHI
			}
			PRC = {
				declare_war_on = {
					target = CHI
					type = annex_everything
				}
			}
		}
	}
}
GEN_protect_china_category = {
	GEN_protect_china = {
		state_target = yes
		on_map_mode = map_and_decisions_view
		icon = generic_form_nation
		#days_remove = 3 #is literally a gacha, so no restrictions here or you will be bonked anyways.
		highlight_states = {
			highlight_states_trigger = {
				is_owned_by = PRC
			}
		}
		target_trigger = {
			FROM = {
				is_owned_by = PRC
			}
		}
		cost = 15
		ai_will_do = {
			base = 300
		}
		visible = {
			#has_completed_focus = GEN_china_defence ### Lackluster and does not fire in time
			check_variable = {
				GEN_CCW_force > 0
			}
		}
		fire_only_once = no
		complete_effect = {
			FROM = {
				if = {
					limit = {
						has_state_flag = CCW_3
					}
					clr_state_flag = CCW_3
					PRC = {
						if = {
							limit = {
								check_variable = {
									GEN_CCW_force > 0
								}
							}
						}
						add_to_variable = {
							var = GEN_CCW_force
							value = -1
						}
					}
				}
			}
		}
	}
}
GEN_nuclear_category = {
	GEN_click_the_button = {
		icon = generic_prepare_civil_war
		fire_only_once = yes
		ai_will_do = {
			base = 0
		}
		available = {
			OR = {
				original_tag = SOV
				original_tag = PRC
				original_tag = USA
				original_tag = ENG
				original_tag = FRA
				### Lesser nuclear countries
				original_tag = ISR
				original_tag = MAN #DPRK
				original_tag = RAJ
				original_tag = PAK
				#original_tag = PER #Currently no data
			}
			has_war = yes
			surrender_progress > 0.2
		}
		cost = 500
		complete_effect = {
			set_technology = {
				experimental_rockets = 1
				rocket_engines = 1
				improved_rocket_engines = 1
				advanced_rocket_engines = 1
				jet_engines = 1
				atomic_research = 1
				nuclear_reactor = 1
				nukes = 1
			}
			every_owned_state = {
				add_extra_state_shared_building_slots = 1
				add_building_construction = {
					type = nuclear_reactor
					level = 1
					instant_build = yes
				}
			}
			add_nuclear_bombs = 100
		}
	}
}
NATO_entry_category = {
	NATO_construct_factory = {
		icon = GFX_decision_generic_construction
		targets = {ITA GER TUR ENG USA FRA}
		fire_only_once = yes
		available = {
			has_country_flag = polit_supported_nato
			NOT = {
				is_ally_with = USA
			}
			#FROM = {
			#	has_opinion = {
			#		target = ROOT
			#		value > 30
			#	}
			#}
			num_of_civilian_factories_available_for_projects > 14
		}
		modifier = {
			civilian_factory_use = 15
		}
		ai_will_do = {
			base = 300
		}
		cost = 10
		days_remove = 30
		complete_effect = {
			FROM = {
				random_owned_state = {
					add_extra_state_shared_building_slots = 1
					add_building_construction = {
						type = industrial_complex
						level = 1
						instant_build = yes
					}
				}
			}
			ROOT = {
				add_to_variable = {
					var = GEN_NATO_support
					value = 1
				}
				if = {
					limit = {
						check_variable = {
							GEN_NATO_support > 5
						}		
					}
					ROOT = {
						add_popularity = {
							ideology = democratic
							popularity = 0.4
						}
					}
					USA = {
						add_to_faction = ROOT
					}
					ROOT = {
						add_ideas = CRI_flexible_foreign_policy
					}
				}
			}	
		}
	}
}
China_entry_category = {
	China_construct_factory = {
		icon = GFX_decision_generic_construction
		targets = {PRC SOV}
		fire_only_once = yes
		available = {
			has_country_flag = polit_supported_china
			NOT = {
				is_ally_with = PRC
				is_ally_with = SOV
			}
			#FROM = {
			#	has_opinion = {
			#		target = ROOT
			#		value > 30
			#	}
			#}
			num_of_civilian_factories_available_for_projects > 14
		}
		modifier = {
			civilian_factory_use = 15
		}
		cost = 30
		ai_will_do = {
			base = 300
		}
		days_remove = 90
		complete_effect = {
			FROM = {
				random_owned_state = {
					limit = {
						is_coastal = yes
					}
					add_extra_state_shared_building_slots = 3
					add_building_construction = {
						type = industrial_complex
						level = 1
						instant_build = yes
					}
					add_building_construction = {
						type = arms_factory
						level = 1
						instant_build = yes
					}
					add_building_construction = {
						type = dockyard
						level = 1
						instant_build = yes
					}
				}
			}
			ROOT = {
				add_to_variable = {
					var = GEN_china_support
					value = 1
				}
				if = {
					limit = {
						check_variable = {
							GEN_china_support > 1
						}		
					}
					if = {
						limit = {
							any_owned_state = {
								is_core_of = SOV
							}
						}
						SOV = {
							add_to_faction = ROOT
						}
						ROOT = {
							add_ideas = CRI_flexible_foreign_policy
						}
					}
					else = {
						ROOT = {
							add_popularity = {
								ideology = communism
								popularity = 0.4
							}
						}
						PRC = {
							add_to_faction = ROOT
						}
						ROOT = {
							add_ideas = CRI_flexible_foreign_policy
						}
					}
					
				}
			}	
		}
	}
}