eligible_for_endsieg = {
	FROM = {
		AND = {
			is_core_of = GER
			is_owned_by = GER
			GER = { has_government = fascism }
			GER = { has_civil_war = no }
			GER = { 
				OR = { 
					surrender_progress > 0.39 
					NOT = { has_full_control_of_state = 64 }
					AND = {
						has_global_flag = d_day_happened #send the words, send the words send the words everywhere! THAT THE YANKS ARE COMING! THE YANKS ARE COMING!
						OR = {
							NOT = { has_full_control_of_state = 42 }
							NOT = { has_full_control_of_state = 51 }
							NOT = { has_full_control_of_state = 57 }
							NOT = { has_full_control_of_state = 50 }
							NOT = { has_full_control_of_state = 56 }
						}
						surrender_progress > 0
					}
				}
			}
			NOT = { has_dynamic_modifier = { modifier = LSM_endsieg_modifier } }
			any_neighbor_state = { 
				controller = { has_war_with = GER }
			}
		}
	}
} 


eligible_for_patriotic_war = {
			FROM = { 
				AND = {
					is_core_of = SOV
					is_owned_by = SOV
					SOV = { has_government = communism }
					SOV = { has_civil_war = no }
					OR = {
						AND = {
							NOT = { has_dynamic_modifier = { modifier = LSM_last_stand_modifier } }
							NOT = { has_dynamic_modifier = { modifier = LSM_dont_starve_modifier } }
							NOT = { has_dynamic_modifier = { modifier = LSM_recency_modifier } } 
							AND = {
								NOT = { 
									any_neighbor_state = { 
										controller = { is_in_faction_with = FROM.controller }
									}
								}
								NOT = { 
									any_neighbor_state = { 
										is_controlled_by = FROM.controller
									}
								}
								any_neighbor_state = {
									controller = { has_war_with = FROM.controller }
								}
							}
							OR = { 
								has_state_category = megalopolis
								has_state_category = metropolis
								has_state_category = large_city
								has_state_category = city
								has_state_category = large_town
								has_state_category = town
							}
							is_island_state = no
						}
						AND = {
							NOT = { has_dynamic_modifier = { modifier = LSM_last_stand_modifier } }
							NOT = { has_dynamic_modifier = { modifier = LSM_dont_starve_modifier } }
							NOT = { has_dynamic_modifier = { modifier = LSM_recency_modifier } }
							AND = {
								any_neighbor_state = {
									NOT = { 
										controller = { is_in_faction_with = FROM.controller } #kinda fucked
									}
								}
								any_neighbor_state = {
									controller = { has_war_with = FROM.controller }
								}
							}
							OR = { 
								AND =  { 
									FROM.controller = { surrender_progress > 0.05 } #ok the threat is there  
									OR = { 
										has_state_category = megalopolis
										has_state_category = metropolis
										has_state_category = large_city
										has_state_category = city
									}
								} 
								AND =  { 
									FROM.controller = { surrender_progress > 0.15 } #ok the threat is quite real  
									OR = { 
										has_state_category = megalopolis
										has_state_category = metropolis
										has_state_category = large_city
										has_state_category = city
										has_state_category = large_town
									}
								} 
								AND =  { 
									FROM.controller = { surrender_progress > 0.3 } #enemy at the gate  
									OR = { 
										has_state_category = megalopolis
										has_state_category = metropolis
										has_state_category = large_city
										has_state_category = city
										has_state_category = large_town
										has_state_category = town
									}
								}
							}
							any_other_country = { 
								AND = {
									has_war_with = FROM.controller
									divisions_in_state = { state = FROM size > 3 } #shit shit they are coming for us, be quick
								}
							}
							is_island_state = no
						}
					}
				}
			}
		}

still_have_trait_slot_for_this = {
	is_ai = yes
}


eligible_for_last_stand = {
			FROM = { 
				AND = {
					is_core_of = FROM.controller
					is_owned_by = FROM.controller
					NOT = { has_dynamic_modifier = { modifier = LSM_endsieg_modifier } }
					OR = {
						AND = {
							NOT = { has_dynamic_modifier = { modifier = LSM_last_stand_modifier } }
							NOT = { has_dynamic_modifier = { modifier = LSM_dont_starve_modifier } }
							NOT = { has_dynamic_modifier = { modifier = LSM_recency_modifier } }
							FROM.controller = { surrender_progress > 0.1 } #ok the threat is real  
							AND = {
								NOT = { 
									any_neighbor_state = { 
										controller = { is_in_faction_with = FROM.controller }
									}
								}
								NOT = { 
									any_neighbor_state = { 
										is_controlled_by = FROM.controller
									}
								}
								any_neighbor_state = {
									controller = { has_war_with = FROM.controller }
								}
							}
							OR = { 
								has_state_category = megalopolis
								has_state_category = metropolis
								has_state_category = large_city
								has_state_category = city
								has_state_category = large_town
								has_state_category = town
							}
							is_island_state = no
						}
						AND = {
							NOT = { has_dynamic_modifier = { modifier = LSM_last_stand_modifier } }
							NOT = { has_dynamic_modifier = { modifier = LSM_dont_starve_modifier } }
							NOT = { has_dynamic_modifier = { modifier = LSM_recency_modifier } }
							AND = {
								any_neighbor_state = {
									NOT = { 
										controller = { is_in_faction_with = FROM.controller } #kinda fucked
									}
								}
								any_neighbor_state = {
									controller = { has_war_with = FROM.controller }
								}
							}
							OR = { 
								AND =  { 
									FROM.controller = { surrender_progress > 0.1 } #ok the threat is there  
									OR = { 
										has_state_category = megalopolis
										has_state_category = metropolis
										has_state_category = large_city
										has_state_category = city
									}
								} 
								AND =  { 
									FROM.controller = { surrender_progress > 0.3 } #ok the threat is quite real  
									OR = { 
										has_state_category = megalopolis
										has_state_category = metropolis
										has_state_category = large_city
										has_state_category = city
										has_state_category = large_town
									}
								} 
								AND =  { 
									FROM.controller = { surrender_progress > 0.5 } #enemy at the gate  
									OR = { 
										has_state_category = megalopolis
										has_state_category = metropolis
										has_state_category = large_city
										has_state_category = city
										has_state_category = large_town
										has_state_category = town
									}
								}
							}
							any_other_country = { 
								AND = {
									has_war_with = FROM.controller
									divisions_in_state = { state = FROM size > 5 } #shit shit they are coming for us
								}
							}
							is_island_state = no
						}
						AND = {
							NOT = { has_dynamic_modifier = { modifier = LSM_last_stand_modifier } }
							NOT = { has_dynamic_modifier = { modifier = LSM_dont_starve_modifier } }
							NOT = { has_dynamic_modifier = { modifier = LSM_recency_modifier } }
							is_capital = yes
							is_island_state = no
							NOT = { is_fully_controlled_by = FROM.controller }
							OR = { 
								has_state_category = megalopolis
								has_state_category = metropolis
								has_state_category = large_city
								has_state_category = city
								has_state_category = large_town
								has_state_category = town
							}
						}
						AND = { #hardcore defence
							NOT = { has_dynamic_modifier = { modifier = LSM_enclave_last_stand_modifier } }
							NOT = { has_dynamic_modifier = { modifier = LSM_enclave_dont_starve_modifier } }
							NOT = { has_dynamic_modifier = { modifier = LSM_enclave_recency_modifier } }
							any_neighbor_state = {
								controller = { has_war_with = FROM.controller }
							}
							FROM.controller = { 
								OR = {
									AND = {  
										has_civil_war = no
										num_of_controlled_states < 2 #last stand, last chance, now or never
										OR = { 
											surrender_progress > 0 #ok the threat is real
											tag = LUX
										}
									}
									AND = { 
										has_civil_war = no
										num_of_controlled_states < 3 #last stand, last chance, now or never
										surrender_progress > 0.5 #ok the threat is real
									}
									AND = {  
										has_civil_war = no
										num_of_controlled_states < 5 #last stand, last chance, now or never
										surrender_progress > 0.7 #ok the threat is real
									}
									AND = { 
										has_civil_war = no 
										surrender_progress > 0.9 #the threat is very real
									}
								}
							}
							is_island_state = no
						}
						AND = {
							NOT = { has_dynamic_modifier = { modifier = LSM_enclave_last_stand_modifier } }
							NOT = { has_dynamic_modifier = { modifier = LSM_enclave_dont_starve_modifier } }
							NOT = { has_dynamic_modifier = { modifier = LSM_enclave_recency_modifier } }
							NOT = { has_dynamic_modifier = { modifier = LSM_island_recency_modifier } }
							NOT = { has_dynamic_modifier = { modifier = LSM_get_them_off_our_islands_modifier } }
							NOT = { has_dynamic_modifier = { modifier = LSM_no_cheesing_modifier } }
							any_other_country = { 
								AND = {
									has_war_with = FROM.controller
									divisions_in_state = { state = PREV size > 0 } #they have landed on our core islands
								}
							}
							is_island_state = yes
							FROM.controller = { 
								num_of_controlled_states < 2 #last stand, last chance, now or never
							}
						}
						AND = {
							is_island_state = no
							OR = { 
								NOT = { is_fully_controlled_by = FROM.controller }
								any_neighbor_state = {
									AND = { 
										is_owned_by = FROM.controller  
										NOT = { is_fully_controlled_by = FROM.controller } 																}
								}
							}
							FROM.controller = { 
								OR = { 
									tag = JAP #tennouheika banzai
									tag = ENG #we shall fight on the beach
									tag = VIN #cuz I am
								}
							}
							
						}	
					}
				}
			}
}
		
