Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
Weapon Class Reference

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

Protected Member Functions

override void AfterStoreLoad ()
void AssembleGun ()
 override on weapons with some assembly required
bool CanChamberBullet (int muzzleIndex, Magazine mag)
bool CanEjectBullet ()
bool CanProcessAction (int action, int actionType)
bool CanProcessWeaponEvents ()
void EEFired (int muzzleType, int mode, string ammoType)
void ForceSyncSelectionState ()
AbilityRecord GetAbility (int index)
int GetAbilityCount ()
float GetChanceToJam ()
int GetCurrentStableStateID ()
 tries to return identifier of current stable state (or nearest stable state if unstable state is currently running)
WeaponStateBase GetCurrentState ()
 returns currently active state
int GetInternalStateID ()
array< MuzzleStateGetMuzzleStates ()
 Helper method for RandomizeFSMState.
float GetSyncChanceToJam ()
int GetWeaponAnimState ()
float GetWeightSpecialized (bool forceRecalc=false)
bool HasActionAbility (int action, int actionType)
void HideBullet (int muzzleIndex)
bool IsIdle ()
bool IsJammed ()
bool IsWaitingForActionFinish ()
 returns true if state machine started playing action/actionType and waits for finish
bool JamCheck (int muzzleIndex)
bool LoadCurrentFSMState (ParamsReadContext ctx, int version)
override bool OnStoreLoad (ParamsReadContext ctx, int version)
override void OnStoreSave (ParamsWriteContext ctx)
bool ProcessWeaponAbortEvent (WeaponEventBase e)
bool ProcessWeaponEvent (WeaponEventBase e)
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.
void ResetWeaponAnimState ()
void SaveCurrentFSMState (ParamsWriteContext ctx)
void SetJammed (bool value)
void SetWeaponAnimState (int state)
void ShowBullet (int muzzleIndex)
void SyncSelectionState (bool has_bullet, bool has_mag)

Protected Attributes

const float DEFAULT_DAMAGE_ON_SHOT = 0.05
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
ref array< ref AbilityRecordm_abilities = new array<ref AbilityRecord>
bool m_BayonetAttached
int m_BayonetAttachmentIdx
ref array< intm_bulletSelectionIndex = new array<int>
int m_BurstCount
bool m_ButtstockAttached
int m_ButtstockAttachmentIdx
ref array< floatm_ChanceToJam = new array<float>
float m_ChanceToJamSync = 0
bool m_Charged = false
ref Timer m_DelayedValidationTimer
float m_DmgPerShot = 0
ref array< floatm_DOFProperties
ref WeaponFSM m_fsm
 weapon abilities
bool m_isJammed = false
 weapon state machine
int m_LastLiftHit
vector m_LastLiftPosition
bool m_LiftWeapon = false
int m_magazineSimpleSelectionIndex = -1
 animation state the weapon is in, -1 == uninitialized
float m_ObstructionDistance
ref PropertyModifiers m_PropertyModifierObject
float m_ShoulderDistance
bool m_WasIronSight
int m_weaponAnimState = -1
int m_weaponHideBarrelIdx = -1
float m_WeaponLength
float m_WeaponLiftCheckVerticalOffset
bool m_WeaponOpen = false

Private Member Functions

override void EEInit ()
override int GetSlotsCountCorrect ()
 Returns number of slots for attachments corrected for weapons.
void InitStateMachine ()
bool IsCharged ()
bool IsWeaponOpen ()
void SetCharged (bool value)
void SetInitialState (WeaponStableState initState)
void SetWeaponOpen (bool value)
void Weapon_Base ()

Private Attributes

float m_coolDownTime = 0
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.

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)

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)
 Perform weapon obstruction check by the provided player.
float GetObstructionPenetrationDistance (float obstruction01)
 Recomputes the provided obstruction01 value typically returned by LiftWeaponCheckEx from the [0 ... 1] range to distance in meters the weapon penetrates the obstacle.
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)
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)
bool SpawnAmmo (string magazineType="", int flags=WeaponWithAmmoFlags.CHAMBER)
Magazine SpawnAttachedMagazine (string magazineType="", int flags=WeaponWithAmmoFlags.CHAMBER)
bool FillInnerMagazine (string ammoType="", int flags=WeaponWithAmmoFlags.CHAMBER)
bool FillChamber (string ammoType="", int flags=WeaponWithAmmoFlags.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
bool InitShoulderDistance ()
 gets approximate weapon distance from shoulder from config
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)
 Returns whether this weapon can use obstruction instead of weapon lift.
void GetApproximateAimOffsets (Blend2DVector dst, int characterStance)
vector GetApproximateMovementOffset (vector localVelocity, int characterStance, float lean, float ud11, float lr11)
void ApproximateWeaponLiftTransform (inout vector start, inout vector direction, HumanMovementState hms, HumanInputController hic, HumanCommandWeapons hcw, HumanCommandMove hcm, vector localVelocity="0 0 0")
 Update provided start position and lift check direction to include appproximated character state.
static Weapon_Base CreateWeaponWithAmmo (string weaponType, string magazineType="", int flags=WeaponWithAmmoFlags.CHAMBER)

Detailed Description

script counterpart to engine's class Weapon

Definition at line 47 of file inventoryitem.c.

Member Function Documentation

◆ AddJunctureToAttachedMagazine()

bool AddJunctureToAttachedMagazine ( PlayerBase player,
int timeoutMS )
inlineprivate

Definition at line 2229 of file weapon_base.c.

References g_Game.

◆ AfterStoreLoad()

override void AfterStoreLoad ( )
inlineprotected

Definition at line 612 of file weapon_base.c.

References m_fsm, and SyncSelectionState().

◆ ApproximateBaseObstructionLength()

float ApproximateBaseObstructionLength ( )
inlineprivate

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

Definition at line 1643 of file weapon_base.c.

References m_ShoulderDistance, m_WeaponLength, and Math::Max().

Referenced by GetObstructionPenetrationDistance(), and LiftWeaponCheckEx().

◆ ApproximateWeaponLiftTransform()

◆ AssembleGun()

void AssembleGun ( )
protected

override on weapons with some assembly required

Referenced by EEInit().

◆ CanBeUsedForSuicide()

override bool CanBeUsedForSuicide ( )
inlineprivate

Definition at line 2215 of file weapon_base.c.

◆ CanChamberBullet()

bool CanChamberBullet ( int muzzleIndex,
Magazine mag )
inlineprotected

Definition at line 324 of file weapon_base.c.

References IsChamberFiredOut(), and IsChamberFull().

◆ CanEjectBullet()

bool CanEjectBullet ( )
inlineprotected

Definition at line 408 of file weapon_base.c.

◆ CanEnterIronsights()

bool CanEnterIronsights ( )
inlineprotected

Definition at line 1275 of file weapon_base.c.

References ItemOptics::HasWeaponIronsightsOverride().

◆ CanFire()

bool CanFire ( )
inlineprotected

Definition at line 1268 of file weapon_base.c.

References IsChamberFiredOut(), IsJammed(), and m_LiftWeapon.

◆ CanProcessAction()

bool CanProcessAction ( int action,
int actionType )
inlineprotected

Definition at line 236 of file weapon_base.c.

◆ CanProcessWeaponEvents()

bool CanProcessWeaponEvents ( )
inlineprotected
Returns
true if weapon has running fsm

Definition at line 270 of file weapon_base.c.

References m_fsm.

Referenced by IsIdle(), and IsWaitingForActionFinish().

◆ CanReleaseAttachment()

override bool CanReleaseAttachment ( EntityAI attachment)
inlineprotected

Definition at line 1195 of file weapon_base.c.

◆ CanRemoveFromHands()

override bool CanRemoveFromHands ( EntityAI parent)
inlineprotected

◆ ClearJunctureToAttachedMagazine()

void ClearJunctureToAttachedMagazine ( PlayerBase player)
inlineprivate

Definition at line 2241 of file weapon_base.c.

References g_Game.

◆ CopyWeaponStateFrom()

bool CopyWeaponStateFrom ( notnull Weapon_Base src)
inlineprivate

◆ CreateWeaponWithAmmo()

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

Definition at line 728 of file weapon_base.c.

References ECE_PLACE_ON_SURFACE, ErrorEx, g_Game, Weapon_Base(), and vector::Zero.

◆ DelayedValidateAndRepair()

void DelayedValidateAndRepair ( )
inlineprotected

Definition at line 1073 of file weapon_base.c.

References Error(), m_DelayedValidationTimer, VALIDATE_DELAY, and ValidateAndRepair().

Referenced by OnInventoryEnter().

◆ EEFired()

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

Definition at line 341 of file weapon_base.c.

References g_Game, and IncreaseOverheating().

◆ EEInit()

override void EEInit ( )
inlineprivate

Definition at line 135 of file weapon_base.c.

References AssembleGun(), CALL_CATEGORY_GAMEPLAY, and g_Game.

◆ EEItemAttached()

override void EEItemAttached ( EntityAI item,
string slot_name )
inlineprotected

Definition at line 1116 of file weapon_base.c.

References GetPropertyModifierObject().

◆ EEItemDetached()

override void EEItemDetached ( EntityAI item,
string slot_name )
inlineprotected

Definition at line 1123 of file weapon_base.c.

References GetPropertyModifierObject().

◆ EEItemLocationChanged()

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

Definition at line 1130 of file weapon_base.c.

References HumanCommandMove::SetMeleeBlock().

◆ EjectCartridge()

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

Definition at line 2044 of file weapon_base.c.

◆ FillChamber()

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

◆ FillInnerMagazine()

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

◆ FillSpecificChamber()

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

Definition at line 986 of file weapon_base.c.

References AmmoTypesAPI::MagazineTypeToAmmoType().

Referenced by FillChamber(), and FillInnerMagazine().

◆ ForceSyncSelectionState()

void ForceSyncSelectionState ( )
inlineprotected

◆ GetAbility()

AbilityRecord GetAbility ( int index)
inlineprotected

Definition at line 265 of file weapon_base.c.

References m_abilities.

Referenced by HasActionAbility().

◆ GetAbilityCount()

int GetAbilityCount ( )
inlineprotected
Returns
number of stored abilities

Definition at line 260 of file weapon_base.c.

References m_abilities.

Referenced by HasActionAbility().

◆ GetApproximateAimOffsets()

void GetApproximateAimOffsets ( Blend2DVector dst,
int characterStance )
inlineprotected

Definition at line 1476 of file weapon_base.c.

References Blend2DVector.

◆ GetApproximateMovementOffset()

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

◆ GetBayonetAttachmentIdx()

override int GetBayonetAttachmentIdx ( )
inlineprivate

Definition at line 2105 of file weapon_base.c.

References m_BayonetAttachmentIdx.

Referenced by GetEffectiveAttachmentLength().

◆ GetBurstCount()

int GetBurstCount ( )
inlineprivate

Definition at line 2191 of file weapon_base.c.

References m_BurstCount.

◆ GetButtstockAttachmentIdx()

override int GetButtstockAttachmentIdx ( )
inlineprivate

Definition at line 2121 of file weapon_base.c.

References m_ButtstockAttachmentIdx.

◆ GetChanceToJam()

float GetChanceToJam ( )
inlineprotected

Definition at line 411 of file weapon_base.c.

References m_ChanceToJam.

◆ GetCurrentStableStateID()

int GetCurrentStableStateID ( )
inlineprotected

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

Definition at line 662 of file weapon_base.c.

References m_fsm.

◆ GetCurrentState()

WeaponStateBase GetCurrentState ( )
inlineprotected

returns currently active state

Returns
current state the FSM is in (or NULL)

Definition at line 276 of file weapon_base.c.

References m_fsm.

Referenced by CanRemoveFromHands(), IsIdle(), IsWaitingForActionFinish(), and LoadCurrentFSMState().

◆ GetEffectiveAttachmentLength()

float GetEffectiveAttachmentLength ( )
inlineprivate

Returns effective length of attachments that influence total weapon length.

Definition at line 2006 of file weapon_base.c.

References GetBayonetAttachmentIdx(), HasBayonetAttached(), and Math::Max().

Referenced by GetObstructionPenetrationDistance(), and LiftWeaponCheckEx().

◆ GetInternalStateID()

int GetInternalStateID ( )
inlineprotected

Definition at line 652 of file weapon_base.c.

References m_fsm.

◆ GetMuzzleStates()

array< MuzzleState > GetMuzzleStates ( )
inlineprotected

Helper method for RandomizeFSMState.

Definition at line 691 of file weapon_base.c.

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

Referenced by RandomizeFSMState().

◆ 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

Definition at line 1986 of file weapon_base.c.

References ApproximateBaseObstructionLength(), GetEffectiveAttachmentLength(), Math::Lerp(), m_ObstructionDistance, m_ShoulderDistance, and m_WeaponLength.

◆ GetPropertyModifierObject()

PropertyModifiers GetPropertyModifierObject ( )
inlineprotected

Definition at line 1019 of file weapon_base.c.

References m_PropertyModifierObject.

Referenced by EEItemAttached(), and EEItemDetached().

◆ GetSlotsCountCorrect() [1/2]

override int GetSlotsCountCorrect ( )
inlineprotected

Returns number of slots for attachments corrected for weapons.

Definition at line 1011 of file weapon_base.c.

◆ GetSlotsCountCorrect() [2/2]

override int GetSlotsCountCorrect ( )
inlineprivate

Returns number of slots for attachments corrected for weapons.

Definition at line 6 of file binocularsbase.c.

◆ GetSyncChanceToJam()

float GetSyncChanceToJam ( )
inlineprotected

Definition at line 410 of file weapon_base.c.

References m_ChanceToJamSync.

Referenced by JamCheck().

◆ GetWasIronSight()

bool GetWasIronSight ( )
inlineprotected

Definition at line 1360 of file weapon_base.c.

References m_WasIronSight.

◆ GetWeaponAnimState()

int GetWeaponAnimState ( )
inlineprotected

Definition at line 339 of file weapon_base.c.

References m_weaponAnimState.

◆ GetWeaponDOF()

ref array< float > GetWeaponDOF ( )
inlineprotected

Definition at line 1355 of file weapon_base.c.

References m_DOFProperties.

◆ GetWeaponSpecificCommand()

int GetWeaponSpecificCommand ( int weaponAction,
int subCommand )
inlineprotected

Definition at line 1263 of file weapon_base.c.

◆ GetWeightSpecialized()

float GetWeightSpecialized ( bool forceRecalc = false)
inlineprotected

◆ HasActionAbility()

bool HasActionAbility ( int action,
int actionType )
inlineprotected

◆ HasBayonetAttached()

override bool HasBayonetAttached ( )
inlineprivate

Definition at line 2100 of file weapon_base.c.

References m_BayonetAttached.

Referenced by GetEffectiveAttachmentLength().

◆ HasButtstockAttached()

override bool HasButtstockAttached ( )
inlineprivate

Definition at line 2116 of file weapon_base.c.

References m_ButtstockAttached.

◆ HideBullet()

void HideBullet ( int muzzleIndex)
inlineprotected

Definition at line 397 of file weapon_base.c.

References m_bulletSelectionIndex.

◆ HideMagazine()

void HideMagazine ( )
inlineprivate

Definition at line 2146 of file weapon_base.c.

References m_magazineSimpleSelectionIndex.

Referenced by ForceSyncSelectionState(), and SyncSelectionState().

◆ HideWeaponBarrel()

void HideWeaponBarrel ( bool state)
inlineprivate

Definition at line 2126 of file weapon_base.c.

References ItemOptics::AllowsDOF(), g_Game, and m_weaponHideBarrelIdx.

Referenced by OnItemLocationChanged().

◆ InitDOFProperties()

bool InitDOFProperties ( out array< float > temp_array)
inlineprotected

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

Definition at line 1285 of file weapon_base.c.

References g_Game, and GetType().

Referenced by Weapon_Base().

