DayZ 1.26
DayZ Explorer by KGB
Загрузка...
Поиск...
Не найдено
Класс Weapon

script counterpart to engine's class Weapon Подробнее...

Защищенные члены

void Weapon_Base ()
 
void InitStateMachine ()
 
override void EEInit ()
 
void SetInitialState (WeaponStableState initState)
 
bool IsCharged ()
 
void SetCharged (bool value)
 
bool IsWeaponOpen ()
 
void SetWeaponOpen (bool value)
 
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.
 
array< MuzzleStateGetMuzzleStates ()
 Helper method for RandomizeFSMState.
 

Защищенные данные

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

Закрытые члены

override int GetSlotsCountCorrect ()
 Returns number of slots for attachments corrected for weapons.
 

Закрытые данные

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)

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.
 
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
 
ref array< floatGetWeaponDOF ()
 
bool LiftWeaponCheck (PlayerBase player)
 
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)
 
static Weapon_Base CreateWeaponWithAmmo (string weaponType, string magazineType="", int flags=WeaponWithAmmoFlags.CHAMBER)
 Create weapon with ammo.
 

Подробное описание

script counterpart to engine's class Weapon

Методы

◆ AddJunctureToAttachedMagazine()

bool AddJunctureToAttachedMagazine ( PlayerBase player,
int timeoutMS )
inlineprotected
1881 {
1882 Magazine mag = GetMagazine(GetCurrentMuzzle());
1884 if (mag)
1885 {
1886 return GetGame().AddInventoryJunctureEx(player, mag, il, false, timeoutMS);
1887 }
1888
1889 return true;
1890 }
InventoryLocation.
Definition InventoryLocation.c:29
Definition EntityAI.c:95
proto native CGame GetGame()

Перекрестные ссылки GetGame().

◆ AfterStoreLoad()

override void AfterStoreLoad ( )
inlineprotected
607 {
608 if (m_fsm)
609 {
610 int mi = GetCurrentMuzzle();
611 Magazine mag = GetMagazine(mi);
612 bool has_mag = mag != null;
613 bool has_bullet = !IsChamberEmpty(mi);
615 }
616 }
ref WeaponFSM m_fsm
weapon abilities
Definition Weapon_Base.c:49
void SyncSelectionState(bool has_bullet, bool has_mag)
Definition Weapon_Base.c:415

◆ AssembleGun()

void AssembleGun ( )
protected

override on weapons with some assembly required

◆ CanBeUsedForSuicide()

override bool CanBeUsedForSuicide ( )
inlineprotected
1867 {
1868 if (!ConfigGetBool("isSuicideWeapon"))
1869 return false;
1870
1871 return super.CanBeUsedForSuicide();
1872 }

◆ CanChamberBullet()

bool CanChamberBullet ( int muzzleIndex,
Magazine mag )
inlineprotected
319 {
320 return CanChamberFromMag(muzzleIndex, mag) && (!IsChamberFull(muzzleIndex) || IsChamberFiredOut(muzzleIndex) || !IsInternalMagazineFull(muzzleIndex));
321 }
bool IsChamberFiredOut(int idx)
Definition WeaponStableState.c:153
bool IsChamberFull(int idx)
Definition WeaponStableState.c:154

Перекрестные ссылки IsChamberFiredOut() и IsChamberFull().

◆ CanEjectBullet()

bool CanEjectBullet ( )
inlineprotected
402{return true;}

◆ CanEnterIronsights()

bool CanEnterIronsights ( )
inlineprotected
1212 {
1213 ItemOptics optic = GetAttachedOptics();
1214 if (!optic)
1215 return true;
1216
1217 return optic.HasWeaponIronsightsOverride();
1218 }
Definition ItemOptics.c:2

◆ CanFire()

bool CanFire ( )
inlineprotected
1205 {
1206 if (!IsChamberEmpty(GetCurrentMuzzle()) && !IsChamberFiredOut(GetCurrentMuzzle()) && !IsJammed() && !m_LiftWeapon && !IsDamageDestroyed())
1207 return true;
1208 return false;
1209 }
bool m_LiftWeapon
Definition Weapon_Base.c:51
bool IsJammed()
Definition Weapon_Base.c:401

Перекрестные ссылки IsChamberFiredOut() и IsJammed().

◆ CanProcessAction()

bool CanProcessAction ( int action,
int actionType )
inlineprotected
231 {
232 return false; // @TODO
233 }

◆ CanProcessWeaponEvents()

CanProcessWeaponEvents ( )
inlineprotected
Возвращает
true if weapon has running fsm
264{ return m_fsm && m_fsm.IsRunning(); }

◆ CanReleaseAttachment()

override bool CanReleaseAttachment ( EntityAI attachment)
inlineprotected
1132 {
1133 if ( !super.CanReleaseAttachment( attachment ) )
1134 return false;
1136 if (mag)
1137 {
1138 PlayerBase player = PlayerBase.Cast( GetHierarchyRootPlayer() );
1139 if ( player )
1140 {
1141 if ( player.GetItemInHands() == this )
1142 return true;
1143 }
1144 return false;
1145 }
1146
1147 return true;
1148 }
Definition PlayerBaseClient.c:2

◆ CanRemoveFromHands()

override bool CanRemoveFromHands ( EntityAI parent)
inlineprotected
1151 {
1152 if (IsIdle())
1153 {
1154 return true;
1155 }
1156 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(this) + " Weapon=" + this + " not in stable state=" + GetCurrentState().Type()); }
1157 return false; // do not allow removal of weapon while weapon is busy
1158 }
void wpnDebugPrint(string s)
Definition Debug.c:9
string Type
Definition JsonDataContaminatedArea.c:11
Definition Debug.c:600
static bool IsWeaponLogEnable()
Definition Debug.c:724
Definition ObjectTyped.c:2
bool IsIdle()
Definition Weapon_Base.c:280
WeaponStateBase GetCurrentState()
returns currently active state
Definition Weapon_Base.c:270

Перекрестные ссылки IsIdle(), LogManager::IsWeaponLogEnable(), Type и wpnDebugPrint().

◆ ClearJunctureToAttachedMagazine()

void ClearJunctureToAttachedMagazine ( PlayerBase player)
inlineprotected
1893 {
1894 Magazine mag = GetMagazine(GetCurrentMuzzle());
1895 if (mag)
1896 {
1897 GetGame().ClearJuncture(player, mag);
1898 }
1899 }

Перекрестные ссылки GetGame().

◆ CopyWeaponStateFrom()

bool CopyWeaponStateFrom ( notnull Weapon_Base src)
inlineprotected
1711 {
1712 float damage = 0.0;
1713 string type;
1714
1715 for (int mi = 0; mi < src.GetMuzzleCount(); ++mi)
1716 {
1717 if (!src.IsChamberEmpty(mi))
1718 {
1719 if (src.GetCartridgeInfo(mi, damage, type))
1720 {
1721 PushCartridgeToChamber(mi, damage, type);
1722 }
1723 }
1724
1725 for (int ci = 0; ci < src.GetInternalMagazineCartridgeCount(mi); ++ci)
1726 {
1727 if (src.GetInternalMagazineCartridgeInfo(mi, ci, damage, type))
1728 {
1729 PushCartridgeToInternalMagazine(mi, damage, type);
1730 }
1731 }
1732 }
1733
1734 int dummy_version = int.MAX;
1735 PlayerBase parentPlayer = PlayerBase.Cast(src.GetHierarchyRootPlayer());
1736 if (!parentPlayer)
1737 dummy_version -= 1;
1739 src.OnStoreSave(ctx.GetWriteContext());
1740 OnStoreLoad(ctx.GetReadContext(), dummy_version);
1741 return true;
1742 }
Definition gameplay.c:134
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Definition Weapon_Base.c:483

Перекрестные ссылки OnStoreLoad().

◆ CreateWeaponWithAmmo()

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

Create weapon with ammo.

Аргументы
[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
Возвращает
The created weapon
723 {
725
726 if ( !wpn )
727 {
728 ErrorEx(string.Format("%1 does not exist or is not a weapon.", weaponType));
729 return null;
730 }
731
732 wpn.SpawnAmmo(magazineType, flags);
733 return wpn;
734 }
const int ECE_PLACE_ON_SURFACE
Definition CentralEconomy.c:37
shorthand
Definition BoltActionRifle_Base.c:6
Definition EnConvert.c:106
static const vector Zero
Definition EnConvert.c:110
enum ShapeType ErrorEx

Перекрестные ссылки ECE_PLACE_ON_SURFACE, ErrorEx, GetGame() и vector::Zero.

◆ DelayedValidateAndRepair()

void DelayedValidateAndRepair ( )
inlineprotected
1045 {
1047 {
1048 m_DelayedValidationTimer.Run(VALIDATE_DELAY , this, "ValidateAndRepair");
1049 }
1050 else
1051 {
1052 Error("[wpn] Weapon_Base::DelayedValidateAndRepair m_DelayedValidationTimer not initialized.");
1054 }
1055 }
const float VALIDATE_DELAY
Validation on client side delay to have time properly synchronize attachments needed for check.
Definition Weapon_Base.c:45
ref Timer m_DelayedValidationTimer
Definition Weapon_Base.c:74
void ValidateAndRepair()
Definition Weapon_Base.c:1057
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90

Перекрестные ссылки Error().

◆ EEFired()

void EEFired ( int muzzleType,
int mode,
string ammoType )
inlineprotected
336 {
337 if ( !GetGame().IsDedicatedServer() )
338 {
339 ItemBase suppressor = GetAttachedSuppressor();
340
341 // Muzzle flash & overheating effects
342 ItemBase.PlayFireParticles(this, muzzleType, ammoType, this, suppressor, "CfgWeapons" );
343 IncreaseOverheating(this, ammoType, this, suppressor, "CfgWeapons");
344
345 if (suppressor)
346 {
347 ItemBase.PlayFireParticles(this, muzzleType, ammoType, suppressor, NULL, "CfgVehicles" );
348 suppressor.IncreaseOverheating(this, ammoType, this, suppressor, "CfgVehicles");
349 }
350 }
351
352 //obsolete, replaced by C++ solution!
353/*
354 if (GetGame().IsServer())
355 {
356 AddHealth("","Health",-m_DmgPerShot); //damages weapon
357 if (suppressor)
358 suppressor.AddHealth("","Health",-m_DmgPerShot); //damages suppressor; TODO add suppressor damage coeficient/parameter (?) to suppressors/weapons (?)
359 }
360*/
361 //JamCheck(muzzleType);
362
363 #ifdef DIAG_DEVELOPER
364 MiscGameplayFunctions.UnlimitedAmmoDebugCheck(this);
365 #endif
366 }
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Definition ItemBase.c:5294
Definition InventoryItem.c:731

Перекрестные ссылки GetGame() и IncreaseOverheating().

◆ EEInit()

override void EEInit ( )
inlineprotected
130 {
131 super.EEInit();
132
133 if (GetGame().IsServer())
134 {
135 GetGame().GetCallQueue( CALL_CATEGORY_GAMEPLAY ).Call( AssembleGun );
136 }
137 }
void AssembleGun()
override on weapons with some assembly required
const int CALL_CATEGORY_GAMEPLAY
Definition tools.c:10

Перекрестные ссылки Weapon_Base::AssembleGun(), CALL_CATEGORY_GAMEPLAY и GetGame().

◆ EEItemAttached()

override void EEItemAttached ( EntityAI item,
string slot_name )
inlineprotected
1079 {
1080 super.EEItemAttached(item, slot_name);
1081
1083 }
void UpdateModifiers()
Definition PropertyModifiers.c:38
PropertyModifiers GetPropertyModifierObject()
Definition Weapon_Base.c:990

◆ EEItemDetached()

override void EEItemDetached ( EntityAI item,
string slot_name )
inlineprotected
1086 {
1087 super.EEItemDetached(item, slot_name);
1088
1090 }

◆ EEItemLocationChanged()

override void EEItemLocationChanged ( notnull InventoryLocation oldLoc,
notnull InventoryLocation newLoc )
inlineprotected
1093 {
1094 super.EEItemLocationChanged(oldLoc, newLoc);
1095
1096 if (newLoc.GetType() == InventoryLocationType.HANDS)
1097 {
1099 if (newLoc.GetParent() && PlayerBase.CastTo(player, newLoc.GetParent()))
1100 {
1101 HumanCommandMove cm = player.GetCommand_Move();
1102 if (cm)
1103 {
1104 cm.SetMeleeBlock(false);
1105 }
1106 }
1107 }
1108 }
InventoryLocationType
types of Inventory Location
Definition InventoryLocation.c:4
Definition human.c:434

◆ EjectCartridge()

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

unload bullet from chamber or internal magazine

@NOTE: EjectCartridge = GetCartridgeInfo + PopCartridge

Аргументы
[in]muzzleIndex
[out]ammoDamagedamage of the ammo
[out]ammoTypeNametype name of the ejected ammo
Возвращает
true if bullet removed from chamber
1696 {
1697 if (IsChamberEjectable(muzzleIndex))
1698 {
1699 if (PopCartridgeFromChamber(muzzleIndex, ammoDamage, ammoTypeName))
1700 return true;
1701 }
1702 else if (GetInternalMagazineCartridgeCount(muzzleIndex) > 0)
1703 {
1704 if (PopCartridgeFromInternalMagazine(muzzleIndex, ammoDamage, ammoTypeName))
1705 return true;
1706 }
1707 return false;
1708 }

◆ FillChamber()

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

Try to fill the chamber.

Аргументы
[in]ammoTypestring The ammo to load, passing in empty string will select random
Заметки
It is best to fill in the actual 'ammo', as in the ones usually prefixed by 'Bullet_', to skip searching for it
Аргументы
[in]flagsint Setup flags, please read WeaponWithAmmoFlags
Возвращает
Whether any chamber was filled
892 {
893 // Quickly check if there are any chambers we can fill
894 int muzzCount = GetMuzzleCount();
895 bool anyEmpty = false;
896
897 for (int m = 0; m < muzzCount; ++m)
898 {
899 if (IsChamberEmpty(m))
900 {
901 anyEmpty = true;
902 break;
903 }
904 }
905
906 if (!anyEmpty)
907 return false;
908
909 // Make sure the given ammoType is actually useable
910 if (ammoType != "")
912 return false;
913
914 // Just so we don't '&' wastefully in a loop
915 bool didSomething = false;
916 bool chamberFullRng = (flags & WeaponWithAmmoFlags.CHAMBER_RNG_SPORADIC);
917 bool chamberRng = (flags & WeaponWithAmmoFlags.CHAMBER_RNG);
918 bool chamber = (flags & WeaponWithAmmoFlags.CHAMBER);
919
921 {
923
924 // No need to do this for full rng, as that will roll for every muzzle
925 if (chamberRng)
927
928 bool chamberAmmoRng = (ammoType == "");
929 bool chamberAmmoFullRng = chamberAmmoRng && (flags & WeaponWithAmmoFlags.AMMO_CHAMBER_RNG);
930
931 // No full RNG flag, so pick one random and use only this one
933 ammoType = GetRandomChamberableAmmoTypeName(0);
934
935 for (int i = 0; i < muzzCount; ++i)
936 {
937 // Skip when there's already something in the chamber
938 if (!IsChamberEmpty(i))
939 continue;
940
941 // Roll the rng when enabled
942 if (chamberFullRng)
944
945 // We chambering
946 if (chamber)
947 {
948 // Full random, decide a new one for every muzzle
949 if ( chamberAmmoFullRng )
950 ammoType = GetRandomChamberableAmmoTypeName(i);
951
952 // Push it
953 PushCartridgeToChamber(i, 0, ammoType);
954 didSomething = true;
955
956 // Stop chambering when we hit the desired amount
958 if (amountToChamber <= 0)
959 break;
960 }
961 }
962 }
963
964 // Only fix the FSM and Synchronize when absolutely needed
965 if (!didSomething)
966 return false;
967
968 // FSM cares about chamber state
970 Synchronize();
971
972 return true;
973 }
void Synchronize()
Definition CombinationLock.c:151
Definition AmmoTypes.c:2
static bool MagazineTypeToAmmoType(string magazineType, out string ammoType)
Helper method.
Definition AmmoTypes.c:12
Definition EnMath.c:7
void RandomizeFSMState()
With the parameters given, selects a random suitable state for the FSM of the weapon @WARNING: Weapon...
Definition Weapon_Base.c:669
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Definition EnMath.c:54

Перекрестные ссылки AmmoTypesAPI::MagazineTypeToAmmoType(), Math::RandomIntInclusive() и Synchronize().

◆ FillInnerMagazine()

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

Try to fill the inner magazine.

Аргументы
[in]ammoTypestring The ammo to load, passing in empty string will select random
Заметки
It is best to fill in the actual 'ammo', as in the ones usually prefixed by 'Bullet_', to skip searching for it
Аргументы
[in]flagsint Setup flags, please read WeaponWithAmmoFlags
Возвращает
Whether any ammo was added to the gun or not
824 {
825 // Don't try to fill it when there are none
826 if (!HasInternalMagazine(-1))
827 return false;
828
829 // Make sure the given ammoType is actually useable
830 if (ammoType != "")
831 {
833 return false;
834 }
835
836
837 bool didSomething = false;
838 int muzzCount = GetMuzzleCount();
839
840 bool ammoRng = ammoType == "";
841 bool ammoFullRng = ammoRng && (flags & WeaponWithAmmoFlags.AMMO_MAG_RNG);
842
843 // No full RNG flag, so pick one random and use only this one
844 if (ammoRng && !ammoFullRng)
845 ammoType = GetRandomChamberableAmmoTypeName(0);
846
847 // Fill the internal magazine
848 for (int i = 0; i < muzzCount; ++i)
849 {
850 int ammoCount = GetInternalMagazineMaxCartridgeCount(i);
851
852 // Decide random quantity when enabled
853 if ( flags & WeaponWithAmmoFlags.QUANTITY_RNG )
855
856 // Only do the things when there is actually ammo to fill
857 if (ammoCount > 0)
858 {
859 // Push in the cartridges
860 for (int j = 0; j < ammoCount; ++j)
861 {
862 // Full random, decide a new one for every cartridge
863 if ( ammoFullRng )
864 ammoType = GetRandomChamberableAmmoTypeName(i);
865
866 PushCartridgeToInternalMagazine(i, 0, ammoType);
867 didSomething = true;
868 }
869 }
870 }
871
872 // Call the chamber method if asked for
873 bool chamber = (flags & WeaponWithAmmoFlags.CHAMBER) || (flags & WeaponWithAmmoFlags.CHAMBER_RNG);
874 if (chamber && FillChamber(ammoType, flags))
875 {
876 didSomething = true;
877 }
878
879 // Does not need any FSM fixing, FSM does not care about inner magazines
880
881 return didSomething;
882 }
bool FillChamber(string ammoType="", int flags=WeaponWithAmmoFlags.CHAMBER)
Try to fill the chamber.
Definition Weapon_Base.c:891

Перекрестные ссылки AmmoTypesAPI::MagazineTypeToAmmoType() и Math::RandomIntInclusive().

◆ ForceSyncSelectionState()

void ForceSyncSelectionState ( )
inlineprotected
457 {
458 int nMuzzles = GetMuzzleCount();
459 for (int i = 0; i < nMuzzles; ++i)
460 {
461 if (IsChamberFull(i))
462 {
463 ShowBullet(i);
464 float damage;
465 string ammoTypeName;
466 GetCartridgeInfo(i, damage, ammoTypeName);
467 EffectBulletShow(i, damage, ammoTypeName);
468 }
469 else
470 {
471 HideBullet(i);
472 EffectBulletHide(i);
473 }
474
475 Magazine mag = GetMagazine(i);
476 if (mag)
477 ShowMagazine();
478 else
479 HideMagazine();
480 }
481 }
void ShowBullet(int muzzleIndex)
Definition Weapon_Base.c:381
void HideBullet(int muzzleIndex)
Definition Weapon_Base.c:391
void ShowMagazine()
Definition Weapon_Base.c:1789
void HideMagazine()
Definition Weapon_Base.c:1797

Перекрестные ссылки Weapon_Base::HideBullet(), IsChamberFull() и Weapon_Base::ShowBullet().

◆ GetAbility()

GetAbility ( int index)
inlineprotected
Аргументы
[in]indexindex into m_abilities storage
Возвращает
ability record
259{ return m_abilities.Get(index); }
ref array< ref AbilityRecord > m_abilities
Definition Weapon_Base.c:48

◆ GetAbilityCount()

GetAbilityCount ( )
inlineprotected
Возвращает
number of stored abilities
254{ return m_abilities.Count(); }

◆ GetBayonetAttachmentIdx()

override int GetBayonetAttachmentIdx ( )
inlineprotected
1757 {
1759 }
int m_BayonetAttachmentIdx
Definition Weapon_Base.c:57

◆ GetBurstCount()

int GetBurstCount ( )
inlineprotected
1843 {
1844 return m_BurstCount;
1845 }
int m_BurstCount
Definition Weapon_Base.c:56

◆ GetButtstockAttachmentIdx()

override int GetButtstockAttachmentIdx ( )
inlineprotected
1773 {
1775 }
int m_ButtstockAttachmentIdx
Definition Weapon_Base.c:58

◆ GetChanceToJam()

float GetChanceToJam ( )
inlineprotected
406 {
407 int level = GetHealthLevel();
408
409 if (level >= 0 && level < m_ChanceToJam.Count())
410 return m_ChanceToJam[level];
411 else
412 return 0.0;
413 }
ref array< float > m_ChanceToJam
Definition Weapon_Base.c:70

◆ GetCurrentStableStateID()

GetCurrentStableStateID ( )
inlineprotected

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

657 {
658 if (m_fsm)
659 {
660 return m_fsm.GetCurrentStableStateID();
661 }
662 return 0;
663 }

◆ GetCurrentState()

GetCurrentState ( )
inlineprotected

returns currently active state

Возвращает
current state the FSM is in (or NULL)
270{ return m_fsm.GetCurrentState(); }

◆ GetEffectiveAttachmentLength()

float GetEffectiveAttachmentLength ( )
inlineprotected

Returns effective length of attachments that influence total weapon length.

1658 {
1660 if (HasBayonetAttached())
1661 {
1663 attachment = ItemBase.Cast(GetInventory().FindAttachment(bayonetIndex));
1664 }
1665 else
1666 {
1667 attachment = GetAttachedSuppressor();
1668 }
1669
1670 if (attachment)
1671 {
1672 return Math.Max(attachment.m_ItemModelLength + attachment.m_ItemAttachOffset, 0);
1673 }
1674 else
1675 {
1676 return 0;
1677 }
1678 }
override int GetBayonetAttachmentIdx()
Definition Weapon_Base.c:1756
override bool HasBayonetAttached()
Definition Weapon_Base.c:1751
static proto float Max(float x, float y)
Returns bigger of two given values.

Перекрестные ссылки Math::Max().

◆ GetInternalStateID()

int GetInternalStateID ( )
inlineprotected
647 {
648 if (m_fsm)
649 return m_fsm.GetInternalStateID();
650 return 0;
651 }

◆ GetMuzzleStates()

array< MuzzleState > GetMuzzleStates ( )
inlineprotected

Helper method for RandomizeFSMState.

686 {
688
689 int nMuzzles = GetMuzzleCount();
690 for (int i = 0; i < nMuzzles; ++i)
691 {
693 if (IsChamberFiredOut(i))
694 state = MuzzleState.F;
695 else if (IsChamberFull(i))
696 state = MuzzleState.L;
697 else if (IsChamberEmpty(i))
698 state = MuzzleState.E;
699 else
700 ErrorEx(string.Format("Unable to identify chamber state of muzzle %1", i));
701
702 muzzleStates.Insert(state);
703 }
704
705 return muzzleStates;
706 }
MuzzleState
Definition WeaponStableState.c:15

Перекрестные ссылки ErrorEx, IsChamberFiredOut() и IsChamberFull().

◆ GetPropertyModifierObject()

PropertyModifiers GetPropertyModifierObject ( )
inlineprotected
991 {
993 {
995 }
997 }
Definition PropertyModifiers.c:2
ref PropertyModifiers m_PropertyModifierObject
Definition Weapon_Base.c:72

◆ GetSlotsCountCorrect() [1/2]

override int GetSlotsCountCorrect ( )
inlineprotected

Returns number of slots for attachments corrected for weapons.

983 {
984 int ac = GetInventory().AttachmentCount();
985 int sc = GetInventory().GetAttachmentSlotsCount() + GetMuzzleCount();
986 if (ac > sc) sc = ac; // fix of some weapons which has 1 attachments but 0 slots...
987 return sc;
988 };

◆ GetSlotsCountCorrect() [2/2]

override int GetSlotsCountCorrect ( )
inlineprivate

Returns number of slots for attachments corrected for weapons.

7 {
8 return GetInventory().GetAttachmentSlotsCount();
9 };

◆ GetSyncChanceToJam()

float GetSyncChanceToJam ( )
inlineprotected
404{ return m_ChanceToJamSync; }
float m_ChanceToJamSync
Definition Weapon_Base.c:71

◆ GetWeaponAnimState()

int GetWeaponAnimState ( )
inlineprotected
333{ return m_weaponAnimState; }
int m_weaponAnimState
Definition Weapon_Base.c:59

◆ GetWeaponDOF()

ref array< float > GetWeaponDOF ( )
inlineprotected
1279 {
1280 return m_DOFProperties;
1281 }
ref array< float > m_DOFProperties
Definition Weapon_Base.c:69

◆ GetWeaponSpecificCommand()

int GetWeaponSpecificCommand ( int weaponAction,
int subCommand )
inlineprotected
1200 {
1201 return subCommand;
1202 }

◆ GetWeightSpecialized()

float GetWeightSpecialized ( bool forceRecalc = false)
inlineprotected
168 {
169 float baseWeight = GetInventoryAndCargoWeight(forceRecalc);
170 float ammoWeight;
171 float ammoDamage;
173
174 int muzzleCount = GetMuzzleCount();
175 #ifdef DEVELOPER
176 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
177 {
178 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
179 data1.SetCalcDetails("TWPN: " + m_ConfigWeight+"(item weight) + " + baseWeight +"(contents weight)" );
180 }
181 #endif
183 {
184 //chamber weight
185 if (!IsChamberEmpty(muzzleIndex))
186 {
187 ammoTypeName = GetChamberAmmoTypeName(muzzleIndex);
188 ammoWeight += g_Game.ConfigGetFloat(string.Format("CfgMagazines %1 weight", ammoTypeName));
189
190 #ifdef DEVELOPER
191 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
192 {
193 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
194 data2.AddCalcDetails( g_Game.ConfigGetFloat("CfgMagazines " + ammoTypeName + " weight").ToString() +"(chamber weight)");
195 }
196 #endif
197 }
198
199 //correctly calculates internal magazine weight based on the ammo type of each bullet
200 if (HasInternalMagazine(muzzleIndex))
201 {
202 #ifdef DEVELOPER
204 #endif
205 int cartridgeCount = GetInternalMagazineCartridgeCount(muzzleIndex);
207 {
208 GetInternalMagazineCartridgeInfo(muzzleIndex, cartridgeIndex, ammoDamage, bulletTypeName);
210 #ifdef DEVELOPER
211 debugInternalMagWeight += g_Game.ConfigGetFloat("CfgMagazines " + ammoTypeName + " weight");
212 #endif
213 }
214 #ifdef DEVELOPER
215
216 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
217 {
218 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
219 data3.AddCalcDetails(debugInternalMagWeight.ToString()+ "(internal mag weight)");
220 }
221 #endif
222 }
223
224 }
225 return ammoWeight + baseWeight + GetConfigWeightModified();
226 }
DayZGame g_Game
Definition DayZGame.c:3815
ammo pile base
Definition AmmunitionPiles.c:3
static float GetAmmoWeightByBulletType(string bulletType)
Definition AmmunitionPiles.c:6
Definition Debug.c:805

Перекрестные ссылки g_Game и Ammunition_Base::GetAmmoWeightByBulletType().

◆ HasActionAbility()

HasActionAbility ( int action,
int actionType )
inlineprotected

query if weapon supports action and actionType

Аргументы
[in]actionone of Human.actions (i.e. RELOAD, MECHANISM, ...)
[in]actionTypeone of Human.actionTypes (i.e. CHAMBERING_ONEBULLET_CLOSED, MECHANISM_CLOSED...)
Возвращает
true if weapon supports operation
241 {
242 int count = GetAbilityCount();
243 for (int i = 0; i < count; ++i)
244 {
246 if (rec.m_action == action && rec.m_actionType == actionType)
247 return true;
248 }
249 return false;
250 }
pair ( action, actionType )
Definition Weapon_Base.c:5
int GetAbilityCount()
Definition Weapon_Base.c:254
AbilityRecord GetAbility(int index)
Definition Weapon_Base.c:259

◆ HasBayonetAttached()

override bool HasBayonetAttached ( )
inlineprotected
1752 {
1753 return m_BayonetAttached;
1754 }
bool m_BayonetAttached
Definition Weapon_Base.c:52

◆ HasButtstockAttached()

override bool HasButtstockAttached ( )
inlineprotected
1768 {
1769 return m_ButtstockAttached;
1770 }
bool m_ButtstockAttached
Definition Weapon_Base.c:53

◆ HideBullet()

void HideBullet ( int muzzleIndex)
inlineprotected
392 {
393 if ( m_bulletSelectionIndex.Count() > muzzleIndex )
394 {
395 SetSimpleHiddenSelectionState(m_bulletSelectionIndex[muzzleIndex],0);
396 }
397 else
398 SelectionBulletHide();
399 }
ref array< int > m_bulletSelectionIndex
Definition Weapon_Base.c:68

◆ HideMagazine()

void HideMagazine ( )
inlineprotected
1798 {
1800 SetSimpleHiddenSelectionState(m_magazineSimpleSelectionIndex,0);
1801 else
1802 SelectionMagazineHide();
1803 }
int m_magazineSimpleSelectionIndex
animation state the weapon is in, -1 == uninitialized
Definition Weapon_Base.c:60

◆ HideWeaponBarrel()

void HideWeaponBarrel ( bool state)
inlineprotected
1778 {
1779 if ( !GetGame().IsDedicatedServer() )//hidden for client only
1780 {
1781 ItemOptics optics = GetAttachedOptics();
1782 if ( optics && !optics.AllowsDOF() && m_weaponHideBarrelIdx != -1 )
1783 {
1784 SetSimpleHiddenSelectionState(m_weaponHideBarrelIdx,!state);
1785 }
1786 }
1787 }
int m_weaponHideBarrelIdx
Definition Weapon_Base.c:61

Перекрестные ссылки GetGame().

◆ InitDOFProperties()

bool InitDOFProperties ( out array< float > temp_array)
inlineprotected

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

1222 {
1223 if (GetGame().ConfigIsExisting("cfgWeapons " + GetType() + " PPDOFProperties"))
1224 {
1225 GetGame().ConfigGetFloatArray("cfgWeapons " + GetType() + " PPDOFProperties", temp_array);
1226 return true;
1227 }
1228 return false;
1229 }
eBleedingSourceType GetType()
Definition BleedingSource.c:63

Перекрестные ссылки GetGame() и GetType().

◆ InitReliability()

bool InitReliability ( out array< float > reliability_array)
inlineprotected
1232 {
1233 if (GetGame().ConfigIsExisting("cfgWeapons " + GetType() + " Reliability ChanceToJam"))
1234 {
1235 GetGame().ConfigGetFloatArray("cfgWeapons " + GetType() + " Reliability ChanceToJam", reliability_array);
1236 return true;
1237 }
1238 return false;
1239 }

Перекрестные ссылки GetGame() и GetType().

◆ InitShoulderDistance()

bool InitShoulderDistance ( )
inlineprotected

gets approximate weapon distance from shoulder from config

1267 {
1268 if (ConfigIsExisting("ShoulderDistance"))
1269 {
1270 m_ShoulderDistance = ConfigGetFloat("ShoulderDistance");
1271 return true;
1272 }
1273
1275 return false;
1276 }
float m_ShoulderDistance
Definition Weapon_Base.c:65

◆ InitStateMachine()

void InitStateMachine ( )
inlineprotected
127{ }

◆ InitWeaponLength()

bool InitWeaponLength ( )
inlineprotected

gets weapon length from config for weaponlift raycast

1243 {
1244 if (ConfigIsExisting("WeaponLength"))
1245 {
1246 m_WeaponLength = ConfigGetFloat("WeaponLength");
1247 return true;
1248 }
1249 m_WeaponLength = 0.8; //default value if not set in config; should not be zero
1250 return false;
1251 }
float m_WeaponLength
Definition Weapon_Base.c:63

◆ InitWeaponLiftCheckVerticalOffset()

bool InitWeaponLiftCheckVerticalOffset ( )
inlineprotected

gets weapon vertical offset from config for weaponlift raycast

1255 {
1256 if (ConfigIsExisting("WeaponLiftCheckVerticalOffset"))
1257 {
1258 m_WeaponLiftCheckVerticalOffset = ConfigGetFloat("WeaponLiftCheckVerticalOffset");
1259 return true;
1260 }
1261 m_WeaponLiftCheckVerticalOffset = 0.0; //no offset by default
1262 return false;
1263 }
float m_WeaponLiftCheckVerticalOffset
Definition Weapon_Base.c:64

◆ IsCharged()

bool IsCharged ( )
inlineprotected
148 {
149 return m_Charged;
150 }
bool m_Charged
Definition Weapon_Base.c:54

◆ IsIdle()

bool IsIdle ( )
inlineprotected
281 {
283 }
bool CanProcessWeaponEvents()
Definition Weapon_Base.c:264
bool IsIdle()
idle state does not expect any animation events
Definition WeaponStateBase.c:158

◆ IsJammed()

bool IsJammed ( )
inlineprotected
401{ return m_isJammed; }
bool m_isJammed
weapon state machine
Definition Weapon_Base.c:50

◆ IsRemoteWeapon()

bool IsRemoteWeapon ( )
inlineprotected
1161 {
1163 if (GetInventory().GetCurrentInventoryLocation(il))
1164 {
1165 EntityAI parent = il.GetParent();
1166 DayZPlayer dayzp = DayZPlayer.Cast(parent);
1167 if (il.GetType() == InventoryLocationType.HANDS && dayzp)
1168 {
1169 bool remote = dayzp.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_REMOTE;
1170 return remote;
1171 }
1172 }
1173 return true;
1174 }
Definition DayZPlayerImplement.c:111
Definition Building.c:6
DayZPlayerInstanceType
defined in C++
Definition dayzplayer.c:1068

◆ IsShowingChamberedBullet()

bool IsShowingChamberedBullet ( )
inlineprotected
1838 {
1839 return true;
1840 }

◆ IsWaitingForActionFinish()

IsWaitingForActionFinish ( )
inlineprotected

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

276 {
278 }
override bool IsWaitingForActionFinish()
waiting for active animation action/actionType finish
Definition WeaponChambering.c:370

◆ IsWeaponOpen()

bool IsWeaponOpen ( )
inlineprotected
158 {
159 return m_WeaponOpen;
160 }
bool m_WeaponOpen
Definition Weapon_Base.c:55

◆ JamCheck()

bool JamCheck ( int muzzleIndex)
inlineprotected
369 {
370 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
371 if ( player )
372 {
373 float rnd = player.GetRandomGeneratorSyncManager().GetRandom01(RandomGeneratorSyncUsage.RGSJam);
374 //Print("Random Jam - " + rnd);
375 if (rnd < GetSyncChanceToJam())
376 return true;
377 }
378 return false;
379 }
RandomGeneratorSyncUsage
Definition RandomGeneratorSyncManager.c:2
float GetSyncChanceToJam()
Definition Weapon_Base.c:404

◆ LiftWeaponCheck()

bool LiftWeaponCheck ( PlayerBase player)
inlineprotected
1285 {
1286 int idx;
1287 float distance;
1288 float hit_fraction;
1289 vector start, end;
1292 Object obj;
1293
1294 bool wasLift = m_LiftWeapon;
1296
1297 m_LiftWeapon = false;
1298 // not a gun, no weap.raise for now
1299 if ( HasSelection("Usti hlavne") )
1300 return false;
1301
1302 if (!player)
1303 {
1304 Print("Error: No weapon owner, returning");
1305 return false;
1306 }
1307
1308 // weapon not raised
1310 player.GetMovementState(movementState);
1311 if (!movementState.IsRaised())
1312 return false;
1313
1314 // suppress raising of weapon during melee attack preventing state inconsistency
1315 if (movementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_MELEE || movementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_MELEE2)
1316 {
1317 return false;
1318 }
1319
1320
1321 // If possible use aiming angles instead as these will work consistently
1322 // and independently of any cameras, etc.
1323 HumanCommandWeapons hcw = player.GetCommandModifier_Weapons();
1324 if (hcw)
1325 {
1327 hcw.GetBaseAimingAngleLR() + player.GetOrientation()[0],
1328 hcw.GetBaseAimingAngleUD(),
1329 0.0);
1330
1331 float xAimHandsOffset = hcw.GetAimingHandsOffsetLR();
1332 float yAimHandsOffset = hcw.GetAimingHandsOffsetUD();
1333
1336
1337 direction = yawPitchRoll.AnglesToVector();
1338 }
1339 else // Fallback to previously implemented logic
1340 {
1341 // freelook raycast
1342 if (player.GetInputController().CameraIsFreeLook())
1343 {
1344 if (player.m_DirectionToCursor != vector.Zero)
1345 {
1346 direction = player.m_DirectionToCursor;
1347 }
1348 // if player raises weapon in freelook
1349 else
1350 {
1351 direction = MiscGameplayFunctions.GetHeadingVector(player);
1352 }
1353 }
1354 else
1355 {
1356 direction = GetGame().GetCurrentCameraDirection(); // exception for freelook. Much better this way!
1357 }
1358 }
1359
1360 idx = player.GetBoneIndexByName("Neck"); //RightHandIndex1
1361 if ( idx == -1 )
1362 { start = player.GetPosition()[1] + 1.5; }
1363 else
1364 { start = player.GetBonePositionWS(idx); }
1365
1366
1367 // Updated weapon lift detection code prototype
1368 {
1369 // 0: construct stable trasformation matrix that
1370 // approximately aligns with the weapon transform
1371 // without actually using the weapon as reference
1372 // (as the weapon can be moved unpredictably by anims)
1373 vector resTM[4];
1374 resTM[0] = Vector(direction[0], 0, direction[2]).Normalized();
1376 resTM[2] = direction;
1377 resTM[1] = resTM[2] * resTM[0];
1378 resTM[3] = start;
1379
1380 // Approximate the roll of leaning
1382 player.GetMovementState(hms);
1383 float leanAngle = hms.m_fLeaning * 35;
1384 vector rotTM[3];
1387
1388 // Draw relative TM diagnostic
1389 #ifdef DIAG_DEVELOPER
1390 if (DiagMenu.GetValue(DiagMenuIDs.WEAPON_LIFT_DEBUG))
1391 {
1392 Shape.CreateArrow(resTM[3], resTM[3] + resTM[0], 0.05, COLOR_RED, ShapeFlags.ONCE);
1393 Shape.CreateArrow(resTM[3], resTM[3] + resTM[1], 0.05, COLOR_GREEN, ShapeFlags.ONCE);
1394 Shape.CreateArrow(resTM[3], resTM[3] + resTM[2], 0.05, COLOR_BLUE, ShapeFlags.ONCE);
1395 }
1396 #endif
1397
1398 // 1: pick from predefined offset relative to
1399 // the previously constructed transform
1400 float udAngle = Math.Asin(direction[1]) * Math.RAD2DEG;
1401
1402 // offsets are [right, up, forward]
1403 // values are based on what felt right after iterating
1404 vector offsets[] =
1405 {
1406 "0.11 0.17 0.0", // offset while aiming down
1407 "0.12 0.05 0.0", // offset while aiming forward
1408 "0.112 0.03 0.0" // offset while aiming up
1409 };
1410 const int lastIndex = 2; // length of offsets - 1
1411
1412 // <0,1> range of aiming
1413 float a = Math.Clamp(Math.InverseLerp(DayZPlayerCamera1stPerson.CONST_UD_MIN, DayZPlayerCamera1stPerson.CONST_UD_MAX, udAngle), 0, 0.9999);
1414 int lo = a * lastIndex;
1415 int hi = Math.Clamp(lo+1, 0, lastIndex);
1416
1417 // remap to current lo-hi range
1418 float t = Math.Clamp(a * lastIndex - lo, 0, 1);
1420
1421 // offsets are [right, up forward]
1422 // additional offsets added to previous offsets per stance
1424 {
1425 "0 -0.015 0", // erect
1426 "0 0.03 0", // crouch
1427 "0 -0.04 0",// prone
1428 };
1429
1430 // 2. pick from predefined offsets based on stance,
1431 // allows to even further approximate the alignment
1432 int stanceOffsetIndex = hms.m_iStanceIdx;
1433 if (stanceOffsetIndex >= DayZPlayerConstants.STANCEIDX_PRONE)
1434 stanceOffsetIndex -= DayZPlayerConstants.STANCEIDX_RAISED;
1435
1436 stanceOffsetIndex -= DayZPlayerConstants.STANCEIDX_ERECT;
1438
1439 // if any additional height offset is defined, apply it
1441 {
1443 }
1444
1445 //
1446 offset = offset.InvMultiply3(rotTM);
1447
1448 // 3. use the offset as the start position.
1449 // it will not be perfect, but it should reflect
1450 // the actual weapon transform more accurately
1451 start = offset.Multiply4(resTM);
1452 }
1453
1454
1456
1459
1460 // Draw diagnostics: Script -> Weapon -> Weapon Lift
1461 #ifdef DIAG_DEVELOPER
1462 if (DiagMenu.GetValue(DiagMenuIDs.WEAPON_LIFT_DEBUG))
1463 {
1465 int diagPtsShpFlgs = ShapeFlags.ONCE | ShapeFlags.NOOUTLINE;
1466 float diagPtsRadius = 0.025;
1470 }
1471 #endif
1472
1473 // For the physical cast, extend the distance by x%
1474 // to allow for smoother transition handling in some cases
1475 end = weaponEnd + ((0.1 * distance) * direction);
1476
1477 // Prepare raycast params and perform the cast in fire geo
1479 rayParm.flags = CollisionFlags.ALLOBJECTS;
1480 rayParm.type = ObjIntersect.Fire;
1481
1482 #ifdef DIAG_DEVELOPER
1484 #endif
1486 if (!DayZPhysics.RaycastRVProxy(rayParm, results) || results.Count() == 0)
1487 {
1489 hit_fraction = 0;
1490 }
1491 else
1492 {
1494
1495 #ifdef DIAG_DEVELOPER // isect diag
1496 if (DiagMenu.GetValue(DiagMenuIDs.WEAPON_LIFT_DEBUG) == 2)
1497 {
1498 DbgUI.Begin("Weapon Lift Diag");
1499 {
1500 if (res.surface)
1501 {
1502 DbgUI.Text("Intersection data:");
1503 DbgUI.Text(" Name: " + res.surface.GetName());
1504 DbgUI.Text(" EntryName: " + res.surface.GetEntryName());
1505 DbgUI.Text(" SurfaceType: " + res.surface.GetSurfaceType());
1506
1507 DbgUI.Text(" IsPassThrough: " + res.surface.IsPassthrough());
1508 DbgUI.Text(" IsSolid: " + res.surface.IsSolid());
1509 }
1510 else
1511 {
1512 DbgUI.Text("Intersection with no surface");
1513 }
1514 }
1515 DbgUI.End();
1516 }
1517 #endif // !isect diag
1518
1520 {
1521 hit_pos = res.pos;
1522 float len0 = (hit_pos - start).Length();
1523 float len1 = (end - start).Length();
1524 if (len0 <= 0 || len1 <= 0)
1525 {
1526 hit_fraction = 1;
1527 }
1528 else
1529 {
1531 }
1532 }
1533 else
1534 {
1536 hit_fraction = 0;
1537 }
1538 }
1539 #ifdef DIAG_DEVELOPER
1541 #endif
1542
1543 // Draw diagnostics: Script -> Weapon -> Weapon Lift
1544 #ifdef DIAG_DEVELOPER
1545 if (DiagMenu.GetValue(DiagMenuIDs.WEAPON_LIFT_DEBUG))
1546 {
1547 const vector epsilon = "0 0.0002 0"; // to overcome excessive z-fighting for diag
1549 {
1551 }
1552
1553 Shape.CreateArrow(start, weaponEnd, 0.05, COLOR_WHITE, ShapeFlags.ONCE | ShapeFlags.NOZBUFFER );
1554
1555 if (hit_fraction != 0)
1556 {
1557 Shape.CreateArrow(start+epsilon, hit_pos+epsilon, 0.05, COLOR_RED, ShapeFlags.ONCE);
1558 }
1559 }
1560 #endif
1561
1562 // Start by assuming that we want to retain state
1563 bool wantsLift = wasLift;
1564
1565 // Sq. distance of weapon movement required to trigger lift (in)
1566 const float inThreshold = 0.002;
1567 // Sq. distance of weapon movement required to trigger lift (out)
1568 const float outThreshold = 0.003;
1569 const float noIsctOutThreshold = 0.01;
1570 // Max num of ticks with no hit for which hysteresis will persist
1571 // value chosen by iteration, should be approx 0.333s
1572 const int maxNumMissedTicks = 10;
1573
1574 // Min angle in degrees change from last lift to stop lifting
1575 // Base threshold of 0.75 degrees + 0.6 degrees per meter of weapon length
1576 float angleThreshold = 0.75 + Math.Clamp( m_WeaponLength * 0.6, 0, 1.5 );
1577
1578 // Update state when a hit is registered
1579 if (hit_fraction != 0)
1580 {
1582 vector v2 = hit_pos - end;
1583 float d = vector.Dot(v1, v2);
1584 // But leave some threshold where previous state is kept
1585 // to prevent excessive switches from occuring
1586 if (!wasLift && d > inThreshold)
1587 {
1588 wantsLift = true;
1589 }
1590 else if (wasLift && d < -outThreshold)
1591 {
1592 wantsLift = false;
1593 }
1594
1596 m_LastLiftHit = player.GetSimulationTimeStamp();
1597 }
1598 else
1599 {
1600 // With no hit and no previous lift
1602 {
1603 wantsLift = false;
1605 }
1606 // See if previous hit wasn't very close to our current position,
1607 // in which case simply don't lift the weapon
1608 else
1609 {
1610 vector v3 = (lastLiftPosition - start).Normalized();
1611 vector v4 = (end-start).Normalized();
1612 float d2 = vector.Dot(v3, v4);
1613 // no isect, angle delta check
1614 if (Math.Acos(d2) > (angleThreshold * Math.DEG2RAD)) // if relative angle is > x degree, stop lifting
1615 {
1616 wantsLift = false;
1618 }
1619 // no isect, distance check
1620 else
1621 {
1622 float d3 = vector.Dot( lastLiftPosition - weaponEnd, (start-end).Normalized() );
1623 if (d3 < -noIsctOutThreshold)
1624 {
1625 wantsLift = false;
1627 }
1628
1629 // fallback in case offending object disappears or moves
1630 int timeSinceHit = player.GetSimulationTimeStamp() - m_LastLiftHit;
1632 {
1633 wantsLift = false;
1635 }
1636 }
1637 }
1638 }
1639
1640 // lift is desired
1641 if (wantsLift)
1642 {
1643 //Print(distance);
1644 m_LiftWeapon = true;
1645 return true;
1646 }
1647 return false;
1648 }
DiagMenuIDs
Definition EDiagMenuIDs.c:2
Definition DayZPhysics.c:124
static proto bool RaycastRVProxy(notnull RaycastRVParams in, out notnull array< ref RaycastRVResult > results, array< Object > excluded=null)
Definition DayZPlayerCameraVehicles.c:5
Definition DbgUI.c:60
Definition EnDebug.c:233
Definition human.c:994
Definition human.c:1139
Definition EnMath3D.c:28
Definition DayZPhysics.c:50
Definition DayZPhysics.c:99
bool LiftWeaponRaycastResultCheck(notnull RaycastRVResult res)
Return whether provided material triggers weapon lift (true) or not (false).
Definition Weapon_Base.c:1651
float GetEffectiveAttachmentLength()
Returns effective length of attachments that influence total weapon length.
Definition Weapon_Base.c:1657
int m_LastLiftHit
Definition Weapon_Base.c:67
vector m_LastLiftPosition
Definition Weapon_Base.c:66
static const vector Up
Definition EnConvert.c:107
static proto native vector Lerp(vector v1, vector v2, float t)
Lerp between two vectors.
static float Dot(vector v1, vector v2)
Returns Dot product of vector v1 and vector v2.
Definition EnConvert.c:271
static vector RotateAroundZeroDeg(vector vec, vector axis, float angle)
Rotate a vector around 0,0,0 by an angle in degrees.
Definition EnConvert.c:450
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
const int COLOR_BLUE
Definition constants.c:66
const int COLOR_RED
Definition constants.c:64
const int COLOR_GREEN
Definition constants.c:65
const int COLOR_WHITE
Definition constants.c:63
const int COLOR_YELLOW
Definition constants.c:67
proto void Print(void var)
Prints content of variable to console/log.
CollisionFlags
Definition EnDebug.c:141
ShapeFlags
Definition EnDebug.c:126
static proto native void Begin(string windowTitle, float x=0, float y=0)
static proto void BeginCleanupScope()
static proto native void Text(string label)
static proto native void EndCleanupScope()
static proto native void End()
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
static proto int GetValue(int id)
Get value as int from the given script id.
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto void MatrixMultiply3(vector mat0[3], vector mat1[3], out vector res[3])
Transforms rotation matrix.
static proto void YawPitchRollMatrix(vector ang, out vector mat[3])
Creates rotation matrix from angles.
static proto float Acos(float c)
Returns angle in radians from cosinus.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static proto float Asin(float s)
Returns angle in radians from sinus.
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...
static const float RAD2DEG
Definition EnMath.c:16
static const float DEG2RAD
Definition EnMath.c:17

