namespace = distar

country_event = { #Atomic Clock follow-up: Selection
    id = distar.310
    hide_window = yes

    is_triggered_only = yes

    immediate = {
        FROMFROM.solar_system = {
            save_event_target_as = atomic_clock_system
        }
        random_list = {
            0 = {
                modifier = {
                    add = 1
                    merg_has_expanded_events = no
                    FROMFROM.solar_system = {
                        any_system_planet = {
                            uninhabitable_regular_planet = yes
                            has_anomaly = no
                            planet_size > 8
                            planet_size < 25
                            NOR = {
                                merg_is_broken = yes
                                is_planet_class = "pc_astral_scar"
                            }
                            is_star = no
                        }
                    }
                }
                modifier = {
                    add = 50
                    merg_has_expanded_events = yes
                    FROMFROM.solar_system = {
                        any_system_planet = {
                            uninhabitable_regular_planet = yes
                            has_anomaly = no
                            planet_size > 8
                            planet_size < 25
                            NOR = {
                                merg_is_broken = yes
                                is_planet_class = "pc_astral_scar"
                            }
                            is_star = no
                        }
                    }
                }
                country_event = { id = distar.311 } #System planet is terraformed
            }
            0 = {
                modifier = {
                    add = 1
                    merg_has_expanded_events = no
                    FROMFROM.solar_system = {
                        has_access_fleet = root
                    }
                }
                modifier = {
                    add = 50
                    merg_has_expanded_events = yes
                    FROMFROM.solar_system = {
                        has_access_fleet = root
                    }
                }
                country_event = { id = distar.315 } #Useable Gray Goo ship is built
            }
            0 = {
                modifier = {
                    add = 1
                    merg_has_expanded_events = no
                    FROMFROM.solar_system = {
                        any_system_planet = {
                            uninhabitable_regular_planet = yes
                            has_anomaly = no
                            is_star = no
                        }
                    }
                }
                modifier = {
                    add = 50
                    merg_has_expanded_events = yes
                    FROMFROM.solar_system = {
                        any_system_planet = {
                            uninhabitable_regular_planet = yes
                            has_anomaly = no
                            is_star = no
                        }
                    }
                }
                country_event = { id = distar.320 } #Unmanned research facilities built (Phys + Eng)
            }
            0 = {
                modifier = {
                    add = 1
                    merg_has_expanded_events = no
                    FROMFROM.solar_system = {
                        any_system_planet = {
                            merg_is_basic_habitable = yes
                            has_anomaly = no
                            exists = owner
                            owner = { is_primitive = yes }
                        }
                    }
                }
                modifier = {
                    add = 40
                    merg_has_expanded_events = yes
                    FROMFROM.solar_system = {
                        any_system_planet = {
                            merg_is_basic_habitable = yes
                            has_anomaly = no
                            exists = owner
                            owner = { is_primitive = yes }
                        }
                    }
                }
                country_event = { id = distar.330 } #Primitive planet is nuked
            }
            0 = {
                modifier = {
                    add = 1
                    merg_has_expanded_events = no
                    FROMFROM.solar_system = {
                        any_system_planet = {
                            merg_is_basic_habitable = yes
                            is_colony = no
                            is_under_colonization = no
                            has_anomaly = no
                        }
                    }
                }
                modifier = {
                    add = 40
                    merg_has_expanded_events = yes
                    FROMFROM.solar_system = {
                        any_system_planet = {
                            merg_is_basic_habitable = yes
                            is_colony = no
                            is_under_colonization = no
                            has_anomaly = no
                        }
                    }
                }
                country_event = { id = distar.335 } #Habitable planet is nuked
            }
            0 = {
                modifier = {
                    add = 20
                    merg_has_expanded_events = yes
                }
                country_event = { id = anomalymod.100 }
            }
            0 = {
                modifier = {
                    add = 20
                    merg_has_expanded_events = yes
                }
                country_event = { id = anomalymod.103 }
            }
            0 = {
                modifier = {
                    add = 15
                    merg_has_expanded_events = yes
                }
                country_event = { id = anomalymod.107 }
            }
            0 = {
                modifier = {
                    add = 5
                    merg_has_expanded_events = yes
                }
                country_event = { id = anomalymod.108 }
            }
            0 = {
                modifier = {
                    add = 1
                    merg_has_expanded_events = yes
                }
                modifier = {
                    factor = 0
                    FROMFROM.solar_system = {
                        OR = {
                            any_neighbor_system = {
                                is_capital_system = yes
                            }
                            any_neighbor_system = {
                                any_neighbor_system = {
                                    is_capital_system = yes
                                }
                            }
                            any_neighbor_system = {
                                any_neighbor_system = {
                                    any_neighbor_system = {
                                        is_capital_system = yes
                                    }
                                }
                            }
                        }
                    }
                }
                country_event = { id = anomalymod.109 }
            }
        }
    }
}

country_event = { #Atomic Clock follow-up: A system planet is terraformed
    id = distar.311
    title = distar.311.name
    desc = distar.311.desc
    picture = GFX_evt_clocks
    show_sound = event_activating_unknown_technology
    location = FROMFROMFROM

    is_triggered_only = yes

    immediate = {
        FROMFROMFROM.solar_system = {
            random_system_planet = {
                limit = {
                    uninhabitable_regular_planet = yes
                    has_anomaly = no
                    planet_size > 8
                    planet_size < 25
                    NOR = {
                        merg_is_broken = yes
                        is_planet_class = pc_astral_scar
                    }
                    is_star = no
                }
                save_event_target_as = atomic_clock_planet
            }
        }
    }

    option = {
        name = "distar.311.a"
        hidden_effect = { country_event = { id = distar.312 days = 30 } }
    }

    option = {
        trigger = {
            event_target:atomic_clock_planet.solar_system = {
                any_fleet_in_system = {
                    is_owned_by = root
                    OR = {
                        is_ship_class = shipclass_military_station
                        is_ship_class = shipclass_military
                    }
                }
            }
        }
        name = "distar.311.b"
        custom_tooltip = "distar.311.b.tooltip"
        add_monthly_resource_mult = {
            resource = influence
            value = @tier1influencereward
            min = @tier1influencemin
            max = @tier1influencemax
        }
        hidden_effect = { country_event = { id = distar.313 days = 10 } } #They gray goo the planet
    }
}
