Part
    name = "SP_SOLAR_CONCENTRATOR"
    description = "SP_SOLAR_CONCENTRATOR_DESC"
    class = General
    mountableSlotTypes = Internal
    buildcost = 70 * [[FLEET_UPKEEP_MULTIPLICATOR]] * [[SHIP_PART_COST_MULTIPLIER]]
    buildtime = 4
    tags = [ "PEDIA_PC_GENERAL" ]
    location = And [
        Planet
        OwnedBy empire = Source.Owner
    ]
    effectsgroups = [
        /// @content_tag{ORGANIC_HULL} Ships with this part contribute towards increased weapon damage of other Ships with this part within 0 starlane jumps
        EffectsGroup
            scope = Source
            activation = Star type = [ Red ]
            stackinggroup = "SOLAR_CONCENTRATOR_PART_STACK"
            effects = [
                SetMaxCapacity partname = "SR_WEAPON_2_1" value = Value + [[SOLAR_CONCENTRATOR_EFFECT]] * 0.5
                SetCapacity partname = "SR_WEAPON_2_1" value = Value + [[SOLAR_CONCENTRATOR_EFFECT]] * 0.5
                SetMaxCapacity partname = "SR_ICE_BEAM" value = Value + [[SOLAR_CONCENTRATOR_EFFECT]] * 0.5
                SetCapacity partname = "SR_ICE_BEAM" value = Value + [[SOLAR_CONCENTRATOR_EFFECT]] * 0.5
            ]
        EffectsGroup
            scope = Source
            activation = Star type = [ Orange ]
            stackinggroup = "SOLAR_CONCENTRATOR_PART_STACK"
            effects = [
                SetMaxCapacity partname = "SR_WEAPON_2_1" value = Value + [[SOLAR_CONCENTRATOR_EFFECT]] * 0.75
                SetCapacity partname = "SR_WEAPON_2_1" value = Value + [[SOLAR_CONCENTRATOR_EFFECT]] * 0.75
                SetMaxCapacity partname = "SR_ICE_BEAM" value = Value + [[SOLAR_CONCENTRATOR_EFFECT]] * 0.75
                SetCapacity partname = "SR_ICE_BEAM" value = Value + [[SOLAR_CONCENTRATOR_EFFECT]] * 0.75
            ]
        EffectsGroup
            scope = Source
            activation = Star type = [ Yellow ]
            stackinggroup = "SOLAR_CONCENTRATOR_PART_STACK"
            effects = [
                SetMaxCapacity partname = "SR_WEAPON_2_1" value = Value + [[SOLAR_CONCENTRATOR_EFFECT]]
                SetCapacity partname = "SR_WEAPON_2_1" value = Value + [[SOLAR_CONCENTRATOR_EFFECT]]
                SetMaxCapacity partname = "SR_ICE_BEAM" value = Value + [[SOLAR_CONCENTRATOR_EFFECT]]
                SetCapacity partname = "SR_ICE_BEAM" value = Value + [[SOLAR_CONCENTRATOR_EFFECT]]
            ]
        EffectsGroup
            scope = Source
            activation = Star type = [ White ]
            stackinggroup = "SOLAR_CONCENTRATOR_PART_STACK"
            effects = [
                SetMaxCapacity partname = "SR_WEAPON_2_1" value = Value + [[SOLAR_CONCENTRATOR_EFFECT]] * 1.25
                SetCapacity partname = "SR_WEAPON_2_1" value = Value + [[SOLAR_CONCENTRATOR_EFFECT]] * 1.25
                SetMaxCapacity partname = "SR_ICE_BEAM" value = Value + [[SOLAR_CONCENTRATOR_EFFECT]] * 1.25
                SetCapacity partname = "SR_ICE_BEAM" value = Value + [[SOLAR_CONCENTRATOR_EFFECT]] * 1.25
            ]
        EffectsGroup
            scope = Source
            activation = Star type = [ Blue ]
            stackinggroup = "SOLAR_CONCENTRATOR_PART_STACK"
            effects = [
                SetMaxCapacity partname = "SR_WEAPON_2_1" value = Value + [[SOLAR_CONCENTRATOR_EFFECT]] * 1.5
                SetCapacity partname = "SR_WEAPON_2_1" value = Value + [[SOLAR_CONCENTRATOR_EFFECT]] * 1.5
                SetMaxCapacity partname = "SR_ICE_BEAM" value = Value + [[SOLAR_CONCENTRATOR_EFFECT]] * 1.5
                SetCapacity partname = "SR_ICE_BEAM" value = Value + [[SOLAR_CONCENTRATOR_EFFECT]] * 1.5
            ]
        ]
    icon = "icons/ship_parts/solarcollector.png"


COUNT_OF_LOCAL_SOLAR_CONCENTRATOR
'''
Statistic Count condition = And [
                OwnerHasTech name = "SHP_SOLAR_CONNECTION"
                Ship
                OwnedBy empire = Source.Owner
                VisibleToEmpire empire = Source.Owner
                Or [
                    HasTag name = "ORGANIC_HULL"
                    HasTag name = "SNOWFLAKE_HULL"
                ]
                DesignHasPart low = 1 high = 999 name = "SP_SOLAR_CONCENTRATOR"
                WithinStarlaneJumps jumps = 0 condition = Source
            ]
'''

SOLAR_CONCENTRATOR_EFFECT
'''
(max(
    min(
        min(
            (([[COUNT_OF_LOCAL_SOLAR_CONCENTRATOR]]) / 2),
            (([[COUNT_OF_LOCAL_SOLAR_CONCENTRATOR]]) ^ 0.5 ) + 4 ),
        15)
    ,3)) * [[SHIP_WEAPON_DAMAGE_FACTOR]]
'''

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