DayZ 1.24
Loading...
Searching...
No Matches
ClaymoreMine.c
Go to the documentation of this file.
1class ClaymoreMine : ExplosivesBase
2{
3 protected const string ANIM_PHASE_PACKED = "Bag";
4 protected const string ANIM_PHASE_DEPLOYED = "Mine";
5 protected const string SELECTION_NAME_LED = "LED";
6
9
11 {
13
14 SetAmmoTypes({"ClaymoreMine_Ammo", "ClaymoreMine_Secondary_Ammo"});
16 SetParticleOrientation("90 0 0");
17
18 RegisterNetSyncVariableInt("m_RAIB.m_PairDeviceNetIdLow");
19 RegisterNetSyncVariableInt("m_RAIB.m_PairDeviceNetIdHigh");
21 }
22
23 override void EOnInit(IEntity other, int extra)
24 {
26 }
27
28 override void EEKilled(Object killer)
29 {
30 super.EEKilled(killer);
31#ifdef DIAG_DEVELOPER
32#ifndef SERVER
34#endif
35#endif
36 }
37
38 override void EEDelete(EntityAI parent)
39 {
40 super.EEDelete(parent);
41
42#ifdef DIAG_DEVELOPER
43#ifndef SERVER
45#endif
46#endif
47 }
48
49 override protected void InitiateExplosion()
50 {
51 if (GetDefused())
52 return;
53
54 super.InitiateExplosion();
55 }
56
57 override void AfterStoreLoad()
58 {
59 super.AfterStoreLoad();
60
62 if (GetArmed())
64 }
65
67 {
68 super.OnVariablesSynchronized();
69
70 if (m_RAIB)
71 m_RAIB.OnVariableSynchronized();
72
74 }
75
77 {
78 super.EEItemLocationChanged(oldLoc, newLoc);
79
80 if (m_RAIB)
81 m_RAIB.Pair();
82 }
83
84
89
91 {
92 m_RAIB.Pair(trigger);
93 }
94
96 {
97 return m_RAIB.GetPairDevice();
98 }
99
100 override bool CanBeDisarmed()
101 {
102 return GetArmed();
103 }
104
106 {
107 if (GetGame().IsServer())
108 {
109 if (m_RAIB.IsPaired() && GetArmed())
110 {
111 if (GetPairDevice() == item)
112 SetHealth("", "", 0.0);
113 }
114 }
115 }
116
117 override void OnArmed()
118 {
119 super.OnArmed();
120
123
124#ifdef DIAG_DEVELOPER
125#ifndef SERVER
126 // have to call this function a little later, after claymore transform has been finalized
127 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(DrawDamageZone, 500);
128#endif
129#endif
130 }
131
132 override void OnDisarmed(bool pWithTool)
133 {
134 super.OnDisarmed(pWithTool);
135
136#ifdef DIAG_DEVELOPER
138#endif
139
141 UnpairRemote();
142
143 if (pWithTool)
144 SetHealth("", "", 0.0);
145
148 }
149
150 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
151 {
152 super.OnPlacementComplete(player, position, orientation);
153
154 if (GetGame().IsServer())
155 {
157 if (rdt)
158 {
160 Arm();
161 }
162 }
163 }
164
165 protected void UpdateVisuals()
166 {
167 if (GetArmed() || GetDefused())
168 {
169 ShowSelection(ANIM_PHASE_DEPLOYED);
170 HideSelection(ANIM_PHASE_PACKED);
171 if (GetOnViewIndexChanged())
172 GetOnViewIndexChanged().Invoke();
173 }
174 else
175 {
176 HideSelection(ANIM_PHASE_DEPLOYED);
177 ShowSelection(ANIM_PHASE_PACKED);
178 if (GetOnViewIndexChanged())
179 GetOnViewIndexChanged().Invoke();
180 }
181 }
182
183 protected void UpdateLED(ERemoteDetonatorLEDState pState, bool pForced = false)
184 {
185 if (pState != m_LastLEDState || pForced)
186 {
187 int selectionIdx = GetHiddenSelectionIndex(SELECTION_NAME_LED);
188
189 switch (pState)
190 {
192 SetObjectTexture(selectionIdx, RemoteDetonator.COLOR_LED_LIT);
193 break;
194 default:
195 SetObjectTexture(selectionIdx, RemoteDetonator.COLOR_LED_OFF);
196 break;
197 }
198
200 }
201 }
202
203 override bool IsTakeable()
204 {
205 return !GetArmed() && super.IsTakeable();
206 }
207
208 override bool IsDeployable()
209 {
210 return true;
211 }
212
213 override void SetActions()
214 {
215 super.SetActions();
216
218 AddAction(ActionDeployObject);
220 }
221
222 override int GetViewIndex()
223 {
224 if (MemoryPointExists("invView2"))
225 {
226 if (GetArmed())
227 return 1;
228 }
229
230 return 0;
231 }
232
233 override protected bool UsesGlobalDeploy()
234 {
235 return true;
236 }
237
238 override string GetDeploySoundset()
239 {
240 return "placeClaymore_SoundSet";
241 }
242
243 override string GetLoopDeploySoundset()
244 {
245 return "claymore_deploy_Soundset";
246 }
247
248 override void OnDebugSpawn()
249 {
250 RemoteDetonatorTrigger rdt = RemoteDetonatorTrigger.Cast(SpawnEntityOnGroundPos("RemoteDetonatorTrigger", GetPosition() + GetDirection() * 0.5));
252 Arm();
253 }
254
255#ifdef DIAG_DEVELOPER
256 //================================================================
257 // DEBUG
258 //================================================================
259
260 protected Shape m_DamageZone;
261
262 override protected string GetDebugText()
263 {
264 string debug_output;
265 debug_output += string.Format("low net id: %1\n", m_RAIB.GetPairDeviceNetIdLow());
266 debug_output += string.Format("high net id: %1\n", m_RAIB.GetPairDeviceNetIdHigh());
267 debug_output += string.Format("pair device: %1\n", m_RAIB.GetPairDevice());
268
269 return debug_output;
270 }
271
272 protected void DrawDamageZone()
273 {
274 if (!DiagMenu.GetBool(DiagMenuIDs.WEAPON_CLAYMORE_DEBUG))
275 return;
276
277 auto game = GetGame();
278 string cfgPath = "CfgAmmo " + m_AmmoTypes[0];
279 float hitRange = game.ConfigGetFloat(cfgPath + " indirectHitRange");
280 float hitRangeMultiplier = game.ConfigGetFloat(cfgPath + " indirectHitRangeMultiplier");
281 float verticalAngle = game.ConfigGetFloat(cfgPath + " indirectHitAngle1");
282 float horizontalAngle = game.ConfigGetFloat(cfgPath + " indirectHitAngle2");
285
287
288 GetTransform(selfMatrix);
290 m_DamageZone.SetMatrix(selfMatrix);
291 }
292
293 void RemoveDebugVisuals()
294 {
295 if (m_DamageZone)
296 {
297 m_DamageZone.Destroy();
299 }
300 }
301#endif
302}
303
ActionArmExplosiveCB ActionContinuousBaseCB ActionArmExplosive()
RepairCarChassisActionReciveData m_DamageZone
void AddAction(typename actionName)
DiagMenuIDs
Definition EDiagMenuIDs.c:2
ref array< string > m_AmmoTypes
void SetDefused(bool state)
bool GetArmed()
void SetAmmoTypes(array< string > pAmmoTypes)
void SetParticleExplosion(int particle)
bool GetDefused()
override void UnpairRemote()
void Arm()
void SetParticleOrientation(vector local_ori)
bool PairWithDevice(notnull ItemBase otherDevice)
Definition ItemBase.c:9308
string GetDebugText()
ERemoteDetonatorLEDState
class JsonUndergroundAreaTriggerData GetPosition
override EntityAI GetPairDevice()
override void PairRemote(notnull EntityAI trigger)
override void OnDebugSpawn()
override void OnVariablesSynchronized()
override bool IsTakeable()
override void EEDelete(EntityAI parent)
override void OnDisarmed(bool pWithTool)
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
void UpdateLED(ERemoteDetonatorLEDState pState, bool pForced=false)
override void OnArmed()
bool UsesGlobalDeploy()
const string ANIM_PHASE_DEPLOYED
Definition ClaymoreMine.c:4
override string GetLoopDeploySoundset()
const string SELECTION_NAME_LED
Definition ClaymoreMine.c:5
override void EEKilled(Object killer)
override int GetViewIndex()
override string GetDeploySoundset()
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
void InitiateExplosion()
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
ref RemotelyActivatedItemBehaviour m_RAIB
Definition ClaymoreMine.c:7
void ClaymoreMine()
override void AfterStoreLoad()
override bool CanBeDisarmed()
override bool IsDeployable()
override void SetActions()
override void OnActivatedByItem(notnull ItemBase item)
override void EOnInit(IEntity other, int extra)
ERemoteDetonatorLEDState m_LastLEDState
Definition ClaymoreMine.c:8
const string ANIM_PHASE_PACKED
Definition ClaymoreMine.c:3
void UpdateVisuals()
Definition Debug.c:14
static Shape DrawFrustum(float horizontalAngle, float verticalAngle, float length, int color=0x1fff7f7f, ShapeFlags flags=ShapeFlags.TRANSP|ShapeFlags.WIREFRAME)
Definition Debug.c:442
InventoryLocation.
static const int CLAYMORE_EXPLOSION
static RemoteDetonatorTrigger SpawnInPlayerHands(notnull EntityAI pEntity, EntityAI deviceToPair=null)
proto native CGame GetGame()
static proto bool GetBool(int id, bool reverse=false)
Get value as bool from the given script id.
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8