@ARCHAEOLOGICAL_SITE_XP_0_CLUE = 10
@ARCHAEOLOGICAL_SITE_XP_1_CLUE = 25
@ARCHAEOLOGICAL_SITE_XP_2_CLUE = 40

######################
# DICE ROLL FUNCTIONS
######################

standard_archaeological_site_on_roll_failed_range_entry = {
	custom_tooltip_with_params = {
		description = "ARCHAEOLOGICAL_SITE_ON_ROLL_FAILED_RANGE"
		description_parameters = {
			"MIN" = $MIN$
			"MAX" = $MAX$
			"CLUES" = $CLUES$
			"CHANCE" = @\[( 2 + ( $MAX$ + $DIE_MAX$ - |$MAX$ - $SCORE$ - $DIE_MAX$| ) - ( $MIN$ + $DIE_MIN$ + |$MIN$ - $SCORE$ - $DIE_MIN$| ) ) / ( 2*( $DIE_MAX$ - $DIE_MIN$ + 1 ) )]
			"SCORE" = $SCORE$
		}
	}
}

standard_archaeological_site_on_roll_failed_greater_than_eq_entry = {
	custom_tooltip_with_params = {
		description = "ARCHAEOLOGICAL_SITE_ON_ROLL_FAILED_GREATER_THAN_EQ"
		description_parameters = {
			"MIN" = $MIN$
			"CHANCE" = @\[( $SCORE$ - $MIN$ + $DIE_MAX$ + 1 ) / ( $DIE_MAX$ - $DIE_MIN$ + 1 )]
			"SCORE" = $SCORE$
		}
	}
}

standard_archaeological_site_on_roll_failed_less_than_eq_entry = {
	custom_tooltip_with_params = {
		description = "ARCHAEOLOGICAL_SITE_ON_ROLL_FAILED_LESS_THAN_EQ"
		description_parameters = {
			"MAX" = $MAX$
			"CLUES" = $CLUES$
			"CHANCE" = @\[( ( $MAX$ - $SCORE$ - $DIE_MIN$ + 1 ) / ( $DIE_MAX$ - $DIE_MIN$ + 1 ) )]
			"SCORE" = $SCORE$
		}
	}
}

standard_archaeological_site_on_roll_failed_case = {
	optimize_memory
	custom_tooltip_with_params = {
		description = archaeology_roll_header
		description_parameters = {
			"SCORE" = $SCORE$
		}
	}
	standard_archaeological_site_on_roll_failed_less_than_eq_entry = { MAX=5 CLUES=0 SCORE=$SCORE$ DIE_MIN=1 DIE_MAX=10 }
	standard_archaeological_site_on_roll_failed_range_entry = { MIN=6 MAX=10 CLUES=1 SCORE=$SCORE$ DIE_MIN=1 DIE_MAX=10 }
	standard_archaeological_site_on_roll_failed_range_entry = { MIN=11 MAX=13 CLUES=2 SCORE=$SCORE$ DIE_MIN=1 DIE_MAX=10 }
	standard_archaeological_site_on_roll_failed_greater_than_eq_entry = { MIN=14 SCORE=$SCORE$ DIE_MIN=1 DIE_MAX=10 }
}

standard_archaeological_site_on_roll_failed = {
	optimize_memory
	switch = {
		trigger = is_site_current_stage_score_no_die
		-8 = { standard_archaeological_site_on_roll_failed_case = { SCORE=-8 } }
		-7 = { standard_archaeological_site_on_roll_failed_case = { SCORE=-7 } }
		-6 = { standard_archaeological_site_on_roll_failed_case = { SCORE=-6 } }
		-5 = { standard_archaeological_site_on_roll_failed_case = { SCORE=-5 } }
		-4 = { standard_archaeological_site_on_roll_failed_case = { SCORE=-4 } }
		-3 = { standard_archaeological_site_on_roll_failed_case = { SCORE=-3 } }
		-2 = { standard_archaeological_site_on_roll_failed_case = { SCORE=-2 } }
		-1 = { standard_archaeological_site_on_roll_failed_case = { SCORE=-1 } }
		0 = { standard_archaeological_site_on_roll_failed_case = { SCORE=0 } }
		1 = { standard_archaeological_site_on_roll_failed_case = { SCORE=1 } }
		2 = { standard_archaeological_site_on_roll_failed_case = { SCORE=2 } }
		3 = { standard_archaeological_site_on_roll_failed_case = { SCORE=3 } }
		4 = { standard_archaeological_site_on_roll_failed_case = { SCORE=4 } }
		5 = { standard_archaeological_site_on_roll_failed_case = { SCORE=5 } }
		6 = { standard_archaeological_site_on_roll_failed_case = { SCORE=6 } }
		7 = { standard_archaeological_site_on_roll_failed_case = { SCORE=7 } }
		8 = { standard_archaeological_site_on_roll_failed_case = { SCORE=8 } }
		9 = { standard_archaeological_site_on_roll_failed_case = { SCORE=9 } }
		10 = { standard_archaeological_site_on_roll_failed_case = { SCORE=10 } }
		11 = { standard_archaeological_site_on_roll_failed_case = { SCORE=11 } }
		12 = { standard_archaeological_site_on_roll_failed_case = { SCORE=12 } }
		13 = { standard_archaeological_site_on_roll_failed_case = { SCORE=13 } }
		14 >= { standard_archaeological_site_on_roll_failed_case = { SCORE=14 } }
	}
	hidden_effect = {
		switch = {
			trigger = is_site_current_stage_score
			5 <= {
				prev = {
					leader = { add_experience = @ARCHAEOLOGICAL_SITE_XP_0_CLUE }
					random_list = {
						120 = {}
						10 = {
							modifier = {
								factor = 0
								from = {
									is_current_stage_clues = 0
								}
							}
							$RANDOM_EVENTS$ = yes
						}
					}
				}
			}
			10 <= { add_stage_clues = 1 prev = { leader = { add_experience = @ARCHAEOLOGICAL_SITE_XP_1_CLUE } } }
			13 <= { add_stage_clues = 2 prev = { leader = { add_experience = @ARCHAEOLOGICAL_SITE_XP_2_CLUE } } }
		}
	}
}

