DIFF

class Weapon_BaseSource

Weapon_Base Weapon InventoryItemSuper

All members, including inherited

script base for all weapons

@NOTE: this class is bound to core-config "Weapon_Base" config class

Constructors 1

Constants 4

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

Members 30

protected bool m_isJammed = false
Referenced by IsJammed(), OnStoreLoad(), OnStoreSave()
Show 1 more, SetJammed()
protected bool m_LiftWeapon = false
Referenced by CanFire(), and LiftWeaponCheckEx()
protected bool m_BayonetAttached
protected bool m_ButtstockAttached
protected bool m_Charged = false
Referenced by IsCharged(), and SetCharged()
protected bool m_WeaponOpen = false
Referenced by IsWeaponOpen(), and SetWeaponOpen()
protected bool m_WasIronSight
protected int m_BurstCount
Referenced by GetBurstCount(), OnFire(), ResetBurstCount()
Show 1 more, Weapon_Base()
protected int m_BayonetAttachmentIdx
protected int m_ButtstockAttachmentIdx
protected int m_weaponAnimState = -1

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

protected int m_magazineSimpleSelectionIndex = -1
protected int m_weaponHideBarrelIdx = -1

index in simpleHiddenSelections cfg array

protected float m_DmgPerShot = 0

default is set to zero, since C++ solution has been implemented. See 'damageBarrel' and 'barrelArmor' in configs.

protected float m_WeaponLiftCheckVerticalOffset
protected float m_ObstructionDistance
protected vector m_LastLiftPosition
Referenced by LiftWeaponCheckEx()
protected int m_LastLiftHit
Referenced by LiftWeaponCheckEx()
ref array<int> m_bulletSelectionIndex = new array<int>
ref array<float> m_DOFProperties
Referenced by GetWeaponDOF(), and Weapon_Base()
ref array<float> m_ChanceToJam = new array<float>
Referenced by GetChanceToJam(), and Weapon_Base()
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

Methods 116

void InitStateMachine()
Referenced by Weapon_Base()
override void EEInit()
Referenced by SCARH_Base.EEInit()
bool IsWeaponOpen()
References m_WeaponOpen
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

in action
one of Human.actions (i.e. RELOAD, MECHANISM, ...)
in actionType
one of Human.actionTypes (i.e. CHAMBERING_ONEBULLET_CLOSED, MECHANISM_CLOSED...)

Returns: true if weapon supports operation

int GetAbilityCount()

Returns: number of stored abilities

References array.Count(), and m_abilities
AbilityRecord GetAbility(int index)
in index
index into m_abilities storage

Returns: ability record

References array.Get(), and m_abilities
bool IsWaitingForActionFinish()

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

bool ProcessWeaponAbortEvent(WeaponEventBase e)

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

void SetWeaponAnimState(int state)
int GetWeaponAnimState()
bool CanEjectBullet()
float GetSyncChanceToJam()
override void AfterStoreLoad()
int GetInternalStateID()

tries to return identifier of current state

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<MuzzleState> GetMuzzleStates()

Helper method for RandomizeFSMState

Referenced by RandomizeFSMState()
static Weapon_Base CreateWeaponWithAmmo(string weaponType, string magazineType = "", int flags = WeaponWithAmmoFlags.CHAMBER)

Create weapon with ammo

in weaponType
string The weapon to create
in magazineType
string The magazine to attach or ammo to load, passing in empty string will select random
in flags
int Setup flags, please read WeaponWithAmmoFlags

Returns: The created weapon

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

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

in magazineType
string The magazine to attach or ammo to load, passing in empty string will select random
in flags
int Setup flags, please read WeaponWithAmmoFlags

Returns: whether anything was spawned or done

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

Try to fill the inner magazine

in ammoType
string The ammo to load, passing in empty string will select random
in flags
int Setup flags, please read WeaponWithAmmoFlags

Returns: Whether any ammo was added to the gun or not

NoteIt is best to fill in the actual 'ammo', as in the ones usually prefixed by 'Bullet_', to skip searching for it
Referenced by SpawnAmmo()
bool FillChamber(string ammoType = "", int flags = WeaponWithAmmoFlags.CHAMBER)

Try to fill the chamber

in ammoType
string The ammo to load, passing in empty string will select random
in flags
int Setup flags, please read WeaponWithAmmoFlags

Returns: Whether any chamber was filled

NoteIt is best to fill in the actual 'ammo', as in the ones usually prefixed by 'Bullet_', to skip searching for it
override int GetSlotsCountCorrect()

Returns number of slots for attachments corrected for weapons

void DelayedValidateAndRepair()
override void OnInventoryEnter(Man player)
override void OnInventoryExit(Man player)
override bool CanReleaseAttachment(EntityAI attachment)
override bool CanRemoveFromHands(EntityAI parent)
RecoilBase SpawnRecoilObject()
bool InitDOFProperties(out array<float> temp_array)

Initializes DOF properties for weapon's ironsight/optics cameras

Referenced by Weapon_Base()
bool InitReliability(out array<float> reliability_array)
Referenced by Weapon_Base()
bool InitWeaponLength()

gets weapon length from config for weaponlift raycast

Referenced by Weapon_Base()
bool InitWeaponLiftCheckVerticalOffset()

gets weapon vertical offset from config for weaponlift raycast

Referenced by Weapon_Base()
protected bool InitShoulderDistance()

gets approximate weapon distance from shoulder from config

Referenced by Weapon_Base()
protected bool InitObstructionDistance()

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

Referenced by Weapon_Base()
bool GetWasIronSight()
References m_WasIronSight
bool LiftWeaponCheck(PlayerBase player)
bool UseWeaponObstruction(PlayerBase player, float obstructionValue, Object hitObject)

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.

obstructionValue
The percentage of penetration into hit object
hitObject
The object obstructing the weapon
protected void GetApproximateAimOffsets(Blend2DVector dst, int characterStance)

CFGGAMEPLAY

References Blend2D.Insert()
protected vector GetApproximateMovementOffset(vector localVelocity, int characterStance, float lean, float ud11, float lr11)
References Math.AbsFloat(), Math.Clamp(), Math.Lerp()
Show 3 more, Math.Max(), Math.Pow(), and Vector()
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)

Perform weapon obstruction check by the provided `player`.

player
The player to perform the check.
outObstruction
Result obstruction value [0 .. 1] or > 1 when out of range and needs lift instead
outHitObject
Object that was hit (if any)

Returns: True whenever weapon should be lifted or obstruted. (See also Weapon_Base.UseWeaponObstruction)

References Math.Acos(), vector.AnglesToVector(), ApproximateBaseObstructionLength()
Show 59 more, ApproximateWeaponLiftTransform(), HumanInputController.CameraIsFreeLook(), Math.Clamp(), array.Count(), WeaponLiftDiag.Data(), vector.DistanceSq(), vector.Dot(), HumanCommandWeapons.GetAimingHandsOffsetLR(), HumanCommandWeapons.GetAimingHandsOffsetUD(), HumanCommandWeapons.GetBaseAimingAngleLR(), HumanCommandWeapons.GetBaseAimingAngleUD(), Human.GetBoneIndexByName(), Object.GetBonePositionWS(), Human.GetCommand_Move(), Human.GetCommandModifier_Weapons(), CGame.GetCurrentCameraDirection(), GetEffectiveAttachmentLength(), MiscGameplayFunctions.GetHeadingVector(), Human.GetInputController(), Human.GetMovementState(), Object.GetOrientation(), Object.GetPosition(), Entity.GetSimulationTimeStamp(), GetVelocity(), PluginDiagMenuClient.GetWeaponLiftDiag(), HumanCommandWeapons.GetWeaponObstruction(), new HumanMovementState(), Math.InverseLerp(), HumanMovementState.IsRaised(), vector.Length(), LiftWeaponRaycastResultCheck(), vector.Normalized(), vector.Normalized(), Print(), new RaycastRVParams(), DayZPhysics.RaycastRVProxy(), WeaponLiftDiag.Reset(), WeaponLiftDiagData.SetIntersectionParams(), WeaponLiftDiagData.SetLastPosition(), WeaponLiftDiagData.SetWeaponRayParams(), Vector(), IEntity.VectorToLocal(), DayZPlayerCamera1stPerson.CONST_UD_MAX, DayZPlayerCamera1stPerson.CONST_UD_MIN, Math.DEG2RAD, RaycastRVParams.flags, HumanMovementState.m_CommandTypeId, PlayerBase.m_DirectionToCursor, m_LastLiftHit, m_LastLiftPosition, m_LiftWeapon, m_ObstructionDistance, m_ShoulderDistance, m_WeaponLength, float.MAX, RaycastRVResult.obj, RaycastRVResult.pos, RaycastRVParams.type, and vector.Zero
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.

obstruction01
Obstruction progress

Returns: Penetration depth in meters

bool LiftWeaponRaycastResultCheck(notnull RaycastRVResult res)

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

Referenced by LiftWeaponCheckEx()
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

@NOTE: EjectCartridge = GetCartridgeInfo + PopCartridge

in muzzleIndex
out ammoDamage
damage of the ammo
out ammoTypeName
type name of the ejected ammo

Returns: true if bullet removed from chamber

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()
bool IsShowingChamberedBullet()
override bool CanBeUsedForSuicide()
bool AddJunctureToAttachedMagazine(PlayerBase player, int timeoutMS)
Referenced by WeaponFire.OnEntry()
void ClearJunctureToAttachedMagazine(PlayerBase player)
Referenced by WeaponFire.OnExit()
void SetNextWeaponMode(int muzzleIndex)
Referenced by ProcessWeaponEvent()
void SetCoolDown(float coolDownTime)
References m_coolDownTime
void UpdateCoolDown(float dt)
References m_coolDownTime
bool IsCoolDown()
References m_coolDownTime
bool MustBeChambered(int muzzleIndex)
void SetSyncStable(bool value)TEST_WEAPON_SYSNC_REPAIR