FieldType
    name = "FLD_MOLECULAR_CLOUD"
    description = "FLD_MOLECULAR_CLOUD_DESC"
    stealth = 0.01
    tags = [ "EXOTIC" ]
    effectsgroups = [
        EffectsGroup    // move around
            scope = Source
            effects = [
                SetSpeed value = 5
                MoveTowards speed = Source.Speed/2.8 x = UniverseCentreX y = UniverseCentreY
                MoveInOrbit speed = Source.Speed/1.4 x = UniverseCentreX y = UniverseCentreY
            ]

        EffectsGroup    // grow size when young
            scope = Source
            activation = And [
                (Source.Age <= max((UniverseWidth ^ 1.1) / 50, 30))
                Size high = 100
            ]
            effects = SetSize value = Value + min(max(Value * RandomNumber(0.05, 0.1), 1.0), 5.0)

        EffectsGroup    // shrink size when old
            scope = Source
            activation = (LocalCandidate.Age >= max((UniverseWidth ^ 1.1) / 50, 30))
            effects = SetSize value = Value - min(max(Value * RandomNumber(0.05, 0.1), 1.0), 5.0)

        EffectsGroup    // reduce shields
            scope = And [
                Ship
                WithinDistance distance = Source.Size *0.9 condition = Source
            ]
            stackinggroup = "MOLECULAR_CLOUD_SHIELD_REDUCTION"
            effects = SetMaxShield value = Value - NamedReal name = "FLD_MOLECULAR_CLOUD_SHIELD_MALUS" value = (15 * [[SHIP_SHIELD_FACTOR]])

        EffectsGroup    // after reaching a certain age, dissipate when small
            scope = Source
            activation = And [
                (LocalCandidate.Age >= 10)
                Size high = 10
            ]
            effects = Destroy
    ]
    graphic = "fields/molecular_cloud.png"

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