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 = 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 = Or [
                OwnedBy affiliation = AnyEmpire
                Species
            ]
            effects = [
                SetMaxShield value = Value + (NamedReal name = "FORTRESS_SPECIAL_SHIELD_BONUS" value = (100 * [[PLANET_SHIELD_FACTOR]] ))
                SetMaxDefense value = Value + (NamedReal name = "FORTRESS_SPECIAL_DEFENSE_BONUS" value = (30 * [[PLANET_DEFENSE_FACTOR]] ))
                SetMaxTroops value = Value + (NamedReal name = "FORTRESS_SPECIAL_TROOPS_BONUS" value = 30)
                SetDetection value = Value + (NamedReal name = "FORTRESS_SPECIAL_DETECTION_BONUS" value = 30)

                //Regeneration
                SetShield value = Value + ( min(5.0, max(Value, 0.25*Target.Construction)) * [[PLANET_SHIELD_FACTOR]] )
                SetDefense value = Value + (NamedReal name = "FORTRESS_SPECIAL_DEFENSE_REGEN" value = ( 1 * [[PLANET_DEFENSE_FACTOR]] ))
            ]
        [[EG_SYSTEM_MINES(NamedRealLookup name = "FORTRESS_SPECIAL_SYSTEM_MINES",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"
        
        [[SPECIAL_LIKES_OR_DISLIKES_SPECIAL_STABILITY_EFFECTS]]
    ]
    graphic = "icons/specials_huge/fortress.png"

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

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