Barotrauma Server Doc
Barotrauma.Attack Class Reference

Attacks are used to deal damage to characters, structures and items. They can be defined in the weapon components of the items or the limb definitions of the characters. The limb attacks can also be used by the player, when they control a monster or have some appendage, like a husk stinger. More...

Inheritance diagram for Barotrauma.Attack:
Barotrauma.ISerializableEntity

Public Member Functions

void SetUser (Character user)
 
List< AfflictionGetMultipliedAfflictions (float multiplier)
 
float GetStructureDamage (float deltaTime)
 
float GetLevelWallDamage (float deltaTime)
 
float GetItemDamage (float deltaTime, float multiplier=1)
 
float GetTotalDamage (bool includeStructureDamage=false)
 
 Attack (float damage, float bleedingDamage, float burnDamage, float structureDamage, float itemDamage, float range=0.0f)
 
 Attack (ContentXElement element, string parentDebugName, Item sourceItem)
 
 Attack (ContentXElement element, string parentDebugName)
 
void ReloadAfflictions (ContentXElement element, string parentDebugName)
 
void Serialize (ContentXElement element)
 
void Deserialize (ContentXElement element, string parentDebugName)
 
AttackResult DoDamage (Character attacker, IDamageable target, Vector2 worldPosition, float deltaTime, bool playSound=true, PhysicsBody sourceBody=null, Limb sourceLimb=null)
 
AttackResult DoDamageToLimb (Character attacker, Limb targetLimb, Vector2 worldPosition, float deltaTime, bool playSound=true, PhysicsBody sourceBody=null, Limb sourceLimb=null)
 
void UpdateCoolDown (float deltaTime)
 
void UpdateAttackTimer (float deltaTime, Character character)
 
void ResetAttackTimer ()
 
void SetCoolDown (bool applyRandom)
 
void ResetCoolDown ()
 
bool IsValidContext (AttackContext context)
 
bool IsValidContext (IEnumerable< AttackContext > contexts)
 
bool IsValidTarget (AttackTarget targetType)
 
bool IsValidTarget (Entity target)
 
Vector2 CalculateAttackPhase (TransitionMode easing=TransitionMode.Linear)
 

Public Attributes

readonly List< int > ForceOnLimbIndices = new List<int>()
 
readonly Dictionary< Affliction, XElement > Afflictions = new Dictionary<Affliction, XElement>()
 

Properties

AttackContext Context [get]
 
AttackTarget TargetType [get]
 
LimbType TargetLimbType [get]
 
HitDetection HitDetectionType [get]
 
AIBehaviorAfterAttack AfterAttack [get, set]
 
float AfterAttackDelay [get, set]
 
bool Reverse [get]
 
bool SnapRopeOnNewAttack [get]
 
bool Retreat [get]
 
float Range [get, set]
 
float DamageRange [get, set]
 
float MinRange [get]
 
float Duration [get]
 
float CoolDown = 5 [get, set]
 
float SecondaryCoolDown = 0 [get, set]
 
float CoolDownRandomFactor = 0 [get]
 
bool FullSpeedAfterAttack [get]
 
float StructureDamage [get, set]
 
bool EmitStructureDamageParticles [get]
 
float ItemDamage [get, set]
 
float Penetration [get]
 
float DamageMultiplier = 1 [get, set]
 Used for multiplying all the damage. More...
 
float RangeMultiplier = 1 [get, set]
 Used for multiplying all the ranges. More...
 
float ImpactMultiplier = 1 [get, set]
 Used for multiplying the physics forces. More...
 
float LevelWallDamage [get, set]
 
bool Ranged [get, set]
 
bool AvoidFriendlyFire [get, set]
 
float RequiredAngle [get, set]
 
float RequiredAngleToShoot [get, set]
 
float AimRotationTorque [get, set]
 
int RotationLimbIndex [get, set]
 
float SwayAmount [get, set]
 
