// For long term changes - Do not modify this definition directly
//                     Instead modify and execute col_bld_gen.py and use the result.
BuildingType
    name = "BLD_COL_SSLITH"
    description = "BLD_COL_SSLITH_DESC"
    buildcost = 50 * [[COLONY_UPKEEP_MULTIPLICATOR]] * [[BUILDING_COST_MULTIPLIER]]
    buildtime = 1.0 * max(5.0, 1.0 +
        (Statistic Min Value = ShortestPath Object = Target.SystemID Object = LocalCandidate.SystemID
            Condition = And [
                Planet
                OwnedBy empire = Source.Owner
                Species name = "SP_SSLITH"
                Population low = [[MIN_RECOLONIZING_SIZE]]
                Happiness low = 5
                ResourceSupplyConnected empire = Source.Owner condition = Target
            ]
        ) / (60
             + 20 * (Statistic If Condition = Or [
                 OwnerHasTech name = "SHP_MIL_ROBO_CONT"
                 OwnerHasTech name = "SHP_ORG_HULL"
                 OwnerHasTech name = "SHP_QUANT_ENRG_MAG"
             ])
             + 20 * (Statistic If Condition = Or [
                 OwnerHasTech name = "SHP_ORG_HULL"
                 OwnerHasTech name = "SHP_QUANT_ENRG_MAG"
             ])
             + 20 * (Statistic If Condition = OwnerHasTech name = "SHP_QUANT_ENRG_MAG")
             + 10 * (Statistic If Condition = OwnerHasTech name = "SHP_IMPROVED_ENGINE_COUPLINGS")
             + 10 * (Statistic If Condition = OwnerHasTech name = "SHP_N_DIMENSIONAL_ENGINE_MATRIX")
             + 10 * (Statistic If Condition = OwnerHasTech name = "SHP_SINGULARITY_ENGINE_CORE")
             + 10 * (Statistic If Condition = OwnerHasTech name = "SHP_TRANSSPACE_DRIVE")
             + 10 * (Statistic If Condition = OwnerHasTech name = "SHP_INTSTEL_LOG")
        )
    )
    tags = [ "SP_SSLITH" ]
    location = And [
        Planet
        OwnedBy empire = Source.Owner
        Population high = 0
        Not Planet environment = Uninhabitable species = "SP_SSLITH"
        Not Contains Building name = "BLD_COL_SSLITH"
        ResourceSupplyConnected empire = Source.Owner condition = And [
            Planet
            OwnedBy empire = Source.Owner
            Species name = "SP_SSLITH"
            Population low = [[MIN_RECOLONIZING_SIZE]]
            Happiness low = 5
        ]
    ]
    EnqueueLocation = And [
        Planet
        OwnedBy empire = Source.Owner
        Population high = 0
        Not Planet environment = Uninhabitable species = "SP_SSLITH"
        Not Contains Building name = "BLD_COL_SSLITH"
        Not Enqueued type = Building name = "BLD_COL_SSLITH"
        ResourceSupplyConnected empire = Source.Owner condition = And [
            Planet
            OwnedBy empire = Source.Owner
            Species name = "SP_SSLITH"
            Population low = [[MIN_RECOLONIZING_SIZE]]
            Happiness low = 5
        ]
    ]
    effectsgroups = [
        [[LIFECYCLE_MANIP_POPULATION_EFFECTS("SP_SSLITH")]]
        
        EffectsGroup
            scope = And [
                Object id = Source.PlanetID
                Planet
            ]
            activation = Turn low = Source.CreationTurn + 1 high = Source.CreationTurn + 1
            effects = [
                GenerateSitRepMessage
                    message = "SITREP_NEW_COLONY_ESTABLISHED"
                    label = "SITREP_NEW_COLONY_ESTABLISHED_LABEL"
                    icon = "icons/species/sslith.png"
                    parameters = [
                        tag = "species" data = "SP_SSLITH"
                        tag = "planet" data = Target.ID
                    ]
                    empire = Source.Owner
            ]
            
        EffectsGroup
            scope = Source
            activation = Turn low = Source.CreationTurn + 2
            effects = Destroy
    ]
    icon = "icons/species/sslith.png"

#include "/scripting/common/misc.macros"
#include "/scripting/common/upkeep.macros"
#include "/scripting/common/priorities.macros"
#include "/scripting/common/base_prod.macros"
#include "/scripting/species/common/population.macros"