##########
# REWARDS
##########

small_artifact_reward = {
	if = {
		limit = { has_ancrel = yes }
		custom_tooltip = minor_artifacts_found
		locked_random_list = {
			33 = {
				owner = { add_resource = { minor_artifacts = 50 } }
			}
			33 = {
				owner = { add_resource = { minor_artifacts = 150 } }
			}
			33 = {
				owner = { add_resource = { minor_artifacts = 250 } }
			}
		}
		hidden_effect = {
			owner = { country_event = { id = tutorial.1337 days = 5 } }
		}
	}
}

medium_artifact_reward = {
	if = {
		limit = { has_ancrel = yes }
		custom_tooltip = minor_artifacts_found
		locked_random_list = {
			33 = {
				owner = { add_resource = { minor_artifacts = 300 } }
			}
			33 = {
				owner = { add_resource = { minor_artifacts = 400 } }
			}
			33 = {
				owner = { add_resource = { minor_artifacts = 500 } }
			}
		}
		hidden_effect = {
			owner = { country_event = { id = tutorial.1337 days = 5 } }
		}
	}
}

large_artifact_reward = {
	if = {
		limit = { has_ancrel = yes }
		custom_tooltip = minor_artifacts_found
		locked_random_list = {
			33 = {
				owner = { add_resource = { minor_artifacts = 750 } }
			}
			33 = {
				owner = { add_resource = { minor_artifacts = 1000 } }
			}
			33 = {
				owner = { add_resource = { minor_artifacts = 1500 } }
			}
		}
		hidden_effect = {
			owner = { country_event = { id = tutorial.1337 days = 5 } }
		}
	}
}

great_artifact_reward = {
	if = {
		limit = { has_ancrel = yes }
		custom_tooltip = minor_artifacts_found
		locked_random_list = {
			33 = {
				owner = { add_resource = { minor_artifacts = 2500 } }
			}
			33 = {
				owner = { add_resource = { minor_artifacts = 3750 } }
			}
			33 = {
				owner = { add_resource = { minor_artifacts = 5000 } }
			}
		}
		hidden_effect = {
			owner = { country_event = { id = tutorial.1337 days = 5 } }
		}
	}
}

###################
# SCRIPTED EFFECTS
###################

relic_world_deposits = {
	reset_planet = yes
	clear_deposits = yes
	add_deposit = d_relic_dense_ruins
	add_deposit = d_collapsed_spire
	add_deposit = d_massive_crevice
	add_deposit = d_shattered_solar_array
	add_deposit = d_flooded_reactor_pits
	add_deposit = d_crumbling_mining_tunnels
	add_deposit = d_relic_metal_boneyard
	prevent_anomaly = yes
}

create_grand_herald = {
	custom_tooltip = get_herald
	hidden_effect = {
		owner = {
			create_fleet = {
				name = "NAME_Grand_Herald"
				settings = {
					spawn_debris = no
				}
				effect = {
					set_owner = prev
					create_ship_design = {
						design = "NAME_Herald"
					}
					create_ship_with_random_graphical_culture = {
						EFFECT_NAME = create_grand_herald_ship
					}
					set_location = fromfrom.planet
					set_herald_damage = yes
				}
			}
		}
	}
}

create_grand_herald_ship = {
	create_ship = {
		name = "NAME_Grand_Herald"
		design = last_created_design
		graphical_culture = $SHIPSET$
		prefix = no
		upgradable = no
	}
}

set_herald_damage = {
	random_list = {
		5 = {
			#
		}
		25 = {
			add_modifier = {
				modifier = herald_75
				days = -1
			}
			owner = {
				enable_special_project = {
					name = "Herald_repair"
				}
			}
		}
		50 = {
			add_modifier = {
				modifier = herald_50
				days = -1
			}
			owner = {
				enable_special_project = {
					name = "Herald_repair"
				}
			}
		}
		20 = {
			add_modifier = {
				modifier = herald_25
				days = -1
			}
			owner = {
				enable_special_project = {
					name = "Herald_repair"
				}
			}
		}
	}
}

remove_herald_damage = {
	every_controlled_fleet = {
		remove_modifier = herald_75
		remove_modifier = herald_50
		remove_modifier = herald_25
	}
}

##################################
# ARCSITE RANDOM EVENTS (GENERIC)
##################################

# You may assume an event is valid for any planet-bound dig site, "Ancient Relics" or not, unless otherwise stated below:

# ancrel.8000-8003	Laser Grid Triggered
# ancrel.8010-8013	Sentry Guns Triggered
# ancrel.8020-8023	Rampaging Crusher-Droid
# ancrel.8030-8033	Sentinel Droids
# ancrel.8040		Resource Cache
# ancrel.8045		Hidden Passage
# ancrel.8050		Lost [Previous] Expedition
# ancrel.8055		Bickering Archaeologists (regular empires only)
# ancrel.8060		Treasure Chamber
# ancrel.8065		Spreading Illness (organic species only)
# ancrel.8070		Equipment Malfunction
# ancrel.8075		Without a Trace [Scientist Vanishes]
# ancrel.8080		Minor Artifacts Discovered ("Ancient Relics")
# ancrel.8090-8093	Hostile Wildlife
# ancrel.8100-8103	Unstable Ruins
# ancrel.8110		Ancient Records
# ancrel.8200-8203	Explosive Decompression (orbital dig sites only)
# ancrel.8210		Minor Artifacts Discovered ("Ancient Relics" | orbital dig sites only)
# ancrel.8215		Unexpected Lockout (orbital dig sites only)
# ancrel.8300-8315	Fungal Zombies (regular empires only | non-oceanic planets)
# ancrel.13030		Disturbing Vision (organic species only)
# ancrel.15006		Bushwhacked! (regular empires only | tropical planets)
# ancrel.15008		Bush Party (regular empires only | tropical planets)

all_random_events = {
	random_list = {
		10 = { site_laser_grid_trap = yes }
		10 = { site_sentry_guns_trap = yes }
		10 = { site_crusher_droids_trap = yes }
		10 = { site_guardian_droids_trap = yes }
		10 = {
			modifier = {
				factor = 0
				from = {
					planet = { habitable_planet = no }
				}
			}
			site_wildlife = yes
		}
		10 = { site_collapsed_roof = yes }
		10 = { fleet_event = { id = ancrel.8040 } }
		10 = { fleet_event = { id = ancrel.8045 } }
		10 = { fleet_event = { id = ancrel.8050 } }
		10 = { fleet_event = { id = ancrel.8055 } }
		10 = { fleet_event = { id = ancrel.8060 } }
		10 = {
			modifier = {
				factor = 0
				owner = { is_machine_empire = yes }
			}
			fleet_event = { id = ancrel.8065 } # Organics only
		}
		10 = {
			fleet_event = { id = ancrel.8070 }
			modifier = {
				factor = 2
				leader = { has_trait = leader_trait_percussive_maintainer }
			}
		}
		2 = { fleet_event = { id = ancrel.8075 } } # Scientist vanishes
		10 = { fleet_event = { id = ancrel.8080 } }
		10 = { fleet_event = { id = ancrel.8110 } }
		10 = {
			modifier = {
				factor = 0
				OR = {
					from.planet = {
						NOT = { is_planet_class = pc_nuked }
					}
					leader.species = {
						has_trait = trait_pc_nuked_preference
					}
					owner = { is_machine_empire = yes }
				}
			}
			fleet_event = { id = federations2.701 }
		}
		5 = {
			modifier = {
				factor = 0
				owner = {
					OR = {
						is_gestalt = yes
						country_uses_food = no
						has_country_flag = triggered_sentinels_random_event
					}
				}
			}
			fleet_event = { id = ancrel.4078 } # Fire (food shortages)
		}
		10 = {
			modifier = {
				factor = 0
				owner = { is_gestalt = yes }
			}
			fleet_event = { id = ancrel.13030 } #Disturbing Vision
		}
		# Bespoke Random Events
		20 = { # Whispers in the Stone
			modifier = {
				factor = 0
				NOT = {
					From = {
						is_site_type = lithoids_digsite
					}
				}
				Owner = {
					has_country_flag = triggered_lithoids_special_event
				}
			}
			modifier = {
				factor = 0
				NOT = { exists = leader }
			}
			fleet_event = { id = ancrel.4006 }
		}
		20 = { # The Rubricator
			modifier = {
				factor = 0
				NOT = {
					From = {
						is_site_type = rubricator_digsite
					}
				}
				Owner = {
					has_country_flag = triggered_rubricator_random_event
				}
			}
			fleet_event = { id = ancrel.4021 }
		}
	}
}

# GENERIC POOLS

site_traps = {
	random_list = {
		25 = { site_laser_grid_trap = yes }
		25 = { site_sentry_guns_trap = yes }
		25 = { site_crusher_droids_trap = yes }
		25 = { site_guardian_droids_trap = yes }
	}
}

site_laser_grid_trap = {
	random_list = {
		5 = { fleet_event = { id = ancrel.8000 } }
		25 = { fleet_event = { id = ancrel.8001 } }
		25 = { fleet_event = { id = ancrel.8002 } }
		25 = { fleet_event = { id = ancrel.8003 } }
	}
}

site_sentry_guns_trap = {
	random_list = {
		5 = { fleet_event = { id = ancrel.8010 } }
		25 = { fleet_event = { id = ancrel.8011 } }
		25 = { fleet_event = { id = ancrel.8012 } }
		25 = { fleet_event = { id = ancrel.8013 } }
	}
}

site_crusher_droids_trap = {
	random_list = {
		5 = { fleet_event = { id = ancrel.8020 } }
		25 = { fleet_event = { id = ancrel.8021 } }
		25 = { fleet_event = { id = ancrel.8022 } }
		25 = { fleet_event = { id = ancrel.8023 } }
	}
}

site_guardian_droids_trap = {
	random_list = {
		5 = { fleet_event = { id = ancrel.8030 } }
		25 = { fleet_event = { id = ancrel.8031 } }
		25 = { fleet_event = { id = ancrel.8032 } }
		25 = { fleet_event = { id = ancrel.8033 } }
	}
}

site_wildlife = {
	random_list = {
		5 = { fleet_event = { id = ancrel.8090 } }
		25 = { fleet_event = { id = ancrel.8091 } }
		25 = { fleet_event = { id = ancrel.8092 } }
		25 = { fleet_event = { id = ancrel.8093 } }
	}
}

site_collapsed_roof = { #Unstable Ruins
	random_list = {
		5 = { fleet_event = { id = ancrel.8100 } }
		25 = { fleet_event = { id = ancrel.8101 } }
		25 = { fleet_event = { id = ancrel.8102 } }
		25 = { fleet_event = { id = ancrel.8103 } }
	}
}

site_ocean_sites_random_events = {
	random_list = {
		10 = { fleet_event = { id = ancrel.8055 } }
		10 = { fleet_event = { id = ancrel.8075 } }
		#Hostile Wildlife
		10 = { fleet_event = { id = ancrel.8090 } }
		10 = { fleet_event = { id = ancrel.8091 } }
		10 = { fleet_event = { id = ancrel.8092 } }
		10 = { fleet_event = { id = ancrel.8093 } }
	}
}

# ORBITAL DIG SITES

space_station_random_events = {
	random_list = {
		10 = { fleet_event = { id = ancrel.8055 } }
		10 = {
			fleet_event = { id = ancrel.8070 }
			modifier = {
				factor = 2
				leader = { has_trait = leader_trait_percussive_maintainer }
			}
		}
		10 = { site_explosive_decompression = yes }
		10 = {
			modifier = {
				factor = 0
				has_ancrel = no
			}
			fleet_event = { id = ancrel.8210 } #Minor Artifacts Discovered
		}
		10 = { fleet_event = { id = ancrel.8215 } }
	}
}

site_explosive_decompression = {
	random_list = {
		5 = {
			fleet_event = { id = ancrel.8200 }
			modifier = {
				factor = 0
				leader.species = { is_robotic = yes }
			}
		}
		25 = {
			fleet_event = { id = ancrel.8201 }
			modifier = {
				factor = 0
				owner_species = { is_robotic = yes }
			}
		}
		25 = { fleet_event = { id = ancrel.8202 } }
		25 = { fleet_event = { id = ancrel.8203 } }
	}
}

###############################
# ORIGIN ARCSITE RANDOM EVENTS
###############################

# GALACTIC DOORSTEP (base game)

site_from_gateway_sent_random_events = {
	random_list = {
		10 = { fleet_event = { id = ancrel.8040 } }
		10 = { fleet_event = { id = ancrel.8045 } }
		10 = { fleet_event = { id = ancrel.8050 } }
		10 = { fleet_event = { id = ancrel.8055 } }
		10 = { fleet_event = { id = ancrel.8060 } }
		10 = {
			modifier = {
				factor = 0
				leader.species = { is_robotic = yes }
			}
			fleet_event = { id = ancrel.8065 } #Spreading Illness
		}
		10 = {
			fleet_event = { id = ancrel.8070 }
			modifier = {
				factor = 2
				leader = { has_trait = leader_trait_percussive_maintainer }
			}
		}
		10 = { fleet_event = { id = ancrel.8075 } }
		10 = {
			modifier = {
				factor = 0
				has_ancrel = no
			}
			fleet_event = { id = ancrel.8080 } #Minor Artifacts Discovered
		}
		10 = { fleet_event = { id = ancrel.8100 } }
		10 = { fleet_event = { id = ancrel.8101 } }
		10 = { fleet_event = { id = ancrel.8102 } }
		10 = { fleet_event = { id = ancrel.8103 } }
		10 = { fleet_event = { id = ancrel.8110 } }
	}
}

# ON THE SHOULDERS OF GIANTS (Federations)
# Note: the origin itself is already blocked for gestalts

site_ex_gravitas_random_events = {
	random_list = {
		10 = { fleet_event = { id = ancrel.8055 } }
		10 = {
			fleet_event = { id = ancrel.8070 }
			modifier = {
				factor = 2
				leader = { has_trait = leader_trait_percussive_maintainer }
			}
		}
		10 = { fleet_event = { id = ancrel.8075 } }
	}
}

site_something_waiting_random_events = {
	random_list = {
		10 = { fleet_event = { id = ancrel.8040 } }
		10 = { fleet_event = { id = ancrel.8045 } }
		10 = { fleet_event = { id = ancrel.8055 } }
		10 = {
			fleet_event = { id = ancrel.8070 }
			modifier = {
				factor = 2
				leader = { has_trait = leader_trait_percussive_maintainer }
			}
		}
		10 = { fleet_event = { id = ancrel.8075 } }
		10 = {
			modifier = {
				factor = 0
				has_ancrel = no
			}
			fleet_event = { id = ancrel.8080 } #Minor Artifacts Discovered
		}
		10 = { fleet_event = { id = ancrel.8100 } }
		10 = { fleet_event = { id = ancrel.8101 } }
		10 = { fleet_event = { id = ancrel.8102 } }
		10 = { fleet_event = { id = ancrel.8103 } }
		10 = { fleet_event = { id = ancrel.8110 } }
	}
}

site_buried_deep_random_events = {
	random_list = {
		10 = { fleet_event = { id = ancrel.8040 } }
		10 = { fleet_event = { id = ancrel.8055 } }
		10 = {
			fleet_event = { id = ancrel.8070 }
			modifier = {
				factor = 2
				leader = { has_trait = leader_trait_percussive_maintainer }
			}
		}
		10 = { fleet_event = { id = ancrel.8100 } }
		10 = { fleet_event = { id = ancrel.8101 } }
	}
}

site_in_memoriam_random_events = {
	random_list = {
		10 = { fleet_event = { id = ancrel.8000 } }
		10 = { fleet_event = { id = ancrel.8001 } }
		10 = { fleet_event = { id = ancrel.8040 } }
		10 = { fleet_event = { id = ancrel.8045 } }
		10 = { fleet_event = { id = ancrel.8060 } }
		10 = { fleet_event = { id = ancrel.8075 } }
		10 = {
			modifier = {
				factor = 0
				has_ancrel = no
			}
			fleet_event = { id = ancrel.8080 } #Minor Artifacts Discovered
		}
		10 = { fleet_event = { id = ancrel.8100 } }
		10 = { fleet_event = { id = ancrel.8101 } }
		10 = { fleet_event = { id = ancrel.8102 } }
		10 = { fleet_event = { id = ancrel.8103 } }
	}
}

site_the_last_stand_random_events = {
	random_list = {
		10 = { fleet_event = { id = ancrel.8000 } }
		10 = { fleet_event = { id = ancrel.8001 } }
		10 = { fleet_event = { id = ancrel.8040 } }
		10 = { fleet_event = { id = ancrel.8045 } }
		10 = { fleet_event = { id = ancrel.8055 } }
		10 = { fleet_event = { id = ancrel.8060 } }
		10 = {
			fleet_event = { id = ancrel.8070 }
			modifier = {
				factor = 2
				leader = { has_trait = leader_trait_percussive_maintainer }
			}
		}
		10 = { fleet_event = { id = ancrel.8075 } }
		10 = {
			modifier = {
				factor = 0
				has_ancrel = no
			}
			fleet_event = { id = ancrel.8080 } #Minor Artifacts Discovered
		}
		10 = { fleet_event = { id = ancrel.8110 } }
	}
}

site_dark_secret_random_events = {
	random_list = {
		10 = { fleet_event = { id = ancrel.8055 } }
		10 = {
			fleet_event = { id = ancrel.8070 }
			modifier = {
				factor = 2
				leader = { has_trait = leader_trait_percussive_maintainer }
			}
		}
		10 = { fleet_event = { id = ancrel.8075 } }
		10 = { fleet_event = { id = ancrel.8100 } }
		10 = { fleet_event = { id = ancrel.8101 } }
		10 = { fleet_event = { id = ancrel.8102 } }
		10 = { fleet_event = { id = ancrel.8103 } }
	}
}

###################################
# ARCSITE RANDOM EVENTS (SPECIFIC)
###################################

site_moon_bump_random_events = { #AncRel
	random_list = {
		10 = { fleet_event = { id = ancrel.8040 } }
		10 = { fleet_event = { id = ancrel.8080 } }
		10 = {
			fleet_event = { id = ancrel.8070 }
			modifier = {
				factor = 2
				leader = { has_trait = leader_trait_percussive_maintainer }
			}
		}
		10 = { fleet_event = { id = ancrel.8100 } }
		10 = { fleet_event = { id = ancrel.8101 } }
		10 = { fleet_event = { id = ancrel.8102 } }
		10 = { fleet_event = { id = ancrel.8103 } }
	}
}

site_echoes_inside_random_events = { #AncRel
	random_list = {
		10 = { fleet_event = { id = ancrel.8050 } }
		10 = { fleet_event = { id = ancrel.8055 } }
		10 = { fleet_event = { id = ancrel.8075 } }
	}
}

site_target_from_orbit_random_events = { #AncRel
	random_list = {
		#Laser Grid
		10 = { fleet_event = { id = ancrel.8000 } }
		10 = { fleet_event = { id = ancrel.8001 } }
		10 = { fleet_event = { id = ancrel.8002 } }
		10 = { fleet_event = { id = ancrel.8003 } }
		#Sentinel Droids
		10 = { fleet_event = { id = ancrel.8030 } }
		10 = { fleet_event = { id = ancrel.8031 } }
		10 = { fleet_event = { id = ancrel.8032 } }
		10 = { fleet_event = { id = ancrel.8033 } }
		#Unstable Ruins
		10 = { fleet_event = { id = ancrel.8100 } }
		10 = { fleet_event = { id = ancrel.8101 } }
		10 = { fleet_event = { id = ancrel.8102 } }
		10 = { fleet_event = { id = ancrel.8103 } }
		#Other
		10 = { fleet_event = { id = ancrel.8040 } }
		10 = { fleet_event = { id = ancrel.8045 } }
		10 = { fleet_event = { id = ancrel.8050 } }
		10 = { fleet_event = { id = ancrel.8055 } }
		10 = { fleet_event = { id = ancrel.8060 } }
		10 = {
			fleet_event = { id = ancrel.8070 }
			modifier = {
				factor = 2
				leader = { has_trait = leader_trait_percussive_maintainer }
			}
		}
		10 = { fleet_event = { id = ancrel.8075 } }
		10 = { fleet_event = { id = ancrel.8080 } }
		10 = { fleet_event = { id = ancrel.8110 } }
	}
}

site_shot_into_the_ground_random_events = { #AncRel
	random_list = {
		10 = { fleet_event = { id = ancrel.8100 } }
		10 = { fleet_event = { id = ancrel.8101 } }
		10 = { fleet_event = { id = ancrel.8102 } }
		10 = { fleet_event = { id = ancrel.8103 } }
		10 = { fleet_event = { id = ancrel.8050 } }
	}
}

site_cut_to_fit_random_events = { #AncRel
	random_list = {
		10 = {
			fleet_event = { id = ancrel.8070 }
			modifier = {
				factor = 2
				leader = { has_trait = leader_trait_percussive_maintainer }
			}
		}
	}
}

site_deja_vu_dig_random_events = { #AncRel
	random_list = {
		10 = { fleet_event = { id = ancrel.8030 } }
		10 = { fleet_event = { id = ancrel.8031 } }
		10 = { fleet_event = { id = ancrel.8032 } }
		10 = { fleet_event = { id = ancrel.8033 } }
		10 = { fleet_event = { id = ancrel.8040 } }
		10 = { fleet_event = { id = ancrel.8045 } }
		10 = { fleet_event = { id = ancrel.8050 } }
		10 = { fleet_event = { id = ancrel.8055 } }
		10 = { fleet_event = { id = ancrel.8060 } }
		10 = { fleet_event = { id = ancrel.8075 } }
		10 = { fleet_event = { id = ancrel.8080 } }
		10 = { fleet_event = { id = ancrel.8100 } }
		10 = { fleet_event = { id = ancrel.8101 } }
		10 = { fleet_event = { id = ancrel.8102 } }
		10 = { fleet_event = { id = ancrel.8103 } }
		10 = { fleet_event = { id = ancrel.8110 } }
	}
}

site_trench_world_random_events = { #AncRel
	random_list = {
		10 = { fleet_event = { id = ancrel.8090 } }
		10 = { fleet_event = { id = ancrel.8091 } }
		10 = { fleet_event = { id = ancrel.8092 } }
		10 = { fleet_event = { id = ancrel.8093 } }
	}
}

site_ebb_and_flow_random_events = { #AncRel
	random_list = {
		10 = { fleet_event = { id = ancrel.8040 } }
		10 = { fleet_event = { id = ancrel.8045 } }
		10 = { fleet_event = { id = ancrel.8050 } }
		10 = { fleet_event = { id = ancrel.8055 } }
		10 = { fleet_event = { id = ancrel.8060 } }
		10 = {
			fleet_event = { id = ancrel.8070 }
			modifier = {
				factor = 2
				leader = { has_trait = leader_trait_percussive_maintainer }
			}
		}
		10 = { fleet_event = { id = ancrel.8075 } }
		10 = { fleet_event = { id = ancrel.8080 } }
		10 = { fleet_event = { id = ancrel.8100 } }
		10 = { fleet_event = { id = ancrel.8101 } }
		10 = { fleet_event = { id = ancrel.8102 } }
		10 = { fleet_event = { id = ancrel.8103 } }
		10 = { fleet_event = { id = ancrel.8110 } }
	}
}

site_sky_glow_hymn_random_events = { #AncRel
	random_list = {
		10 = { fleet_event = { id = ancrel.8040 } }
		10 = { fleet_event = { id = ancrel.8045 } }
		10 = { fleet_event = { id = ancrel.8080 } }
		10 = { fleet_event = { id = ancrel.8090 } }
		10 = { fleet_event = { id = ancrel.8091 } }
		10 = { fleet_event = { id = ancrel.8092 } }
		10 = { fleet_event = { id = ancrel.8093 } }
		10 = { fleet_event = { id = ancrel.8110 } }
	}
}

site_warmer_climates_random_events = { #AncRel
	random_list = {
		10 = { fleet_event = { id = ancrel.8040 } }
		10 = { fleet_event = { id = ancrel.8045 } }
		10 = { fleet_event = { id = ancrel.8060 } }
		10 = {
			fleet_event = { id = ancrel.8070 }
			modifier = {
				factor = 2
				leader = { has_trait = leader_trait_percussive_maintainer }
			}
		}
		10 = { fleet_event = { id = ancrel.8075 } }
		10 = { fleet_event = { id = ancrel.8080 } }
		10 = { fleet_event = { id = ancrel.8100 } }
		10 = { fleet_event = { id = ancrel.8101 } }
		10 = { fleet_event = { id = ancrel.8102 } }
		10 = { fleet_event = { id = ancrel.8103 } }
		10 = { fleet_event = { id = ancrel.8110 } }
	}
}

site_phoenix_collective_random_events = { #AncRel
	random_list = {
		10 = { fleet_event = { id = ancrel.8040 } }
		10 = { fleet_event = { id = ancrel.8055 } }
		10 = { fleet_event = { id = ancrel.8060 } }
		10 = {
			fleet_event = { id = ancrel.8070 }
			modifier = {
				factor = 2
				leader = { has_trait = leader_trait_percussive_maintainer }
			}
		}
		10 = { fleet_event = { id = ancrel.8075 } }
		10 = { fleet_event = { id = ancrel.8080 } }
		10 = { fleet_event = { id = ancrel.8090 } }
		10 = { fleet_event = { id = ancrel.8091 } }
		10 = { fleet_event = { id = ancrel.8092 } }
		10 = { fleet_event = { id = ancrel.8093 } }
		10 = { fleet_event = { id = ancrel.8110 } }
	}
}

