DayZ 1.24
Loading...
Searching...
No Matches
FirearmActionAttachMagazine Class Reference
Inheritance diagram for FirearmActionAttachMagazine:
[legend]
Collaboration diagram for FirearmActionAttachMagazine:
[legend]

Private Member Functions

void FirearmActionAttachMagazine ()
 
override int GetActionCategory ()
 
override bool ActionCondition (PlayerBase player, ActionTarget target, ItemBase item)
 
override bool ActionConditionContinue (ActionData action_data)
 
override ActionData CreateActionData ()
 
override void WriteToContext (ParamsWriteContext ctx, ActionData action_data)
 
override bool ReadFromContext (ParamsReadContext ctx, out ActionReciveData action_recive_data)
 
override void HandleReciveData (ActionReciveData action_recive_data, ActionData action_data)
 
override bool Post_SetupAction (ActionData action_data)
 
override bool InventoryReservation (ActionData action_data)
 
override void Start (ActionData action_data)
 
override bool CanBePerformedFromInventory ()
 
override bool CanBePerformedFromQuickbar ()
 

Detailed Description

Definition at line 11 of file FirearmActionAttachMagazine.c.

Constructor & Destructor Documentation

◆ FirearmActionAttachMagazine()

void FirearmActionAttachMagazine::FirearmActionAttachMagazine ( )
inlineprivate

Definition at line 16 of file FirearmActionAttachMagazine.c.

17 {
18 m_Text = "#attach";
19 }
string m_Text
Definition ActionBase.c:49

References m_Text.

Member Function Documentation

◆ ActionCondition()

override bool FirearmActionAttachMagazine::ActionCondition ( PlayerBase player,
ActionTarget target,
ItemBase item )
inlineprivate

Definition at line 26 of file FirearmActionAttachMagazine.c.

27 {
28 if (!super.ActionCondition(player, target, item))
29 return false;
30
31 HumanCommandWeapons hcw = player.GetCommandModifier_Weapons();
32 Magazine mag = Magazine.Cast(target.GetObject());
34 return mag && (player.GetWeaponManager().CanAttachMagazine(wpn, mag) || player.GetWeaponManager().CanSwapMagazine(wpn, mag)) && (!hcw || hcw.GetRunningAction() != WeaponActions.RELOAD);
35 }
WeaponActions
actions
Definition human.c:796

◆ ActionConditionContinue()

override bool FirearmActionAttachMagazine::ActionConditionContinue ( ActionData action_data)
inlineprivate

Definition at line 37 of file FirearmActionAttachMagazine.c.

38 {
39 return true;
40 }

◆ CanBePerformedFromInventory()

override bool FirearmActionAttachMagazine::CanBePerformedFromInventory ( )
inlineprivate

Definition at line 193 of file FirearmActionAttachMagazine.c.

194 {
195 return true;
196 }

◆ CanBePerformedFromQuickbar()

override bool FirearmActionAttachMagazine::CanBePerformedFromQuickbar ( )
inlineprivate

Definition at line 198 of file FirearmActionAttachMagazine.c.

199 {
200 return true;
201 }

◆ CreateActionData()

override ActionData FirearmActionAttachMagazine::CreateActionData ( )
inlineprivate

◆ GetActionCategory()

override int FirearmActionAttachMagazine::GetActionCategory ( )
inlineprivate

Definition at line 21 of file FirearmActionAttachMagazine.c.

22 {
23 return AC_SINGLE_USE;
24 }
const int AC_SINGLE_USE
Definition _constants.c:2

References AC_SINGLE_USE.

◆ HandleReciveData()

override void FirearmActionAttachMagazine::HandleReciveData ( ActionReciveData action_recive_data,
ActionData action_data )
inlineprivate

Definition at line 75 of file FirearmActionAttachMagazine.c.

76 {
79
80 action_data.m_MainItem = action_recive_data.m_MainItem;
81 if (!action_recive_data.m_Target)
82 action_data.m_Target = new ActionTarget(NULL, NULL, -1, vector.Zero, 0);
83 else
84 action_data.m_Target = action_recive_data.m_Target;
85 action_data_am.m_ilOldMagazine = recive_data_am.m_ilOldMagazine;
86 }
class ActionTargets ActionTarget
static const vector Zero
Definition EnConvert.c:110

References ActionTarget, and vector::Zero.

◆ InventoryReservation()

override bool FirearmActionAttachMagazine::InventoryReservation ( ActionData action_data)
inlineprivate

Definition at line 107 of file FirearmActionAttachMagazine.c.

108 {
109 if ((IsLocal() || !UseAcknowledgment()) && IsInstant())
110 return true;
111
112 bool success = true;
116
117 PlayerBase player = action_data.m_Player;
119
120 Weapon_Base wpn = Weapon_Base.Cast(action_data.m_MainItem);
121 int muzzle_index = wpn.GetCurrentMuzzle();
122
123 Magazine new_mag = Magazine.Cast(action_data.m_Target.GetObject());
124
125 if (am_action_data.m_oldMagazine)
126 {
128 if (action_data.m_Player.GetInventory().HasInventoryReservation(am_action_data.m_oldMagazine, am_action_data.m_ilOldMagazine))
129 success = false;
130 else
131 player.GetInventory().AddInventoryReservationEx(am_action_data.m_oldMagazine, am_action_data.m_ilOldMagazine, GameInventory.c_InventoryReservationTimeoutMS);
132 }
133
134 if (success)
135 {
137 targetInventoryLocation.SetAttachment(wpn, new_mag, InventorySlots.MAGAZINE);
138 if (action_data.m_Player.GetInventory().HasInventoryReservation(new_mag, targetInventoryLocation))
139 {
140 success = false;
141 if (am_action_data.m_oldMagazine)
142 player.GetInventory().ClearInventoryReservation(am_action_data.m_oldMagazine, am_action_data.m_ilOldMagazine);
143 }
144 else
145 action_data.m_Player.GetInventory().AddInventoryReservationEx(new_mag, targetInventoryLocation, GameInventory.c_InventoryReservationTimeoutMS);
146 }
147
148 if (success)
149 {
151 handInventoryLocation.SetHands(action_data.m_Player, wpn);
152
153 if (action_data.m_Player.GetInventory().HasInventoryReservation(wpn, handInventoryLocation))
154 {
155 if (am_action_data.m_oldMagazine)
156 player.GetInventory().ClearInventoryReservation(am_action_data.m_oldMagazine, am_action_data.m_ilOldMagazine);
157 player.GetInventory().ClearInventoryReservation(new_mag, targetInventoryLocation);
158 success = false;
159 }
160 else
161 action_data.m_Player.GetInventory().AddInventoryReservationEx(wpn, handInventoryLocation, GameInventory.c_InventoryReservationTimeoutMS);
162 }
163
164 if (success)
165 {
166 if (am_action_data.m_ilOldMagazine)
167 action_data.m_ReservedInventoryLocations.Insert(am_action_data.m_ilOldMagazine);
168
170 action_data.m_ReservedInventoryLocations.Insert(targetInventoryLocation);
171
173 action_data.m_ReservedInventoryLocations.Insert(handInventoryLocation);
174 }
175
176 return success;
177 }
bool UseAcknowledgment()
Definition ActionBase.c:821
bool IsLocal()
Definition ActionBase.c:222
bool IsInstant()
Definition ActionBase.c:228
script counterpart to engine's class Inventory
Definition Inventory.c:79
const int c_InventoryReservationTimeoutMS
reservations
Definition Inventory.c:687
InventoryLocation.
provides access to slot configuration

References GameInventory::c_InventoryReservationTimeoutMS, IsInstant(), IsLocal(), and UseAcknowledgment().

Referenced by Start().

◆ Post_SetupAction()

override bool FirearmActionAttachMagazine::Post_SetupAction ( ActionData action_data)
inlineprivate

Definition at line 88 of file FirearmActionAttachMagazine.c.

89 {
90 if (!GetGame().IsDedicatedServer())
91 {
92 Weapon_Base wpn = Weapon_Base.Cast(action_data.m_MainItem);
93 int muzzle_index = wpn.GetCurrentMuzzle();
94
96 am_action_data.m_oldMagazine = wpn.GetMagazine(muzzle_index);
97
99
100 if (!action_data.m_Player.GetWeaponManager().PrepareInventoryLocationForMagazineSwap(wpn, Magazine.Cast(action_data.m_Target.GetObject()), new_il))
101 return false;
102 am_action_data.m_ilOldMagazine = new_il;
103 }
104 return true;
105 }
proto native CGame GetGame()

References GetGame().

◆ ReadFromContext()

override bool FirearmActionAttachMagazine::ReadFromContext ( ParamsReadContext ctx,
out ActionReciveData action_recive_data )
inlineprivate

Definition at line 58 of file FirearmActionAttachMagazine.c.

59 {
62
63 super.ReadFromContext(ctx, action_recive_data);
64
66 if (!il.ReadFromContext(ctx))
67 return false;
68
70 recive_data_am.m_ilOldMagazine = il;
71
72 return true;
73 }

◆ Start()

override void FirearmActionAttachMagazine::Start ( ActionData action_data)
inlineprivate

Definition at line 179 of file FirearmActionAttachMagazine.c.

180 {
181 super.Start(action_data);
183 Weapon_Base wpn = Weapon_Base.Cast(action_data.m_MainItem);
184 Magazine mag = Magazine.Cast(action_data.m_Target.GetObject());
186 if (action_data.m_Player.GetWeaponManager().CanAttachMagazine(wpn, mag, false))
187 action_data.m_Player.GetWeaponManager().AttachMagazine(mag, this);
188 else
189 action_data.m_Player.GetWeaponManager().SwapMagazineEx(mag, action_data_am.m_ilOldMagazine, this);
191 }
void ClearInventoryReservationEx(ActionData action_data)
Definition ActionBase.c:790
override bool InventoryReservation(ActionData action_data)

References ClearInventoryReservationEx(), and InventoryReservation().

◆ WriteToContext()

override void FirearmActionAttachMagazine::WriteToContext ( ParamsWriteContext ctx,
ActionData action_data )
inlineprivate

Definition at line 49 of file FirearmActionAttachMagazine.c.

50 {
51 super.WriteToContext(ctx, action_data);
52
54
55 action_data_am.m_ilOldMagazine.WriteToContext(ctx);
56 }

The documentation for this class was generated from the following file: