Tech
    name = "DEF_PLAN_BARRIER_SHLD_1"
    description = "DEF_PLAN_BARRIER_SHLD_1_DESC"
    short_description = "SHIELD_SHORT_DESC"
    category = "DEFENSE_CATEGORY"
    researchcost = 80 * [[TECH_COST_MULTIPLIER]]
    researchturns = 5
    tags = [ "PEDIA_DEFENSE_CATEGORY" ]
    prerequisites = "LRN_FORCE_FIELD"
    effectsgroups = [
        EffectsGroup
            scope = And [
                Planet
                OwnedBy empire = Source.Owner
            ]
            priority = [[DEFAULT_PRIORITY]]
            effects =
                SetMaxShield value = Value + ( 30 * [[PLANET_SHIELD_FACTOR]] ) accountinglabel = "DEF_PLAN_BARRIER_SHLD_1"

        EffectsGroup
            scope = And [
                Planet
                OwnedBy empire = Source.Owner
                (LocalCandidate.LastTurnAttackedByShip < CurrentTurn - 1)
            ]
            priority = [[AFTER_ALL_TARGET_MAX_METERS_PRIORITY]]
            effects = SetShield value = Value + max(min([[PLANET_SHIELD_FACTOR]], Value), 0.25*Target.Construction*[[PLANET_SHIELD_FACTOR]])
    ]

    graphic = "icons/tech/planetary_barrier_shield.png"

Tech
    name = "DEF_PLAN_BARRIER_SHLD_2"
    description = "DEF_PLAN_BARRIER_SHLD_2_DESC"
    short_description = "SHIELD_SHORT_DESC"
    category = "DEFENSE_CATEGORY"
    researchcost = 120 * [[TECH_COST_MULTIPLIER]]
    researchturns = 6
    tags = [ "PEDIA_DEFENSE_CATEGORY" ]
    prerequisites = "DEF_PLAN_BARRIER_SHLD_1"
    effectsgroups = [
        EffectsGroup
            scope = And [
                Planet
                OwnedBy empire = Source.Owner
                (LocalCandidate.LastTurnAttackedByShip < CurrentTurn - 1)
            ]
            priority = [[DEFAULT_PRIORITY]]
            effects = SetMaxShield value = Value + ( 60 * [[PLANET_SHIELD_FACTOR]] ) accountinglabel = "DEF_PLAN_BARRIER_SHLD_2"

        EffectsGroup
            scope = And [
                Planet
                OwnedBy empire = Source.Owner
                (LocalCandidate.LastTurnAttackedByShip < CurrentTurn - 1)
            ]
            priority = [[AFTER_ALL_TARGET_MAX_METERS_PRIORITY]]
            effects = SetShield value = Value + max(min(3.0*[[PLANET_SHIELD_FACTOR]], Value), 0.75*Target.Construction*[[PLANET_SHIELD_FACTOR]])
    ]

    graphic = "icons/tech/planetary_barrier_shield.png"

Tech
    name = "DEF_PLAN_BARRIER_SHLD_3"
    description = "DEF_PLAN_BARRIER_SHLD_3_DESC"
    short_description = "SHIELD_SHORT_DESC"
    category = "DEFENSE_CATEGORY"
    researchcost = 240 * [[TECH_COST_MULTIPLIER]]
    researchturns = 8
    tags = [ "PEDIA_DEFENSE_CATEGORY" ]
    prerequisites = "DEF_PLAN_BARRIER_SHLD_2"
    effectsgroups = [
        EffectsGroup
            scope = And [
                Planet
                OwnedBy empire = Source.Owner
                (LocalCandidate.LastTurnAttackedByShip < CurrentTurn - 1)
            ]
            priority = [[DEFAULT_PRIORITY]]
            effects = SetMaxShield value = Value + ( 90 * [[PLANET_SHIELD_FACTOR]] ) accountinglabel = "DEF_PLAN_BARRIER_SHLD_3"

        EffectsGroup
            scope = And [
                Planet
                OwnedBy empire = Source.Owner
                (LocalCandidate.LastTurnAttackedByShip < CurrentTurn - 1)
            ]
            priority = [[AFTER_ALL_TARGET_MAX_METERS_PRIORITY]]
            effects = SetShield value = Value + max(min(5.0*[[PLANET_SHIELD_FACTOR]], Value), 1.0*Target.Construction*[[PLANET_SHIELD_FACTOR]])
    ]
    
    graphic = "icons/tech/planetary_barrier_shield.png"

Tech
    name = "DEF_PLAN_BARRIER_SHLD_4"
    description = "DEF_PLAN_BARRIER_SHLD_4_DESC"
    short_description = "SHIELD_SHORT_DESC"
    category = "DEFENSE_CATEGORY"
    researchcost = 500 * [[TECH_COST_MULTIPLIER]]
    researchturns = 10
    tags = [ "PEDIA_DEFENSE_CATEGORY" ]
    prerequisites = "DEF_PLAN_BARRIER_SHLD_3"
    effectsgroups = [
        EffectsGroup
            scope = And [
                Planet
                OwnedBy empire = Source.Owner
                (LocalCandidate.LastTurnAttackedByShip < CurrentTurn - 1)
            ]
            priority = [[DEFAULT_PRIORITY]]
            effects = SetMaxShield value = Value + ( 150 * [[PLANET_SHIELD_FACTOR]] ) accountinglabel = "DEF_PLAN_BARRIER_SHLD_4"

        EffectsGroup
            scope = And [
                Planet
                OwnedBy empire = Source.Owner
                (LocalCandidate.LastTurnAttackedByShip < CurrentTurn - 1)
            ]
            priority = [[AFTER_ALL_TARGET_MAX_METERS_PRIORITY]]
            effects = SetShield value = Value + max(min(9.0*[[PLANET_SHIELD_FACTOR]], Value), 1.5*Target.Construction*[[PLANET_SHIELD_FACTOR]])
    ]
    
    graphic = "icons/tech/planetary_barrier_shield.png"

Tech
    name = "DEF_PLAN_BARRIER_SHLD_5"
    description = "DEF_PLAN_BARRIER_SHLD_5_DESC"
    short_description = "SHIELD_SHORT_DESC"
    category = "DEFENSE_CATEGORY"
    researchcost = 1200* [[TECH_COST_MULTIPLIER]]
    researchturns = 12
    tags = [ "PEDIA_DEFENSE_CATEGORY" ]
    prerequisites = "DEF_PLAN_BARRIER_SHLD_4"
    effectsgroups = [
        EffectsGroup
            scope = And [
                Planet
                OwnedBy empire = Source.Owner
            ]
            priority = [[DEFAULT_PRIORITY]]
            effects = SetMaxShield value = Value + ( 150 * [[PLANET_SHIELD_FACTOR]] ) accountinglabel = "DEF_PLAN_BARRIER_SHLD_5"

        EffectsGroup
            scope = And [
                Planet
                OwnedBy empire = Source.Owner
                (LocalCandidate.LastTurnAttackedByShip < CurrentTurn - 1)
            ]
            priority = [[AFTER_ALL_TARGET_MAX_METERS_PRIORITY]]
            effects = SetShield value = Value + max(min(14.0*[[PLANET_SHIELD_FACTOR]], Value), 2.5*Target.Construction*[[PLANET_SHIELD_FACTOR]])
    ]
    
    graphic = "icons/tech/planetary_barrier_shield.png"

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

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