Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
plastic_explosive.c
Go to the documentation of this file.
1class Plastic_Explosive : ExplosivesBase
2{
3 protected const string SLOT_TRIGGER = "TriggerRemoteDetonator_Receiver";
4 protected const string ANIM_PHASE_TRIGGER_REMOTE = "TriggerRemote";
5
6 protected bool m_UsedAsCharge;
7
9
11 {
13
14 SetAmmoType("Plastic_Explosive_Ammo");
15 SetParticleExplosion(ParticleList.PLASTIC_EXPLOSION);
16
17 RegisterNetSyncVariableInt("m_RAIB.m_PairDeviceNetIdLow");
18 RegisterNetSyncVariableInt("m_RAIB.m_PairDeviceNetIdHigh");
19 }
20
21 override void EOnInit(IEntity other, int extra)
22 {
23 if (!g_Game.IsMultiplayer())
25 }
26
28 override void EEKilled(Object killer)
29 {
30 //analytics (behaviour from EntityAI)
32 }
33
34 override bool HasLockedTriggerSlots()
35 {
36 return GetInventory().GetSlotLock(InventorySlots.GetSlotIdFromString(SLOT_TRIGGER));
37 }
38
39 override void LockTriggerSlots()
40 {
41 GetInventory().SetSlotLock(InventorySlots.GetSlotIdFromString(SLOT_TRIGGER), true);
42 }
43
44 override void UnlockTriggerSlots()
45 {
46 GetInventory().SetSlotLock(InventorySlots.GetSlotIdFromString(SLOT_TRIGGER), false);
47 }
48
49 override bool OnStoreLoad(ParamsReadContext ctx, int version)
50 {
51 if (!super.OnStoreLoad(ctx, version))
52 return false;
53
54 if (version <= 134) // up to 1.21
55 {
56 int slotId = InventorySlots.GetSlotIdFromString(SLOT_TRIGGER);
57 bool locked = GetInventory().GetSlotLock(slotId);
58 while (locked)
59 {
60 GetInventory().SetSlotLock(slotId, false);
61 locked = GetInventory().GetSlotLock(slotId);
62 }
63 }
64
65 return true;
66 }
67
69 {
70 super.OnStoreSave(ctx);
71
73 }
74
76 {
77 super.OnVariablesSynchronized();
78
79 if (m_RAIB)
80 {
82 }
83
84 int slotId = InventorySlots.GetSlotIdFromString(SLOT_TRIGGER);
85 UpdateVisuals(GetInventory().FindAttachment(slotId));
86 }
87
88 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
89 {
90 super.EEItemLocationChanged(oldLoc, newLoc);
91
92 if (m_RAIB)
93 {
94 m_RAIB.Pair();
95 }
96 }
97
98 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
99 {
101 GetInventory().GetCurrentInventoryLocation(il);
102 if (il.GetType() != InventoryLocationType.GROUND)
103 {
104 return false;
105 }
106
107 ClockBase timer = ClockBase.Cast(attachment);
108 if (timer && !timer.IsAlarmOn())
109 {
110 return false;
111 }
112
113 return !GetArmed();
114 }
115
116 override bool CanDisplayAttachmentSlot(int slot_id)
117 {
118 string slotName = InventorySlots.GetSlotName(slot_id);
119
120 switch (slotName)
121 {
122 case SLOT_TRIGGER:
123 return FindAttachmentBySlotName(slotName) != null;
124 break;
125 }
126
127 return true;
128 }
129
130 override bool IsTakeable()
131 {
132 return !GetArmed() && super.IsTakeable();
133 }
134
135 override bool IsDeployable()
136 {
137 return !GetArmed();
138 }
139
140 override void SetActions()
141 {
142 super.SetActions();
143
146 }
147
148 override void OnWasAttached(EntityAI parent, int slot_id)
149 {
150 super.OnWasAttached(parent, slot_id);
151
152 m_UsedAsCharge = false;
153
154 if (parent && parent.IsInherited(ExplosivesBase))
155 {
156 m_UsedAsCharge = true;
157 }
158 }
159
160 override void OnWasDetached(EntityAI parent, int slot_id)
161 {
162 super.OnWasDetached(parent, slot_id);
163
164 if (parent && !parent.IsInherited(ExplosivesBase))
165 {
166 m_UsedAsCharge = false;
167 }
168 }
169
170 override bool EEOnDamageCalculated(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
171 {
173 if (damageType == DamageType.EXPLOSION)
174 {
175 return !m_UsedAsCharge;
176 }
177
178 return true;
179 }
180
181 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
182 {
183 super.EEHealthLevelChanged(oldLevel, newLevel, zone);
184
185 if (GetGame().IsServer())
186 {
187 if (newLevel == GameConstants.STATE_RUINED)
188 {
189 for (int attachmentIdx = 0; attachmentIdx < GetInventory().AttachmentCount(); attachmentIdx++)
190 {
191 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(attachmentIdx));
192 if (attachment)
193 {
194 attachment.UnlockFromParent();
195 attachment.SetHealth("", "", 0.0);
196 }
197 }
198
199 SetArmed(false);
200 SetTakeable(true);
201 }
202 }
203 }
204
209
210 override void PairRemote(notnull EntityAI trigger)
211 {
212 m_RAIB.Pair(trigger);
213 }
214
215
217 {
218 return m_RAIB.GetPairDevice();
219 }
220
221 override bool CanBeArmed()
222 {
223 if (!super.CanBeArmed())
224 {
225 return false;
226 }
227
228 return HasLockedTriggerSlots() && !GetArmed();
229 }
230
231 override bool CanBeDisarmed()
232 {
233 return GetArmed();
234 }
235
236 override void OnActivatedByItem(notnull ItemBase item)
237 {
238 if (GetGame().IsServer())
239 {
240 if (GetHealthLevel("") == GameConstants.STATE_RUINED)
241 {
242 return;
243 }
244
245 if (item == this)
246 {
247 SetHealth("", "", 0.0);
249 return;
250 }
251
252 if (m_RAIB.IsPaired() && GetArmed())
253 {
254 if (GetPairDevice() == item)
255 {
256 SetHealth("", "", 0.0);
258 }
259 }
260 }
261 }
262
263 override void OnDisarmed(bool pWithTool)
264 {
265 super.OnDisarmed(pWithTool);
266
267 UnpairRemote();
268 UpdateVisuals(null);
269
270 for (int att = 0; att < GetInventory().AttachmentCount(); att++)
271 {
272 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(att));
273 if (attachment)
274 {
275 attachment.UnlockFromParent();
276 if (attachment.IsInherited(RemoteDetonator))
277 {
278 if (pWithTool)
279 {
280 GetInventory().DropEntity(InventoryMode.SERVER, this, attachment);
281 attachment.SetHealth("", "", 0.0);
282 }
283 else
284 {
285 attachment.Delete();
286 }
287 }
288 }
289 }
290
292 SetTakeable(true);
293 }
294
295 override void EEItemAttached(EntityAI item, string slot_name)
296 {
297 super.EEItemAttached(item, slot_name);
298
299 if (slot_name == SLOT_TRIGGER)
300 OnTriggerAttached(item);
301 }
302
303 override void EEItemDetached(EntityAI item, string slot_name)
304 {
305 super.EEItemDetached(item, slot_name);
306
307 if (slot_name == SLOT_TRIGGER)
308 OnTriggerDetached(item);
309 }
310
311 override void UpdateLED(int pState)
312 {
313 RemoteDetonatorReceiver receiver = RemoteDetonatorReceiver.Cast(FindAttachmentBySlotName(SLOT_TRIGGER));
314 if (receiver)
315 {
316 receiver.UpdateLED(pState, true);
317 }
318 }
319
320 protected void OnTriggerAttached(EntityAI entity)
321 {
322 Arm();
323 UpdateVisuals(entity);
325
326 for (int att = 0; att < GetInventory().AttachmentCount(); att++)
327 {
328 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(att));
329 if (attachment)
330 {
331 attachment.LockToParent();
332 }
333 }
334 }
335
336 protected void OnTriggerDetached(EntityAI entity)
337 {
338 UpdateVisuals(null);
340 }
341
342 protected void UpdateVisuals(EntityAI entity)
343 {
344 if (entity)
345 {
346 SetAnimationPhase(ANIM_PHASE_TRIGGER_REMOTE, 0.0);
347 }
348 else
349 {
350 SetAnimationPhase(ANIM_PHASE_TRIGGER_REMOTE, 1.0);
351 }
352 }
353
354 override string GetDeploySoundset()
355 {
356 return "placePlasticExplosive_SoundSet";
357 }
358
359 override string GetLoopDeploySoundset()
360 {
361 return "plasticexplosive_deploy_SoundSet";
362 }
363
364 override string GetArmSoundset()
365 {
366 return "ImprovisedExplosive_disarm_SoundSet";
367 }
368
369 override string GetDisarmSoundset()
370 {
371 return "ImprovisedExplosive_disarm_SoundSet";
372 }
373
374}
375
376class Plastic_Explosive_Placing : Plastic_Explosive {}
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition inventory.c:22
void AddAction(typename actionName)
PlayerSpawnPreset slotName
void OnEntityKilled(Object killer, EntityAI target)
AnalyticsManagerServer GetAnalyticsServer()
Definition game.c:1563
InventoryLocation.
provides access to slot configuration
override bool EEOnDamageCalculated(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
override void OnStoreSave(ParamsWriteContext ctx)
override void EEItemAttached(EntityAI item, string slot_name)
override void UpdateLED(int pState)
void OnTriggerDetached(EntityAI entity)
override EntityAI GetPairDevice()
override bool CanBeArmed()
override void OnActivatedByItem(notnull ItemBase item)
override void OnDisarmed(bool pWithTool)
override void LockTriggerSlots()
override bool CanBeDisarmed()
void OnTriggerAttached(EntityAI entity)
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
override void PairRemote(notnull EntityAI trigger)
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
override string GetDisarmSoundset()
override bool IsTakeable()
override void EOnInit(IEntity other, int extra)
override void OnVariablesSynchronized()
void UpdateVisuals(EntityAI entity)
override void EEKilled(Object killer)
special behaviour - do not call super from ExplosivesBase
const string ANIM_PHASE_TRIGGER_REMOTE
override bool OnStoreLoad(ParamsReadContext ctx, int version)
override void OnWasDetached(EntityAI parent, int slot_id)
override bool CanDisplayAttachmentSlot(int slot_id)
override void EEItemDetached(EntityAI item, string slot_name)
override bool IsDeployable()
override string GetDeploySoundset()
override string GetLoopDeploySoundset()
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
override void OnWasAttached(EntityAI parent, int slot_id)
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
override void UnlockTriggerSlots()
const string SLOT_TRIGGER
override void SetActions()
override string GetArmSoundset()
ref RemotelyActivatedItemBehaviour m_RAIB
override bool HasLockedTriggerSlots()
Serialization general interface. Serializer API works with:
Definition serializer.c:56
void UpdateVisuals()
DamageType
exposed from C++ (do not change)
DayZGame g_Game
Definition dayzgame.c:3868
void SetArmed(bool state)
void InitiateExplosion()
bool GetArmed()
void SetParticleExplosion(int particle)
override void UnpairRemote()
void Arm()
void SetAmmoType(string pAmmoType)
proto native CGame GetGame()
InventoryLocationType
types of Inventory Location
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
override void SetTakeable(bool pState)
Definition itembase.c:9184
RemoteDetonatorTrigger RemoteDetonator RemoteDetonatorReceiver()
ERemoteDetonatorLEDState