Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
firearmactionloadbullet.c
Go to the documentation of this file.
2 {
4  {
5  m_Text = "#load_bullet";
6  }
7 
8  override int GetActionCategory()
9  {
10  return AC_SINGLE_USE;
11  }
12 
13  override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
14  {
15  if (!super.ActionCondition(player, target, item))
16  return false;
17 
18  HumanCommandWeapons hcw = player.GetCommandModifier_Weapons();
19  if (!target.GetObject())
20  return false;
21 
22  Magazine mag = null;
23  EntityAI entity = EntityAI.Cast(target.GetObject());
24  if (entity && entity.IsManagingArrows() && entity.IsDamageDestroyed())
25  {
26  ArrowManagerBase arrowManager = ArrowManagerBase.Cast(entity.GetArrowManager());
27  if (arrowManager)
28  mag = Magazine.Cast(arrowManager.GetFirstArrow());
29  }
30  else
31  mag = Magazine.Cast(target.GetObject());
32 
33  Weapon_Base weapon = Weapon_Base.Cast(item);
34  return mag && player.GetWeaponManager().CanLoadBullet(weapon, mag) && hcw && hcw.GetRunningAction() != WeaponActions.CHAMBERING;
35  }
36 
37  override void Start(ActionData action_data)
38  {
39  super.Start(action_data);
40 
41  Magazine mag;
42  EntityAI entity = EntityAI.Cast(action_data.m_Target.GetObject());
43  if (entity && entity.IsManagingArrows() && entity.IsDamageDestroyed())
44  {
45  ArrowManagerBase arrowManager = ArrowManagerBase.Cast(entity.GetArrowManager());
46  if (arrowManager)
47  {
48  mag = Magazine.Cast(arrowManager.AcquireFirstArrow(false));
49  }
50  }
51  else
52  mag = Magazine.Cast(action_data.m_Target.GetObject());
53 
54  action_data.m_Player.GetWeaponManager().LoadBullet(mag, this);
55  }
56 
57  override Object GetDisplayInteractObject(PlayerBase player, ActionTarget target)
58  {
59  EntityAI entity = EntityAI.Cast(target.GetObject());
60  if (!entity || (entity && entity.IsManagingArrows() && !entity.IsDamageDestroyed()))
61  return null;
62 
63  ArrowManagerBase arrowManager = entity.GetArrowManager();
64  if (arrowManager)
65  return arrowManager.GetFirstArrow();
66 
67  return null;
68  }
69 
70  override bool CanBePerformedFromInventory()
71  {
72  return true;
73  }
74 
75  override bool CanBePerformedFromQuickbar()
76  {
77  return true;
78  }
79 }
80 
82 {
84 
85  override typename GetInputType()
86  {
88  }
89 
90  override void CreateConditionComponents()
91  {
93  m_ConditionTarget = new CCTSelf();
94  }
95 
96  override bool HasProgress()
97  {
98  return false;
99  }
100 
101  override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
102  {
103  if (!super.ActionCondition(player, target, item))
104  return false;
105 
106  HumanCommandWeapons hcw = player.GetCommandModifier_Weapons();
107  Weapon_Base weapon = Weapon_Base.Cast(item);
108 
109  return player.GetWeaponManager().CanLoadBullet(weapon, player.GetWeaponManager().GetPreparedMagazine(), true) && hcw && hcw.GetRunningAction() != WeaponActions.CHAMBERING;
110  }
111 
112  override bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data = NULL)
113  {
114  if (super.SetupAction(player, target, item, action_data, extra_data))
115  {
116  #ifndef SERVER
117  ActionTarget newTarget = new ActionTarget(player.GetWeaponManager().GetPreparedMagazine(), null, -1, vector.Zero, -1);
118  action_data.m_Target = newTarget;
119  #endif
120 
121  return true;
122  }
123 
124  return false;
125  }
126 
127  override void Start(ActionData action_data)
128  {
129  super.Start(action_data);
130 
131  Magazine mag = Magazine.Cast(action_data.m_Target.GetObject());
132  action_data.m_Player.GetWeaponManager().LoadBullet(mag, this);
133  }
134 }
ItemBase
Definition: inventoryitem.c:730
ActionCondition
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition: firearmactionloadbullet.c:12
Param
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition: param.c:11
GetInputType
override GetInputType()
Definition: firearmactionloadbullet.c:85
SetupAction
override bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data=NULL)
Definition: firearmactionloadbullet.c:112
WeaponActions
WeaponActions
actions
Definition: human.c:808
PlayerBase
Definition: playerbaseclient.c:1
vector
Definition: enconvert.c:105
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
Start
override void Start(ActionData action_data)
Definition: firearmactionloadbullet.c:36
FirearmActionLoadBullet
Definition: firearmactionloadbullet.c:1
CCTSelf
Definition: cctself.c:1
Object
Definition: objecttyped.c:1
FirearmActionLoadBulletQuick
FirearmActionLoadBullet FirearmActionBase FirearmActionLoadBulletQuick()
ContinuousWeaponManipulationActionInput
Definition: actioninput.c:907
AC_SINGLE_USE
const int AC_SINGLE_USE
Definition: _constants.c:2
HumanCommandWeapons
Definition: human.c:986
m_Text
protected string m_Text
Definition: actionbase.c:49
CreateConditionComponents
override void CreateConditionComponents()
Definition: firearmactionloadbullet.c:90
Weapon_Base
shorthand
Definition: boltactionrifle_base.c:5
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
CCINonRuined
Definition: ccinonruined.c:1
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
HasProgress
override bool HasProgress()
Definition: firearmactionloadbullet.c:96
FirearmActionBase
Definition: firearmactionbase.c:1
ArrowManagerBase
Definition: arrowmanagerbase.c:1
EntityAI
Definition: building.c:5