Special
    name = "GAIA_SPECIAL"
    description = "GAIA_SPECIAL_DESC"
    stealth = 0
    spawnrate = 0.2
    spawnlimit = 12
    location = And [
        Planet
        Not Planet type = [Asteroids GasGiant]
        Not WithinStarlaneJumps jumps = max(3, (NamedIntegerLookup name = "MIN_MONSTER_DISTANCE")) 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
            
        [[SPECIAL_LIKES_OR_DISLIKES_SPECIAL_STABILITY_EFFECTS]]
    ]
    graphic = "icons/specials_huge/gaia.png"

#include "/scripting/macros/priorities.macros"
#include "/scripting/specials/specials.macros.txt"