Part
    name = "SH_ROBOTIC_INTERFACE_SHIELDS"
    description = "SH_ROBOTIC_INTERFACE_SHIELDS_DESC"
    class = Shield
    capacity = 0
    mountableSlotTypes = [Internal]
    buildcost = 40 * [[FLEET_UPKEEP_MULTIPLICATOR]] * [[SHIP_PART_COST_MULTIPLIER]]
    buildtime = 4
    tags = [ "PEDIA_PC_SHIELD" ]
    location = And [
        Planet
        OwnedBy empire = Source.Owner
        /// @content_tag{ROBOTIC} Allows a location to produce this ShipPart
        HasTag name = "ROBOTIC"
    ]
    effectsgroups =
        /// @content_tag{ROBOTIC} Ships with this part and ROBOTIC_HULL tag contribute towards increased shields of other ships with this part within 0 starlane jumps
        /// @content_tag{ROBOTIC_HULL} Ships with this part and ROBOTIC tag contribute towards increased shields of other ships with this part within 0 starlane jumps
        EffectsGroup
            scope = And [
                Source
                HasTag name = "ROBOTIC"
                /// @content_tag{ROBOTIC_HULL} Combined with ROBOTIC tag, allows shield increase from this ShipPart
                HasTag name = "ROBOTIC_HULL"
            ]
            activation = ([[ROBOTIC_SHIELD_EFFECT]] >= [[BEST_SHIELD_EFFECT]])
            stackinggroup = "ROBOTIC_SHIELD_PART_STACK"
            accountinglabel = "ROBOTIC_INTERFACE_EFFECT"
            effects = SetMaxShield value = Value - [[BEST_SHIELD_EFFECT]] + ( [[ROBOTIC_SHIELD_EFFECT]] * [[SHIP_SHIELD_FACTOR]] )
    icon = "icons/ship_parts/robotic-interface-shields.png"


COUNT_OF_LOCAL_ROBOTIC_INTERFACE_SHIELDS
'''
Statistic Count condition = And [
                Ship
                OwnedBy empire = Source.Owner
                VisibleToEmpire empire = Source.Owner
                HasTag name = "ROBOTIC"
                HasTag name = "ROBOTIC_HULL"
                Not Source
                DesignHasPart low = 1 high = 999 name = "SH_ROBOTIC_INTERFACE_SHIELDS"
                WithinStarlaneJumps jumps = 0 condition = Source
            ]
'''

ROBOTIC_SHIELD_EFFECT
'''
min(
    20.0,
    [[COUNT_OF_LOCAL_ROBOTIC_INTERFACE_SHIELDS]],
    ([[COUNT_OF_LOCAL_ROBOTIC_INTERFACE_SHIELDS]] * 7 ) ^ 0.5
)
'''

BEST_SHIELD_EFFECT
'''
max(max(max(max(
    min(1, PartsInShipDesign name = "SH_DEFENSE_GRID" design = Source.DesignID)
    * PartCapacity name = "SH_DEFENSE_GRID",
    min(1, PartsInShipDesign name = "SH_DEFLECTOR" design = Source.DesignID)
    * PartCapacity name = "SH_DEFLECTOR"),
    min(1, PartsInShipDesign name = "SH_PLASMA" design = Source.DesignID)
    * PartCapacity name = "SH_PLASMA"),
    min(1, PartsInShipDesign name = "SH_BLACK" design = Source.DesignID)
    * PartCapacity name = "SH_BLACK"),
    min(1, PartsInShipDesign name = "SH_MULTISPEC" design = Source.DesignID)
    * PartCapacity name = "SH_MULTISPEC" 
    )
'''

#include "/scripting/macros/upkeep.macros"

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