DayZ 1.24
Loading...
Searching...
No Matches
WeaponStableState.c
Go to the documentation of this file.
1
15{
17 U = -1,
19 E = 0,
21 F = 1,
23 L = 2
25
27{
29
31
38
40 {
41 int curr = m_weapon.GetWeaponAnimState();
42 if (curr != m_animState)
43 {
44 //if (LogManager.IsWeaponLogEnable()) fsmDebugSpam("[wpnfsm] " + Object.GetDebugName(m_weapon) + " synchronizing anim state: " + curr + " --> " + m_animState);
46 if (Class.CastTo(p, m_weapon.GetHierarchyParent()))
47 {
48 if (p.GetItemInHands() == m_weapon)
49 {
50 HumanCommandWeapons hcw = p.GetCommandModifier_Weapons();
51 if (hcw)
52 {
53 hcw.SetInitState(m_animState);
54 if (LogManager.IsWeaponLogEnable()) fsmDebugSpam("[wpnfsm] " + Object.GetDebugName(m_weapon) + " state=" + m_weapon.GetCurrentState().Type() + " synchronized anim state: " + typename.EnumToString(PistolAnimState, curr) + " --> " + typename.EnumToString(PistolAnimState, m_animState));
55 }
56 else
57 {
58 Human wpnOwner = Human.Cast(m_weapon.GetHierarchyRootPlayer());
60 if (LogManager.IsWeaponLogEnable()) fsmDebugSpam("[wpnfsm] " + Object.GetDebugName(m_weapon) + " state=" + m_weapon.GetCurrentState().Type() + " synchronized remote anim state: " + typename.EnumToString(PistolAnimState, curr) + " --> " + typename.EnumToString(PistolAnimState, m_animState));
61 }
62 }
63 m_weapon.SetWeaponAnimState(m_animState);
64 }
65 else
66 m_weapon.SetGroundAnimFrameIndex(m_animState);
67 }
68 }
69
70 override void OnEntry(WeaponEventBase e)
71 {
72 super.OnEntry(e);
73 m_weapon.SetJammed(false);
74 if (e)
76 m_weapon.ResetWeaponAnimState();
77 }
78 override void OnUpdate(float dt)
79 {
80 super.OnUpdate(dt);
82 }
83 override void OnExit(WeaponEventBase e)
84 {
85 m_weapon.ResetWeaponAnimState();
86 super.OnExit(e);
87 }
88
89 override bool IsIdle() { return true; }
90
91 int GetCurrentStateID() { return 0; }
92
104
113 bool IsRepairEnabled() { return false; }
114
120 bool HasBullet() { return false; }
121
123 bool HasMagazine() { return false; }
124
126 bool IsJammed() { return false; }
127
129 bool IsDischarged() { return false; }
130
132 bool IsWeaponOpen() { return false; }
133
136
138 bool IsSingleState() { return false; }
139
141
146
149 int GetMuzzleStateCount() { return m_muzzleHasBullet.Count(); }
153
155
158 {
159 // There is only one
160 if (IsSingleState())
161 return;
162
163 bool failed = false;
164
165 if (!failed)
166 {
168 {
169 if (state == MuzzleState.U)
170 {
171 failed = true;
172 break;
173 }
174 }
175 }
176
177 if (failed)
178 {
180
181#ifdef DEVELOPER
182 if (DayZGame.m_IsPreviewSpawn)
183 {
184 // we do not want VMEs when spawning the item in order to visualize it for preview in script console
186 }
187#endif
188
189 ErrorEx("Muzzle array validation has failed. Please set up the correct muzzle states by overriding InitMuzzleArray.", severity);
190 }
191 }
192};
193
class WeaponGuardIsDestroyed extends WeaponGuardBase m_weapon
Definition Guards.c:602
void fsmDebugSpam(string s)
Definition HFSMBase.c:9
PistolAnimState
Definition Pistol_Base.c:3
class SSPFireout extends WeaponStableState OnEntry
int GetMuzzleStateCount()
bool IsChamberValid(int idx)
void SyncAnimState()
enum MuzzleState m_animState
MuzzleState
@ E
EMPTY.
@ U
UNKNOWN.
@ L
LOADED.
@ F
FIRED.
void ValidateMuzzleArray()
Safety check and error message in case not set up correctly.
override bool IsIdle()
ref array< MuzzleState > m_muzzleHasBullet
bool IsSingleState()
Special one for when the weapon only has one singular state (like Magnum)
void WeaponStableState(Weapon_Base w=NULL, WeaponStateBase parent=NULL, int anim_state=-1)
bool IsChamberFiredOut(int idx)
bool IsWeaponOpen()
Whether the gun is open.
MuzzleState GetMuzzleState(int idx)
Get chamber state of the muzzle at index.
bool IsChamberFull(int idx)
Super root of all classes in Enforce script.
Definition EnScript.c:11
proto static native void StaticSetInitState(Human pHuman, int pFrameIdx)
just static version of SetInitState
static bool IsWeaponLogEnable()
Definition Debug.c:799
signalize mechanism manipulation
Definition Events.c:35
represents weapon's stable state (i.e. the basic states that the weapon will spend the most time in)
Definition Crossbow.c:27
override bool IsJammed()
Definition Crossbow.c:33
override bool IsDischarged()
Definition Pistol_Base.c:82
override void OnExit(WeaponEventBase e)
Definition Crossbow.c:29
override void InitMuzzleArray()
Definition Crossbow.c:35
override bool HasBullet()
Definition Crossbow.c:31
override int GetCurrentStateID()
Definition Crossbow.c:30
override bool IsRepairEnabled()
Definition Crossbow.c:34
override bool HasMagazine()
Definition Crossbow.c:32
represent weapon state base
Definition BulletHide.c:2
ErrorExSeverity
Definition EnDebug.c:62
enum ShapeType ErrorEx
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
proto native void OnUpdate()
Definition tools.c:333