############################
### ANOMALY CATEGORIES ###
############################

@distar_weight = 1

# Crashed Ship (Asteroid)
crashed_ship_asteroid_category = {
	desc = crashed_ship_asteroid_category_desc
	picture = GFX_evt_crashed_station
	level = 3

	spawn_chance = {
		modifier = {
			add = 3
			is_asteroid = yes
		}
	}

	on_success = {
		1 = anomaly.35
		1 = {
			modifier = {
				factor = 0
				from = { has_any_strategic_resource = yes }
			}
			anomaly_event = anomaly.65
		}
	}
}

# Unknown Origin (Asteroid)
origin_asteroid_category = {
	desc = "origin_asteroid_category_desc"
	picture = GFX_evt_mining_station
	level = 1

	spawn_chance = {
		modifier = {
			add = 3
			is_asteroid = yes
		}
	}

	on_success = {
		1 = {
			modifier = {
				factor = 0
				from = { has_any_strategic_resource = yes }
			}
			anomaly_event = anomaly.1
		}
		1 = anomaly.15
		0 = {
			modifier = {
				add = @distar_weight
				has_distar = yes
			}
			modifier = {
				factor = 0
				from = { has_any_strategic_resource = yes }
			}
			anomaly_event = distar.225
		}
	}
}

# Covered in Debris (Asteroid)
debris_asteroid_category = {
	desc = "debris_asteroid_category_desc"
	picture = GFX_evt_mining_station
	level = 3

	spawn_chance = {
		modifier = {
			add = 3
			is_asteroid = yes
			has_any_strategic_resource = no
		}
	}

	on_success = {
		1 = anomaly.30
		1 = anomaly.6800
	}
}

# Energy Emissions (Asteroid)
emissions_asteroid_category = {
	desc = "emissions_asteroid_category_desc"
	picture = GFX_evt_mining_station
	level = 1

	spawn_chance = {
		modifier = {
			add = 3
			is_asteroid = yes
		}
	}

	on_success = {
		1 = {
			modifier = {
				factor = 0
				from = { has_any_strategic_resource = yes }
			}
			anomaly_event = anomaly.50
		}
		1 = anomaly.60
	}
}

# Docking Hatch (Asteroid)
hatch_asteroid_category = {
	desc = "hatch_asteroid_category_desc"
	picture = GFX_evt_mining_station
	level = 3

	spawn_chance = {
		modifier = {
			add = 3
			is_asteroid = yes
		}
	}

	on_success = {
		1 = anomaly.5
		1 = {
			modifier = {
				factor = 0
				from = { has_any_strategic_resource = yes }
			}
			anomaly_event = anomaly.25
		}
	}
}

# Collision Asteroid (Asteroid)
collision_asteroid_category = {
	desc = "collision_asteroid_category_desc"
	picture = GFX_evt_mining_station
	level = 1

	spawn_chance = {
		modifier = {
			add = 3
			is_asteroid = yes
		}
	}

	max_once = yes

	on_success = {
		1 = {
			modifier = {
				factor = 0
				from = { has_any_strategic_resource = yes }
			}
			anomaly_event = anomaly.55
		}
		1 = anomaly.6805
	}
}

# Abandoned Station (Asteroid)
station_asteroid_category = {
	desc = "station_asteroid_category_desc"
	picture = GFX_evt_mining_station
	level = 3

	spawn_chance = {
		modifier = {
			add = 3
			is_asteroid = yes
			num_minerals > 0
		}
	}

	max_once = yes

	on_success = {
		1 = anomaly.40
		1 = anomaly.6810
	}
}

# Life Signs (Asteroid)
life_asteroid_category = {
	desc = "life_asteroid_category_desc"
	picture = GFX_evt_microscopic_life
	level = 2

	spawn_chance = {
		modifier = {
			add = 3
			is_asteroid = yes
			has_any_strategic_resource = no
		}
	}

	max_once = yes

	on_success = {
		1 = anomaly.10
		1 = anomaly.6825
	}
}

# Atmospheric Object (Gas Giant)
object_gasgiant_category = {
	desc = "object_gasgiant_category_desc"
	picture = GFX_evt_gas_giant_station
	level = 4

	spawn_chance = {
		modifier = {
			add = 3
			is_planet_class = pc_gas_giant
		}
	}

	on_success = {
		1 = anomaly.325
		1 = anomaly.335
	}
}

# Promising Moon (Gas Giant)
moon_gasgiant_category = {
	desc = "moon_gasgiant_category_desc"
	picture = GFX_evt_ship_in_orbit_3
	level = 1

	spawn_chance = {
		modifier = {
			add = 3
			is_planet_class = pc_gas_giant
			has_any_strategic_resource = no
		}
	}

	max_once = yes

	on_success = {
		1 = anomaly.340
		0 = {
			modifier = {
				add = 10
				FROM = { has_ring = no }
			}
			anomaly_event = anomaly.6840
		}
	}
}

# Life Signs (Gas Giant)
life_gasgiant_category = {
	desc = "life_gasgiant_category_desc"
	picture = GFX_evt_atmospheric_flight
	level = 2

	spawn_chance = {
		modifier = {
			add = 3
			is_planet_class = pc_gas_giant
			has_any_strategic_resource = no
		}
	}

	max_once = yes

	on_success = {
		1 = anomaly.300
		1 = anomaly.6845
	}
}

# Atmospheric Storms (Gas Giant)
storms_gasgiant_category = {
	desc = "storms_gasgiant_category_desc"
	picture = GFX_evt_atmospheric_flight
	level = 1

	spawn_chance = {
		modifier = {
			add = 3
			is_planet_class = pc_gas_giant
		}
	}

	on_success = {
		1 = anomaly.330
		0 = {
			modifier = {
				add = 1
				owner = {
					count_owned_ship = {
						limit = { is_ship_class = shipclass_science_ship }
						count > 1
					}
				}
			}
			anomaly_event = anomaly.6855
		}
	}
}


aerostat_gasgiant_category = {
	desc = "aerostat_gasgiant_category_desc"
	picture = GFX_evt_gas_giant_station
	level = 1

	spawn_chance = {
		modifier = {
			add = 3
			is_planet_class = pc_gas_giant
		}
	}

	on_success = {
		1 = anomaly.310
		1 = anomaly.315
	}
}


cargo_gasgiant_category = {
	desc = "cargo_gasgiant_category_desc"
	picture = GFX_evt_ship_in_orbit
	level = 1

	spawn_chance = {
		modifier = {
			add = 3
			is_planet_class = pc_gas_giant
		}
	}

	on_success = {
		1 = anomaly.305
		1 = anomaly.6865
	}
}


debris_gasgiant_category = {
	desc = "debris_gasgiant_category_desc"
	picture = GFX_evt_ruined_system
	level = 1

	spawn_chance = {
		modifier = {
			add = 3
			is_planet_class = pc_gas_giant
			has_any_strategic_resource = no
		}
	}

	on_success = {
		0 = {
			modifier = {
				add = 1
				OR = {
					any_system = {
						OR = {
							has_star_flag = com_sol
							has_star_flag = nuked_sol
						}
					}
					any_country = {
						OR = {
							has_country_flag = human_1
							has_country_flag = humans_early_space_age
						}
					}
				}
				owner = {
					is_human_prescripted_empire = no
					is_human_species = no
				}
			}
			anomaly_event = distar.1055
		}
		1 = anomaly.320
	}
}


impact_uninhabitable_category = {
	desc = "impact_uninhabitable_category_desc"
	picture = GFX_evt_nuclear_explosion
	level = 2

	spawn_chance = {
		modifier = {
			add = 3
			uninhabitable_regular_planet = yes
		}
	}

	on_success = {
		1 = {
			modifier = {
				factor = 0
				from = { has_any_strategic_resource = yes }
			}
			anomaly_event = anomaly.600
		}
		1 = anomaly.605
	}
}


energy_uninhabitable_category = {
	desc = "energy_uninhabitable_category_desc"
	picture = GFX_evt_ship_in_orbit_3
	level = 2

	spawn_chance = {
		modifier = {
			add = 3
			uninhabitable_regular_planet = yes
		}
	}

	on_success = {
		1 = {
			modifier = {
				factor = 0
				from = { has_any_strategic_resource = yes }
			}
			anomaly_event = anomaly.610
		}
		1 = anomaly.615
		1 = anomaly.655
		1 = distar.1040
	}
}


signal_uninhabitable_category = {
	desc = "signal_uninhabitable_category_desc"
	picture = GFX_evt_ship_in_orbit_2
	level = 2

	spawn_chance = {
		modifier = {
			add = 3
			uninhabitable_regular_planet = yes
		}
	}

	on_success = {
		1 = anomaly.625
		1 = anomaly.630
	}
}

# Asteroid in Orbit (Uninhabitable Planet)
asteroid_uninhabitable_category = {
	desc = "asteroid_uninhabitable_category_desc"
	picture = GFX_evt_asteroid_approaching_planet
	level = 1

	spawn_chance = {
		modifier = {
			add = 3
			uninhabitable_regular_planet = yes
		}
		modifier = {
			factor = 0
			is_moon = yes
		}
	}

	on_success = {
		1 = {
			modifier = {
				factor = 0
				from = { has_any_strategic_resource = yes }
			}
			anomaly_event = anomaly.660
		}
		1 = anomaly.6875
	}
}

# Solar Sailer (Uninhabitable Planet)
solar_uninhabitable_category = {
	desc = "solar_uninhabitable_category_desc"
	picture = GFX_evt_ship_in_orbit
	level = 2

	spawn_chance = {
		modifier = {
			add = 2
			uninhabitable_regular_planet = yes
		}
	}

	on_success = anomaly.650
}

# Life Signs (Toxic Planet)
life_toxic_category = {
	desc = "life_toxic_category_desc"
	picture = GFX_evt_microscopic_life
	level = 2

	spawn_chance = {
		modifier = {
			add = 3
			is_planet_class = pc_toxic
			has_any_strategic_resource = no
		}
	}

	on_success = {
		1 = anomaly.690
		1 = anomaly.6895
	}
}


life_frozen_category = {
	desc = "life_frozen_category_desc"
	picture = GFX_evt_microscopic_life
	level = 2

	spawn_chance = {
		modifier = {
			add = 3
			is_planet_class = pc_frozen
			has_any_strategic_resource = no
		}
	}

	on_success = {
		1 = anomaly.2510
		1 = anomaly.6900
	}

}


life_barren_category = {
	desc = "life_barren_category_desc"
	picture = GFX_evt_microscopic_life
	level = 2

	spawn_chance = {
		modifier = {
			add = 3
			OR = {
				is_planet_class = pc_barren
				is_planet_class = pc_barren_cold
			}
			has_any_strategic_resource = no
		}
	}

	on_success = anomaly.695
}


#station_uninhabitable_category = {
#	desc = "station_uninhabitable_category_desc"
#	picture = GFX_evt_ship_travel
#	level = 1
#
#	spawn_chance = {
#		modifier = {
#			add = 3
#			uninhabitable_regular_planet = yes
#			num_minerals > 0
#			exists = space_owner
#			space_owner = { is_same_value = from.owner }
#		}
#	}
#
#	on_success = anomaly.700
#}


battle_uninhabitable_category = {
	desc = "battle_uninhabitable_category_desc"
	picture = GFX_evt_small_space_battle
	level = 4

	spawn_chance = {
		modifier = {
			add = 3
			uninhabitable_regular_planet = yes
			has_any_strategic_resource = no
		}
	}

	on_success = anomaly.2530
}


shipyard_uninhabitable_category = {
	desc = "shipyard_uninhabitable_category_desc"
	picture = GFX_evt_ruined_system
	level = 4

	spawn_chance = {
		modifier = {
			add = 1
			uninhabitable_regular_planet = yes
		}
	}

	on_success = anomaly.2550
}


inhabited_toxic_category = {
	desc = "inhabited_toxic_category_desc"
	picture = GFX_evt_relic_world_street
	level = 1

	spawn_chance = {
		modifier = {
			add = 3
			is_planet_class = pc_toxic
			has_any_strategic_resource = no
		}
	}

	on_success = {
		1 = anomaly.670
		1 = anomaly.685
	}
}


writing_uninhabitable_category = {
	desc = "writing_uninhabitable_category_desc"
	picture = GFX_evt_ship_in_orbit
	level = 2

	spawn_chance = {
		modifier = {
			add = 3
			uninhabitable_regular_planet = yes
			has_any_strategic_resource = no
		}
	}

	on_success = anomaly.635
}


beacon_uninhabitable_category = {
	desc = "beacon_uninhabitable_category_desc"
	picture = GFX_evt_ship_in_orbit
	level = 1

	spawn_chance = {
		modifier = {
			add = 3
			uninhabitable_regular_planet = yes
			has_any_strategic_resource = no
		}
	}

	on_success = anomaly.705
}


mountain_uninhabitable_category = {
	desc = "mountain_uninhabitable_category_desc"
	picture = GFX_evt_ship_in_orbit_3
	level = 3

	spawn_chance = {
		modifier = {
			add = 3
			uninhabitable_regular_planet = yes
			has_any_strategic_resource = no
		}
	}

	on_success = {
		1 = anomaly.2520
		1 = anomaly.6905
	}
}


object_uninhabitable_category = {
	desc = "object_uninhabitable_category_desc"
	picture = GFX_evt_ship_in_orbit_2
	level = 2

	spawn_chance = {
		modifier = {
			add = 3
			uninhabitable_regular_planet = yes
			has_any_strategic_resource = no
		}
	}

	on_success = anomaly.2540
}


signal_gasgiant_category = {
	desc = "signal_gasgiant_category_desc"
	picture = GFX_evt_atmospheric_flight
	level = 5

	spawn_chance = {
		modifier = {
			add = 1
			is_planet_class = pc_gas_giant
		}
	}

	max_once_global = yes

	on_success = anomaly.5000
}


ship_gasgiant_category = {
	desc = "ship_gasgiant_category_desc"
	picture = GFX_evt_atmospheric_flight
	level = 5

	spawn_chance = {
		modifier = {
			add = 3
			is_planet_class = pc_gas_giant
		}
	}

	on_success = anomaly.2560
}


terminal_gasgiant_category = {
	desc = "terminal_gasgiant_category_desc"
	picture = GFX_evt_ship_in_orbit_3
	level = 5
	#risk = 30

	spawn_chance = {
		modifier = {
			add = 3
			is_planet_class = pc_gas_giant
			is_moon = no
		}
	}

	on_success = anomaly.2570
}


sol_wasteland_category = {
	desc = "sol_wasteland_category_desc"
	picture = GFX_evt_city_ruins
	level = 1

	#Spawn set via initialisers

	on_success = galactic_features.104
}

living_metal_category = {
	desc = "living_metal_category_desc"
	picture = GFX_evt_cold_barren
	level = 7

	should_ai_and_humans_use = yes

	spawn_chance = {
		modifier = {
			add = 0.1
			OR = {
				is_planet_class = pc_barren
				is_planet_class = pc_barren_cold
				is_asteroid = yes
			}
			has_any_strategic_resource = no
		}
		modifier = {
			factor = 0
			OR = {
				has_deposit_for = shipclass_mining_station
				has_deposit_for = shipclass_research_station
			}
		}
	}

	on_success = anomaly.2576
}

the_lonely_bot_category = {
	desc = "the_lonely_bot_category_desc"
	picture = "GFX_evt_alien_ruins"

	max_once_global = yes

	level = 3

	spawn_chance = {
		modifier = {
			add = 0.1
			colonizable_planet = yes
			years_passed > 10
		}
		modifier = {
			factor = 3
			is_planet_class = pc_relic
		}
		modifier = {
			factor = 0
			OR = {
				from.owner = { is_gestalt = yes }
				is_artificial = yes
			}
		}
	}

	on_success = anomaly.2580
}

# Fungal Emitters
fungal_emitters_category = {
	desc = "fungal_emitters_category_desc"
	picture = GFX_evt_cold_barren
	level = 4

	spawn_chance = {
		modifier = {
			add = 30
			is_planet_class = pc_barren
			has_global_flag = fumongus_spawned
			closest_system = {
				limit = {
					has_star_flag = fumongus_system
				}
				min_steps = 1
				max_steps = 12
			}
		}
	}

	on_success = {
		1 = {
			modifier = {
				factor = 0
				owner = { has_global_flag = fumongus_resolved }
			}
			anomaly_event = anomaly.6755
		}
		1 = {
			modifier = {
				factor = 0
				owner = {
					NAND = {
						has_global_flag = fumongus_resolved
						has_global_flag = fumongus_active
					}
				}
			}
			anomaly_event = anomaly.6760
		}
		1 = {
			modifier = {
				factor = 0
				owner = {
					NAND = {
						has_global_flag = fumongus_dismantled
						has_global_flag = fumongus_resolved
					}
				}
			}
			anomaly_event = anomaly.6765
		}
	}
}

lost_soul_cat = {
	desc = "lost_soul_cat_desc"
	picture = GFX_evt_star_neutron
	level = 2
	spawn_chance = {
		modifier = {
			add = 3
			is_asteroid = yes
		}
	}
	on_success = anomaly.6786
}

on_solar_sails_cat = {
	desc = "on_solar_sails_cat_desc"
	picture = GFX_evt_star_neutron
	level = 2
	max_once_global = yes
	spawn_chance = {
		modifier = {
			add = 0.1
			from.leader = {
				species = {
					NOT = { has_aquatic_trait = yes }
				}
			}
		}
		modifier = {
			add = 0.3
			from.leader = {
				species = { has_aquatic_trait = yes }
			}
		}
		modifier = {
			factor = 0
			from.owner = { is_gestalt = yes }
		}
	}
	on_success = anomaly.7020
}

on_crashed_ship_cat = {
	desc = "on_crashed_ship_desc"
	picture = GFX_evt_physics_cache
	level = 2
	spawn_chance = {
		modifier = {
			add = 3
			is_asteroid = yes
		}
		modifier = {
			factor = 0
			from.owner = { is_gestalt = yes }
		}
	}
	on_success = anomaly.7030
}
