Part
    name = "SP_CHAOS_WAVE"
    description = "SP_CHAOS_WAVE_DESC"
    class = Bombard
    capacity = 2.0
    mountableSlotTypes = External
    buildcost = 10 * [[FLEET_UPKEEP_MULTIPLICATOR]] * [[SHIP_PART_COST_MULTIPLIER]]
    buildtime = 5
    tags = [ "CTRL_ALWAYS_BOMBARD" "PEDIA_PC_BOMBARD" ]
    location = All
    effectsgroups = [
        EffectsGroup    // players can order chaos wave used on enemies
            scope = And [
                Planet
                InSystem id = Source.SystemID
                OrderedBombardedBy condition = Source
                Or [
                    OwnedBy affiliation = EnemyOf empire = Source.Owner
                    Unowned
                ]
                VisibleToEmpire empire = Source.Owner
            ]
            priority = [[POPULATION_DEFAULT_PRIORITY]]
            effects = [
                SetPopulation value = Value - 2
                GenerateSitRepMessage
                    message = "EFFECT_BIOWEAPON"
                    label = "EFFECT_BIOWEAPON_LABEL"
                    icon = "icons/sitrep/bio_weapon_2.png"
                    parameters = [
                        tag = "planet" data = Target.ID
                        tag = "rawtext" data = "2"
                        tag = "shippart" data = "SP_CHAOS_WAVE"
                    ]
                    empire = Target.Owner
            ]

        EffectsGroup    // players can order chaos wave used on enemies
            scope = And [
                Planet
                InSystem id = Source.SystemID
                OrderedBombardedBy condition = Source
                Or [
                    OwnedBy affiliation = EnemyOf empire = Source.Owner
                    Unowned
                ]
                VisibleToEmpire empire = Source.Owner
                HasSpecial name = "GAIA_SPECIAL"
            ]
            priority = [[POPULATION_DEFAULT_PRIORITY]]
            effects = [
                RemoveSpecial name = "GAIA_SPECIAL"
                GenerateSitRepMessage
                    message = "EFFECT_BIOWEAPON_GAIA"
                    label = "EFFECT_BIOWEAPON_LABEL"
                    icon = "icons/sitrep/bio_weapon_2.png"
                    parameters = [
                        tag = "planet" data = Target.ID
                        tag = "shippart" data = "SP_CHAOS_WAVE"
                    ]
                    empire = Target.Owner
            ]

        EffectsGroup    // players can order chaos wave used on enemies outposts
            scope = And [
                Planet
                InSystem id = Source.SystemID
                OrderedBombardedBy condition = Source
                OwnedBy affiliation = EnemyOf empire = Source.Owner
                Population high = 0
                VisibleToEmpire empire = Source.Owner
            ]
            priority = [[POPULATION_DEFAULT_PRIORITY]]
            effects = [
                SetOwner empire = [[UNOWNED_EMPIRE_ID]]
                GenerateSitRepMessage
                    message = "EFFECT_BIOWEAPON_UNOWN"
                    label = "EFFECT_BIOWEAPON_LABEL"
                    icon = "icons/sitrep/bio_weapon_2.png"
                    parameters = [
                        tag = "planet" data = Target.ID
                        tag = "shippart" data = "SP_CHAOS_WAVE"
                    ]
                    empire = Target.Owner
            ]

        EffectsGroup    // monsters use chaos wave on player planets
            scope = NumberOf number = 1 condition = And [
                Planet
                InSystem id = Source.SystemID
                OwnedBy affiliation = AnyEmpire
                Stealth high = Source.Detection
            ]
            activation = And [
                Unowned
                InSystem
            ]
            priority = [[POPULATION_DEFAULT_PRIORITY]]
            effects = [
                SetPopulation value = Value - 2
                GenerateSitRepMessage
                    message = "EFFECT_BIOWEAPON"
                    label = "EFFECT_BIOWEAPON_LABEL"
                    icon = "icons/sitrep/bio_weapon_2.png"
                    parameters = [
                        tag = "planet" data = Target.ID
                        tag = "rawtext" data = "2"
                        tag = "shippart" data = "SP_CHAOS_WAVE"
                    ]
                    empire = Target.Owner
            ]

        EffectsGroup    // monsters use chaos wave on player planets
            scope = NumberOf number = 1 condition = And [
                Planet
                InSystem id = Source.SystemID
                OwnedBy affiliation = AnyEmpire
                Stealth high = Source.Detection
                HasSpecial name = "GAIA_SPECIAL"
            ]
            activation = And [
                Unowned
                InSystem
            ]
            priority = [[POPULATION_DEFAULT_PRIORITY]]
            effects = [
                RemoveSpecial name = "GAIA_SPECIAL"
                GenerateSitRepMessage
                    message = "EFFECT_BIOWEAPON_GAIA"
                    label = "EFFECT_BIOWEAPON_LABEL"
                    icon = "icons/sitrep/bio_weapon_2.png"
                    parameters = [
                        tag = "planet" data = Target.ID
                        tag = "shippart" data = "SP_CHAOS_WAVE"
                    ]
                    empire = Target.Owner
            ]

        EffectsGroup    // monsters use chaos wave on player outposts
            scope = NumberOf number = 1 condition = And [
                Planet
                InSystem id = Source.SystemID
                OwnedBy affiliation = AnyEmpire
                Stealth high = Source.Detection
                Population high = 0
            ]
            activation = And [
                Unowned
                InSystem
            ]
            priority = [[POPULATION_DEFAULT_PRIORITY]]
            effects = [
                SetOwner empire = [[UNOWNED_EMPIRE_ID]]
                GenerateSitRepMessage
                    message = "EFFECT_BIOWEAPON_UNOWN"
                    label = "EFFECT_BIOWEAPON_LABEL"
                    icon = "icons/sitrep/bio_weapon_2.png"
                    parameters = [
                        tag = "planet" data = Target.ID
                        tag = "shippart" data = "SP_CHAOS_WAVE"
                    ]
                    empire = Target.Owner
            ]
    ]
    icon = "icons/ship_parts/chaos-wave.png"

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