DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
ClaymoreMine.c
Go to the documentation of this file.
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");
20
22 }
23
24 override void EOnInit(IEntity other, int extra)
25 {
27 }
28
29 override void EEKilled(Object killer)
30 {
31 super.EEKilled(killer);
32#ifdef DIAG_DEVELOPER
33#ifndef SERVER
34 RemoveDebugVisuals();
35#endif
36#endif
37 }
38
39 override void EEDelete(EntityAI parent)
40 {
41 super.EEDelete(parent);
42
43#ifdef DIAG_DEVELOPER
44#ifndef SERVER
45 RemoveDebugVisuals();
46#endif
47#endif
48 }
49
50 override protected void InitiateExplosion()
51 {
52 if (GetDefused())
53 {
54 return;
55 }
56
57 super.InitiateExplosion();
58 }
59
60 override void AfterStoreLoad()
61 {
62 super.AfterStoreLoad();
63
65 if (GetArmed())
66 {
68 }
69 }
70
72 {
73 super.OnVariablesSynchronized();
74
75 if (m_RAIB)
76 {
78 }
79
81 }
82
83 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
84 {
85 super.EEItemLocationChanged(oldLoc, newLoc);
86
87 if (m_RAIB)
88 {
89 m_RAIB.Pair();
90 }
91 }
92
93 override bool CanPutInCargo(EntityAI parent)
94 {
95 if (!super.CanPutInCargo(parent))
96 {
97 return false;
98 }
99
100 return IsTakeable();
101 }
102
103 override bool CanPutIntoHands(EntityAI parent)
104 {
105 if (!super.CanPutIntoHands(parent))
106 {
107 return false;
108 }
109
110 return IsTakeable();
111 }
112
113 override bool CanRemoveFromHands(EntityAI parent)
114 {
115 return IsTakeable();
116 }
117
119 {
120 return m_RAIB;
121 }
122
123 override void PairRemote(notnull EntityAI trigger)
124 {
125 m_RAIB.Pair(trigger);
126 }
127
129 {
130 return m_RAIB.GetPairDevice();
131 }
132
133 override bool CanBeDisarmed()
134 {
135 return GetArmed();
136 }
137
138 override void OnActivatedByItem(notnull ItemBase item)
139 {
140 if (GetGame().IsServer())
141 {
142 if (m_RAIB.IsPaired() && GetArmed())
143 {
144 if (GetPairDevice() == item)
145 {
146 SetHealth("", "", 0.0);
147 }
148 }
149 }
150 }
151
152 override void OnArmed()
153 {
154 super.OnArmed();
155
158
159#ifdef DIAG_DEVELOPER
160#ifndef SERVER
161 // have to call this function a little later, after claymore transform has been finalized
162 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(DrawDamageZone, 500);
163#endif
164#endif
165 }
166
167 override void OnDisarmed(bool pWithTool)
168 {
169 super.OnDisarmed(pWithTool);
170
171#ifdef DIAG_DEVELOPER
172 RemoveDebugVisuals();
173#endif
174
175 SetDefused(pWithTool);
176 UnpairRemote();
177
178 if (pWithTool)
179 {
180 SetHealth("", "", 0.0);
181 }
182
185 }
186
187 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
188 {
189 super.OnPlacementComplete(player, position, orientation);
190
191 if (GetGame().IsServer())
192 {
194 if (rdt)
195 {
196 PairWithDevice(rdt);
197 Arm();
198 }
199 }
200 }
201
202 protected void UpdateVisuals()
203 {
204 if (GetArmed() || GetDefused())
205 {
206 ShowSelection(ANIM_PHASE_DEPLOYED);
207 HideSelection(ANIM_PHASE_PACKED);
208 if (GetOnViewIndexChanged())
209 {
210 GetOnViewIndexChanged().Invoke();
211 }
212 }
213 else
214 {
215 HideSelection(ANIM_PHASE_DEPLOYED);
216 ShowSelection(ANIM_PHASE_PACKED);
217 if (GetOnViewIndexChanged())
218 {
219 GetOnViewIndexChanged().Invoke();
220 }
221 }
222 }
223
224 protected void UpdateLED(ERemoteDetonatorLEDState pState, bool pForced = false)
225 {
226 if (pState != m_LastLEDState || pForced)
227 {
228 int selectionIdx = GetHiddenSelectionIndex(SELECTION_NAME_LED);
229
230 switch (pState)
231 {
233 SetObjectTexture(selectionIdx, RemoteDetonator.COLOR_LED_LIT);
234 break;
235 default:
236 SetObjectTexture(selectionIdx, RemoteDetonator.COLOR_LED_OFF);
237 break;
238 }
239
240 m_LastLEDState = pState;
241 }
242 }
243
244 override bool IsTakeable()
245 {
246 return !GetArmed();
247 }
248
249 override bool IsDeployable()
250 {
251 return true;
252 }
253
254 override void SetActions()
255 {
256 super.SetActions();
257
261 }
262
263 override int GetViewIndex()
264 {
265 if (MemoryPointExists("invView2"))
266 {
267 if (GetArmed())
268 {
269 return 1;
270 }
271 }
272
273 return 0;
274 }
275
276 override void OnDebugSpawn()
277 {
278 RemoteDetonatorTrigger rdt = RemoteDetonatorTrigger.Cast(SpawnEntityOnGroundPos("RemoteDetonatorTrigger", GetPosition() + GetDirection() * 0.5));
279 PairWithDevice(rdt);
280 Arm();
281 }
282
283#ifdef DIAG_DEVELOPER
284 //================================================================
285 // DEBUG
286 //================================================================
287
288 protected Shape m_DamageZone;
289
290 override protected string GetDebugText()
291 {
292 string debug_output;
293 debug_output += string.Format("low net id: %1\n", m_RAIB.GetPairDeviceNetIdLow());
294 debug_output += string.Format("high net id: %1\n", m_RAIB.GetPairDeviceNetIdHigh());
295 debug_output += string.Format("pair device: %1\n", m_RAIB.GetPairDevice());
296
297 return debug_output;
298 }
299
300 protected void DrawDamageZone()
301 {
302 if (!DiagMenu.GetBool(DiagMenuIDs.WEAPON_CLAYMORE_DEBUG))
303 {
304 return;
305 }
306
307 auto game = GetGame();
308 string cfgPath = "CfgAmmo " + m_AmmoTypes[0];
309 float hitRange = game.ConfigGetFloat(cfgPath + " indirectHitRange");
310 float hitRangeMultiplier = game.ConfigGetFloat(cfgPath + " indirectHitRangeMultiplier");
311 float verticalAngle = game.ConfigGetFloat(cfgPath + " indirectHitAngle1");
312 float horizontalAngle = game.ConfigGetFloat(cfgPath + " indirectHitAngle2");
313 float range = hitRange * hitRangeMultiplier;
314 vector selfMatrix[4];
315
316 RemoveDebugVisuals();
317
318 GetTransform(selfMatrix);
319 m_DamageZone = Debug.DrawFrustum(horizontalAngle, verticalAngle, range);
320 m_DamageZone.SetMatrix(selfMatrix);
321 }
322
323 void RemoveDebugVisuals()
324 {
325 if ( m_DamageZone )
326 {
327 m_DamageZone.Destroy();
328 m_DamageZone = null;
329 }
330 }
331#endif
332}
333
334class ClaymoreMinePlacing : ClaymoreMine {}
PlaceObjectActionReciveData ActionReciveData ActionDeployObject()
RepairCarChassisActionReciveData m_DamageZone
void AddAction(typename actionName)
DiagMenuIDs
Definition EDiagMenuIDs.c:2
bool GetArmed()
void SetAmmoTypes(array< string > pAmmoTypes)
void SetParticleExplosion(int particle)
bool GetDefused()
override void UnpairRemote()
void Arm()
void SetParticleOrientation(vector local_ori)
protected void SetDefused(bool state)
void ExplosivesBase()
protected ref array< string > m_AmmoTypes
bool PairWithDevice(notnull ItemBase otherDevice)
Definition ItemBase.c:9225
string GetDebugText()
ERemoteDetonatorLEDState
class JsonUndergroundAreaTriggerData GetPosition
override ScriptCallQueue GetCallQueue(int call_category)
Definition DayZGame.c:1153
protected void UpdateVisuals()
override void OnDebugSpawn()
protected const string ANIM_PHASE_PACKED
Definition ClaymoreMine.c:3
protected const string SELECTION_NAME_LED
Definition ClaymoreMine.c:5
override EntityAI GetPairDevice()
override void OnArmed()
override bool CanBeDisarmed()
override int GetViewIndex()
override void EEKilled(Object killer)
override bool CanPutInCargo(EntityAI parent)
override void OnDisarmed(bool pWithTool)
protected const string ANIM_PHASE_DEPLOYED
Definition ClaymoreMine.c:4
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
void ClaymoreMine()
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
override void EEDelete(EntityAI parent)
override void PairRemote(notnull EntityAI trigger)
override void AfterStoreLoad()
override protected void InitiateExplosion()
override bool CanPutIntoHands(EntityAI parent)
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
override bool IsDeployable()
override void EOnInit(IEntity other, int extra)
override void OnActivatedByItem(notnull ItemBase item)
override bool IsTakeable()
override void OnVariablesSynchronized()
protected ref RemotelyActivatedItemBehaviour m_RAIB
Definition ClaymoreMine.c:7
protected void UpdateLED(ERemoteDetonatorLEDState pState, bool pForced=false)
protected ERemoteDetonatorLEDState m_LastLEDState
Definition ClaymoreMine.c:8
override bool CanRemoveFromHands(EntityAI parent)
override void SetActions()
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:314
InventoryLocation.
static const int CLAYMORE_EXPLOSION
static RemoteDetonatorTrigger SpawnInPlayerHands(notnull EntityAI pEntity)
proto void CallLater(func fn, int delay=0, bool repeat=false, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
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
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8