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< MuzzleState > | GetMuzzleStates () |
| Helper method for RandomizeFSMState. | |
| override int | GetSlotsCountCorrect () |
| Returns number of slots for attachments corrected for weapons. | |
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< float > | GetWeaponDOF () |
| 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. | |
script counterpart to engine's class Weapon
|
inlineprivate |
References CGame::AddInventoryJunctureEx(), and GetGame().
|
inlineprivate |
|
inlineprivate |
Approximate ObstructionDistance for weapons with no configuration. Returned length doesn't account for attachments.
References Math::Max().
|
inlineprivate |
Update provided start position and lift check direction to include appproximated character state.
| start | Ray start position, to be modified |
| direction | Ray direction |
References Blend2DVector, Math::Clamp(), HumanCommandWeapons::GetAimingHandsOffsetLR(), HumanCommandWeapons::GetAimingHandsOffsetUD(), Weapon_Base::GetApproximateAimOffsets(), Weapon_Base::GetApproximateMovementOffset(), HumanCommandWeapons::GetBaseAimingAngleLR(), HumanCommandWeapons::GetBaseAimingAngleUD(), Math::InverseLerp(), vector::InvMultiply3(), HumanCommandMove::IsChangingStance(), HumanMovementState::m_fLeaning, HumanMovementState::m_iStanceIdx, Math3D::MatrixMultiply3(), vector::Multiply4(), vector::Normalized(), vector::RotateAroundZeroDeg(), vector::Up, Vector(), and Math3D::YawPitchRollMatrix().
|
private |
override on weapons with some assembly required
|
inlineprivate |
References IsChamberFiredOut(), and IsChamberFull().
|
inlineprivate |
|
inlineprivate |
References ItemOptics::HasWeaponIronsightsOverride().
|
inlineprivate |
References IsChamberFiredOut(), and IsJammed().
|
inlineprivate |
References IsIdle(), LogManager::IsWeaponLogEnable(), Type, and wpnDebugPrint().
|
inlineprivate |
References CGame::ClearJunctureEx(), and GetGame().
|
inlineprivate |
|
inlinestaticprivate |
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 |
References ECE_PLACE_ON_SURFACE, ErrorEx, GetGame(), and vector::Zero.
|
inlineprivate |
References Error().
References GetGame(), and IncreaseOverheating().
|
inlineprivate |
|
inlineprivate |
References HumanCommandMove::SetMeleeBlock().
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 |
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 |
References AmmoTypesAPI::MagazineTypeToAmmoType(), Math::RandomIntInclusive(), and Synchronize().
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 |
References AmmoTypesAPI::MagazineTypeToAmmoType(), Math::RandomIntInclusive(), and Synchronize().
References AmmoTypesAPI::MagazineTypeToAmmoType().
|
inlineprivate |
References Weapon_Base::HideBullet(), IsChamberFull(), and Weapon_Base::ShowBullet().
|
inlineprivate |
| [in] | index | index into m_abilities storage |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
References Math::AbsFloat(), Math::Clamp(), Math::Lerp(), Math::Max(), Math::Pow(), and Vector().
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
tries to return identifier of current stable state (or nearest stable state if unstable state is currently running)
|
inlineprivate |
returns currently active state
|
inlineprivate |
Returns effective length of attachments that influence total weapon length.
References Math::Max().
|
inlineprivate |
|
inlineprivate |
Helper method for RandomizeFSMState.
References ErrorEx, IsChamberFiredOut(), and IsChamberFull().
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 |
References Math::Lerp().
|
inlineprivate |
|
inlineprivate |
Returns number of slots for attachments corrected for weapons.
|
inlineprivate |
Returns number of slots for attachments corrected for weapons.
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
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...) |
References AbilityRecord::m_action, and AbilityRecord::m_actionType.
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
References ItemOptics::AllowsDOF(), and GetGame().
Initializes DOF properties for weapon's ironsight/optics cameras.
References CGame::ConfigGetFloatArray(), GetGame(), and GetType().
|
inlineprivate |
gets weapon obstruction distance from shoulder at which the weapon is fully obstructed
References CGame::ConfigGetFloatArray(), GetGame(), and GetType().
|
inlineprivate |
gets approximate weapon distance from shoulder from config
|
inlineprivate |
|
inlineprivate |
gets weapon length from config for weaponlift raycast
|
inlineprivate |
gets weapon vertical offset from config for weaponlift raycast
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
References InventoryLocation::GetParent(), and InventoryLocation::GetType().
|
inlineprivate |
|
inlineprivate |
returns true if state machine started playing action/actionType and waits for finish
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
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) |
References Math::Acos(), vector::AnglesToVector(), HumanInputController::CameraIsFreeLook(), Math::Clamp(), Math::DEG2RAD, vector::DistanceSq(), vector::Dot(), RaycastRVParams::flags, HumanCommandWeapons::GetAimingHandsOffsetLR(), HumanCommandWeapons::GetAimingHandsOffsetUD(), HumanCommandWeapons::GetBaseAimingAngleLR(), HumanCommandWeapons::GetBaseAimingAngleUD(), CGame::GetCurrentCameraDirection(), GetGame(), GetVelocity(), HumanCommandWeapons::GetWeaponObstruction(), Math::InverseLerp(), HumanMovementState::IsRaised(), HumanMovementState::m_CommandTypeId, vector::Normalized(), RaycastRVResult::obj, RaycastRVResult::pos, Print(), DayZPhysics::RaycastRVProxy(), RaycastRVParams::type, Vector(), and vector::Zero.
|
inlineprivate |
Return whether provided material triggers weapon lift (true) or not (false).
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
References GetGame(), GetPosition, SEffectManager::PlaySound(), and EffectSound::SetAutodestroy().
|
inlineprivate |
References GetGame().
|
inlineprivate |
References Class::CastTo().
|
inlineprivate |
References Error(), LogManager::IsWeaponLogEnable(), Serializer::Read(), and wpnDebugPrint().
|
inlineprivate |
References Serializer::Write().
|
inlineprivate |
@NOTE: warning: ProcessWeaponEvent can be called only within DayZPlayer::HandleWeapons (or CommandHandler)
|
inlineprivate |
weapon's fsm handling of events @NOTE: warning: ProcessWeaponEvent can be called only within DayZPlayer::HandleWeapons (or CommandHandler)
References WeaponEventBase::GetEventID().
|
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().
|
inlineprivate |
|
inlineprivate |
References fsmDebugSpam(), and LogManager::IsWeaponLogEnable().
|
inlineprivate |
References Error(), GetType(), LogManager::IsWeaponLogEnable(), and wpnDebugPrint().
|
inlineprivate |
References AddAction(), and FirearmActionLoadBulletQuick().
attachment helpers (firearm melee)
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
References WeaponStableState::IsDischarged().
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
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 |
|
inlineprivate |
Try to spawn and attach a magazine.
| [in] | magazineType | string The magazine to attach, passing in empty string will select random |
| [in] | flags | int Setup flags, please read WeaponWithAmmoFlags |
References ErrorEx, GetDebugName(), Math::RandomIntInclusive(), and Synchronize().
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
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.
| obstructionValue | The percentage of penetration into hit object |
| hitObject | The object obstructing the weapon |
CFGGAMEPLAY
References dBodyIsDynamic(), dynamicMode, DiagMenu::GetValue(), CfgGameplayHandler::GetWeaponObstructionModeDynamic(), CfgGameplayHandler::GetWeaponObstructionModeStatic(), HumanMovementState::IsInProne(), HumanMovementState::IsInRaisedProne(), and staticMode.
|
inlineprivate |
|
inlineprivate |
References GetGame(), and Weapon_Base::InitStateMachine().
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
weapon abilities
|
private |
weapon state machine
|
private |
|
private |
|
private |
|
private |
animation state the weapon is in, -1 == uninitialized
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Full highest capacity magazine + chambered round.
|
private |
Random bullet quantity + maybe chambered round.
|
private |
Validation on client side delay to have time properly synchronize attachments needed for check.