float SwayFrequency [get, set]
 
float Stun [get, set]
 
bool OnlyHumans [get, set]
 
string ApplyForceOnLimbs [get, set]
 
float Force [get]
 
Vector2 RootForceWorldStart [get]
 
Vector2 RootForceWorldMiddle [get]
 
Vector2 RootForceWorldEnd [get]
 
TransitionMode RootTransitionEasing [get]
 
float Torque [get]
 
bool ApplyForcesOnlyOnce [get]
 
float TargetImpulse [get]
 
Vector2 TargetImpulseWorld [get]
 
float TargetForce [get]
 
Vector2 TargetForceWorld [get]
 
float SubmarineImpactMultiplier [get]
 
float SeverLimbsProbability [get, set]
 
float StickChance [get]
 
float Priority [get]
 
bool Blink [get]
 
IEnumerable< StatusEffectStatusEffects [get]
 
string Name [get]
 
Dictionary< Identifier, SerializablePropertySerializableProperties = new Dictionary<Identifier, SerializableProperty>() [get]
 
List< PropertyConditionalConditionals = new List<PropertyConditional>() [get]
 Only affects ai decision making. All the conditionals has to be met in order to select the attack. TODO: allow to define conditionals using any (implemented in StatusEffect -> move from there to PropertyConditional?) More...
 
Item SourceItem [get, set]
 
float AttackTimer [get]
 
float CoolDownTimer [get, set]
 
float CurrentRandomCoolDown [get]
 
float SecondaryCoolDownTimer [get, set]
 
bool IsRunning [get]
 
- Properties inherited from Barotrauma.ISerializableEntity
string Name [get]
 
Dictionary< Identifier, SerializablePropertySerializableProperties [get]
 

Detailed Description

Attacks are used to deal damage to characters, structures and items. They can be defined in the weapon components of the items or the limb definitions of the characters. The limb attacks can also be used by the player, when they control a monster or have some appendage, like a husk stinger.

Definition at line 87 of file Attack.cs.

Constructor & Destructor Documentation

◆ Attack() [1/3]

Barotrauma.Attack.Attack ( float  damage,
float  bleedingDamage,
float  burnDamage,
float  structureDamage,
float  itemDamage,
float  range = 0.0f 
)

Definition at line 369 of file Attack.cs.

◆ Attack() [2/3]

Barotrauma.Attack.Attack ( ContentXElement  element,
string  parentDebugName,
Item  sourceItem 
)

Definition at line 381 of file Attack.cs.

◆ Attack() [3/3]

Barotrauma.Attack.Attack ( ContentXElement  element,
string  parentDebugName 
)

Definition at line 386 of file Attack.cs.

Member Function Documentation

◆ CalculateAttackPhase()

Vector2 Barotrauma.Attack.CalculateAttackPhase ( TransitionMode  easing = TransitionMode.Linear)

Definition at line 814 of file Attack.cs.

◆ Deserialize()

void Barotrauma.Attack.Deserialize ( ContentXElement  element,
string  parentDebugName 
)

Definition at line 486 of file Attack.cs.

◆ DoDamage()

AttackResult Barotrauma.Attack.DoDamage ( Character  attacker,
IDamageable  target,
Vector2  worldPosition,
float  deltaTime,
bool  playSound = true,
PhysicsBody  sourceBody = null,
Limb  sourceLimb = null 
)

Definition at line 492 of file Attack.cs.

◆ DoDamageToLimb()

AttackResult Barotrauma.Attack.DoDamageToLimb ( Character  attacker,
Limb  targetLimb,
Vector2  worldPosition,
float  deltaTime,
bool  playSound = true,
PhysicsBody  sourceBody = null,
Limb  sourceLimb = null 
)

Definition at line 594 of file Attack.cs.

◆ GetItemDamage()

float Barotrauma.Attack.GetItemDamage ( float  deltaTime,
float  multiplier = 1 
)

Definition at line 353 of file Attack.cs.

◆ GetLevelWallDamage()

float Barotrauma.Attack.GetLevelWallDamage ( float  deltaTime)

Definition at line 348 of file Attack.cs.

◆ GetMultipliedAfflictions()

List<Affliction> Barotrauma.Attack.GetMultipliedAfflictions ( float  multiplier)

Definition at line 333 of file Attack.cs.

◆ GetStructureDamage()

float Barotrauma.Attack.GetStructureDamage ( float  deltaTime)

Definition at line 343 of file Attack.cs.

◆ GetTotalDamage()

float Barotrauma.Attack.GetTotalDamage ( bool  includeStructureDamage = false)

Definition at line 359 of file Attack.cs.

◆ IsValidContext() [1/2]

bool Barotrauma.Attack.IsValidContext ( AttackContext  context)

◆ IsValidContext() [2/2]

bool Barotrauma.Attack.IsValidContext ( IEnumerable< AttackContext contexts)

Definition at line 765 of file Attack.cs.

◆ IsValidTarget() [1/2]

bool Barotrauma.Attack.IsValidTarget ( AttackTarget  targetType)

◆ IsValidTarget() [2/2]

bool Barotrauma.Attack.IsValidTarget ( Entity  target)

Definition at line 804 of file Attack.cs.

◆ ReloadAfflictions()

void Barotrauma.Attack.ReloadAfflictions ( ContentXElement  element,
string  parentDebugName 
)

Definition at line 449 of file Attack.cs.

◆ ResetAttackTimer()

void Barotrauma.Attack.ResetAttackTimer ( )

Definition at line 730 of file Attack.cs.

◆ ResetCoolDown()

void Barotrauma.Attack.ResetCoolDown ( )

Definition at line 754 of file Attack.cs.

◆ Serialize()

void Barotrauma.Attack.Serialize ( ContentXElement  element)

Definition at line 474 of file Attack.cs.

◆ SetCoolDown()

void Barotrauma.Attack.SetCoolDown ( bool  applyRandom)

Definition at line 736 of file Attack.cs.

◆ SetUser()

void Barotrauma.Attack.SetUser ( Character  user)

Definition at line 321 of file Attack.cs.

◆ UpdateAttackTimer()

void Barotrauma.Attack.UpdateAttackTimer ( float  deltaTime,
Character  character 
)

Definition at line 719 of file Attack.cs.

◆ UpdateCoolDown()

void Barotrauma.Attack.UpdateCoolDown ( float  deltaTime)

Definition at line 711 of file Attack.cs.

Member Data Documentation

◆ Afflictions

readonly Dictionary<Affliction, XElement> Barotrauma.Attack.Afflictions = new Dictionary<Affliction, XElement>()

Definition at line 308 of file Attack.cs.

◆ ForceOnLimbIndices

readonly List<int> Barotrauma.Attack.ForceOnLimbIndices = new List<int>()

Definition at line 306 of file Attack.cs.

Property Documentation

◆ AfterAttack

AIBehaviorAfterAttack Barotrauma.Attack.AfterAttack
getset

Definition at line 102 of file Attack.cs.

◆ AfterAttackDelay

float Barotrauma.Attack.AfterAttackDelay
getset

Definition at line 105 of file Attack.cs.

◆ AimRotationTorque

float Barotrauma.Attack.AimRotationTorque
getset

Definition at line 203 of file Attack.cs.

◆ ApplyForceOnLimbs

string Barotrauma.Attack.ApplyForceOnLimbs
getset

Definition at line 221 of file Attack.cs.

◆ ApplyForcesOnlyOnce

bool Barotrauma.Attack.ApplyForcesOnlyOnce
get

Definition at line 260 of file Attack.cs.

◆ AttackTimer

float Barotrauma.Attack.AttackTimer
get

Definition at line 705 of file Attack.cs.

◆ AvoidFriendlyFire

bool Barotrauma.Attack.AvoidFriendlyFire
getset

Definition at line 194 of file Attack.cs.

◆ Blink

bool Barotrauma.Attack.Blink
get

Definition at line 289 of file Attack.cs.

◆ Conditionals

List<PropertyConditional> Barotrauma.Attack.Conditionals = new List<PropertyConditional>()
get

Only affects ai decision making. All the conditionals has to be met in order to select the attack. TODO: allow to define conditionals using any (implemented in StatusEffect -> move from there to PropertyConditional?)

Definition at line 313 of file Attack.cs.

◆ Context

AttackContext Barotrauma.Attack.Context
get

Definition at line 90 of file Attack.cs.

◆ CoolDown

float Barotrauma.Attack.CoolDown = 5
getset

Definition at line 139 of file Attack.cs.

◆ CoolDownRandomFactor

float Barotrauma.Attack.CoolDownRandomFactor = 0
get

Definition at line 145 of file Attack.cs.

◆ CoolDownTimer

float Barotrauma.Attack.CoolDownTimer
getset

Definition at line 706 of file Attack.cs.

◆ CurrentRandomCoolDown

float Barotrauma.Attack.CurrentRandomCoolDown
get

Definition at line 707 of file Attack.cs.

◆ DamageMultiplier

float Barotrauma.Attack.DamageMultiplier = 1
getset

Used for multiplying all the damage.

Definition at line 175 of file Attack.cs.

◆ DamageRange

float Barotrauma.Attack.DamageRange
getset

Definition at line 126 of file Attack.cs.

◆ Duration

float Barotrauma.Attack.Duration
get

Definition at line 136 of file Attack.cs.

◆ EmitStructureDamageParticles

bool Barotrauma.Attack.EmitStructureDamageParticles
get

Definition at line 159 of file Attack.cs.

◆ Force

float Barotrauma.Attack.Force
get

Definition at line 242 of file Attack.cs.

◆ FullSpeedAfterAttack

bool Barotrauma.Attack.FullSpeedAfterAttack
get

Definition at line 148 of file Attack.cs.

◆ HitDetectionType

HitDetection Barotrauma.Attack.HitDetectionType
get

Definition at line 99 of file Attack.cs.

◆ ImpactMultiplier

float Barotrauma.Attack.ImpactMultiplier = 1
getset

Used for multiplying the physics forces.

Definition at line 185 of file Attack.cs.

◆ IsRunning

bool Barotrauma.Attack.IsRunning
get

Definition at line 709 of file Attack.cs.

◆ ItemDamage

float Barotrauma.Attack.ItemDamage
getset

Definition at line 163 of file Attack.cs.

◆ LevelWallDamage

float Barotrauma.Attack.LevelWallDamage
getset

Definition at line 188 of file Attack.cs.

◆ MinRange

float Barotrauma.Attack.MinRange
get

Definition at line 133 of file Attack.cs.

◆ Name

string Barotrauma.Attack.Name
get

Definition at line 296 of file Attack.cs.

◆ OnlyHumans

bool Barotrauma.Attack.OnlyHumans
getset

Definition at line 218 of file Attack.cs.

◆ Penetration

float Barotrauma.Attack.Penetration
get

Definition at line 170 of file Attack.cs.

◆ Priority

float Barotrauma.Attack.Priority
get

Definition at line 286 of file Attack.cs.

◆ Range

float Barotrauma.Attack.Range
getset

Definition at line 118 of file Attack.cs.

◆ Ranged

bool Barotrauma.Attack.Ranged
getset

Definition at line 191 of file Attack.cs.

◆ RangeMultiplier

float Barotrauma.Attack.RangeMultiplier = 1
getset

Used for multiplying all the ranges.

Definition at line 180 of file Attack.cs.

◆ RequiredAngle

float Barotrauma.Attack.RequiredAngle
getset

Definition at line 197 of file Attack.cs.

◆ RequiredAngleToShoot

float Barotrauma.Attack.RequiredAngleToShoot
getset

Definition at line 200 of file Attack.cs.

◆ Retreat

bool Barotrauma.Attack.Retreat
get

Definition at line 114 of file Attack.cs.

◆ Reverse

bool Barotrauma.Attack.Reverse
get

Definition at line 108 of file Attack.cs.

◆ RootForceWorldEnd

Vector2 Barotrauma.Attack.RootForceWorldEnd
get

Definition at line 251 of file Attack.cs.

◆ RootForceWorldMiddle

Vector2 Barotrauma.Attack.RootForceWorldMiddle
get

Definition at line 248 of file Attack.cs.

◆ RootForceWorldStart

Vector2 Barotrauma.Attack.RootForceWorldStart
get

Definition at line 245 of file Attack.cs.

◆ RootTransitionEasing

TransitionMode Barotrauma.Attack.RootTransitionEasing
get

Definition at line 254 of file Attack.cs.

◆ RotationLimbIndex

int Barotrauma.Attack.RotationLimbIndex
getset

Definition at line 206 of file Attack.cs.

◆ SecondaryCoolDown

float Barotrauma.Attack.SecondaryCoolDown = 0
getset

Definition at line 142 of file Attack.cs.

◆ SecondaryCoolDownTimer

float Barotrauma.Attack.SecondaryCoolDownTimer
getset

Definition at line 708 of file Attack.cs.

◆ SerializableProperties

Dictionary<Identifier, SerializableProperty> Barotrauma.Attack.SerializableProperties = new Dictionary<Identifier, SerializableProperty>()
get

Definition at line 298 of file Attack.cs.

◆ SeverLimbsProbability

float Barotrauma.Attack.SeverLimbsProbability
getset

Definition at line 278 of file Attack.cs.

◆ SnapRopeOnNewAttack

bool Barotrauma.Attack.SnapRopeOnNewAttack
get

Definition at line 111 of file Attack.cs.

◆ SourceItem

Item Barotrauma.Attack.SourceItem
getset

Definition at line 331 of file Attack.cs.

◆ StatusEffects

IEnumerable<StatusEffect> Barotrauma.Attack.StatusEffects
get

Definition at line 291 of file Attack.cs.

◆ StickChance

float Barotrauma.Attack.StickChance
get

Definition at line 283 of file Attack.cs.

◆ StructureDamage

float Barotrauma.Attack.StructureDamage
getset

Definition at line 152 of file Attack.cs.

◆ Stun

float Barotrauma.Attack.Stun
getset

Definition at line 215 of file Attack.cs.

◆ SubmarineImpactMultiplier

float Barotrauma.Attack.SubmarineImpactMultiplier
get

Definition at line 275 of file Attack.cs.

◆ SwayAmount

float Barotrauma.Attack.SwayAmount
getset

Definition at line 209 of file Attack.cs.

◆ SwayFrequency

float Barotrauma.Attack.SwayFrequency
getset

Definition at line 212 of file Attack.cs.

◆ TargetForce

float Barotrauma.Attack.TargetForce
get

Definition at line 269 of file Attack.cs.

◆ TargetForceWorld

Vector2 Barotrauma.Attack.TargetForceWorld
get

Definition at line 272 of file Attack.cs.

◆ TargetImpulse

float Barotrauma.Attack.TargetImpulse
get

Definition at line 263 of file Attack.cs.

◆ TargetImpulseWorld

Vector2 Barotrauma.Attack.TargetImpulseWorld
get

Definition at line 266 of file Attack.cs.

◆ TargetLimbType

LimbType Barotrauma.Attack.TargetLimbType
get

Definition at line 96 of file Attack.cs.

◆ TargetType

AttackTarget Barotrauma.Attack.TargetType
get

Definition at line 93 of file Attack.cs.

◆ Torque

float Barotrauma.Attack.Torque
get

Definition at line 257 of file Attack.cs.