DayZ 1.24
Loading...
Searching...
No Matches
ActionEmptyMagazine.c
Go to the documentation of this file.
12};
13
15{
17 {
19 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_EMPTYMAG;
20 m_CommandUIDProne = DayZPlayerConstants.CMD_ACTIONFB_EMPTYMAG;
21 m_Text = "#empty_magazine";
22 }
23
25 {
26 if (super.SetupAction(player, target, item, action_data, extra_data))
27 {
29 emActionData.m_magazinePile = NULL;
30 return true;
31 }
32 return false;
33 }
34
40
46
47 override bool HasProneException()
48 {
49 return true;
50 }
51
53 {
55 return (item && Class.CastTo(mag, item) && mag.GetAmmoCount() > 0);
56 }
57
59 {
60 return CanEmpty(action_data.m_MainItem);
61 }
62
63 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
64 {
66 return CanEmpty(item);
67 }
68
69 override bool HasTarget()
70 {
71 return false;
72 }
73
75 {
77
79 if (!Class.CastTo(mag, action_data.m_MainItem))
80 return;
81
82 //float dmg;
83 //string bulletType;
84
85 /*int ammoCount = mag.GetAmmoCount();
86 if(GetAmmoCount() > 0)
87 {
88 mag.Get
89 mag.SetAmmoCount( ammoCount - 1 );
90 array< Magazine > piles;
91
92 if( !callback.m_magazinePile )
93 {
94 piles = MiscGameplayFunctions.CreateMagazinePilesFromBullet(bulletType, action_data.m_Player.GetPosition(),1,dmg);
95 if( piles.Count() > 0 )
96 callback.m_magazinePile = piles.Get(0);
97 }
98 else
99 {
100 if( callback.m_magazinePile.GetAmmoMax() > callback.m_magazinePile.GetAmmoCount() && (vector.Distance(action_data.m_Player.GetPosition(), callback.m_magazinePile.GetPosition()) < MAX_GROUND_PILE_DISTANCE ) )
101 {
102 callback.m_magazinePile.StoreCartridge(dmg, bulletType);
103 }
104 else
105 {
106 piles = MiscGameplayFunctions.CreateMagazinePilesFromBullet(bulletType, action_data.m_Player.GetPosition(),1,dmg);
107 if( piles.Count() > 0 )
108 callback.m_magazinePile = piles.Get(0);
109 }
110 }
111
112
113
114 } */
115
116
117 //----Uncomment after AcquireCartridge will work
118
119 float dmg;
120 string ammoType;
121
122 if (!mag.ServerAcquireCartridge(dmg, ammoType))
123 return;
124
125 mag.ApplyManipulationDamage();
126
127 string magazineTypeName;
128 GetGame().ConfigGetText("CfgAmmo " + ammoType + " spawnPileType", magazineTypeName);
129
130 if (!DayZPlayerUtils.HandleStoreCartridge(action_data.m_Player, NULL, -1, dmg, ammoType, magazineTypeName, false))
131 {
133
134 if (!emActionData.m_magazinePile)
135 {
136 piles = MiscGameplayFunctions.CreateMagazinePilesFromBullet(ammoType, action_data.m_Player.GetPosition(), 1, dmg);
137 if (piles.Count() > 0)
138 emActionData.m_magazinePile = piles.Get(0);
139 }
140 else
141 {
142 if (emActionData.m_magazinePile.GetAmmoMax() > emActionData.m_magazinePile.GetAmmoCount() && (vector.DistanceSq(action_data.m_Player.GetPosition(), emActionData.m_magazinePile.GetPosition()) < (UAMaxDistances.DEFAULT * UAMaxDistances.DEFAULT)))
143 emActionData.m_magazinePile.ServerStoreCartridge(dmg, ammoType);
144 else
145 {
146 piles = MiscGameplayFunctions.CreateMagazinePilesFromBullet(ammoType, action_data.m_Player.GetPosition(), 1, dmg);
147 if (piles.Count() > 0)
148 emActionData.m_magazinePile = piles.Get(0);
149 }
150 }
151 //emActionData.m_magazinePile.SetSynchDirty();
152 }
153 //mag.SetSynchDirty();
154 }
155};
string m_Text
Definition ActionBase.c:49
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
ActionEmptyMagazine CreateActionComponent
void DayZPlayerUtils()
cannot be instantiated
override ActionData CreateActionData()
override bool HasProneException()
override bool HasTarget()
override bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data=NULL)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override void OnExecuteServer(ActionData action_data)
override bool ActionConditionContinue(ActionData action_data)
override void CreateConditionComponents()
bool CanEmpty(ItemBase item)
Super root of all classes in Enforce script.
Definition EnScript.c:11
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
const float DEFAULT
const float MAG_EMPTY
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.