Special
    name = "GAIA_SPECIAL"
    description = "GAIA_SPECIAL_DESC"
    stealth = 0
    spawnrate = 1.0
    spawnlimit = 12
    location = And [
        Planet
        Not Planet type = [Asteroids GasGiant]
        Not WithinStarlaneJumps jumps = 2 condition = And [
            System
            Contains And [
                Planet
                OwnedBy affiliation = AnyEmpire
            ]
        ]
        Not ContainedBy Contains Design name = "SM_EXP_OUTPOST"
    ]
    effectsgroups = [
        EffectsGroup
            scope = Source
            activation = AND [
                Planet
                Species
                Not Planet environment = Good
                Population low = 0.01
                OwnedBy affiliation = AnyEmpire
                Not Planet type = Source.NextBetterPlanetType
                Random probability = 0.5
            ]
            effects = [
                SetPlanetType type = Target.NextBetterPlanetType
                GenerateSitRepMessage
                    message = "EFFECT_GAIAN_TERRAFORM"
                    label = "EFFECT_GAIAN_TERRAFORM_LABEL"
                    icon = "icons/building/terraform.png"
                    parameters = [
                        tag = "planet" data = Source.ID
                    ]
                    empire = Source.Owner
            ]

        EffectsGroup
            scope = And [
                Object id = Source.PlanetID
                Planet environment = Good
            ]
            priority = [[TARGET_POPULATION_AFTER_SCALING_PRIORITY]]
            effects = [
                SetTargetPopulation value = Value + 3 * Target.HabitableSize accountinglabel = "GAIA_LABEL"
                SetTargetHappiness value = Value + 5 accountinglabel = "GAIA_LABEL"
            ]

        EffectsGroup
            scope = Source
            activation = And [
                Turn high = 0
                (GalaxyMaxAIAggression >= 1)
                (GalaxyMonsterFrequency >= 1)
            ]
            stackinggroup = "GAIAN_STACK"
            effects = CreateShip designname = "SM_GUARD_2"

        EffectsGroup
            scope = Source
            activation = Turn high = 0
            stackinggroup = "GAIAN_STACK"
            effects = Destroy
    ]
    graphic = "icons/specials_huge/gaia.png"

#include "/scripting/common/priorities.macros"
