DayZ 1.24
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");
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)
31 GetGame().GetAnalyticsServer().OnEntityKilled(killer, this);
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 {
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 m_RAIB.OnVariableSynchronized();
81
83 UpdateVisuals(GetInventory().FindAttachment(slotId));
84 }
85
87 {
88 super.EEItemLocationChanged(oldLoc, newLoc);
89
90 if (m_RAIB)
91 m_RAIB.Pair();
92 }
93
95 {
97 GetInventory().GetCurrentInventoryLocation(il);
98 if (il.GetType() == InventoryLocationType.HANDS)
99 return false;
100
101 ClockBase timer = ClockBase.Cast(attachment);
102 if (timer && !timer.IsAlarmOn())
103 return false;
104
105 return !GetArmed();
106 }
107
109 {
111
112 switch (slotName)
113 {
114 case SLOT_TRIGGER:
115 return FindAttachmentBySlotName(slotName) != null;
116 break;
117 }
118
119 return true;
120 }
121
122 override bool IsTakeable()
123 {
124 return !GetArmed() && super.IsTakeable();
125 }
126
127 override bool IsDeployable()
128 {
129 return !GetArmed();
130 }
131
132 override void SetActions()
133 {
134 super.SetActions();
135
137 AddAction(ActionDeployObject);
138 }
139
140 override void OnWasAttached(EntityAI parent, int slot_id)
141 {
142 super.OnWasAttached(parent, slot_id);
143
144 m_UsedAsCharge = false;
145
146 if (parent && parent.IsInherited(ExplosivesBase))
147 m_UsedAsCharge = true;
148 }
149
150 override void OnWasDetached(EntityAI parent, int slot_id)
151 {
152 super.OnWasDetached(parent, slot_id);
153
154 if (parent && !parent.IsInherited(ExplosivesBase))
155 m_UsedAsCharge = false;
156 }
157
159 {
161 if (damageType == DamageType.EXPLOSION)
162 return !m_UsedAsCharge;
163
164 return true;
165 }
166
167 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
168 {
169 super.EEHealthLevelChanged(oldLevel, newLevel, zone);
170
171 if (GetGame().IsServer())
172 {
174 {
175 for (int attachmentIdx = 0; attachmentIdx < GetInventory().AttachmentCount(); attachmentIdx++)
176 {
177 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(attachmentIdx));
178 if (attachment)
179 {
180 attachment.UnlockFromParent();
181 attachment.SetHealth("", "", 0.0);
182 }
183 }
184
185 SetArmed(false);
186 SetTakeable(true);
187 }
188 }
189 }
190
195
197 {
198 m_RAIB.Pair(trigger);
199 }
200
201
203 {
204 return m_RAIB.GetPairDevice();
205 }
206
207 override bool CanBeArmed()
208 {
209 if (!super.CanBeArmed())
210 return false;
211
212 return HasLockedTriggerSlots() && !GetArmed();
213 }
214
215 override bool CanBeDisarmed()
216 {
217 return GetArmed();
218 }
219
221 {
222 if (GetGame().IsServer())
223 {
224 if (GetHealthLevel("") == GameConstants.STATE_RUINED)
225 return;
226
227 if (item == this)
228 {
229 SetHealth("", "", 0.0);
231 return;
232 }
233
234 if (m_RAIB.IsPaired() && GetArmed())
235 {
236 if (GetPairDevice() == item)
237 {
238 SetHealth("", "", 0.0);
240 }
241 }
242 }
243 }
244
245 override void OnDisarmed(bool pWithTool)
246 {
247 super.OnDisarmed(pWithTool);
248
249 UnpairRemote();
251
252 for (int att = 0; att < GetInventory().AttachmentCount(); att++)
253 {
254 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(att));
255 if (attachment)
256 {
257 attachment.UnlockFromParent();
258 if (attachment.IsInherited(RemoteDetonator))
259 {
260 if (pWithTool)
261 {
262 GetInventory().DropEntity(InventoryMode.SERVER, this, attachment);
263 attachment.SetHealth("", "", 0.0);
264 }
265 else
266 attachment.Delete();
267 }
268 }
269 }
270
272 SetTakeable(true);
273 }
274
275 override void EEItemAttached(EntityAI item, string slot_name)
276 {
277 super.EEItemAttached(item, slot_name);
278
279 if (slot_name == SLOT_TRIGGER)
281 }
282
283 override void EEItemDetached(EntityAI item, string slot_name)
284 {
285 super.EEItemDetached(item, slot_name);
286
287 if (slot_name == SLOT_TRIGGER)
289 }
290
291 override void UpdateLED(int pState)
292 {
294 if (receiver)
295 receiver.UpdateLED(pState, true);
296 }
297
299 {
300 Arm();
303
304 for (int att = 0; att < GetInventory().AttachmentCount(); att++)
305 {
306 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(att));
307 if (attachment)
308 attachment.LockToParent();
309 }
310 }
311
317
319 {
320 if (entity)
321 SetAnimationPhase(ANIM_PHASE_TRIGGER_REMOTE, 0.0);
322 else
323 SetAnimationPhase(ANIM_PHASE_TRIGGER_REMOTE, 1.0);
324 }
325
326
327 override string GetDeploySoundset()
328 {
329 return "placeImprovisedExplosive_SoundSet";
330 }
331
332 override string GetLoopDeploySoundset()
333 {
334 return "improvisedexplosive_deploy_SoundSet";
335 }
336
337 override protected bool UsesGlobalDeploy()
338 {
339 return true;
340 }
341}
342
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition Inventory.c:22
void AddAction(typename actionName)
PlayerSpawnPreset slotName
void UpdateVisuals()
DamageType
exposed from C++ (do not change)
DayZGame g_Game
Definition DayZGame.c:3528
void SetArmed(bool state)
void InitiateExplosion()
bool GetArmed()
void SetParticleExplosion(int particle)
override void UnpairRemote()
void Arm()
void SetAmmoType(string pAmmoType)
InventoryLocationType
types of Inventory Location
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
override void SetTakeable(bool pState)
Definition ItemBase.c:8905
RemoteDetonatorTrigger RemoteDetonator RemoteDetonatorReceiver()
ERemoteDetonatorLEDState
InventoryLocation.
provides access to slot configuration
static proto native owned string GetSlotName(int id)
converts slot_id to string
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
static const int PLASTIC_EXPLOSION
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 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()
ref RemotelyActivatedItemBehaviour m_RAIB
override bool HasLockedTriggerSlots()
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto native CGame GetGame()
const int STATE_RUINED
Definition constants.c:757