DayZ 1.24
Loading...
Searching...
No Matches
WeaponReplacingMagAndChamberNext.c
Go to the documentation of this file.
1
6{
9
11 {
13 m_newDst = NULL;
14 }
15
16 override void OnEntry(WeaponEventBase e)
17 {
18 super.OnEntry(e);
19 }
20
21 override void OnAbort(WeaponEventBase e)
22 {
23 super.OnAbort(e);
25 m_newDst = NULL;
26 }
27
28 override void OnExit(WeaponEventBase e)
29 {
30 if (m_oldMagazine)
31 {
33 e.m_player.GetInventory().FindFreeLocationFor(m_oldMagazine, FindInventoryLocationType.CARGO, il);
34
35 if (!m_newDst || !m_newDst.IsValid() || m_newDst.GetType() == InventoryLocationType.GROUND)
36 {
37 if (DayZPlayerUtils.HandleDropMagazine(e.m_player, m_oldMagazine))
38 {
39 if (LogManager.IsWeaponLogEnable()) wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " DetachOldMagazine, ok - no inventory space for old magazine - dropped to ground");
40 }
41 else
42 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " DetachOldMagazine, error - cannot drop magazine from left hand after not found inventory space for old magazine");
43
44 }
45 else
46 {
48 m_oldMagazine.GetInventory().GetCurrentInventoryLocation(oldSrc);
49
51 {
52 if (LogManager.IsWeaponLogEnable()) wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " DetachOldMagazine, ok - old magazine removed from wpn (LHand->inv)");
53 }
54 else
55 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " DetachOldMagazine, error - cannot remove old mag from wpn");
56 }
57 }
58
59 m_weapon.HideMagazine();
61 m_newDst = null;
62 super.OnExit(e);
63 }
64
66 {
67 if (!super.SaveCurrentFSMState(ctx))
68 return false;
69
70 if (!ctx.Write(m_oldMagazine))
71 {
72 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " DetachOldMagazine.SaveCurrentFSMState: cannot write m_oldMagazine for weapon=" + m_weapon);
73 return false;
74 }
75
76
77 if (!OptionalLocationWriteToContext(m_newDst, ctx))
78 {
79 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " DetachOldMagazine.SaveCurrentFSMState: cannot write m_newDst for weapon=" + m_weapon);
80 return false;
81 }
82
83 return true;
84 }
85
86 override bool LoadCurrentFSMState(ParamsReadContext ctx, int version)
87 {
88 if (!super.LoadCurrentFSMState(ctx, version))
89 return false;
90
91 if (!ctx.Read(m_oldMagazine))
92 {
93 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " DetachOldMagazine.LoadCurrentFSMState: cannot read m_oldMagazine for weapon=" + m_weapon);
94 return false;
95 }
96
98 {
99 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " DetachOldMagazine.LoadCurrentFSMState: cannot read m_newDst for weapon=" + m_weapon);
100 return false;
101 }
102 return true;
103 }
104};
105
111{
112};
113
122{
123 Magazine m_newMagazine;
124 ref InventoryLocation m_newDst;
125
126 override void OnEntry(WeaponEventBase e)
127 {
128 super.OnEntry(e);
129
130 if (e)
131 {
132 if (!m_newMagazine || !m_newDst || !m_newDst.IsValid())
133 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " SwapOldAndNewMagazine, error - m_newMagazine(" + m_newMagazine + ") or destination(" + InventoryLocation.DumpToStringNullSafe(m_newDst) + ") is not set ");
134 else
135 {
136 e.m_player.GetInventory().ClearInventoryReservationEx(m_newMagazine, m_newDst);
137 m_weapon.ShowMagazine();
139 lhand.SetAttachment(e.m_player, m_newMagazine, InventorySlots.LEFTHAND);
140
142 {
143 if (LogManager.IsWeaponLogEnable()) wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " SwapOldAndNewMagazine, ok - new magazine removed from inv (LHand->Att)");
144 }
145 else
146 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " SwapOldAndNewMagazine, error - cannot remove new mag from LHand");
147 }
148 }
149 }
150
151 override void OnAbort(WeaponEventBase e)
152 {
153 //m_weapon.HideMagazine();
154
155 m_newMagazine = NULL;
156 m_newDst = NULL;
157
158 super.OnAbort(e);
159 }
160
161 override void OnExit(WeaponEventBase e)
162 {
163 m_newMagazine = NULL;
164 m_newDst = NULL;
165
166 super.OnExit(e);
167 }
168
170 {
171 if (!super.SaveCurrentFSMState(ctx))
172 return false;
173
174 if (!ctx.Write(m_newMagazine))
175 {
176 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " SwapOldAndNewMagazine.SaveCurrentFSMState: cannot write m_newMagazine for weapon=" + m_weapon);
177 return false;
178 }
179
180 if (!OptionalLocationWriteToContext(m_newDst, ctx))
181 {
182 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " SwapOldAndNewMagazine.SaveCurrentFSMState: cannot write m_newDst for weapon=" + m_weapon);
183 return false;
184 }
185
186 return true;
187 }
188
189 override bool LoadCurrentFSMState(ParamsReadContext ctx, int version)
190 {
191 if (!super.LoadCurrentFSMState(ctx, version))
192 return false;
193
194 if (!ctx.Read(m_newMagazine))
195 {
196 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " SwapOldAndNewMagazine.LoadCurrentFSMState: cannot read m_newMagazine for weapon=" + m_weapon);
197 return false;
198 }
199 if (!OptionalLocationReadFromContext(m_newDst, ctx))
200 {
201 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " SwapOldAndNewMagazine.LoadCurrentFSMState: cannot read m_newDst for weapon=" + m_weapon);
202 return false;
203 }
204
205 return true;
206 }
207};
208
213{
214 Magazine m_newMagazine;
215 ref InventoryLocation m_newDst;
216
218 {
219 m_newMagazine = NULL;
220 m_newDst = NULL;
221 }
222
224 {
225 return true;
226 }
227
228 override void OnEntry(WeaponEventBase e)
229 {
230 super.OnEntry(e);
231 if (e)
232 {
233 if (m_newMagazine && m_newDst)
234 {
236 if (m_newMagazine.GetInventory().GetCurrentInventoryLocation(il))
237 {
239 lhand.SetAttachment(e.m_player, m_newMagazine, InventorySlots.LEFTHAND);
241 {
242 m_weapon.ShowMagazine();
243 if (LogManager.IsWeaponLogEnable()) wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " AttachNewMagazine, ok - attached new magazine (LHand->dst)");
244 }
245 else
246 {
247 if (LogManager.IsWeaponLogEnable()) wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " AttachNewMagazine, error - cannot attach new magazine!");
248 }
249 }
250 else
251 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " AttachNewMagazine, error - cannot get curr location");
252 }
253 else
254 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " AttachNewMagazine, error - no magazines configured for replace (m_new=NULL)");
255 }
256 }
257
258 override void OnAbort(WeaponEventBase e)
259 {
260 if (m_newMagazine && m_newDst)
261 {
262 if (DayZPlayerUtils.HandleDropMagazine(e.m_player, m_newMagazine))
263 {
264 if (LogManager.IsWeaponLogEnable()) wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponDetachingMag_Store, ok - aborting, detached magazine dropped to ground");
265 }
266 else
267 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponDetachingMag_Store, error - cannot abort detaching of magazine");
268
269 m_weapon.HideMagazine(); // force hide on abort
270 }
271
272 if (LogManager.IsWeaponLogEnable()) wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " AttachNewMagazine, aborting, but attached new magazine already in place");
273 m_newMagazine = NULL;
274 m_newDst = NULL;
275
276 super.OnAbort(e);
277 }
278
279 override void OnExit(WeaponEventBase e)
280 {
281 m_newMagazine = NULL;
282 m_newDst = NULL;
283 super.OnExit(e);
284 }
285
287 {
288 if (!super.SaveCurrentFSMState(ctx))
289 return false;
290
291 if (!ctx.Write(m_newMagazine))
292 {
293 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " AttachNewMagazine.SaveCurrentFSMState: cannot write m_newMagazine for weapon=" + m_weapon);
294 return false;
295 }
296
297 if (!OptionalLocationWriteToContext(m_newDst, ctx))
298 {
299 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " AttachNewMagazine.SaveCurrentFSMState: cannot write m_newDst for weapon=" + m_weapon);
300 return false;
301 }
302 return true;
303 }
304
305 override bool LoadCurrentFSMState(ParamsReadContext ctx, int version)
306 {
307 if (!super.LoadCurrentFSMState(ctx, version))
308 return false;
309
310 if (!ctx.Read(m_newMagazine))
311 {
312 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " AttachNewMagazine.LoadCurrentFSMState: cannot read m_newMagazine for weapon=" + m_weapon);
313 return false;
314 }
315 if (!OptionalLocationReadFromContext(m_newDst, ctx))
316 {
317 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " AttachNewMagazine.LoadCurrentFSMState: cannot read m_newDst for weapon=" + m_weapon);
318 return false;
319 }
320 return true;
321 }
322};
323
325{
326 override bool IsWaitingForActionFinish() { return true; }
327};
328
329
337{
339 int m_actionType;
340
347 ref WeaponCharging_CK m_onCK;
349
350 // substates configuration
352 Magazine m_newMagazine;
353 ref InventoryLocation m_newDst;
354
356 {
358 m_actionType = actionType;
359 m_newMagazine = NULL;
360
361 // setup nested state machine
362 m_start = new WeaponStartAction(m_weapon, this, m_action, m_actionType);
364 m_detach = new DetachOldMagazine(m_weapon, this);
365 m_hideOld = new OldMagazineHide(m_weapon, this);
366 m_swapMags = new SwapOldAndNewMagazine(m_weapon, this);
367 m_attach = new AttachNewMagazine_W4T(m_weapon, this);
369 m_onCK = new WeaponCharging_CK(m_weapon, this);
370
371 // events
372 WeaponEventBase __so_ = new WeaponEventAnimSliderOpen;
373 WeaponEventBase __md_ = new WeaponEventAnimMagazineDetached;
374 WeaponEventBase __mh_ = new WeaponEventAnimMagazineHide;
375 WeaponEventBase __ms_ = new WeaponEventAnimMagazineShow;
376 WeaponEventBase __ma_ = new WeaponEventAnimMagazineAttached;
377 WeaponEventBase __ck_ = new WeaponEventAnimCocked;
378 WeaponEventBase _fin_ = new WeaponEventHumanCommandActionFinished;
379
380 m_fsm = new WeaponFSM(this); // @NOTE: set owner of the submachine fsm
381 m_fsm.AddTransition(new WeaponTransition(m_start, __md_, m_detach));
382 m_fsm.AddTransition(new WeaponTransition(m_start, __so_, m_eject));
383 m_fsm.AddTransition(new WeaponTransition(m_eject, __md_, m_detach));
384 m_fsm.AddTransition(new WeaponTransition(m_detach, __mh_, m_hideOld));
385 m_fsm.AddTransition(new WeaponTransition(m_hideOld, __ms_, m_swapMags));
386 m_fsm.AddTransition(new WeaponTransition(m_swapMags, __ma_, m_attach));
387 m_fsm.AddTransition(new WeaponTransition(m_attach, __ck_, m_chamber, NULL, new GuardAnd(new WeaponGuardCurrentChamberEmpty(m_weapon), new WeaponGuardHasAmmo(m_weapon))));
388 m_fsm.AddTransition(new WeaponTransition(m_attach, __ck_, m_onCK));
389
390 m_fsm.AddTransition(new WeaponTransition(m_attach, _fin_, NULL));
391 m_fsm.AddTransition(new WeaponTransition(m_chamber, _fin_, NULL));
392 m_fsm.AddTransition(new WeaponTransition(m_onCK, _fin_, NULL));
393
394 // Safety exits
395 m_fsm.AddTransition(new WeaponTransition(m_swapMags, _fin_, null));
396 m_fsm.AddTransition(new WeaponTransition(m_hideOld, _fin_, null));
397 m_fsm.AddTransition(new WeaponTransition(m_detach, _fin_, null));
398 m_fsm.AddTransition(new WeaponTransition(m_eject, _fin_, null));
399 m_fsm.AddTransition(new WeaponTransition(m_start, _fin_, null));
400
401 m_fsm.SetInitialState(m_start);
402 }
403
404 override void OnEntry(WeaponEventBase e)
405 {
406 if (e != NULL)
407 {
408 WeaponEventSwapMagazine se;
409 if (Class.CastTo(se, e))
410 {
411 int mi = m_weapon.GetCurrentMuzzle();
412 m_oldMagazine = m_weapon.GetMagazine(mi);
413 m_newMagazine = se.m_magazine;
414 m_newDst = se.m_dst;
415
416 if (LogManager.IsWeaponLogEnable()) wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponReplacingMagAndChamberNext, m_oldMagazine= " + m_oldMagazine + " m_newMagazine= " + m_newMagazine + " m_oldMagazineDst= " + typename.EnumToString(InventoryLocationType, se.m_dst.GetType()));
417
420
421 if (!m_newMagazine.GetInventory().GetCurrentInventoryLocation(newSrc))
422 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponReplacingMagAndChamberNext cannot get curr inv loc of NEW mag=" + Object.GetDebugName(m_newMagazine));
423 if (!m_oldMagazine.GetInventory().GetCurrentInventoryLocation(oldSrc))
424 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponReplacingMagAndChamberNext cannot get curr inv loc of OLD mag=" + Object.GetDebugName(m_oldMagazine));
425
426 // move to LH
428 lhand.SetAttachment(e.m_player, m_newMagazine, InventorySlots.LEFTHAND);
429
431 {
432 if (LogManager.IsWeaponLogEnable()) wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " RemoveNewMagazineFromInventory, ok - new magazine removed from inv (inv->LHand)");
433 }
434 else
435 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " RemoveNewMagazineFromInventory, error - cannot new remove mag from inv");
436
437 m_detach.m_oldMagazine = m_oldMagazine;
438 m_detach.m_newDst = m_newDst;
439
440 m_swapMags.m_newMagazine = m_newMagazine;
441
442 oldSrc.SetItem(m_newMagazine);
443 m_swapMags.m_newDst = oldSrc;
444 }
445 }
446 super.OnEntry(e);
447 }
448
449 override void OnExit(WeaponEventBase e)
450 {
451 super.OnExit(e);
452
453 EntityAI leftHandItem = e.m_player.GetInventory().FindAttachment(InventorySlots.LEFTHAND);
455
456 if (mag)
457 {
458 if (m_newMagazine)
459 e.m_player.GetInventory().ClearInventoryReservationEx(m_newMagazine, null);
460 if (m_oldMagazine)
461 e.m_player.GetInventory().ClearInventoryReservationEx(m_oldMagazine, null);
462
464
465 e.m_player.GetInventory().FindFreeLocationFor(mag, FindInventoryLocationType.CARGO, il);
466
467 if (!il.IsValid())
468 {
469 if (DayZPlayerUtils.HandleDropMagazine(e.m_player, mag))
470 {
471 if (LogManager.IsWeaponLogEnable()) wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " DetachOldMagazine, ok - no inventory space for old magazine - dropped to ground - exit");
472 }
473 else
474 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " DetachOldMagazine, error - cannot drop magazine from left hand after not found inventory space for old magazine - exit");
475
476 }
477 else
478 {
480 mag.GetInventory().GetCurrentInventoryLocation(oldSrc);
481
483 {
484 if (LogManager.IsWeaponLogEnable()) wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " DetachOldMagazine, ok - old magazine removed from wpn (LHand->inv) - exit");
485 }
486 else
487 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " DetachOldMagazine, error - cannot remove old mag from wpn - exit");
488 }
489 }
490
492 m_newMagazine = NULL;
493 m_newDst = NULL;
494 }
495
496 override void OnAbort(WeaponEventBase e)
497 {
498 super.OnAbort(e);
499
500 EntityAI leftHandItem = e.m_player.GetInventory().FindAttachment(InventorySlots.LEFTHAND);
502
503 if (mag)
504 {
505 if (m_newMagazine)
506 e.m_player.GetInventory().ClearInventoryReservationEx(m_newMagazine, null);
507 if (m_oldMagazine)
508 e.m_player.GetInventory().ClearInventoryReservationEx(m_oldMagazine, null);
509
511
512 e.m_player.GetInventory().FindFreeLocationFor(mag, FindInventoryLocationType.CARGO, il);
513
514 if (!il.IsValid())
515 {
516 if (DayZPlayerUtils.HandleDropMagazine(e.m_player, mag))
517 {
518 if (LogManager.IsWeaponLogEnable()) wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " DetachOldMagazine, ok - no inventory space for old magazine - dropped to ground - abort");
519 }
520 else
521 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " DetachOldMagazine, error - cannot drop magazine from left hand after not found inventory space for old magazine - abort");
522
523 }
524 else
525 {
527 mag.GetInventory().GetCurrentInventoryLocation(oldSrc);
528
530 {
531 if (LogManager.IsWeaponLogEnable()) wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " DetachOldMagazine, ok - old magazine removed from wpn (LHand->inv) - abort");
532 }
533 else
534 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " DetachOldMagazine, error - cannot remove old mag from wpn - abort");
535 }
536 }
537 }
538
540 {
541 if (!super.SaveCurrentFSMState(ctx))
542 return false;
543
544 if (!ctx.Write(m_newMagazine))
545 {
546 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " DetachOldMagazine.SaveCurrentFSMState: cannot write m_newMagazine for weapon=" + m_weapon);
547 return false;
548 }
549
550 if (!ctx.Write(m_oldMagazine))
551 {
552 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " DetachOldMagazine.SaveCurrentFSMState: cannot write m_oldMagazine for weapon=" + m_weapon);
553 return false;
554 }
555
556 if (!m_newDst.WriteToContext(ctx))
557 {
558 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " DetachOldMagazine.SaveCurrentFSMState: cannot write m_newDst for weapon=" + m_weapon);
559 return false;
560 }
561
562 return true;
563 }
564
565 override bool LoadCurrentFSMState(ParamsReadContext ctx, int version)
566 {
567 if (!super.LoadCurrentFSMState(ctx, version))
568 return false;
569
570 if (!ctx.Read(m_newMagazine))
571 {
572 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " DetachOldMagazine.LoadCurrentFSMState: cannot read m_newMagazine for weapon=" + m_weapon);
573 return false;
574 }
575 if (!ctx.Read(m_oldMagazine))
576 {
577 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " DetachOldMagazine.LoadCurrentFSMState: cannot read m_oldMagazine for weapon=" + m_weapon);
578 return false;
579 }
580 m_newDst = new InventoryLocation;
581
582 if (!m_newDst.ReadFromContext(ctx))
583 {
584 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " DetachOldMagazine.LoadCurrentFSMState: cannot read m_newDst for weapon=" + m_weapon);
585 return false;
586 }
587
588 return true;
589 }
590};
591
void wpnDebugPrint(string s)
Definition Debug.c:9
void DayZPlayerUtils()
cannot be instantiated
Magazine m_oldMagazine
class WeaponGuardIsDestroyed extends WeaponGuardBase m_weapon
Definition Guards.c:602
void WeaponGuardHasAmmo(Weapon_Base w=NULL)
Definition Guards.c:99
FindInventoryLocationType
flags for searching locations in inventory
bool OptionalLocationReadFromContext(out InventoryLocation loc, notnull ParamsReadContext ctx)
InventoryLocationType
types of Inventory Location
bool OptionalLocationWriteToContext(InventoryLocation loc, notnull ParamsWriteContext ctx)
enum FSMTransition WeaponTransition
ref WeaponStateBase m_start
class WeaponEndAction extends WeaponStartAction m_action
ref WeaponChambering_Base m_chamber
ref WeaponEjectCasingMultiMuzzle m_eject
attach mag in LH into weapon
Super root of all classes in Enforce script.
Definition EnScript.c:11
detaches old magazine from weapon and stores it in left hand (LH)
script counterpart to engine's class Inventory
Definition Inventory.c:79
static proto native bool LocationSyncMoveEntity(notnull InventoryLocation src_loc, notnull InventoryLocation dst_loc)
synchronously removes item from current inventory location and adds it to destination no anims involv...
InventoryLocation.
static string DumpToStringNullSafe(InventoryLocation loc)
provides access to slot configuration
static bool IsWeaponLogEnable()
Definition Debug.c:799
hides old magazine, but keep it in LH
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
old magazine to inventory, new to left hand
signalize mechanism manipulation
Definition Events.c:35
weapon finite state machine
replace current magazine with new one
simple class starting animation action specified by m_action and m_actionType
represent weapon state base
Definition BulletHide.c:2
void AttachNewMagazine(Weapon_Base w=NULL, WeaponStateBase parent=NULL)
ref AttachNewMagazine_W4T m_attach
void DetachOldMagazine(Weapon_Base w=NULL, WeaponStateBase parent=NULL)
override void OnEntry(WeaponEventBase e)
ref SwapOldAndNewMagazine m_swapMags
ref InventoryLocation m_newDst
magazine that will be detached
override bool LoadCurrentFSMState(ParamsReadContext ctx, int version)
void WeaponReplacingMagAndChamberNext(Weapon_Base w=NULL, WeaponStateBase parent=NULL, WeaponActions action=WeaponActions.NONE, int actionType=-1)
override void OnAbort(WeaponEventBase e)
override void OnExit(WeaponEventBase e)
override bool SaveCurrentFSMState(ParamsWriteContext ctx)
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
WeaponActions
actions
Definition human.c:796