◆ InitObstructionDistance()

bool InitObstructionDistance ( )
inlineprotected

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

Definition at line 1343 of file weapon_base.c.

References m_ObstructionDistance.

Referenced by Weapon_Base().

◆ InitReliability()

bool InitReliability ( out array< float > reliability_array)
inlineprotected

Definition at line 1295 of file weapon_base.c.

References g_Game, and GetType().

Referenced by Weapon_Base().

◆ InitShoulderDistance()

bool InitShoulderDistance ( )
inlineprotected

gets approximate weapon distance from shoulder from config

Definition at line 1330 of file weapon_base.c.

References m_ShoulderDistance.

Referenced by Weapon_Base().

◆ InitStateMachine()

void InitStateMachine ( )
inlineprivate

Definition at line 133 of file weapon_base.c.

◆ InitWeaponLength()

bool InitWeaponLength ( )
inlineprotected

gets weapon length from config for weaponlift raycast

Definition at line 1306 of file weapon_base.c.

References m_WeaponLength.

Referenced by Weapon_Base().

◆ InitWeaponLiftCheckVerticalOffset()

bool InitWeaponLiftCheckVerticalOffset ( )
inlineprotected

gets weapon vertical offset from config for weaponlift raycast

Definition at line 1318 of file weapon_base.c.

References m_WeaponLiftCheckVerticalOffset.

Referenced by Weapon_Base().

◆ IsCharged()

bool IsCharged ( )
inlineprivate

Definition at line 153 of file weapon_base.c.

References m_Charged.

◆ IsCoolDown()

bool IsCoolDown ( )
inlineprivate

Definition at line 2261 of file weapon_base.c.

References m_coolDownTime.

◆ IsIdle()

bool IsIdle ( )
inlineprotected

Definition at line 286 of file weapon_base.c.

References CanProcessWeaponEvents(), and GetCurrentState().

◆ IsJammed()

bool IsJammed ( )
inlineprotected

Definition at line 407 of file weapon_base.c.

References m_isJammed.

◆ IsRemoteWeapon()

bool IsRemoteWeapon ( )
inlineprotected

Definition at line 1224 of file weapon_base.c.

References InventoryLocation::GetParent(), and InventoryLocation::GetType().

◆ IsShowingChamberedBullet()

bool IsShowingChamberedBullet ( )
inlineprivate

Definition at line 2186 of file weapon_base.c.

◆ IsWaitingForActionFinish()

bool IsWaitingForActionFinish ( )
inlineprotected

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

Definition at line 281 of file weapon_base.c.

References CanProcessWeaponEvents(), and GetCurrentState().

◆ IsWeaponOpen()

bool IsWeaponOpen ( )
inlineprivate

Definition at line 163 of file weapon_base.c.

References m_WeaponOpen.

◆ JamCheck()

bool JamCheck ( int muzzleIndex)
inlineprotected

Definition at line 374 of file weapon_base.c.

References GetSyncChanceToJam().

◆ LiftWeaponCheck()

bool LiftWeaponCheck ( PlayerBase player)
inlineprotected

Definition at line 1372 of file weapon_base.c.

References LiftWeaponCheckEx().

◆ LiftWeaponCheckEx()

◆ LiftWeaponRaycastResultCheck()

bool LiftWeaponRaycastResultCheck ( notnull RaycastRVResult res)
inlineprivate

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

Definition at line 2000 of file weapon_base.c.

Referenced by LiftWeaponCheckEx().

◆ LoadCurrentFSMState()

◆ MustBeChambered()

bool MustBeChambered ( int muzzleIndex)
inlineprivate

Definition at line 2267 of file weapon_base.c.

Referenced by FillInnerMagazine(), and SpawnAttachedMagazine().

◆ OnDebugSpawn()

override void OnDebugSpawn ( )
inlineprivate

Definition at line 2224 of file weapon_base.c.

References SAMF_DEFAULT, and SpawnAmmo().

◆ OnFire()

void OnFire ( int muzzle_index)
inlineprotected

Definition at line 1028 of file weapon_base.c.

References m_BurstCount.

◆ OnFireModeChange()

void OnFireModeChange ( int fireMode)
inlineprotected

◆ OnInventoryEnter()

override void OnInventoryEnter ( Man player)
inlineprotected

◆ OnInventoryExit()

override void OnInventoryExit ( Man player)
inlineprotected

Definition at line 1110 of file weapon_base.c.

References m_PropertyModifierObject.

◆ OnItemLocationChanged()

override void OnItemLocationChanged ( EntityAI old_owner,
EntityAI new_owner )
inlineprotected

Definition at line 1148 of file weapon_base.c.

References Class::CastTo(), HideWeaponBarrel(), and SetWasIronSight().

◆ OnStoreLoad()

override bool OnStoreLoad ( ParamsReadContext ctx,
int version )
inlineprotected

◆ OnStoreSave()

override void OnStoreSave ( ParamsWriteContext ctx)
inlineprotected

Definition at line 624 of file weapon_base.c.

References m_fsm, m_isJammed, and Serializer::Write().

◆ ProcessMeleeItemDamage()

override EntityAI ProcessMeleeItemDamage ( int mode = 0)
inlineprivate

Definition at line 2154 of file weapon_base.c.

References m_BayonetAttachmentIdx, and m_ButtstockAttachmentIdx.

◆ ProcessWeaponAbortEvent()

bool ProcessWeaponAbortEvent ( WeaponEventBase e)
inlineprotected

Definition at line 315 of file weapon_base.c.

References m_fsm, and SyncEventToRemote().

◆ ProcessWeaponEvent()

bool ProcessWeaponEvent ( WeaponEventBase e)
inlineprotected

◆ RandomizeFSMState()

void RandomizeFSMState ( )
inlineprotected

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.

Definition at line 675 of file weapon_base.c.

References ForceSyncSelectionState(), GetMuzzleStates(), IsJammed(), and m_fsm.

Referenced by FillChamber(), FillInnerMagazine(), and SpawnAttachedMagazine().

◆ ResetBurstCount()

void ResetBurstCount ( )
inlineprivate

Definition at line 2196 of file weapon_base.c.

References m_BurstCount.

Referenced by OnFireModeChange().

◆ ResetWeaponAnimState()

void ResetWeaponAnimState ( )
inlineprotected

Definition at line 334 of file weapon_base.c.

References fsmDebugSpam(), LogManager::IsWeaponLogEnable(), and m_weaponAnimState.

◆ SaveCurrentFSMState()

void SaveCurrentFSMState ( ParamsWriteContext ctx)
inlineprotected

Definition at line 564 of file weapon_base.c.

References Error(), GetType(), LogManager::IsWeaponLogEnable(), m_fsm, and wpnDebugPrint().

◆ SetActions()

override void SetActions ( )
inlineprivate

Definition at line 2201 of file weapon_base.c.

References AddAction(), and FirearmActionLoadBulletQuick().

◆ SetBayonetAttached()

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

attachment helpers (firearm melee)

Definition at line 2094 of file weapon_base.c.

References m_BayonetAttached, and m_BayonetAttachmentIdx.

◆ SetButtstockAttached()

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

Definition at line 2110 of file weapon_base.c.

References m_ButtstockAttached, and m_ButtstockAttachmentIdx.

◆ SetCharged()

void SetCharged ( bool value)
inlineprivate

Definition at line 158 of file weapon_base.c.

References m_Charged.

Referenced by SetInitialState().

◆ SetCoolDown()

void SetCoolDown ( float coolDownTime)
inlineprivate

Definition at line 2256 of file weapon_base.c.

References m_coolDownTime.

◆ SetInitialState()

void SetInitialState ( WeaponStableState initState)
inlineprivate

Definition at line 145 of file weapon_base.c.

References WeaponStableState::IsDischarged(), m_fsm, SetCharged(), and SetWeaponOpen().

◆ SetJammed()

void SetJammed ( bool value)
inlineprotected

Definition at line 409 of file weapon_base.c.

References m_isJammed.

◆ SetNextWeaponMode()

void SetNextWeaponMode ( int muzzleIndex)
inlineprivate

