Barotrauma Client Doc
Barotrauma.StatusEffect Class Reference

StatusEffects can be used to execute various kinds of effects: modifying the state of some entity in some way, spawning things, playing sounds, emitting particles, creating fire and explosions, increasing a characters' skill. They are a crucial part of modding Barotrauma: all kinds of custom behaviors of an item or a creature for example are generally created using StatusEffects. More...

Inheritance diagram for Barotrauma.StatusEffect:
Barotrauma.DelayedEffect

Classes

class  AbilityStatusEffectIdentifier
 Can be used by AbilityConditionStatusEffectIdentifier to check whether some specific StatusEffect is running. More...
 
class  AITrigger
 Can be used to trigger a behavior change of some kind on an AI character. Only applicable for enemy characters, not humans. More...
 
class  CharacterSpawnInfo
 Defines characters spawned by the effect, and where and how they're spawned. More...
 
class  GiveSkill
 Increases a character's skills when the effect executes. Only valid if the target is a character or a limb. More...
 
class  GiveTalentInfo
 Unlocks a talent, or multiple talents when the effect executes. Only valid if the target is a character or a limb. More...
 

Public Types

enum class  TargetType {
  This = 1 , Parent = 2 , Character = 4 , Contained = 8 ,
  NearbyCharacters = 16 , NearbyItems = 32 , UseTarget = 64 , Hull = 128 ,
  Limb = 256 , AllLimbs = 512 , LastLimb = 1024
}
 

Public Member Functions

bool HasTargetType (TargetType targetType)
 
bool ReducesItemCondition ()
 
bool IncreasesItemCondition ()
 
bool MatchesTagConditionals (ItemPrefab itemPrefab)
 
bool HasRequiredAfflictions (AttackResult attackResult)
 
virtual bool HasRequiredItems (Entity entity)
 
void AddNearbyTargets (Vector2 worldPosition, List< ISerializableEntity > targets)
 
bool HasRequiredConditions (IReadOnlyList< ISerializableEntity > targets)
 
void SetUser (Character user)
 
bool ShouldWaitForInterval (Entity entity, float deltaTime)
 
virtual void Apply (ActionType type, float deltaTime, Entity entity, ISerializableEntity target, Vector2? worldPosition=null)
 
virtual void Apply (ActionType type, float deltaTime, Entity entity, IReadOnlyList< ISerializableEntity > targets, Vector2? worldPosition=null)
 
void AddTag (Identifier tag)
 
bool HasTag (Identifier tag)
 

Static Public Member Functions

static StatusEffect Load (ContentXElement element, string parentDebugName)
 
static void UpdateAll (float deltaTime)
 
static void StopAll ()
 

Public Attributes

int TargetSlot = -1
 Index of the slot the target must be in. Only valid when targeting a Contained item. More...
 
readonly ImmutableArray<(Identifier propertyName, object value)> PropertyEffects
 
readonly bool CheckConditionalAlways
 Only applicable for StatusEffects with a duration or delay. Should the conditional checks only be done when the effect triggers, or for the whole duration it executes / when the delay runs out and the effect executes? In other words, if false, the conditionals are only checked once when the effect triggers, but after that it can keep running for the whole duration, or is guaranteed to execute after the delay. More...
 
readonly bool Stackable = true
 Only valid if the effect has a duration or delay. Can the effect be applied on the same target(s) if the effect is already being applied? More...
 
readonly float Interval
 The interval at which the effect is executed. The difference between delay and interval is that effects with a delay find the targets, check the conditions, etc immediately when Apply is called, but don't apply the effects until the delay has passed. Effects with an interval check if the interval has passed when Apply is called and apply the effects if it has, otherwise they do nothing. More...
 
readonly ActionType type = ActionType.OnActive
 
readonly List< GiveTalentInfogiveTalentInfos
 
readonly float FireSize
 
readonly LimbType[] targetLimbs
 Which types of limbs this effect can target? Only valid when targeting characters or limbs. More...
 
readonly float SeverLimbsProbability
 The probability of severing a limb damaged by this status effect. Only valid when targeting characters or limbs. More...
 
PhysicsBody sourceBody
 
readonly bool OnlyInside
 If enabled, this effect can only execute inside a hull. More...
 
readonly bool OnlyOutside
 If enabled, this effect can only execute outside hulls. More...
 
readonly bool OnlyWhenDamagedByPlayer
 If enabled, the effect only executes when the entity receives damage from a player character (a character controlled by a human player). Only valid for characters, and effects of the type OnDamaged. More...
 
readonly bool AllowWhenBroken = false
 Can the StatusEffect be applied when the item applying it is broken? More...
 
readonly ImmutableHashSet< IdentifierTargetIdentifiers
 Identifier(s), tag(s) or species name(s) of the entity the effect can target. Null if there's no identifiers. More...
 
readonly string TargetItemComponent
 If set to the name of one of the target's ItemComponents, the effect is only applied on that component. Only works on items. More...
 
float AfflictionMultiplier = 1.0f
 
readonly List<(Identifier AfflictionIdentifier, float ReduceAmount)> ReduceAffliction = new List<(Identifier affliction, float amount)>()
 
readonly float Duration
 How long the effect runs (in seconds). Note that if Stackable is true, there can be multiple instances of the effect running at a time. In other words, if the effect has a duration and executes every frame, you probably want to make it non-stackable or it'll lead to a large number of overlapping effects running at the same time. More...
 

Static Public Attributes

static readonly List< DurationListElementDurationList = new List<DurationListElement>()
 

Protected Member Functions

 StatusEffect (ContentXElement element, string parentDebugName)
 
bool IsValidTarget (ISerializableEntity entity)
 
bool IsValidTarget (ItemComponent itemComponent)
 
bool IsValidTarget (Item item)
 
bool IsValidTarget (Character character)
 
void Apply (float deltaTime, Entity entity, IReadOnlyList< ISerializableEntity > targets, Vector2? worldPosition=null)
 

Protected Attributes

readonly List< ISerializableEntitycurrentTargets = new List<ISerializableEntity>()
 

Properties

bool HasConditions [get]
 
IEnumerable< Explosion >?? Explosions [get]
 
List< AfflictionAfflictions = new List<Affliction>() [get]
 
IEnumerable< CharacterSpawnInfo >?? SpawnCharacters [get]
 
float Range [get]
 How close to the entity executing the effect the targets must be. Only applicable if targeting NearbyCharacters or NearbyItems. More...
 
Vector2 Offset [get]
 An offset added to the position of the effect is executed at. Only relevant if the effect does something where position matters, for example emitting particles or explosions, spawning something or playing sounds. More...
 
string Tags [get, set]
 
bool Disabled [get]
 
IEnumerable< RoundSoundSounds [get]
 

Detailed Description

StatusEffects can be used to execute various kinds of effects: modifying the state of some entity in some way, spawning things, playing sounds, emitting particles, creating fire and explosions, increasing a characters' skill. They are a crucial part of modding Barotrauma: all kinds of custom behaviors of an item or a creature for example are generally created using StatusEffects.

<doc> <Field identifier="delay" type="float" defaultValue="0.0"> Can be used to delay the execution of the effect. For example, you could have an effect that triggers when a character receives damage, but takes 5 seconds before it starts to do anything. </Field> <Field identifier="tags" type="string[]" defaultValue=""> An arbitrary tag (or a list of tags) that describe the status effect and can be used by Conditionals to check whether some StatusEffect is running. For example, an item could execute a StatusEffect with the tag "poisoned" on some character, and the character could have an effect that makes the character do something when an effect with that tag is active. </Field>
<Field identifier="conditionalComparison" type="Comparison" defaultValue="Or"> And/Or. Do all of the Conditionals defined in the effect be true for the effect to execute, or should the effect execute when any of them is true? </Field> <Field identifier="Any property of the target" type="Any" defaultValue=""> These are the meat of the StatusEffects. You can set, increment or decrement any value of the target, be it an item, character, limb or hull. By default, the value is added to the existing value. If you want to instead set the value, use the setValue attribute. For example, Condition="-5" would decrease the condition of the item the effect is targeting by 5 per second. If the target has no property with the specified name, the attribute does nothing. </Field> </doc>

Definition at line 70 of file BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs.

Member Enumeration Documentation

◆ TargetType

Enumerator
This 

The entity (item, character, limb) the StatusEffect is defined in.

Parent 

In the context of items, the container the item is inside (if any). In the context of limbs, the character the limb belongs to.

Character 

The character the StatusEffect is defined in. In the context of items and attacks, the character using the item/attack.

Contained 

The item(s) contained in the inventory of the entity the StatusEffect is defined in.

NearbyCharacters 

Characters near the entity the StatusEffect is defined in. The range is defined using Range.

NearbyItems 

Items near the entity the StatusEffect is defined in. The range is defined using Range.

UseTarget 

The entity the item/attack is being used on.

Hull 

The hull the entity is inside.

Limb 

The entity the item/attack is being used on. In the context of characters, one of the character's limbs (specify which one using targetLimbs).

AllLimbs 

All limbs of the character the effect is being used on.

LastLimb 

Last limb of the character the effect is being used on.

Definition at line 79 of file BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs.

Constructor & Destructor Documentation

◆ StatusEffect()

Barotrauma.StatusEffect.StatusEffect ( ContentXElement  element,
string  parentDebugName 
)
protected

Member Function Documentation

◆ AddNearbyTargets()

void Barotrauma.StatusEffect.AddNearbyTargets ( Vector2  worldPosition,
List< ISerializableEntity targets 
)

◆ AddTag()

void Barotrauma.StatusEffect.AddTag ( Identifier  tag)

◆ Apply() [1/3]

virtual void Barotrauma.StatusEffect.Apply ( ActionType  type,
float  deltaTime,
Entity  entity,
IReadOnlyList< ISerializableEntity targets,
Vector2?  worldPosition = null 
)
virtual

◆ Apply() [2/3]

virtual void Barotrauma.StatusEffect.Apply ( ActionType  type,
float  deltaTime,
Entity  entity,
ISerializableEntity  target,
Vector2?  worldPosition = null 
)
virtual

◆ Apply() [3/3]

void Barotrauma.StatusEffect.Apply ( float  deltaTime,
Entity  entity,
IReadOnlyList< ISerializableEntity targets,
Vector2?  worldPosition = null 
)
protected

◆ HasRequiredAfflictions()

bool Barotrauma.StatusEffect.HasRequiredAfflictions ( AttackResult  attackResult)

◆ HasRequiredConditions()

bool Barotrauma.StatusEffect.HasRequiredConditions ( IReadOnlyList< ISerializableEntity targets)

◆ HasRequiredItems()

virtual bool Barotrauma.StatusEffect.HasRequiredItems ( Entity  entity)
virtual

◆ HasTag()

bool Barotrauma.StatusEffect.HasTag ( Identifier  tag)

◆ HasTargetType()

bool Barotrauma.StatusEffect.HasTargetType ( TargetType  targetType)

◆ IncreasesItemCondition()

bool Barotrauma.StatusEffect.IncreasesItemCondition ( )

◆ IsValidTarget() [1/4]

bool Barotrauma.StatusEffect.IsValidTarget ( Character  character)
protected

◆ IsValidTarget() [2/4]

bool Barotrauma.StatusEffect.IsValidTarget ( ISerializableEntity  entity)
protected

◆ IsValidTarget() [3/4]

bool Barotrauma.StatusEffect.IsValidTarget ( Item  item)
protected

◆ IsValidTarget() [4/4]

bool Barotrauma.StatusEffect.IsValidTarget ( ItemComponent  itemComponent)
protected

◆ Load()

static StatusEffect Barotrauma.StatusEffect.Load ( ContentXElement  element,
string  parentDebugName 
)
static

◆ MatchesTagConditionals()

bool Barotrauma.StatusEffect.MatchesTagConditionals ( ItemPrefab  itemPrefab)

◆ ReducesItemCondition()

bool Barotrauma.StatusEffect.ReducesItemCondition ( )

◆ SetUser()

void Barotrauma.StatusEffect.SetUser ( Character  user)

◆ ShouldWaitForInterval()

bool Barotrauma.StatusEffect.ShouldWaitForInterval ( Entity  entity,
float  deltaTime 
)

◆ StopAll()

static void Barotrauma.StatusEffect.StopAll ( )
static

◆ UpdateAll()

static void Barotrauma.StatusEffect.UpdateAll ( float  deltaTime)
static

Member Data Documentation

◆ AfflictionMultiplier

float Barotrauma.StatusEffect.AfflictionMultiplier = 1.0f

◆ AllowWhenBroken

readonly bool Barotrauma.StatusEffect.AllowWhenBroken = false

Can the StatusEffect be applied when the item applying it is broken?

Definition at line 665 of file BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs.

◆ CheckConditionalAlways

readonly bool Barotrauma.StatusEffect.CheckConditionalAlways

Only applicable for StatusEffects with a duration or delay. Should the conditional checks only be done when the effect triggers, or for the whole duration it executes / when the delay runs out and the effect executes? In other words, if false, the conditionals are only checked once when the effect triggers, but after that it can keep running for the whole duration, or is guaranteed to execute after the delay.

Definition at line 555 of file BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs.

◆ currentTargets

readonly List<ISerializableEntity> Barotrauma.StatusEffect.currentTargets = new List<ISerializableEntity>()
protected

◆ Duration

readonly float Barotrauma.StatusEffect.Duration

How long the effect runs (in seconds). Note that if Stackable is true, there can be multiple instances of the effect running at a time. In other words, if the effect has a duration and executes every frame, you probably want to make it non-stackable or it'll lead to a large number of overlapping effects running at the same time.

Definition at line 715 of file BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs.

◆ DurationList

readonly List<DurationListElement> Barotrauma.StatusEffect.DurationList = new List<DurationListElement>()
static

◆ FireSize

readonly float Barotrauma.StatusEffect.FireSize

◆ giveTalentInfos

readonly List<GiveTalentInfo> Barotrauma.StatusEffect.giveTalentInfos

◆ Interval

readonly float Barotrauma.StatusEffect.Interval

The interval at which the effect is executed. The difference between delay and interval is that effects with a delay find the targets, check the conditions, etc immediately when Apply is called, but don't apply the effects until the delay has passed. Effects with an interval check if the interval has passed when Apply is called and apply the effects if it has, otherwise they do nothing.

Definition at line 567 of file BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs.

◆ OnlyInside

readonly bool Barotrauma.StatusEffect.OnlyInside

If enabled, this effect can only execute inside a hull.

Definition at line 650 of file BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs.

◆ OnlyOutside

readonly bool Barotrauma.StatusEffect.OnlyOutside

If enabled, this effect can only execute outside hulls.

Definition at line 654 of file BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs.

◆ OnlyWhenDamagedByPlayer

readonly bool Barotrauma.StatusEffect.OnlyWhenDamagedByPlayer

If enabled, the effect only executes when the entity receives damage from a player character (a character controlled by a human player). Only valid for characters, and effects of the type OnDamaged.

Definition at line 660 of file BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs.

◆ PropertyEffects

readonly ImmutableArray<(Identifier propertyName, object value)> Barotrauma.StatusEffect.PropertyEffects

◆ ReduceAffliction

readonly List<(Identifier AfflictionIdentifier, float ReduceAmount)> Barotrauma.StatusEffect.ReduceAffliction = new List<(Identifier affliction, float amount)>()

◆ SeverLimbsProbability

readonly float Barotrauma.StatusEffect.SeverLimbsProbability

The probability of severing a limb damaged by this status effect. Only valid when targeting characters or limbs.

Definition at line 643 of file BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs.

◆ sourceBody

PhysicsBody Barotrauma.StatusEffect.sourceBody

◆ Stackable

readonly bool Barotrauma.StatusEffect.Stackable = true

Only valid if the effect has a duration or delay. Can the effect be applied on the same target(s) if the effect is already being applied?

Definition at line 560 of file BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs.

◆ TargetIdentifiers

readonly ImmutableHashSet<Identifier> Barotrauma.StatusEffect.TargetIdentifiers

Identifier(s), tag(s) or species name(s) of the entity the effect can target. Null if there's no identifiers.

Definition at line 670 of file BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs.

◆ TargetItemComponent

readonly string Barotrauma.StatusEffect.TargetItemComponent

If set to the name of one of the target's ItemComponents, the effect is only applied on that component. Only works on items.

Definition at line 676 of file BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs.

◆ targetLimbs

readonly LimbType [] Barotrauma.StatusEffect.targetLimbs

Which types of limbs this effect can target? Only valid when targeting characters or limbs.

Definition at line 638 of file BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs.

◆ TargetSlot

int Barotrauma.StatusEffect.TargetSlot = -1

Index of the slot the target must be in. Only valid when targeting a Contained item.

Definition at line 504 of file BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs.

◆ type

readonly ActionType Barotrauma.StatusEffect.type = ActionType.OnActive

Property Documentation

◆ Afflictions

List<Affliction> Barotrauma.StatusEffect.Afflictions = new List<Affliction>()
get

◆ Disabled

bool Barotrauma.StatusEffect.Disabled
get

◆ Explosions

IEnumerable<Explosion>?? Barotrauma.StatusEffect.Explosions
get

◆ HasConditions

bool Barotrauma.StatusEffect.HasConditions
get

◆ Offset

Vector2 Barotrauma.StatusEffect.Offset
get

An offset added to the position of the effect is executed at. Only relevant if the effect does something where position matters, for example emitting particles or explosions, spawning something or playing sounds.

Definition at line 730 of file BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs.

◆ Range

float Barotrauma.StatusEffect.Range
get

How close to the entity executing the effect the targets must be. Only applicable if targeting NearbyCharacters or NearbyItems.

Definition at line 720 of file BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs.

◆ Sounds

IEnumerable<RoundSound> Barotrauma.StatusEffect.Sounds
get

◆ SpawnCharacters

IEnumerable<CharacterSpawnInfo>?? Barotrauma.StatusEffect.SpawnCharacters
get

◆ Tags

string Barotrauma.StatusEffect.Tags
getset