
planet_megastructure_construction = {
	situation_log_category = planetmegas
	complete_icon_frame = GFX_situation_outcome_frame_green
	complete_icon = GFX_situation_outcome_positive
	fail_icon_frame = GFX_situation_outcome_frame_red
	fail_icon = GFX_situation_outcome_meh
	inline_script = situations/plnmg_sit_pics

	triggered_target_modifier = {
		potential = {
			target = { 
				or = { 
					not = { exists = owner } 
					is_planetmega_byd_space_need = no
				}
			}
		}
		planet_max_districts_add = -2
		#planet_max_buildings_add = -1
	}
	triggered_target_modifier = {
		potential = {
			has_situation_flag = can_use_building_capacity
			target = {
				or = {
					not = { exists = owner }
					is_plnmg_const_sit_byd_cap_need = no
				}
			}
		}
		planet_building_capacity_add = -1
	}

	# total_progress = {
	# 	base = 1560
	# 	factor = value:plnmg_const_sit_tp_non_cntr_mult
	# }
	stages = {
		stage_1 = {
			icon = GFX_planet_mega_stage_1
			icon_background = GFX_situation_stage_frame_green
			custom_tooltip = stage_planet_mega_1_tooltip
			#section_weight= 10
			end = 520 #33.33%
		}
		stage_2 = {
			icon = GFX_planet_mega_stage_2
			icon_background = GFX_situation_stage_frame_green
			custom_tooltip = stage_planet_mega_2_tooltip
			on_first_enter = {
				random_list = {
					5 = {}
					2 = {
						inline_script = situations/plnmg_sit_1st_enter_bad
						random_list = {
							1 = { situation_event = { id = planetmega.10 } }
							1 = { situation_event = { id = planetmega.15 } }
							1 = { situation_event = { id = planetmega.16 } }
							1 = { situation_event = { id = planetmega.25 } }
						}
					}
					3 = {
						inline_script = situations/plnmg_sit_1st_enter_good
						random_list = {
							9 = { situation_event = { id = planetmega.20 } }
							1 = { situation_event = { id = planetmega.22 } }
						}
					}
				}
                reroll_random = yes
			}
			inline_script = situations/plnmg_sit_stage2
			#section_weight= 10
			end = 1040 #66.66%
		}
		stage_3 = {
			icon = GFX_planet_mega_stage_3
			icon_background = GFX_situation_stage_frame_green
			custom_tooltip = stage_planet_mega_3_tooltip
			on_first_enter = {
				random_list = {
					2 = {}
					1 = {
						inline_script = situations/plnmg_sit_1st_enter_bad
						random_list = {
							1 = { situation_event = { id = planetmega.10 } }
							1 = { situation_event = { id = planetmega.15 } }
							1 = { situation_event = { id = planetmega.16 } }
							1 = { situation_event = { id = planetmega.25 } }
						}
					}
					1 = {
						inline_script = situations/plnmg_sit_1st_enter_good
						situation_event = { id = planetmega.20 }
					}
				}
                reroll_random = yes
			}
			inline_script = situations/plnmg_sit_stage3
			#section_weight= 10
			end = 1560 #13年
		}
	}

	category = positive

	on_progress_complete = {
		custom_tooltip = planet_megastructure_construction_tooltip
		hidden_effect = { situation_event = { id = planetmega.50 } }
	}
	on_start = { situation_event = { id = planetmega.5 } }
	on_fail = {
		custom_tooltip = planet_megastructure_construction_fail_tooltip
		hidden_effect = { situation_event = { id = planetmega.9 } }
	}
	on_abort = { situation_event = { id = planetmega.99 } }
	on_monthly = {
		events = {
			planetmega.11
		}
	}

	inline_script = {
		script = situations/plnmg_sit_approach
		energy_upkp = 15 alloys_upkp = 5
	}

	monthly_progress = {
		base = @progressBase_buildPlanetMega
		inline_script = situations/plnmg_sit_progress
	}

	inline_script = situations/plnmg_sit_abort_blocks
}

planet_megastructure_constimp = {
	situation_log_category = planetmegas
	complete_icon_frame = GFX_situation_outcome_frame_green
	complete_icon = GFX_situation_outcome_positive
	fail_icon_frame = GFX_situation_outcome_frame_red
	fail_icon = GFX_situation_outcome_meh
	inline_script = situations/plnmg_sit_pics

	triggered_target_modifier = {
		potential = {
			target = {
				or = {
					not = { exists = owner } 
					is_planetmega_byd_space_need = no
				}
			}
		}
		planet_max_districts_add = -3
		#planet_max_buildings_add = -2
	}
	triggered_target_modifier = {
		potential = {
			has_situation_flag = can_use_building_capacity
			target = {
				or = {
					not = { exists = owner }
					is_plnmg_const_sit_byd_cap_need = no
				}
			}
		}
		planet_building_capacity_add = -1
	}

	# total_progress = {
	# 	base = 3000
	# 	factor = value:plnmg_const_sit_tp_non_cntr_mult
	# }
	stages = {
		stage_1 = {
			icon = GFX_planet_mega_stage_1
			icon_background = GFX_situation_stage_frame_green
			custom_tooltip = stage_planet_mega_1_tooltip
			#section_weight= 10
			end = 750 #25%
		}
		stage_2 = {
			icon = GFX_planet_mega_stage_2
			icon_background = GFX_situation_stage_frame_green
			custom_tooltip = stage_planet_mega_2_tooltip
			on_first_enter = {
				random_list = {
					9 = {}
					4 = {
						inline_script = situations/plnmg_sit_1st_enter_bad
						random_list = {
							6 = { situation_event = { id = planetmega.10 } }
							8 = { situation_event = { id = planetmega.15 } }
							3 = { situation_event = { id = planetmega.16 } }
							2 = { situation_event = { id = planetmega.25 } }
						}
					}
					5 = {
						inline_script = situations/plnmg_sit_1st_enter_good
						random_list = {
							9 = { situation_event = { id = planetmega.20 } }
							1 = { situation_event = { id = planetmega.22 } }
						}
					}
				}
				if = {
					limit = { has_situation_flag = building_plnmg_bore_of_the_shroud }
					random = {
						chance = 1
						random_list = {
							1 = { target = { carrier_event = { id = planetmega.910 } } }
							1 = { target = { carrier_event = { id = planetmega.911 } } }
						}
					}
				}
                reroll_random = yes
			}
			inline_script = situations/plnmg_sit_stage2
			#section_weight= 10
			end = 1500 #50%
		}
		stage_3 = {
			icon = GFX_planet_mega_stage_2
			icon_background = GFX_situation_stage_frame_green
			custom_tooltip = stage_planet_mega_2_tooltip
			on_first_enter = {
				random_list = {
					2 = {}
					1 = {
						inline_script = situations/plnmg_sit_1st_enter_bad
						random_list = {
							6 = { situation_event = { id = planetmega.10 } }
							8 = { situation_event = { id = planetmega.15 } }
							3 = { situation_event = { id = planetmega.16 } }
							2 = { situation_event = { id = planetmega.25 } }
						}
					}
					1 = {
						inline_script = situations/plnmg_sit_1st_enter_good
						random_list = {
							19 = { situation_event = { id = planetmega.20 } }
							1 = { situation_event = { id = planetmega.22 } }
						}
					}
				}
				if = {
					limit = { has_situation_flag = building_plnmg_bore_of_the_shroud }
					random = {
						chance = 1
						random_list = {
							1 = { target = { carrier_event = { id = planetmega.910 } } }
							1 = { target = { carrier_event = { id = planetmega.911 } } }
						}
					}
				}
                reroll_random = yes
			}
			inline_script = situations/plnmg_sit_stage3
			#section_weight= 10
			end = 2250 #75%
		}
		stage_4 = {
			icon = GFX_planet_mega_stage_3
			icon_background = GFX_situation_stage_frame_green
			custom_tooltip = stage_planet_mega_3_tooltip
			on_first_enter = {
				random_list = {
					10 = {}
					6 = {
						inline_script = situations/plnmg_sit_1st_enter_bad
						random_list = {
							6 = { situation_event = { id = planetmega.10 } }
							8 = { situation_event = { id = planetmega.15 } }
							3 = { situation_event = { id = planetmega.16 } }
							2 = { situation_event = { id = planetmega.25 } }
						}
					}
					4 = {
						inline_script = situations/plnmg_sit_1st_enter_good
						situation_event = { id = planetmega.20 }
					}
				}
				if = {
					limit = { has_situation_flag = building_plnmg_bore_of_the_shroud }
					random = {
						chance = 1
						random_list = {
							1 = { target = { carrier_event = { id = planetmega.910 } } }
							1 = { target = { carrier_event = { id = planetmega.911 } } }
						}
					}
				}
                reroll_random = yes
			}
			inline_script = situations/plnmg_sit_stage4
			#section_weight= 10
			end = 3000 #25年
		}
	}

	category = positive

	on_progress_complete = {
		custom_tooltip = planet_megastructure_construction_tooltip
		hidden_effect = { situation_event = { id = planetmega.70 } }
	}
	on_start = { situation_event = { id = planetmega.5 } }
	on_fail = {
		custom_tooltip = planet_megastructure_construction_fail_tooltip
		hidden_effect = { situation_event = { id = planetmega.9 } }
	}
	on_abort = { situation_event = { id = planetmega.99 } }
	on_monthly = {
		events = {
			planetmega.903
			planetmega.904
			planetmega.11
		}
	}

	inline_script = {
		script = situations/plnmg_sit_approach
		energy_upkp = 25 alloys_upkp = 10
	}

	monthly_progress = {
		base = @progressBase_buildPlanetMega
		inline_script = situations/plnmg_sit_progress
	}
}

planet_megastructure_constadv = {
	situation_log_category = planetmegas
	complete_icon_frame = GFX_situation_outcome_frame_green
	complete_icon = GFX_situation_outcome_positive
	fail_icon_frame = GFX_situation_outcome_frame_red
	fail_icon = GFX_situation_outcome_meh
	inline_script = situations/plnmg_sit_pics

	triggered_target_modifier = {
		potential = {
			has_situation_flag = building_plnmg_omnipotence
			target = {
				or = {
					not = { exists = owner } 
					is_planetmega_byd_space_need = no
				}
			}
		}
		planet_max_districts_add = -3
	}
	triggered_target_modifier = {
		potential = {
			has_situation_flag = can_use_building_capacity
			target = {
				or = {
					not = { exists = owner }
					is_plnmg_const_sit_byd_cap_need = no
				}
			}
		}
		planet_building_capacity_add = -1
	}

	# total_progress = {
	# 	base = 4200
	# 	factor = value:plnmg_const_sit_tp_non_cntr_mult
	# }
	stages = {
		stage_1 = {
			icon = GFX_planet_mega_stage_1
			icon_background = GFX_situation_stage_frame_green
			custom_tooltip = stage_planet_mega_1_tooltip
			#section_weight= 10
			end = 840 #20%
		}
		stage_2 = {
			icon = GFX_planet_mega_stage_2
			icon_background = GFX_situation_stage_frame_green
			custom_tooltip = stage_planet_mega_2_tooltip
			on_first_enter = {
				random_list = {
					11 = {}
					5 = {
						inline_script = situations/plnmg_sit_1st_enter_bad
						random_list = {
							6 = { situation_event = { id = planetmega.10 } }
							8 = { situation_event = { id = planetmega.15 } }
							3 = { situation_event = { id = planetmega.16 } }
							2 = { situation_event = { id = planetmega.25 } }
						}
					}
					6 = {
						inline_script = situations/plnmg_sit_1st_enter_good
						random_list = {
							9 = { situation_event = { id = planetmega.20 } }
							1 = { situation_event = { id = planetmega.22 } }
						}
					}
				}
                reroll_random = yes
			}
			inline_script = situations/plnmg_sit_stage2
			#section_weight= 10
			end = 1680 #40%
		}
		stage_3 = {
			icon = GFX_planet_mega_stage_2
			icon_background = GFX_situation_stage_frame_green
			custom_tooltip = stage_planet_mega_2_tooltip
			on_first_enter = {
				random_list = {
					2 = {}
					1 = {
						inline_script = situations/plnmg_sit_1st_enter_bad
						random_list = {
							6 = { situation_event = { id = planetmega.10 } }
							8 = { situation_event = { id = planetmega.15 } }
							3 = { situation_event = { id = planetmega.16 } }
							2 = { situation_event = { id = planetmega.25 } }
						}
					}
					1 = {
						inline_script = situations/plnmg_sit_1st_enter_good
						random_list = {
							19 = { situation_event = { id = planetmega.20 } }
							1 = { situation_event = { id = planetmega.22 } }
						}
					}
				}
                reroll_random = yes
			}
			inline_script = situations/plnmg_sit_stage3
			#section_weight= 10
			end = 2520 #60%
		}
		stage_4 = {
			icon = GFX_planet_mega_stage_3
			icon_background = GFX_situation_stage_frame_green
			custom_tooltip = stage_planet_mega_2_tooltip
			on_first_enter = {
				random_list = {
					11 = {}
					6 = {
						inline_script = situations/plnmg_sit_1st_enter_bad
						random_list = {
							6 = { situation_event = { id = planetmega.10 } }
							8 = { situation_event = { id = planetmega.15 } }
							3 = { situation_event = { id = planetmega.16 } }
							2 = { situation_event = { id = planetmega.25 } }
						}
					}
					5 = {
						inline_script = situations/plnmg_sit_1st_enter_good
						random_list = {
							29 = { situation_event = { id = planetmega.20 } }
							1 = { situation_event = { id = planetmega.22 } }
						}
					}
				}
                reroll_random = yes
			}
			inline_script = situations/plnmg_sit_stage4
			#section_weight= 10
			end = 3360 #80%
		}
		stage_5 = {
			icon = GFX_planet_mega_stage_3
			icon_background = GFX_situation_stage_frame_green
			custom_tooltip = stage_planet_mega_3_tooltip
			on_first_enter = {
				random_list = {
					7 = {}
					4 = {
						inline_script = situations/plnmg_sit_1st_enter_bad
						random_list = {
							6 = { situation_event = { id = planetmega.10 } }
							8 = { situation_event = { id = planetmega.15 } }
							3 = { situation_event = { id = planetmega.16 } }
							2 = { situation_event = { id = planetmega.25 } }
						}
					}
					3 = {
						inline_script = situations/plnmg_sit_1st_enter_good
						situation_event = { id = planetmega.20 }
					}
				}
                reroll_random = yes
			}
			triggered_target_modifier = {
				potential = { has_situation_flag = building_plnmg_omnipotence }
				planet_jobs_unity_produces_mult = -0.3
			}
			triggered_target_modifier = {
				potential = { has_situation_flag = building_plnmg_nano_storm }
				planet_jobs_nanites_produces_mult = 0.2
			}
			#section_weight= 10
			end = 4200 #35年
		}
	}

	category = positive

	on_progress_complete = {
		custom_tooltip = planet_megastructure_construction_tooltip
		hidden_effect = { situation_event = { id = planetmega.70 } }
	}
	on_start = { situation_event = { id = planetmega.5 } }
	on_fail = {
		custom_tooltip = planet_megastructure_construction_fail_tooltip
		hidden_effect = { situation_event = { id = planetmega.9 } }
	}
	on_abort = { situation_event = { id = planetmega.99 } }
	on_monthly = {
		events = {
			planetmega.11
			planetmega.981
		}
	}

	inline_script = {
		script = situations/plnmg_sit_approach
		energy_upkp = 35 alloys_upkp = 15
	}

	monthly_progress = {
		base = @progressBase_buildPlanetMega
		inline_script = situations/plnmg_sit_progress
	}

	inline_script = situations/plnmg_sit_abort_blocks
}

# upgradings

planet_megastructure_upgrading = {
	situation_log_category = planetmegas
	complete_icon_frame = GFX_situation_outcome_frame_green
	complete_icon = GFX_situation_outcome_positive
	fail_icon_frame = GFX_situation_outcome_frame_red
	fail_icon = GFX_situation_outcome_meh
	inline_script = situations/plnmg_sit_pics

	triggered_target_modifier = {
		potential = {
			target = {
				or = {
					not = { exists = owner } 
					is_planetmega_byd_space_need = no
				}
			}
		}
		planet_max_districts_add = -1
		#planet_max_buildings_add = -1
	}
	triggered_target_modifier = {
		potential = {
			has_situation_flag = can_use_building_capacity
			target = {
				or = {
					not = { exists = owner }
					is_plnmg_const_sit_byd_cap_need = no
				}
			}
		}
		planet_building_capacity_add = -1
	}

	# total_progress = {
	# 	base = 3600
	# 	factor = value:plnmg_const_sit_tp_non_cntr_mult
	# }
	stages = {
		stage_1 = {
			icon = GFX_planet_mega_stage_1
			icon_background = GFX_situation_stage_frame_green
			custom_tooltip = stage_planet_mega_1_tooltip
			#section_weight= 10
			end = 900 #25%
		}
		stage_2 = {
			icon = GFX_planet_mega_stage_2
			icon_background = GFX_situation_stage_frame_green
			custom_tooltip = stage_planet_mega_2_tooltip
			on_first_enter = {
				random_list = {
					13 = {}
					6 = {
						inline_script = situations/plnmg_sit_1st_enter_bad
						random_list = {
							6 = { situation_event = { id = planetmega.10 } }
							5 = { situation_event = { id = planetmega.15 } }
							5 = { situation_event = { id = planetmega.16 } }
							2 = { situation_event = { id = planetmega.25 } }
						}
					}
					7 = {
						inline_script = situations/plnmg_sit_1st_enter_good
						situation_event = { id = planetmega.20 }
					}
				}
                reroll_random = yes
			}
			inline_script = situations/plnmg_sit_stage2
			#section_weight= 10
			end = 1800 #50%
		}
		stage_3 = {
			icon = GFX_planet_mega_stage_2
			icon_background = GFX_situation_stage_frame_green
			custom_tooltip = stage_planet_mega_2_tooltip
			on_first_enter = {
				random_list = {
					2 = {}
					1 = {
						inline_script = situations/plnmg_sit_1st_enter_bad
						random_list = {
							6 = { situation_event = { id = planetmega.10 } }
							5 = { situation_event = { id = planetmega.15 } }
							5 = { situation_event = { id = planetmega.16 } }
							2 = { situation_event = { id = planetmega.25 } }
						}
					}
					1 = {
						inline_script = situations/plnmg_sit_1st_enter_good
						situation_event = { id = planetmega.20 }
					}
				}
				if = {
					limit = { has_situation_flag = building_plnmg_singularity_generator }
					random_list = {
						99 = {}
						1 = {
							random_list = {
								1 = { target = { carrier_event = { id = planetmega.915 } } }
								1 = { situation_event = { id = planetmega.916 } }
							}
						}
					}
				}
                reroll_random = yes
			}
			inline_script = situations/plnmg_sit_stage3
			#section_weight= 10
			end = 2700 #75%
		}
		stage_4 = {
			icon = GFX_planet_mega_stage_3
			icon_background = GFX_situation_stage_frame_green
			custom_tooltip = stage_planet_mega_3_tooltip
			on_first_enter = {
				random_list = {
					9 = {}
					5 = {
						inline_script = situations/plnmg_sit_1st_enter_bad
						random_list = {
							6 = { situation_event = { id = planetmega.10 } }
							5 = { situation_event = { id = planetmega.15 } }
							5 = { situation_event = { id = planetmega.16 } }
							2 = { situation_event = { id = planetmega.25 } }
						}
					}
					4 = {
						inline_script = situations/plnmg_sit_1st_enter_good
						situation_event = { id = planetmega.20 }
					}
				}
				if = {
					limit = { has_situation_flag = building_plnmg_singularity_generator }
					random_list = {
						99 = {}
						1 = {
							random_list = {
								1 = { target = { carrier_event = { id = planetmega.915 } } }
								1 = { situation_event = { id = planetmega.916 } }
							}
						}
					}
				}
                reroll_random = yes
			}
			inline_script = situations/plnmg_sit_stage4
			#section_weight= 10
			end = 3600 #30年
		}
	}

	category = positive

	on_progress_complete = {
		custom_tooltip = planet_megastructure_upgrading_tooltip
		hidden_effect = { situation_event = { id = planetmega.60 } }
	}
	on_start = { situation_event = { id = planetmega.6 } }
	on_fail = {
		custom_tooltip = planet_megastructure_upgrading_fail_tooltip
		hidden_effect = { situation_event = { id = planetmega.9 } }
	}
	on_abort = { situation_event = { id = planetmega.99 } }
	on_monthly = {
		events = {
			planetmega.11
			planetmega.903
		}
	}

	inline_script = {
		script = situations/plnmg_sit_approach
		energy_upkp = 30 alloys_upkp = 10
	}

	monthly_progress = {
		base = @progressBase_buildPlanetMega
		inline_script = situations/plnmg_sit_progress
	}

	inline_script = situations/plnmg_sit_abort_blocks
}
