Special
    name = "FORTRESS_SPECIAL"
    description = "FORTRESS_SPECIAL_DESC"
    stealth = 0
    spawnrate = 0.2
    spawnlimit = 3
    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 = Or [
                OwnedBy affiliation = AnyEmpire
                Species
            ]
            effects = [
                SetMaxShield value = Value + ( 100 * [[PLANET_SHIELD_FACTOR]] )
                SetMaxDefense value = Value + ( 30 * [[PLANET_DEFENSE_FACTOR]] )
                SetMaxTroops value = Value + 30
                SetDetection value = Value + 30

                //Regeneration
                SetShield value = Value + ( min(5.0, max(Value, 0.25*Target.Construction)) * [[PLANET_SHIELD_FACTOR]] )
                SetDefense value = Value + ( 1 * [[PLANET_DEFENSE_FACTOR]] )
            ]
        [[EG_SYSTEM_MINES(3,70,SOURCE)]] //Priority deliberately not a macro

        EffectsGroup
            scope = Source
            activation = AND [
                Planet
                OwnedBy affiliation = AnyEmpire
                Not ContainedBy Contains Design name = "SM_GUARD_1"
                Random probability = 0.05
            ]
            effects = [
                CreateShip designname = "SM_GUARD_1" empire = Source.Owner
                GenerateSitRepMessage
                    message = "EFFECT_SENTRY_CREATED"
                    label = "EFFECT_SENTRY_CREATED_LABEL"
                    icon = "icons/monsters/sentry.png"
                    parameters = [
                        tag = "planet" data = Source.ID
                        tag = "predefinedshipdesign" data = "SM_GUARD_1"
                    ]
                    empire = Source.Owner
            ]

        EffectsGroup
            scope = Source
            activation = And [
                Turn high = 0
                (GalaxyMaxAIAggression >= 1)
                (GalaxyMonsterFrequency >= 1)
            ]
            effects = CreateShip designname = "SM_GUARD_2"
        ]
        graphic = "icons/specials_huge/fortress.png"

#include "/scripting/techs/defense/mines.macros"

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