Перекрестные ссылки Math::Acos(), Math::Asin(), DbgUI::Begin(), DbgUI::BeginCleanupScope(), Math::Clamp(), COLOR_BLUE, COLOR_GREEN, COLOR_RED, COLOR_WHITE, COLOR_YELLOW, Math::DEG2RAD, vector::Dot(), DbgUI::End(), DbgUI::EndCleanupScope(), GetGame(), DiagMenu::GetValue(), Math::InverseLerp(), vector::Lerp(), Math3D::MatrixMultiply3(), Print(), Math::RAD2DEG, DayZPhysics::RaycastRVProxy(), vector::RotateAroundZeroDeg(), Shape, DbgUI::Text(), vector::Up, Vector(), Math3D::YawPitchRollMatrix() и vector::Zero.

◆ LiftWeaponRaycastResultCheck()

bool LiftWeaponRaycastResultCheck ( notnull RaycastRVResult res)
inlineprotected

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

1652 {
1653 return res.surface.IsSolid();
1654 }

◆ LoadCurrentFSMState()

bool LoadCurrentFSMState ( ParamsReadContext ctx,
int version )
inlineprotected
574 {
575 if (m_fsm)
576 {
577 if (m_fsm.LoadCurrentFSMState(ctx, version))
578 {
580 if (state)
581 {
582 SyncSelectionState(state.HasBullet(), state.HasMagazine());
583 state.SyncAnimState();
584 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(this) + " Weapon=" + this + " stable state loaded and synced."); }
585 return true;
586 }
587 else
588 {
589 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(this) + " Weapon=" + this + " unstable/error state loaded."); }
590 return false;
591 }
592 }
593 else
594 {
595 Error("[wpnfsm] " + Object.GetDebugName(this) + " Weapon=" + this + " did not load.");
596 return false;
597 }
598 }
599 else
600 {
601 Error("[wpnfsm] " + Object.GetDebugName(this) + " Weapon.LoadCurrentFSMState: trying to load weapon without FSM (or uninitialized weapon) this=" + this + " type=" + GetType());
602 return false;
603 }
604 }
represents weapon's stable state (i.e. the basic states that the weapon will spend the most time in)
Definition Crossbow.c:27

Перекрестные ссылки Error(), GetType(), LogManager::IsWeaponLogEnable() и wpnDebugPrint().

◆ OnDebugSpawn()

override void OnDebugSpawn ( )
inlineprotected
1876 {
1878 }
const int SAMF_DEFAULT
Full highest capacity magazine + chambered round.
Definition Weapon_Base.c:41
bool SpawnAmmo(string magazineType="", int flags=WeaponWithAmmoFlags.CHAMBER)
General method trying to attch magazine, fill inner magazine and fill chamber.
Definition Weapon_Base.c:742

◆ OnFire()

void OnFire ( int muzzle_index)
inlineprotected
1000 {
1001/*
1002 array<Man> players();
1003 GetGame().GetPlayers(players);
1004
1005 Man root = GetHierarchyRootPlayer();
1006
1007 if (!root)
1008 {
1009 return;
1010 }
1011
1012 vector safePosition = root.GetPosition() + (root.GetDirection() * "0 1 0" * 3.0);
1013
1014 Man other = null;
1015 foreach (auto player : players)
1016 {
1017 if (player != GetHierarchyRootPlayer())
1018 {
1019 player.SetPosition(safePosition);
1020 }
1021 }
1022*/
1023
1024 m_BurstCount++;
1025 }

◆ OnFireModeChange()

void OnFireModeChange ( int fireMode)
inlineprotected
1028 {
1029 if ( !GetGame().IsDedicatedServer() )
1030 {
1032
1033 if ( fireMode == 0 )
1034 eff = SEffectManager.PlaySound("Fire_Mode_Switch_Marked_Click_SoundSet", GetPosition());
1035 else
1036 eff = SEffectManager.PlaySound("Fire_Mode_Switch_Simple_Click_SoundSet", GetPosition());
1037
1038 eff.SetAutodestroy(true);
1039 }
1040
1042 }
class JsonUndergroundAreaTriggerData GetPosition
Definition UndergroundAreaLoader.c:9
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
Manager class for managing Effect (EffectParticle, EffectSound)
Definition EffectManager.c:6
static EffectSound PlaySound(string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
Create and play an EffectSound.
Definition EffectManager.c:169
void ResetBurstCount()
Definition Weapon_Base.c:1847

Перекрестные ссылки GetGame(), GetPosition и SEffectManager::PlaySound().

◆ OnInventoryEnter()

override void OnInventoryEnter ( Man player)
inlineprotected
1064 {
1066
1068
1069 super.OnInventoryEnter(player);
1070 }

◆ OnInventoryExit()

override void OnInventoryExit ( Man player)
inlineprotected
1073 {
1075 super.OnInventoryExit(player);
1076 }

◆ OnItemLocationChanged()

override void OnItemLocationChanged ( EntityAI old_owner,
EntityAI new_owner )
inlineprotected
1111 {
1112 super.OnItemLocationChanged(old_owner,new_owner);
1113
1114 // "resets" optics memory on optics
1116 if (PlayerBase.CastTo(player,old_owner))
1117 {
1118 player.SetReturnToOptics(false);
1119
1120 //optics item state reset
1122 if (Class.CastTo(optics,GetAttachedOptics()))
1123 {
1124 player.SwitchOptics(optics,false);
1125 }
1126 }
1127
1128 HideWeaponBarrel(false);
1129 }
Super root of all classes in Enforce script.
Definition EnScript.c:11
void HideWeaponBarrel(bool state)
Definition Weapon_Base.c:1777
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

Перекрестные ссылки Class::CastTo().

◆ OnStoreLoad()

override bool OnStoreLoad ( ParamsReadContext ctx,
int version )
inlineprotected
484 {
485 if ( !super.OnStoreLoad(ctx, version) )
486 return false;
487
488
489 if (version >= 113)
490 {
491 int current_muzzle = 0;
492 if (!ctx.Read(current_muzzle))
493 {
494 Error("Weapon.OnStoreLoad " + this + " cannot read current muzzle!");
495 return false;
496 }
497
498 if (current_muzzle >= GetMuzzleCount() || current_muzzle < 0)
499 Error("Weapon.OnStoreLoad " + this + " trying to set muzzle index " + current_muzzle + " while it only has " + GetMuzzleCount() + " muzzles!");
500 else
501 SetCurrentMuzzle(current_muzzle);
502 }
503
504 if (version >= 105)
505 {
506 int mode_count = 0;
507 if (!ctx.Read(mode_count))
508 {
509 Error("Weapon.OnStoreLoad " + this + " cannot read mode count!");
510 return false;
511 }
512
513 for (int m = 0; m < mode_count; ++m)
514 {
515 int mode = 0;
516 if (!ctx.Read(mode))
517 {
518 Error("Weapon.OnStoreLoad " + this + " cannot read mode[" + m + "]");
519 return false;
520 }
521
522 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(this) + " OnStoreLoad - loaded muzzle[" + m + "].mode = " + mode); }
523 SetCurrentMode(m, mode);
524 }
525 }
526
527 if ( version >= 106 )
528 {
529 if ( !ctx.Read(m_isJammed) )
530 {
531 Error("Weapon.OnStoreLoad cannot load jamming state");
532 return false;
533 }
534 }
535
536 if (m_fsm)
537 {
538 if (!m_fsm.OnStoreLoad(ctx, version))
539 return false;
540
541 WeaponStableState wss = WeaponStableState.Cast(m_fsm.GetCurrentState());
542 if (wss)
543 {
544 SetGroundAnimFrameIndex(wss.m_animState);
545 }
546
547 }
548 else
549 {
550 int dummy = 0;
551 if (!ctx.Read(dummy))
552 return false;
553 }
554
555 return true;
556 }

Перекрестные ссылки Error(), LogManager::IsWeaponLogEnable() и wpnDebugPrint().

◆ OnStoreSave()

override void OnStoreSave ( ParamsWriteContext ctx)
inlineprotected
619 {
620 super.OnStoreSave(ctx);
621
622 // current muzzle added in version 113
623 int current_muzzle = GetCurrentMuzzle();
624 ctx.Write(current_muzzle);
625
626 // fire mode added in version 105
627 int mode_count = GetMuzzleCount();
628 ctx.Write(mode_count);
629 for (int m = 0; m < mode_count; ++m)
630 ctx.Write(GetCurrentMode(m));
631
632 ctx.Write(m_isJammed);
633
634 if (m_fsm)
635 m_fsm.OnStoreSave(ctx);
636 else
637 {
638 int dummy = 0;
639 ctx.Write(dummy);
640 }
641 }

◆ ProcessMeleeItemDamage()

override EntityAI ProcessMeleeItemDamage ( int mode = 0)
inlineprotected
1806 {
1808
1809 switch (mode)
1810 {
1811 case 0:
1812 super.ProcessMeleeItemDamage();
1813 break;
1814
1815 case 1:
1816 attachment = GetInventory().FindAttachment(m_ButtstockAttachmentIdx);
1817 break;
1818
1819 case 2:
1820 attachment = GetInventory().FindAttachment(m_BayonetAttachmentIdx);
1821 break;
1822
1823 default:
1824 super.ProcessMeleeItemDamage();
1825 break;
1826 }
1827
1828 if (attachment)
1829 {
1830 attachment.ProcessMeleeItemDamage();
1831 return attachment;
1832 }
1833
1834 return this;
1835 }

◆ ProcessWeaponAbortEvent()

ProcessWeaponAbortEvent ( WeaponEventBase e)
inlineprotected

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

310 {
312
314 m_fsm.ProcessAbortEvent(e, aa);
315 return aa == ProcessEventResult.FSM_OK;
316 }
ProcessEventResult
Definition FSMBase.c:41
void SyncEventToRemote(WeaponEventBase e)
Definition Weapon_Base.c:1176

◆ ProcessWeaponEvent()

ProcessWeaponEvent ( WeaponEventBase e)
inlineprotected

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

290 {
292
293 // @NOTE: synchronous events not handled by fsm
294 if (e.GetEventID() == WeaponEventID.SET_NEXT_MUZZLE_MODE)
295 {
296 SetNextMuzzleMode(GetCurrentMuzzle());
297 return true;
298 }
299
300 if (m_fsm.ProcessEvent(e) == ProcessEventResult.FSM_OK)
301 return true;
302
303 //if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("FSM refused to process event (no transition): src=" + GetCurrentState().ToString() + " event=" + e.ToString()); }
304 return false;
305 }
WeaponEventID
identifier for events. mainly for rpc purposes
Definition Events.c:6

◆ RandomizeFSMState()

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.

670 {
671 if (m_fsm)
672 {
673 int mi = GetCurrentMuzzle();
674 Magazine mag = GetMagazine(mi);
675 bool has_mag = mag != null;
676 bool has_bullet = !IsChamberEmpty(mi);
677 bool has_jam = IsJammed();
679 m_fsm.RandomizeFSMStateEx(muzzleStates, has_mag, has_jam);
681 }
682 }
array< MuzzleState > GetMuzzleStates()
Helper method for RandomizeFSMState.
Definition Weapon_Base.c:685
void ForceSyncSelectionState()
Definition Weapon_Base.c:456

Перекрестные ссылки IsJammed().

◆ ResetBurstCount()

void ResetBurstCount ( )
inlineprotected
1848 {
1849 m_BurstCount = 0;
1850 }

◆ ResetWeaponAnimState()

void ResetWeaponAnimState ( )
inlineprotected
329 {
330 if (LogManager.IsWeaponLogEnable()) fsmDebugSpam("[wpnfsm] " + Object.GetDebugName(this) + " resetting anim state: " + typename.EnumToString(PistolAnimState, m_weaponAnimState) + " --> " + typename.EnumToString(PistolAnimState, -1));
332 }
void fsmDebugSpam(string s)
Definition HFSMBase.c:9
PistolAnimState
Definition Pistol_Base.c:3

Перекрестные ссылки fsmDebugSpam() и LogManager::IsWeaponLogEnable().

◆ SaveCurrentFSMState()

void SaveCurrentFSMState ( ParamsWriteContext ctx)
inlineprotected
559 {
560 if (m_fsm && m_fsm.IsRunning())
561 {
562 if (m_fsm.SaveCurrentFSMState(ctx))
563 {
564 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(this) + " Weapon=" + this + " state saved."); }
565 }
566 else
567 Error("[wpnfsm] " + Object.GetDebugName(this) + " Weapon=" + this + " state NOT saved.");
568 }
569 else
570 Error("[wpnfsm] " + Object.GetDebugName(this) + " Weapon.SaveCurrentFSMState: trying to save weapon without FSM (or uninitialized weapon) this=" + this + " type=" + GetType());
571 }

Перекрестные ссылки Error(), GetType(), LogManager::IsWeaponLogEnable() и wpnDebugPrint().

◆ SetActions()

override void SetActions ( )
inlineprotected
1853 {
1854 super.SetActions();
1861
1864 }
void AddAction(typename actionName)
Definition AdvancedCommunication.c:220
FirearmActionLoadBullet FirearmActionBase FirearmActionLoadBulletQuick()
Definition ActionTurnOffWeaponFlashlight.c:2
Definition ActionTurnOnWeaponFlashlight.c:2
Definition FirearmActionAttachMagazine.c:12
Definition FirearmActionAttachMagazine.c:226
Definition FirearmActionLoadBullet.c:2
Definition FirearmActionMechanicManipulate.c:2
Definition FirearmActionUnjam.c:2

Перекрестные ссылки AddAction() и FirearmActionLoadBulletQuick().

◆ SetBayonetAttached()

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

attachment helpers (firearm melee)

◆ SetButtstockAttached()

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

◆ SetCharged()

void SetCharged ( bool value)
inlineprotected
153 {
155 }

◆ SetInitialState()

void SetInitialState ( WeaponStableState initState)
inlineprotected
140 {
141 m_fsm.SetInitialState(initState);
142 SetCharged(!initState.IsDischarged());
143 SetWeaponOpen(!initState.IsWeaponOpen());
144 SetGroundAnimFrameIndex(initState.m_animState);
145 }
void SetCharged(bool value)
Definition Weapon_Base.c:152
void SetWeaponOpen(bool value)
Definition Weapon_Base.c:162

◆ SetJammed()

void SetJammed ( bool value)
inlineprotected
403{ m_isJammed = value; }

◆ SetSyncJammingChance()

void SetSyncJammingChance ( float jamming_chance)
inlineprotected
1681 {
1683 }

◆ SetWeaponAnimState()

void SetWeaponAnimState ( int state)
inlineprotected
324 {
326 SetGroundAnimFrameIndex(state);
327 }

◆ SetWeaponOpen()

void SetWeaponOpen ( bool value)
inlineprotected
163 {
165 }

◆ ShowBullet()

void ShowBullet ( int muzzleIndex)
inlineprotected
382 {
383 if ( m_bulletSelectionIndex.Count() > muzzleIndex )
384 {
385 SetSimpleHiddenSelectionState(m_bulletSelectionIndex[muzzleIndex],1);
386 }
387 else
388 SelectionBulletShow();
389 }

◆ ShowMagazine()

void ShowMagazine ( )
inlineprotected
1790 {
1792 SetSimpleHiddenSelectionState(m_magazineSimpleSelectionIndex,1);
1793 else
1794 SelectionMagazineShow();
1795 }

◆ SpawnAmmo()

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

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

Аргументы
[in]magazineTypestring The magazine to attach or ammo to load, passing in empty string will select random
[in]flagsint Setup flags, please read WeaponWithAmmoFlags
Возвращает
whether anything was spawned or done
743 {
744 // Attempt internal mag
745 if ( HasInternalMagazine(-1) && FillInnerMagazine(magazineType, flags) )
746 return true;
747
748 // Attempt mag attachment
749 if ( GetMagazineTypeCount(0) > 0 && SpawnAttachedMagazine(magazineType, flags) )
750 return true;
751
752 // Attempt chamber
753 if ( FillChamber(magazineType, flags) )
754 return true;
755
756 return false;
757 }
Magazine SpawnAttachedMagazine(string magazineType="", int flags=WeaponWithAmmoFlags.CHAMBER)
Try to spawn and attach a magazine.
Definition Weapon_Base.c:765
bool FillInnerMagazine(string ammoType="", int flags=WeaponWithAmmoFlags.CHAMBER)
Try to fill the inner magazine.
Definition Weapon_Base.c:823

◆ SpawnAttachedMagazine()

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

Try to spawn and attach a magazine.

Аргументы
[in]magazineTypestring The magazine to attach, passing in empty string will select random
[in]flagsint Setup flags, please read WeaponWithAmmoFlags
Возвращает
The created magazine or null
766 {
767 // Check if the gun has any magazines registered in config
768 if ( GetMagazineTypeCount(0) == 0 )
769 {
770 ErrorEx(string.Format("No 'magazines' config entry for %1.", this));
771 return null;
772 }
773
774 // Randomize when no specific one is given
775 if ( magazineType == "" )
776 {
777 if ( flags & WeaponWithAmmoFlags.MAX_CAPACITY_MAG)
778 magazineType = GetMaxMagazineTypeName(0);
779 else
780 magazineType = GetRandomMagazineTypeName(0);
781 }
782
783 EntityAI magAI = GetInventory().CreateAttachment(magazineType);
784 if (!magAI)
785 {
786 ErrorEx(string.Format("Failed to create and attach %1 to %2", GetDebugName(magAI), this));
787 return null;
788 }
789
791 if (!CastTo(mag, magAI))
792 {
793 ErrorEx(string.Format("Expected magazine, created: %1", GetDebugName(magAI)));
794 return null;
795 }
796
797 // Decide random quantity when enabled
798 if (flags & WeaponWithAmmoFlags.QUANTITY_RNG)
799 mag.ServerSetAmmoCount(Math.RandomIntInclusive(0, mag.GetAmmoMax()));
800
801 // Fill chamber when flagged
802 bool chamberRng = (flags & WeaponWithAmmoFlags.CHAMBER_RNG);
803 bool chamber = (flags & WeaponWithAmmoFlags.CHAMBER) || chamberRng;
804 if (chamber || chamberRng)
805 {
807 }
808
809 // FSM cares about magazine state
811 Synchronize();
812
813 return mag;
814 }
override string GetDebugName()
Definition dayzplayer.c:1170

Перекрестные ссылки ErrorEx, GetDebugName(), Math::RandomIntInclusive() и Synchronize().

◆ SpawnRecoilObject()

RecoilBase SpawnRecoilObject ( )
inlineprotected
1195 {
1196 return new DefaultRecoil(this);
1197 }
Definition DefaultRecoil.c:2

◆ SyncEventToRemote()

void SyncEventToRemote ( WeaponEventBase e)
inlineprotected
1177 {
1178 DayZPlayer p = DayZPlayer.Cast(GetHierarchyParent());
1179 if (p && p.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1180 {
1182
1184 e.WriteToContext(ctx);
1185
1187 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(this) + " send 2 remote: sending e=" + e + " id=" + e.GetEventID() + " p=" + e.m_player + " m=" + e.m_magazine);
1188
1189 p.StoreInputForRemotes(ctx);
1190 }
1191 }
const int INPUT_UDT_WEAPON_REMOTE_EVENT
Definition _constants.c:12
Definition gameplay.c:143

Перекрестные ссылки INPUT_UDT_WEAPON_REMOTE_EVENT, LogManager::IsWeaponLogEnable() и wpnDebugPrint().

◆ SyncSelectionState()

void SyncSelectionState ( bool has_bullet,
bool has_mag )
inlineprotected
416 {
417 if (has_bullet)
418 {
420 float chamberedAmmoDmg;
421
422 if ( GetCartridgeInfo(0, chamberedAmmoDmg, chamberedAmmoTypeName) )
423 {
424 EffectBulletShow(0, chamberedAmmoDmg, chamberedAmmoTypeName);
425 }
426 //ShowBullet(0);
427 SelectionBulletShow();
428 }
429 else
430 {
431 //HideBullet(0);
432 SelectionBulletHide();
433 EffectBulletHide(0);
434 }
435
436 if (has_mag)
437 ShowMagazine();
438 else
439 HideMagazine();
440 }

◆ ValidateAndRepair()

void ValidateAndRepair ( )
inlineprotected
1058 {
1059 if ( m_fsm )
1060 m_fsm.ValidateAndRepair();
1061 }

◆ Weapon_Base()

void Weapon_Base ( )
inlineprotected
76 {
77 //m_DmgPerShot = ConfigGetFloat("damagePerShot");
78 m_BayonetAttached = false;
79 m_ButtstockAttached = false;
82 m_BurstCount = 0;
84 if (GetGame().IsClient())
85 {
87 }
88
89 if ( ConfigIsExisting("simpleHiddenSelections") )
90 {
92 ConfigGetTextArray("simpleHiddenSelections",selectionNames);
93 m_weaponHideBarrelIdx = selectionNames.Find("hide_barrel");
95
96 int bulletIndex = selectionNames.Find("bullet");
97 if ( bulletIndex != -1 )
98 {
100
101 for (int i = 2; i < 100; i++)
102 {
103 bulletIndex = selectionNames.Find(string.Format("bullet%1",i));
104 if (bulletIndex != -1)
105 {
107 }
108 else
109 {
110 break;
111 }
112 }
113 }
114 }
115
120 if (GetGame().IsServer())
121 {
123 }
125 }
Definition DayZPlayerImplement.c:63
void InitStateMachine()
Definition Weapon_Base.c:127
bool InitDOFProperties(out array< float > temp_array)
Initializes DOF properties for weapon's ironsight/optics cameras.
Definition Weapon_Base.c:1221
bool InitWeaponLiftCheckVerticalOffset()
gets weapon vertical offset from config for weaponlift raycast
Definition Weapon_Base.c:1254
bool InitReliability(out array< float > reliability_array)
Definition Weapon_Base.c:1231
bool InitWeaponLength()
gets weapon length from config for weaponlift raycast
Definition Weapon_Base.c:1242
bool InitShoulderDistance()
gets approximate weapon distance from shoulder from config
Definition Weapon_Base.c:1266
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition IsBoxCollidingGeometryProxyClasses.c:28
array< string > TStringArray
Definition EnScript.c:685

Перекрестные ссылки GetGame() и Weapon_Base::InitStateMachine().

Поля

◆ DEFAULT_DAMAGE_ON_SHOT

const float DEFAULT_DAMAGE_ON_SHOT = 0.05
protected

◆ hit_mask

◆ m_abilities

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

◆ m_BayonetAttached

bool m_BayonetAttached
protected

◆ m_BayonetAttachmentIdx

int m_BayonetAttachmentIdx
protected

◆ m_bulletSelectionIndex

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

◆ m_BurstCount

int m_BurstCount
protected

◆ m_ButtstockAttached

bool m_ButtstockAttached
protected

◆ m_ButtstockAttachmentIdx

int m_ButtstockAttachmentIdx
protected

◆ m_ChanceToJam

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

◆ m_ChanceToJamSync

float m_ChanceToJamSync = 0
protected

◆ m_Charged

bool m_Charged = false
protected

◆ m_DelayedValidationTimer

ref Timer m_DelayedValidationTimer
protected

◆ m_DmgPerShot

float m_DmgPerShot = 0
protected

◆ m_DOFProperties

ref array<float> m_DOFProperties
protected

◆ m_fsm

ref WeaponFSM m_fsm
protected

weapon abilities

◆ m_isJammed

bool m_isJammed = false
protected

weapon state machine

◆ m_LastLiftHit

int m_LastLiftHit
protected

◆ m_LastLiftPosition

vector m_LastLiftPosition
protected

◆ m_LiftWeapon

bool m_LiftWeapon = false
protected

◆ m_magazineSimpleSelectionIndex

int m_magazineSimpleSelectionIndex = -1
protected

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

◆ m_PropertyModifierObject

ref PropertyModifiers m_PropertyModifierObject
protected

◆ m_ShoulderDistance

float m_ShoulderDistance
protected

◆ m_weaponAnimState

int m_weaponAnimState = -1
protected

◆ m_weaponHideBarrelIdx

int m_weaponHideBarrelIdx = -1
protected

◆ m_WeaponLength

float m_WeaponLength
protected

◆ m_WeaponLiftCheckVerticalOffset

float m_WeaponLiftCheckVerticalOffset
protected

◆ m_WeaponOpen

bool m_WeaponOpen = false
protected

◆ 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.


Объявления и описания членов классов находятся в файлах: