Dayz Explorer 1.28.160049
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"});
15 SetParticleExplosion(ParticleList.CLAYMORE_EXPLOSION);
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
33 RemoveDebugVisuals();
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
44 RemoveDebugVisuals();
45#endif
46#endif
47 }
48
49 override protected void InitiateExplosion()
50 {
51 if (GetDefused())
52 {
53 return;
54 }
55
56 super.InitiateExplosion();
57 }
58
59 override void AfterStoreLoad()
60 {
61 super.AfterStoreLoad();
62
64 if (GetArmed())
65 {
67 }
68 }
69
71 {
72 super.OnVariablesSynchronized();
73
74 if (m_RAIB)
75 {
77 }
78
80 }
81
82 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
83 {
84 super.EEItemLocationChanged(oldLoc, newLoc);
85
86 if (m_RAIB)
87 {
88 m_RAIB.Pair();
89 }
90 }
91
92
93
98
99 override void PairRemote(notnull EntityAI trigger)
100 {
101 m_RAIB.Pair(trigger);
102 }
103
105 {
106 return m_RAIB.GetPairDevice();
107 }
108
109 override bool CanBeDisarmed()
110 {
111 return GetArmed();
112 }
113
114 override void OnActivatedByItem(notnull ItemBase item)
115 {
116 if (GetGame().IsServer())
117 {
118 if (m_RAIB.IsPaired() && GetArmed())
119 {
120 if (GetPairDevice() == item)
121 {
122 SetHealth("", "", 0.0);
123 }
124 }
125 }
126 }
127
128 override void OnArmed()
129 {
130 super.OnArmed();
131
134
135#ifdef DIAG_DEVELOPER
136#ifndef SERVER
137 // have to call this function a little later, after claymore transform has been finalized
138 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(DrawDamageZone, 500);
139#endif
140#endif
141 }
142
143 override void OnDisarmed(bool pWithTool)
144 {
145 super.OnDisarmed(pWithTool);
146
147#ifdef DIAG_DEVELOPER
148 RemoveDebugVisuals();
149#endif
150
151 SetDefused(pWithTool);
152 UnpairRemote();
153
154 if (pWithTool)
155 {
156 SetHealth("", "", 0.0);
157 }
158
161 }
162
163 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
164 {
165 super.OnPlacementComplete(player, position, orientation);
166
167 if (GetGame().IsServer())
168 {
170 if (rdt)
171 {
172 PairWithDevice(rdt);
173 Arm();
174 }
175 }
176 }
177
178 protected void UpdateVisuals()
179 {
180 if (GetArmed() || GetDefused())
181 {
182 ShowSelection(ANIM_PHASE_DEPLOYED);
183 HideSelection(ANIM_PHASE_PACKED);
184 if (GetOnViewIndexChanged())
185 {
186 GetOnViewIndexChanged().Invoke();
187 }
188 }
189 else
190 {
191 HideSelection(ANIM_PHASE_DEPLOYED);
192 ShowSelection(ANIM_PHASE_PACKED);
193 if (GetOnViewIndexChanged())
194 {
195 GetOnViewIndexChanged().Invoke();
196 }
197 }
198 }
199
200 protected void UpdateLED(ERemoteDetonatorLEDState pState, bool pForced = false)
201 {
202 if (pState != m_LastLEDState || pForced)
203 {
204 int selectionIdx = GetHiddenSelectionIndex(SELECTION_NAME_LED);
205
206 switch (pState)
207 {
209 SetObjectTexture(selectionIdx, RemoteDetonator.COLOR_LED_LIT);
210 break;
211 default:
212 SetObjectTexture(selectionIdx, RemoteDetonator.COLOR_LED_OFF);
213 break;
214 }
215
216 m_LastLEDState = pState;
217 }
218 }
219
220 override bool IsTakeable()
221 {
222 return !GetArmed() && super.IsTakeable();
223 }
224
225 override bool IsDeployable()
226 {
227 return true;
228 }
229
230 override void SetActions()
231 {
232 super.SetActions();
233
237 }
238
239 override int GetViewIndex()
240 {
241 if (MemoryPointExists("invView2"))
242 {
243 if (GetArmed())
244 {
245 return 1;
246 }
247 }
248
249 return 0;
250 }
251
252 override string GetDeploySoundset()
253 {
254 return "placeClaymore_SoundSet";
255 }
256
257 override string GetLoopDeploySoundset()
258 {
259 return "claymore_deploy_Soundset";
260 }
261
262 override string GetArmSoundset()
263 {
264 return "claymore_disarm_SoundSet";
265 }
266
267 override string GetDisarmSoundset()
268 {
269 return "claymore_disarm_SoundSet";
270 }
271
272 override void OnDebugSpawn()
273 {
274 RemoteDetonatorTrigger rdt = RemoteDetonatorTrigger.Cast(SpawnEntityOnGroundPos("RemoteDetonatorTrigger", GetPosition() + GetDirection() * 0.5));
275 PairWithDevice(rdt);
276 Arm();
277 }
278
279#ifdef DIAG_DEVELOPER
280 //================================================================
281 // DEBUG
282 //================================================================
283
284 protected Shape m_DamageZone;
285
286 override protected string GetDebugText()
287 {
288 string debug_output;
289 debug_output += string.Format("low net id: %1\n", m_RAIB.GetPairDeviceNetIdLow());
290 debug_output += string.Format("high net id: %1\n", m_RAIB.GetPairDeviceNetIdHigh());
291 debug_output += string.Format("pair device: %1\n", m_RAIB.GetPairDevice());
292
293 return debug_output;
294 }
295
296 protected void DrawDamageZone()
297 {
298 if (!DiagMenu.GetBool(DiagMenuIDs.WEAPON_CLAYMORE_DEBUG))
299 {
300 return;
301 }
302
303 auto game = GetGame();
304 string cfgPath = "CfgAmmo " + m_AmmoTypes[0];
305 float hitRange = game.ConfigGetFloat(cfgPath + " indirectHitRange");
306 float hitRangeMultiplier = game.ConfigGetFloat(cfgPath + " indirectHitRangeMultiplier");
307 float verticalAngle = game.ConfigGetFloat(cfgPath + " indirectHitAngle1");
308 float horizontalAngle = game.ConfigGetFloat(cfgPath + " indirectHitAngle2");
309 float range = hitRange * hitRangeMultiplier;
310 vector selfMatrix[4];
311
312 RemoveDebugVisuals();
313
314 GetTransform(selfMatrix);
315 m_DamageZone = Debug.DrawFrustum(horizontalAngle, verticalAngle, range);
316 m_DamageZone.SetMatrix(selfMatrix);
317 }
318
319 void RemoveDebugVisuals()
320 {
321 if ( m_DamageZone )
322 {
323 m_DamageZone.Destroy();
324 m_DamageZone = null;
325 }
326 }
327#endif
328}
329
330class ClaymoreMinePlacing : ClaymoreMine {}
ActionArmExplosiveCB ActionContinuousBaseCB ActionArmExplosive()
RepairTentActionReciveData m_DamageZone
void AddAction(typename actionName)
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 string GetDisarmSoundset()
override void OnArmed()
override string GetArmSoundset()
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:2
InventoryLocation.
static RemoteDetonatorTrigger SpawnInPlayerHands(notnull EntityAI pEntity, EntityAI deviceToPair=null)
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)
proto native CGame GetGame()
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
class JsonUndergroundAreaTriggerData GetPosition
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8
bool PairWithDevice(notnull ItemBase otherDevice)
Definition itembase.c:9601
string GetDebugText()
ERemoteDetonatorLEDState