Definition at line 2250 of file weapon_base.c.

Referenced by ProcessWeaponEvent().

◆ SetSyncJammingChance()

void SetSyncJammingChance ( float jamming_chance)
inlineprivate

Definition at line 2029 of file weapon_base.c.

References m_ChanceToJamSync.

◆ SetWasIronSight()

void SetWasIronSight ( bool state)
inlineprotected

Definition at line 1366 of file weapon_base.c.

References m_WasIronSight.

Referenced by OnItemLocationChanged().

◆ SetWeaponAnimState()

void SetWeaponAnimState ( int state)
inlineprotected

Definition at line 329 of file weapon_base.c.

References m_weaponAnimState.

◆ SetWeaponOpen()

void SetWeaponOpen ( bool value)
inlineprivate

Definition at line 168 of file weapon_base.c.

References m_WeaponOpen.

Referenced by SetInitialState().

◆ ShowBullet()

void ShowBullet ( int muzzleIndex)
inlineprotected

Definition at line 387 of file weapon_base.c.

References m_bulletSelectionIndex.

◆ ShowMagazine()

void ShowMagazine ( )
inlineprivate

Definition at line 2138 of file weapon_base.c.

References m_magazineSimpleSelectionIndex.

Referenced by ForceSyncSelectionState(), and SyncSelectionState().

◆ SpawnAmmo()

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

Definition at line 748 of file weapon_base.c.

References FillChamber(), FillInnerMagazine(), and SpawnAttachedMagazine().

Referenced by OnDebugSpawn().

◆ SpawnAttachedMagazine()

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

◆ SpawnRecoilObject()

RecoilBase SpawnRecoilObject ( )
inlineprotected

Definition at line 1258 of file weapon_base.c.

◆ SyncEventToRemote()

◆ SyncSelectionState()

void SyncSelectionState ( bool has_bullet,
bool has_mag )
inlineprotected

Definition at line 421 of file weapon_base.c.

References HideMagazine(), and ShowMagazine().

Referenced by AfterStoreLoad(), and LoadCurrentFSMState().

◆ UpdateCoolDown()

void UpdateCoolDown ( float dt)
inlineprivate

Definition at line 2260 of file weapon_base.c.

References m_coolDownTime.

◆ UseWeaponObstruction()

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

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

Definition at line 1385 of file weapon_base.c.

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

◆ ValidateAndRepair()

void ValidateAndRepair ( )
inlineprotected

Definition at line 1086 of file weapon_base.c.

References m_fsm.

Referenced by DelayedValidateAndRepair(), and OnInventoryEnter().

◆ Weapon_Base()

Field Documentation

◆ DEFAULT_DAMAGE_ON_SHOT

const float DEFAULT_DAMAGE_ON_SHOT = 0.05
protected

Definition at line 47 of file weapon_base.c.

◆ hit_mask

◆ m_abilities

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

Definition at line 48 of file weapon_base.c.

Referenced by GetAbility(), and GetAbilityCount().

◆ m_BayonetAttached

bool m_BayonetAttached
protected

Definition at line 52 of file weapon_base.c.

Referenced by HasBayonetAttached(), SetBayonetAttached(), and Weapon_Base().

◆ m_BayonetAttachmentIdx

int m_BayonetAttachmentIdx
protected

◆ m_bulletSelectionIndex

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

Definition at line 70 of file weapon_base.c.

Referenced by HideBullet(), ShowBullet(), and Weapon_Base().

◆ m_BurstCount

int m_BurstCount
protected

Definition at line 57 of file weapon_base.c.

Referenced by GetBurstCount(), OnFire(), ResetBurstCount(), and Weapon_Base().

◆ m_ButtstockAttached

bool m_ButtstockAttached
protected

Definition at line 53 of file weapon_base.c.

Referenced by HasButtstockAttached(), SetButtstockAttached(), and Weapon_Base().

◆ m_ButtstockAttachmentIdx

int m_ButtstockAttachmentIdx
protected

◆ m_ChanceToJam

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

Definition at line 72 of file weapon_base.c.

Referenced by GetChanceToJam(), and Weapon_Base().

◆ m_ChanceToJamSync

float m_ChanceToJamSync = 0
protected

Definition at line 73 of file weapon_base.c.

Referenced by GetSyncChanceToJam(), and SetSyncJammingChance().

◆ m_Charged

bool m_Charged = false
protected

Definition at line 54 of file weapon_base.c.

Referenced by IsCharged(), and SetCharged().

◆ m_coolDownTime

float m_coolDownTime = 0
private

Definition at line 77 of file weapon_base.c.

Referenced by IsCoolDown(), SetCoolDown(), and UpdateCoolDown().

◆ m_DelayedValidationTimer

ref Timer m_DelayedValidationTimer
protected

Definition at line 76 of file weapon_base.c.

Referenced by DelayedValidateAndRepair(), and Weapon_Base().

◆ m_DmgPerShot

float m_DmgPerShot = 0
protected

Definition at line 63 of file weapon_base.c.

◆ m_DOFProperties

ref array<float> m_DOFProperties
protected

Definition at line 71 of file weapon_base.c.

Referenced by GetWeaponDOF(), and Weapon_Base().

◆ m_fsm

◆ m_isJammed

bool m_isJammed = false
protected

weapon state machine

Definition at line 50 of file weapon_base.c.

Referenced by IsJammed(), OnStoreLoad(), OnStoreSave(), and SetJammed().

◆ m_LastLiftHit

int m_LastLiftHit
protected

Definition at line 69 of file weapon_base.c.

Referenced by LiftWeaponCheckEx().

◆ m_LastLiftPosition

vector m_LastLiftPosition
protected

Definition at line 68 of file weapon_base.c.

Referenced by LiftWeaponCheckEx().

◆ m_LiftWeapon

bool m_LiftWeapon = false
protected

Definition at line 51 of file weapon_base.c.

Referenced by CanFire(), and LiftWeaponCheckEx().

◆ m_magazineSimpleSelectionIndex

int m_magazineSimpleSelectionIndex = -1
protected

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

Definition at line 61 of file weapon_base.c.

Referenced by HideMagazine(), ShowMagazine(), and Weapon_Base().

◆ m_ObstructionDistance

float m_ObstructionDistance
protected

◆ m_PropertyModifierObject

ref PropertyModifiers m_PropertyModifierObject
protected

Definition at line 74 of file weapon_base.c.

Referenced by GetPropertyModifierObject(), OnInventoryEnter(), and OnInventoryExit().

◆ m_ShoulderDistance

float m_ShoulderDistance
protected

◆ m_WasIronSight

bool m_WasIronSight
protected

Definition at line 56 of file weapon_base.c.

Referenced by GetWasIronSight(), SetWasIronSight(), and Weapon_Base().

◆ m_weaponAnimState

int m_weaponAnimState = -1
protected

Definition at line 60 of file weapon_base.c.

Referenced by GetWeaponAnimState(), ResetWeaponAnimState(), and SetWeaponAnimState().

◆ m_weaponHideBarrelIdx

int m_weaponHideBarrelIdx = -1
protected

Definition at line 62 of file weapon_base.c.

Referenced by HideWeaponBarrel(), and Weapon_Base().

◆ m_WeaponLength

◆ m_WeaponLiftCheckVerticalOffset

float m_WeaponLiftCheckVerticalOffset
protected

◆ m_WeaponOpen

bool m_WeaponOpen = false
protected

Definition at line 55 of file weapon_base.c.

Referenced by IsWeaponOpen(), and SetWeaponOpen().

◆ SAMF_DEFAULT

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

Full highest capacity magazine + chambered round.

Definition at line 41 of file weapon_base.c.

Referenced by OnDebugSpawn().

◆ SAMF_RNG

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

Random bullet quantity + maybe chambered round.

Definition at line 43 of file weapon_base.c.

◆ VALIDATE_DELAY

const float VALIDATE_DELAY = 5.0
private

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

Definition at line 45 of file weapon_base.c.

Referenced by DelayedValidateAndRepair().


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