site_grand_herald_random_events = { #AncRel
	random_list = {
		10 = { fleet_event = { id = ancrel.8040 } }
		10 = { fleet_event = { id = ancrel.8045 } }
		10 = { fleet_event = { id = ancrel.8055 } }
		10 = { fleet_event = { id = ancrel.8060 } }
		10 = {
			fleet_event = { id = ancrel.8070 }
			modifier = {
				factor = 2
				leader = { has_trait = leader_trait_percussive_maintainer }
			}
		}
		10 = { fleet_event = { id = ancrel.8075 } }
		10 = { fleet_event = { id = ancrel.8080 } }
		10 = { fleet_event = { id = ancrel.8110 } }
	}
}

site_popular_rock_random_events = { #AncRel
	random_list = {
		10 = { fleet_event = { id = ancrel.8030 } }
		10 = { fleet_event = { id = ancrel.8031 } }
		10 = { fleet_event = { id = ancrel.8032 } }
		10 = { fleet_event = { id = ancrel.8033 } }
		10 = { fleet_event = { id = ancrel.8040 } }
		10 = { fleet_event = { id = ancrel.8045 } }
		10 = {
			fleet_event = { id = ancrel.8070 }
			modifier = {
				factor = 2
				leader = { has_trait = leader_trait_percussive_maintainer }
			}
		}
		10 = { fleet_event = { id = ancrel.8080 } }
		10 = { fleet_event = { id = ancrel.8110 } }
	}
}

site_strange_flows_random_events = { #AncRel
	random_list = {
		10 = { fleet_event = { id = ancrel.8055 } }
		10 = {
			fleet_event = { id = ancrel.8070 }
			modifier = {
				factor = 2
				leader = { has_trait = leader_trait_percussive_maintainer }
			}
		}
	}
}

site_ruins_of_shallash_random_events = {
	random_list = {
		10 = { site_guardian_droids_trap = yes }
		10 = { fleet_event = { id = ancrel.8040 } }
		10 = { fleet_event = { id = ancrel.8055 } }
		10 = {
			fleet_event = { id = ancrel.8070 }
			modifier = {
				factor = 2
				leader = { has_trait = leader_trait_percussive_maintainer }
			}
		}
		2 = { fleet_event = { id = ancrel.8075 } }
		10 = {
			modifier = {
				factor = 0
				has_ancrel = no
			}
			fleet_event = { id = ancrel.8080 } #Minor Artifacts Discovered
		}
		10 = { fleet_event = { id = ancrel.8100 } }
		10 = { fleet_event = { id = ancrel.8110 } }
		10 = {
			modifier = {
				factor = 0
				OR = {
					from.planet = {
						NOT = { is_planet_class = pc_nuked }
					}
					leader.species = {
						has_trait = trait_pc_nuked_preference
					}
					owner = { is_machine_empire = yes }
				}
			}
			fleet_event = { id = federations2.701 }
		}
		40 = { fleet_event = { id = federations2.702 } }
	}
}

site_fumongus_random_events = {
	random_list = {
		#Hostile Wildlife
		5 = { fleet_event = { id = ancrel.8090 } }
		25 = { fleet_event = { id = ancrel.8091 } }
		25 = { fleet_event = { id = ancrel.8092 } }
		25 = { fleet_event = { id = ancrel.8093 } }
		#Fungal Zombies
		5 = { fleet_event = { id = ancrel.8300 } }
		25 = { fleet_event = { id = ancrel.8305 } }
		25 = { fleet_event = { id = ancrel.8310 } }
		25 = { fleet_event = { id = ancrel.8315 } }

		30 = { fleet_event = { id = ancrel.8040 } } #Resource Cache
	}
}

site_relicrails_random_events = { #AncRel
	random_list = {
		10 = { fleet_event = { id = ancrel.8040 } }
		10 = { fleet_event = { id = ancrel.8055 } }
		10 = { fleet_event = { id = ancrel.8065 } }
		10 = {
			fleet_event = { id = ancrel.8070 }
			modifier = {
				factor = 2
				leader = { has_trait = leader_trait_percussive_maintainer }
			}
		}
		10 = { fleet_event = { id = ancrel.8080 } }
	}
}

clone_army_random_events = { #Humanoids species pack
	random_list = {
		10 = { site_wildlife = yes }
		10 = { site_collapsed_roof = yes }
		10 = { fleet_event = { id = ancrel.8040 } }
		10 = { fleet_event = { id = ancrel.8045 } }
		10 = { fleet_event = { id = ancrel.8050 } }
		10 = { fleet_event = { id = ancrel.8055 } }
		10 = { fleet_event = { id = ancrel.8060 } }
		10 = { fleet_event = { id = ancrel.8065 } }
		10 = { fleet_event = { id = ancrel.8065 } }
		10 = { fleet_event = { id = ancrel.8070 } }
		10 = { fleet_event = { id = ancrel.8075 } }
	}
}

site_transformation_random_events = {
	random_list = {
		10 = { fleet_event = { id = ancrel.15006 } }
		10 = { fleet_event = { id = ancrel.15007 } }
		10 = { fleet_event = { id = ancrel.15008 } }
	}
}

site_spaceship_random_events = {
	random_list = {
		10 = { site_laser_grid_trap = yes }
		10 = { site_sentry_guns_trap = yes }
		10 = { fleet_event = { id = ancrel.8055 } }
		10 = { site_explosive_decompression = yes }
		10 = {
			modifier = {
				factor = 0
				has_ancrel = no
			}
			fleet_event = { id = ancrel.8210 } #Minor Artifacts Discovered
		}
		10 = { fleet_event = { id = ancrel.8215 } }
	}
}

tiyanki_graveyard_random_events = {
	random_list = {
		10 = { fleet_event = { id = ancrel.8055 } }
		10 = {
			fleet_event = { id = ancrel.8070 }
			modifier = {
				factor = 2
				leader = { has_trait = leader_trait_percussive_maintainer }
			}
		}
		10 = { fleet_event = { id = ancrel.8075 } }
		10 = { fleet_event = { id = ancrel.14910 } }
	}
}

site_ice_trauma_random_events = {
	random_list = {
		5 = { site_laser_grid_trap = yes }
		5 = { site_sentry_guns_trap = yes }
		10 = { fleet_event = { id = ancrel.8040 } } #Resource Cache
		10 = { fleet_event = { id = ancrel.8055 } } #Bickering Archaeologists
		10 = { fleet_event = { id = ancrel.8065 } } #Spreading Illness
		10 = {
			modifier = {
				factor = 2
				leader = { has_trait = leader_trait_percussive_maintainer }
			}
			fleet_event = { id = ancrel.8070 } #Equipment Malfunction
		}
		10 = { fleet_event = { id = ancrel.13030 } } #Disturbing Vision
		50 = { fleet_event = { id = arcsite.9000 } } #Lonely Vigil
		50 = {
			modifier = {
				factor = 0
				owner = {
					NOR = {
						has_technology = tech_massive_glacier
						has_technology = tech_ecological_adaptation
						has_technology = tech_climate_restoration
						has_ascension_perk = ap_hydrocentric
					}
				}
			}
			fleet_event = { id = arcsite.9005 } #Icebreaker
		}
	}
}

site_genius_caeli_random_events = {
	random_list = {
		10 = { fleet_event = { id = ancrel.8050 } } #Lost Expedition
		10 = { fleet_event = { id = ancrel.8055 } } #Bickering Archaeologists
		5 = { fleet_event = { id = ancrel.8075 } } #Without a Trace (lead scientist disappears)
		10 = { site_collapsed_roof = yes } #Unstable Ruins
		10 = { fleet_event = { id = ancrel.8110 } } #Ancient Records
		5 = {
			modifier = {
				factor = 0
				is_organic_species = no
				is_lithoid = yes
			}
			fleet_event = { id = ancrel.4078 } #Fire (food shortage)
		}
		10 = {
			modifier = {
				factor = 0
				is_organic_species = no
			}
			fleet_event = { id = ancrel.8065 } #Spreading Illness
		}
		10 = {
			modifier = {
				factor = 0
				is_organic_species = no
			}
			fleet_event = { id = ancrel.13030 } #Disturbing Vision
		}
		20 = {
			modifier = {
				factor = 0
				has_ancrel = no
			}
			fleet_event = { id = ancrel.8210 } #Minor Artifacts Discovered
		}
	}
}

site_engineered_species_random_events = {
	random_list = {
		10 = { fleet_event = { id = ancrel.8055 } } #Bickering Archaeologists
		5 = { fleet_event = { id = ancrel.8075 } } #Without a Trace (lead scientist disappears)
		10 = { fleet_event = { id = ancrel.8110 } } #Ancient Records
		5 = { fleet_event = { id = ancrel.8090 } } #Hostile Wildlife
		10 = { fleet_event = { id = ancrel.8091 } } #Hostile Wildlife
		5 = { fleet_event = { id = ancrel.8092 } } #Hostile Wildlife
		10 = { fleet_event = { id = ancrel.8093 } } #Hostile Wildlife
		5 = {
			modifier = {
				factor = 0
				is_organic_species = no
				is_lithoid = yes
			}
			fleet_event = { id = ancrel.4078 } #Fire (food shortage)
		}
		10 = {
			modifier = {
				factor = 0
				has_ancrel = no
			}
			fleet_event = { id = ancrel.8210 } #Minor Artifacts Discovered
		}
	}
}

site_krazura_random_events = {
	random_list = {
		80 = { fleet_event = { id = arcsite.3055 } } #Baleful Bird
		20 = {
			modifier = {
				factor = 50
				owner = {
					is_species_class = AVI
				}
			}
			fleet_event = { id = arcsite.3060 } #Feather Rot
		}
	}
}

cosmic_storm_precursor_random_events = {
	random_list = {
		10 = { fleet_event = { id = ancrel.8040 } } #Resource Cache
		10 = { fleet_event = { id = ancrel.8045 } } #Hidden Passage
		10 = { fleet_event = { id = ancrel.8055 } } #Bickering Archaeologists
		10 = {
			fleet_event = { id = ancrel.8070 }
			modifier = {
				factor = 2
				leader = { has_trait = leader_trait_percussive_maintainer }
			}
		}
	}
}
