PC Stable Documentation
 
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Loading...
Searching...
No Matches
Weapon Class Reference

script counterpart to engine's class Weapon More...

Private Member Functions

void Weapon_Base ()
 
void InitStateMachine ()
 
override void EEInit ()
 
void SetInitialState (WeaponStableState initState)
 
bool IsCharged ()
 
void SetCharged (bool value)
 
bool IsWeaponOpen ()
 
void SetWeaponOpen (bool value)
 
override protected float GetWeightSpecialized (bool forceRecalc=false)
 
void AssembleGun ()
 override on weapons with some assembly required
 
bool CanProcessAction (int action, int actionType)
 
bool HasActionAbility (int action, int actionType)
 query if weapon supports action and actionType
 
int GetAbilityCount ()
 
AbilityRecord GetAbility (int index)
 
bool CanProcessWeaponEvents ()
 
WeaponStateBase GetCurrentState ()
 returns currently active state
 
bool IsWaitingForActionFinish ()
 returns true if state machine started playing action/actionType and waits for finish
 
bool IsIdle ()
 
bool ProcessWeaponEvent (WeaponEventBase e)
 weapon's fsm handling of events @NOTE: warning: ProcessWeaponEvent can be called only within DayZPlayer::HandleWeapons (or CommandHandler)
 
bool ProcessWeaponAbortEvent (WeaponEventBase e)
 
bool CanChamberBullet (int muzzleIndex, Magazine mag)
 
void SetWeaponAnimState (int state)
 
void ResetWeaponAnimState ()
 
int GetWeaponAnimState ()
 
void EEFired (int muzzleType, int mode, string ammoType)
 
bool JamCheck (int muzzleIndex)
 
void ShowBullet (int muzzleIndex)
 
void HideBullet (int muzzleIndex)
 
bool IsJammed ()
 
bool CanEjectBullet ()
 
void SetJammed (bool value)
 
float GetSyncChanceToJam ()
 
float GetChanceToJam ()
 
void SyncSelectionState (bool has_bullet, bool has_mag)
 
void ForceSyncSelectionState ()
 
override bool OnStoreLoad (ParamsReadContext ctx, int version)
 
void SaveCurrentFSMState (ParamsWriteContext ctx)
 
bool LoadCurrentFSMState (ParamsReadContext ctx, int version)
 
override void AfterStoreLoad ()
 
override void OnStoreSave (ParamsWriteContext ctx)
 
int GetInternalStateID ()
 
int GetCurrentStableStateID ()
 tries to return identifier of current stable state (or nearest stable state if unstable state is currently running)
 
void RandomizeFSMState ()
 With the parameters given, selects a random suitable state for the FSM of the weapon @WARNING: Weapon_Base.Synchronize call might be needed, if this method is called while clients are connected.
 
protected array< MuzzleStateGetMuzzleStates ()
 Helper method for RandomizeFSMState.
 
override int GetSlotsCountCorrect ()
 Returns number of slots for attachments corrected for weapons.
 

Private Attributes

const int SAMF_DEFAULT = WeaponWithAmmoFlags.CHAMBER | WeaponWithAmmoFlags.MAX_CAPACITY_MAG
 Full highest capacity magazine + chambered round.
 
const int SAMF_RNG = WeaponWithAmmoFlags.CHAMBER_RNG | WeaponWithAmmoFlags.QUANTITY_RNG
 Random bullet quantity + maybe chambered round.
 
const float VALIDATE_DELAY = 5.0
 Validation on client side delay to have time properly synchronize attachments needed for check.
 
protected const float DEFAULT_DAMAGE_ON_SHOT = 0.05
 
protected ref array< ref AbilityRecordm_abilities = new array<ref AbilityRecord>
 
protected ref WeaponFSM m_fsm
 weapon abilities
 
protected bool m_isJammed = false
 weapon state machine
 
protected bool m_LiftWeapon = false
 
protected bool m_BayonetAttached
 
protected bool m_ButtstockAttached
 
protected bool m_Charged = false
 
protected bool m_WeaponOpen = false
 
protected bool m_WasIronSight
 
protected int m_BurstCount
 
protected int m_BayonetAttachmentIdx
 
protected int m_ButtstockAttachmentIdx
 
protected int m_weaponAnimState = -1
 
protected int m_magazineSimpleSelectionIndex = -1
 animation state the weapon is in, -1 == uninitialized
 
protected int m_weaponHideBarrelIdx = -1
 
protected float m_DmgPerShot = 0
 
protected float m_WeaponLength
 
protected float m_WeaponLiftCheckVerticalOffset
 
protected float m_ShoulderDistance
 
protected float m_ObstructionDistance
 
protected vector m_LastLiftPosition
 
protected int m_LastLiftHit
 
ref array< intm_bulletSelectionIndex = new array<int>
 
ref array< floatm_DOFProperties
 
ref array< floatm_ChanceToJam = new array<float>
 
protected float m_ChanceToJamSync = 0
 
protected ref PropertyModifiers m_PropertyModifierObject
 
protected PhxInteractionLayers hit_mask = PhxInteractionLayers.CHARACTER | PhxInteractionLayers.BUILDING | PhxInteractionLayers.DOOR | PhxInteractionLayers.VEHICLE | PhxInteractionLayers.ROADWAY | PhxInteractionLayers.TERRAIN | PhxInteractionLayers.ITEM_SMALL | PhxInteractionLayers.ITEM_LARGE | PhxInteractionLayers.FENCE | PhxInteractionLayers.AI
 
protected ref Timer m_DelayedValidationTimer
 
private float m_coolDownTime = 0
 

Weapon With Ammo

Helpers for spawning ammo/magazine in weapon For the flags, either a combination of WeaponWithAmmoFlags can be used Or one of the preset 'const int' with 'SAMF_' prefix (SAMF_DEFAULT, SAMF_RNG)

bool SpawnAmmo (string magazineType="", int flags=WeaponWithAmmoFlags.CHAMBER)
 General method trying to attch magazine, fill inner magazine and fill chamber.
 
Magazine SpawnAttachedMagazine (string magazineType="", int flags=WeaponWithAmmoFlags.CHAMBER)
 Try to spawn and attach a magazine.
 
bool FillInnerMagazine (string ammoType="", int flags=WeaponWithAmmoFlags.CHAMBER)
 Try to fill the inner magazine.
 
bool FillChamber (string ammoType="", int flags=WeaponWithAmmoFlags.CHAMBER)
 Try to fill the chamber.
 
bool FillSpecificChamber (int muzzleIndex, float dmg=0, string ammoType="")
 
override int GetSlotsCountCorrect ()
 Returns number of slots for attachments corrected for weapons.
 
PropertyModifiers GetPropertyModifierObject ()
 
void OnFire (int muzzle_index)
 
void OnFireModeChange (int fireMode)
 
void DelayedValidateAndRepair ()
 
void ValidateAndRepair ()
 
override void OnInventoryEnter (Man player)
 
override void OnInventoryExit (Man player)
 
override void EEItemAttached (EntityAI item, string slot_name)
 
override void EEItemDetached (EntityAI item, string slot_name)
 
override void EEItemLocationChanged (notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
 
override void OnItemLocationChanged (EntityAI old_owner, EntityAI new_owner)
 
override bool CanReleaseAttachment (EntityAI attachment)
 
override bool CanRemoveFromHands (EntityAI parent)
 
bool IsRemoteWeapon ()
 
void SyncEventToRemote (WeaponEventBase e)
 
RecoilBase SpawnRecoilObject ()
 
int GetWeaponSpecificCommand (int weaponAction, int subCommand)
 
bool CanFire ()
 
bool CanEnterIronsights ()
 
bool InitDOFProperties (out array< float > temp_array)
 Initializes DOF properties for weapon's ironsight/optics cameras.
 
bool InitReliability (out array< float > reliability_array)
 
bool InitWeaponLength ()
 gets weapon length from config for weaponlift raycast
 
bool InitWeaponLiftCheckVerticalOffset ()
 gets weapon vertical offset from config for weaponlift raycast
 
protected bool InitShoulderDistance ()
 gets approximate weapon distance from shoulder from config
 
protected bool InitObstructionDistance ()
 gets weapon obstruction distance from shoulder at which the weapon is fully obstructed
 
ref array< floatGetWeaponDOF ()
 
bool GetWasIronSight ()
 
void SetWasIronSight (bool state)
 
bool LiftWeaponCheck (PlayerBase player)
 
bool UseWeaponObstruction (PlayerBase player, float obstructionValue, Object hitObject)
 
protected void GetApproximateAimOffsets (Blend2DVector dst, int characterStance)
 
protected vector GetApproximateMovementOffset (vector localVelocity, int characterStance, float lean, float ud11, float lr11)
 
protected void ApproximateWeaponLiftTransform (inout vector start, inout vector direction, HumanMovementState hms, HumanInputController hic, HumanCommandWeapons hcw, HumanCommandMove hcm, vector localVelocity="0 0 0")
 
private float ApproximateBaseObstructionLength ()
 Approximate ObstructionDistance for weapons with no configuration. Returned length doesn't account for attachments.

 
bool LiftWeaponCheckEx (PlayerBase player, out float outObstruction, out Object outHitObject)
 
float GetObstructionPenetrationDistance (float obstruction01)
 
bool LiftWeaponRaycastResultCheck (notnull RaycastRVResult res)
 Return whether provided material triggers weapon lift (true) or not (false).
 
float GetEffectiveAttachmentLength ()
 Returns effective length of attachments that influence total weapon length.
 
void SetSyncJammingChance (float jamming_chance)
 
bool EjectCartridge (int muzzleIndex, out float ammoDamage, out string ammoTypeName)
 unload bullet from chamber or internal magazine
 
bool CopyWeaponStateFrom (notnull Weapon_Base src)
 
override void SetBayonetAttached (bool pState, int slot_idx=-1)
 attachment helpers (firearm melee)
 
override bool HasBayonetAttached ()
 
override int GetBayonetAttachmentIdx ()
 
override void SetButtstockAttached (bool pState, int slot_idx=-1)
 
override bool HasButtstockAttached ()
 
override int GetButtstockAttachmentIdx ()
 
void HideWeaponBarrel (bool state)
 
void ShowMagazine ()
 
void HideMagazine ()
 
override EntityAI ProcessMeleeItemDamage (int mode=0)
 
bool IsShowingChamberedBullet ()
 
int GetBurstCount ()
 
void ResetBurstCount ()
 
override void SetActions ()
 
override bool CanBeUsedForSuicide ()
 
override void OnDebugSpawn ()
 
bool AddJunctureToAttachedMagazine (PlayerBase player, int timeoutMS)
 
void ClearJunctureToAttachedMagazine (PlayerBase player)
 
void SetNextWeaponMode (int muzzleIndex)
 
void SetCoolDown (float coolDownTime)
 
void UpdateCoolDown (float dt)
 
bool IsCoolDown ()
 
bool MustBeChambered (int muzzleIndex)
 
static Weapon_Base CreateWeaponWithAmmo (string weaponType, string magazineType="", int flags=WeaponWithAmmoFlags.CHAMBER)
 Create weapon with ammo.
 

Detailed Description

script counterpart to engine's class Weapon

Member Function Documentation

◆ AddJunctureToAttachedMagazine()

bool AddJunctureToAttachedMagazine ( PlayerBase  player,
int  timeoutMS 
)
inlineprivate

◆ AfterStoreLoad()

override void AfterStoreLoad ( )
inlineprivate

◆ ApproximateBaseObstructionLength()

private float ApproximateBaseObstructionLength ( )
inlineprivate

Approximate ObstructionDistance for weapons with no configuration. Returned length doesn't account for attachments.

References Math::Max().

◆ ApproximateWeaponLiftTransform()

◆ AssembleGun()

void AssembleGun ( )
private

override on weapons with some assembly required

◆ CanBeUsedForSuicide()

override bool CanBeUsedForSuicide ( )
inlineprivate

◆ CanChamberBullet()

bool CanChamberBullet ( int  muzzleIndex,
Magazine  mag 
)
inlineprivate

◆ CanEjectBullet()

bool CanEjectBullet ( )
inlineprivate

◆ CanEnterIronsights()

bool CanEnterIronsights ( )
inlineprivate

◆ CanFire()

bool CanFire ( )
inlineprivate

References IsChamberFiredOut(), and IsJammed().

◆ CanProcessAction()

bool CanProcessAction ( int  action,
int  actionType 
)
inlineprivate

◆ CanProcessWeaponEvents()

CanProcessWeaponEvents ( )
inlineprivate
Returns
true if weapon has running fsm

◆ CanReleaseAttachment()

override bool CanReleaseAttachment ( EntityAI  attachment)
inlineprivate

◆ CanRemoveFromHands()

override bool CanRemoveFromHands ( EntityAI  parent)
inlineprivate

◆ ClearJunctureToAttachedMagazine()

void ClearJunctureToAttachedMagazine ( PlayerBase  player)
inlineprivate

◆ CopyWeaponStateFrom()

bool CopyWeaponStateFrom ( notnull Weapon_Base  src)
inlineprivate

◆ CreateWeaponWithAmmo()

CreateWeaponWithAmmo ( string  weaponType,
string  magazineType = "",
int  flags = WeaponWithAmmoFlags.CHAMBER 
)
inlinestaticprivate

Create weapon with ammo.

Parameters
[in]weaponTypestring The weapon to create
[in]magazineTypestring The magazine to attach or ammo to load, passing in empty string will select random
[in]flagsint Setup flags, please read WeaponWithAmmoFlags
Returns
The created weapon

References ECE_PLACE_ON_SURFACE, ErrorEx, GetGame(), and vector::Zero.

◆ DelayedValidateAndRepair()

void DelayedValidateAndRepair ( )
inlineprivate

References Error().

◆ EEFired()

void EEFired ( int  muzzleType,
int  mode,
string  ammoType 
)
inlineprivate

References GetGame(), and IncreaseOverheating().

◆ EEInit()

◆ EEItemAttached()

override void EEItemAttached ( EntityAI  item,
string  slot_name 
)
inlineprivate

◆ EEItemDetached()

override void EEItemDetached ( EntityAI  item,
string  slot_name 
)
inlineprivate

◆ EEItemLocationChanged()

override void EEItemLocationChanged ( notnull InventoryLocation  oldLoc,
notnull InventoryLocation  newLoc 
)
inlineprivate

◆ EjectCartridge()

EjectCartridge ( int  muzzleIndex,
out float  ammoDamage,
out string  ammoTypeName 
)
inlineprivate

unload bullet from chamber or internal magazine

@NOTE: EjectCartridge = GetCartridgeInfo + PopCartridge

Parameters
[in]muzzleIndex
[out]ammoDamagedamage of the ammo
[out]ammoTypeNametype name of the ejected ammo
Returns
true if bullet removed from chamber

◆ FillChamber()

FillChamber ( string  ammoType = "",
int  flags = WeaponWithAmmoFlags.CHAMBER 
)
inlineprivate

Try to fill the chamber.

Parameters
[in]ammoTypestring The ammo to load, passing in empty string will select random
Note
It is best to fill in the actual 'ammo', as in the ones usually prefixed by 'Bullet_', to skip searching for it
Parameters
[in]flagsint Setup flags, please read WeaponWithAmmoFlags
Returns
Whether any chamber was filled

References AmmoTypesAPI::MagazineTypeToAmmoType(), Math::RandomIntInclusive(), and Synchronize().

◆ FillInnerMagazine()

FillInnerMagazine ( string  ammoType = "",
int  flags = WeaponWithAmmoFlags.CHAMBER 
)
inlineprivate

Try to fill the inner magazine.

Parameters
[in]ammoTypestring The ammo to load, passing in empty string will select random
Note
It is best to fill in the actual 'ammo', as in the ones usually prefixed by 'Bullet_', to skip searching for it
Parameters
[in]flagsint Setup flags, please read WeaponWithAmmoFlags
Returns
Whether any ammo was added to the gun or not

References AmmoTypesAPI::MagazineTypeToAmmoType(), Math::RandomIntInclusive(), and Synchronize().

◆ FillSpecificChamber()

bool FillSpecificChamber ( int  muzzleIndex,
float  dmg = 0,
string  ammoType = "" 
)
inlineprivate

◆ ForceSyncSelectionState()

void ForceSyncSelectionState ( )
inlineprivate

◆ GetAbility()

GetAbility ( int  index)
inlineprivate
Parameters
[in]indexindex into m_abilities storage
Returns
ability record

◆ GetAbilityCount()

GetAbilityCount ( )
inlineprivate
Returns
number of stored abilities

◆ GetApproximateAimOffsets()

protected void GetApproximateAimOffsets ( Blend2DVector  dst,
int  characterStance 
)
inlineprivate

◆ GetApproximateMovementOffset()

protected vector GetApproximateMovementOffset ( vector  localVelocity,
int  characterStance,
float  lean,
float  ud11,
float  lr11 
)
inlineprivate

◆ GetBayonetAttachmentIdx()

override int GetBayonetAttachmentIdx ( )
inlineprivate

◆ GetBurstCount()

int GetBurstCount ( )
inlineprivate

◆ GetButtstockAttachmentIdx()

override int GetButtstockAttachmentIdx ( )
inlineprivate

◆ GetChanceToJam()

float GetChanceToJam ( )
inlineprivate

◆ GetCurrentStableStateID()

GetCurrentStableStateID ( )
inlineprivate

tries to return identifier of current stable state (or nearest stable state if unstable state is currently running)

◆ GetCurrentState()

GetCurrentState ( )
inlineprivate

returns currently active state

Returns
current state the FSM is in (or NULL)

◆ GetEffectiveAttachmentLength()

float GetEffectiveAttachmentLength ( )
inlineprivate

Returns effective length of attachments that influence total weapon length.

References Math::Max().

◆ GetInternalStateID()

int GetInternalStateID ( )
inlineprivate

◆ GetMuzzleStates()

protected array< MuzzleState > GetMuzzleStates ( )
inlineprivate

Helper method for RandomizeFSMState.

References ErrorEx, IsChamberFiredOut(), and IsChamberFull().

◆ GetObstructionPenetrationDistance()

float GetObstructionPenetrationDistance ( float  obstruction01)
inlineprivate

Recomputes the provided obstruction01 value typically returned by LiftWeaponCheckEx from the [0 ... 1] range to distance in meters the weapon penetrates the obstacle.

Parameters
obstruction01Obstruction progress
Returns
Penetration depth in meters

References Math::Lerp().

◆ GetPropertyModifierObject()

PropertyModifiers GetPropertyModifierObject ( )
inlineprivate

◆ GetSlotsCountCorrect() [1/2]

override int GetSlotsCountCorrect ( )
inlineprivate

Returns number of slots for attachments corrected for weapons.

◆ GetSlotsCountCorrect() [2/2]

override int GetSlotsCountCorrect ( )
inlineprivate

Returns number of slots for attachments corrected for weapons.

◆ GetSyncChanceToJam()

float GetSyncChanceToJam ( )
inlineprivate

◆ GetWasIronSight()

bool GetWasIronSight ( )
inlineprivate

◆ GetWeaponAnimState()

int GetWeaponAnimState ( )
inlineprivate

◆ GetWeaponDOF()

ref array< float > GetWeaponDOF ( )
inlineprivate

◆ GetWeaponSpecificCommand()

int GetWeaponSpecificCommand ( int  weaponAction,
int  subCommand 
)
inlineprivate

◆ GetWeightSpecialized()

override protected float GetWeightSpecialized ( bool  forceRecalc = false)
inlineprivate

◆ HasActionAbility()

HasActionAbility ( int  action,
int  actionType 
)
inlineprivate

query if weapon supports action and actionType

Parameters
[in]actionone of Human.actions (i.e. RELOAD, MECHANISM, ...)
[in]actionTypeone of Human.actionTypes (i.e. CHAMBERING_ONEBULLET_CLOSED, MECHANISM_CLOSED...)
Returns
true if weapon supports operation

References AbilityRecord::m_action, and AbilityRecord::m_actionType.

◆ HasBayonetAttached()

override bool HasBayonetAttached ( )
inlineprivate

◆ HasButtstockAttached()

override bool HasButtstockAttached ( )
inlineprivate

◆ HideBullet()

void HideBullet ( int  muzzleIndex)
inlineprivate

◆ HideMagazine()

void HideMagazine ( )
inlineprivate

◆ HideWeaponBarrel()

void HideWeaponBarrel ( bool  state)
inlineprivate

◆ InitDOFProperties()

bool InitDOFProperties ( out array< float temp_array)
inlineprivate

Initializes DOF properties for weapon's ironsight/optics cameras.

References CGame::ConfigGetFloatArray(), GetGame(), and GetType().

◆ InitObstructionDistance()

protected bool InitObstructionDistance ( )
inlineprivate

gets weapon obstruction distance from shoulder at which the weapon is fully obstructed

◆ InitReliability()

bool InitReliability ( out array< float reliability_array)
inlineprivate

◆ InitShoulderDistance()

protected bool InitShoulderDistance ( )
inlineprivate

gets approximate weapon distance from shoulder from config

◆ InitStateMachine()

void InitStateMachine ( )
inlineprivate

◆ InitWeaponLength()

bool InitWeaponLength ( )
inlineprivate

gets weapon length from config for weaponlift raycast

◆ InitWeaponLiftCheckVerticalOffset()

bool InitWeaponLiftCheckVerticalOffset ( )
inlineprivate

gets weapon vertical offset from config for weaponlift raycast

◆ IsCharged()

bool IsCharged ( )
inlineprivate

◆ IsCoolDown()

bool IsCoolDown ( )
inlineprivate

◆ IsIdle()

bool IsIdle ( )
inlineprivate

◆ IsJammed()

bool IsJammed ( )
inlineprivate

◆ IsRemoteWeapon()

bool IsRemoteWeapon ( )
inlineprivate

◆ IsShowingChamberedBullet()

bool IsShowingChamberedBullet ( )
inlineprivate

◆ IsWaitingForActionFinish()

IsWaitingForActionFinish ( )
inlineprivate

returns true if state machine started playing action/actionType and waits for finish

◆ IsWeaponOpen()

bool IsWeaponOpen ( )
inlineprivate

◆ JamCheck()

bool JamCheck ( int  muzzleIndex)
inlineprivate

◆ LiftWeaponCheck()

bool LiftWeaponCheck ( PlayerBase  player)
inlineprivate

◆ LiftWeaponCheckEx()

bool LiftWeaponCheckEx ( PlayerBase  player,
out float  outObstruction,
out Object  outHitObject 
)
inlineprivate

◆ LiftWeaponRaycastResultCheck()

bool LiftWeaponRaycastResultCheck ( notnull RaycastRVResult  res)
inlineprivate

Return whether provided material triggers weapon lift (true) or not (false).

◆ LoadCurrentFSMState()

◆ MustBeChambered()

bool MustBeChambered ( int  muzzleIndex)
inlineprivate

◆ OnDebugSpawn()

override void OnDebugSpawn ( )
inlineprivate

◆ OnFire()

void OnFire ( int  muzzle_index)
inlineprivate

◆ OnFireModeChange()

void OnFireModeChange ( int  fireMode)
inlineprivate

◆ OnInventoryEnter()

override void OnInventoryEnter ( Man  player)
inlineprivate

References GetGame().

◆ OnInventoryExit()

override void OnInventoryExit ( Man  player)
inlineprivate

◆ OnItemLocationChanged()

override void OnItemLocationChanged ( EntityAI  old_owner,
EntityAI  new_owner 
)
inlineprivate

References Class::CastTo().

◆ OnStoreLoad()

override bool OnStoreLoad ( ParamsReadContext  ctx,
int  version 
)
inlineprivate

◆ OnStoreSave()

override void OnStoreSave ( ParamsWriteContext  ctx)
inlineprivate

References Serializer::Write().

◆ ProcessMeleeItemDamage()

override EntityAI ProcessMeleeItemDamage ( int  mode = 0)
inlineprivate

◆ ProcessWeaponAbortEvent()

ProcessWeaponAbortEvent ( WeaponEventBase  e)
inlineprivate

@NOTE: warning: ProcessWeaponEvent can be called only within DayZPlayer::HandleWeapons (or CommandHandler)

◆ ProcessWeaponEvent()

ProcessWeaponEvent ( WeaponEventBase  e)
inlineprivate

weapon's fsm handling of events @NOTE: warning: ProcessWeaponEvent can be called only within DayZPlayer::HandleWeapons (or CommandHandler)

References WeaponEventBase::GetEventID().

◆ RandomizeFSMState()

RandomizeFSMState ( )
inlineprivate

With the parameters given, selects a random suitable state for the FSM of the weapon @WARNING: Weapon_Base.Synchronize call might be needed, if this method is called while clients are connected.

References IsJammed().

◆ ResetBurstCount()

void ResetBurstCount ( )
inlineprivate

◆ ResetWeaponAnimState()

void ResetWeaponAnimState ( )
inlineprivate

◆ SaveCurrentFSMState()

void SaveCurrentFSMState ( ParamsWriteContext  ctx)
inlineprivate

◆ SetActions()

override void SetActions ( )
inlineprivate

◆ SetBayonetAttached()

override void SetBayonetAttached ( bool  pState,
int  slot_idx = -1 
)
inlineprivate

attachment helpers (firearm melee)

◆ SetButtstockAttached()

override void SetButtstockAttached ( bool  pState,
int  slot_idx = -1 
)
inlineprivate

◆ SetCharged()

void SetCharged ( bool  value)
inlineprivate

◆ SetCoolDown()

void SetCoolDown ( float  coolDownTime)
inlineprivate

◆ SetInitialState()

void SetInitialState ( WeaponStableState  initState)
inlineprivate

◆ SetJammed()

void SetJammed ( bool  value)
inlineprivate

◆ SetNextWeaponMode()

void SetNextWeaponMode ( int  muzzleIndex)
inlineprivate

◆ SetSyncJammingChance()

void SetSyncJammingChance ( float  jamming_chance)
inlineprivate

◆ SetWasIronSight()

void SetWasIronSight ( bool  state)
inlineprivate

◆ SetWeaponAnimState()

void SetWeaponAnimState ( int  state)
inlineprivate

◆ SetWeaponOpen()

void SetWeaponOpen ( bool  value)
inlineprivate

◆ ShowBullet()

void ShowBullet ( int  muzzleIndex)
inlineprivate

◆ ShowMagazine()

void ShowMagazine ( )
inlineprivate

◆ SpawnAmmo()

SpawnAmmo ( string  magazineType = "",
int  flags = WeaponWithAmmoFlags.CHAMBER 
)
inlineprivate

General method trying to attch magazine, fill inner magazine and fill chamber.

Parameters
[in]magazineTypestring The magazine to attach or ammo to load, passing in empty string will select random
[in]flagsint Setup flags, please read WeaponWithAmmoFlags
Returns
whether anything was spawned or done

◆ SpawnAttachedMagazine()

SpawnAttachedMagazine ( string  magazineType = "",
int  flags = WeaponWithAmmoFlags.CHAMBER 
)
inlineprivate

Try to spawn and attach a magazine.

Parameters
[in]magazineTypestring The magazine to attach, passing in empty string will select random
[in]flagsint Setup flags, please read WeaponWithAmmoFlags
Returns
The created magazine or null

References ErrorEx, GetDebugName(), Math::RandomIntInclusive(), and Synchronize().

◆ SpawnRecoilObject()

RecoilBase SpawnRecoilObject ( )
inlineprivate

◆ SyncEventToRemote()

◆ SyncSelectionState()

void SyncSelectionState ( bool  has_bullet,
bool  has_mag 
)
inlineprivate

◆ UpdateCoolDown()

void UpdateCoolDown ( float  dt)
inlineprivate

◆ UseWeaponObstruction()

bool UseWeaponObstruction ( PlayerBase  player,
float  obstructionValue,
Object  hitObject 
)
inlineprivate

Returns whether this weapon can use obstruction instead of weapon lift. Implement simple conditions only (e.g. checking for attachments, weapon types, ...) to prevent possible desyncs.

Parameters
obstructionValueThe percentage of penetration into hit object
hitObjectThe object obstructing the weapon

CFGGAMEPLAY

References dBodyIsDynamic(), dynamicMode, DiagMenu::GetValue(), CfgGameplayHandler::GetWeaponObstructionModeDynamic(), CfgGameplayHandler::GetWeaponObstructionModeStatic(), HumanMovementState::IsInProne(), HumanMovementState::IsInRaisedProne(), and staticMode.

◆ ValidateAndRepair()

void ValidateAndRepair ( )
inlineprivate

◆ Weapon_Base()

void Weapon_Base ( )
inlineprivate

Field Documentation

◆ DEFAULT_DAMAGE_ON_SHOT

protected const float DEFAULT_DAMAGE_ON_SHOT = 0.05
private

◆ hit_mask

◆ m_abilities

protected ref array<ref AbilityRecord> m_abilities = new array<ref AbilityRecord>
private

◆ m_BayonetAttached

protected bool m_BayonetAttached
private

◆ m_BayonetAttachmentIdx

protected int m_BayonetAttachmentIdx
private

◆ m_bulletSelectionIndex

ref array<int> m_bulletSelectionIndex = new array<int>
private

◆ m_BurstCount

protected int m_BurstCount
private

◆ m_ButtstockAttached

protected bool m_ButtstockAttached
private

◆ m_ButtstockAttachmentIdx

protected int m_ButtstockAttachmentIdx
private

◆ m_ChanceToJam

ref array<float> m_ChanceToJam = new array<float>
private

◆ m_ChanceToJamSync

protected float m_ChanceToJamSync = 0
private

◆ m_Charged

protected bool m_Charged = false
private

◆ m_coolDownTime

private float m_coolDownTime = 0
private

◆ m_DelayedValidationTimer

protected ref Timer m_DelayedValidationTimer
private

◆ m_DmgPerShot

protected float m_DmgPerShot = 0
private

◆ m_DOFProperties

ref array<float> m_DOFProperties
private

◆ m_fsm

protected ref WeaponFSM m_fsm
private

weapon abilities

◆ m_isJammed

protected bool m_isJammed = false
private

weapon state machine

◆ m_LastLiftHit

protected int m_LastLiftHit
private

◆ m_LastLiftPosition

protected vector m_LastLiftPosition
private

◆ m_LiftWeapon

protected bool m_LiftWeapon = false
private

◆ m_magazineSimpleSelectionIndex

protected int m_magazineSimpleSelectionIndex = -1
private

animation state the weapon is in, -1 == uninitialized

◆ m_ObstructionDistance

protected float m_ObstructionDistance
private

◆ m_PropertyModifierObject

protected ref PropertyModifiers m_PropertyModifierObject
private

◆ m_ShoulderDistance

protected float m_ShoulderDistance
private

◆ m_WasIronSight

protected bool m_WasIronSight
private

◆ m_weaponAnimState

protected int m_weaponAnimState = -1
private

◆ m_weaponHideBarrelIdx

protected int m_weaponHideBarrelIdx = -1
private

◆ m_WeaponLength

protected float m_WeaponLength
private

◆ m_WeaponLiftCheckVerticalOffset

protected float m_WeaponLiftCheckVerticalOffset
private

◆ m_WeaponOpen

protected bool m_WeaponOpen = false
private

◆ SAMF_DEFAULT

const int SAMF_DEFAULT = WeaponWithAmmoFlags.CHAMBER | WeaponWithAmmoFlags.MAX_CAPACITY_MAG
private

Full highest capacity magazine + chambered round.

◆ SAMF_RNG

const int SAMF_RNG = WeaponWithAmmoFlags.CHAMBER_RNG | WeaponWithAmmoFlags.QUANTITY_RNG
private

Random bullet quantity + maybe chambered round.

◆ VALIDATE_DELAY

const float VALIDATE_DELAY = 5.0
private

Validation on client side delay to have time properly synchronize attachments needed for check.


The documentation for this class was generated from the following files: