DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ImprovisedExplosive.c
См. документацию.
2{
3 protected const float TIME_TRIGGER_INITIAL_DELAY_SECS = 0.1;
4 protected const float TIME_TRIGGER_TIMER_BASED_DELAY_SECS = 1.0;
5 protected const float TIME_TRIGGER_DELAY_SECS = 0.3;
6
7 protected static const string SLOT_TRIGGER_ALARM_CLOCK = "TriggerAlarmClock";
8 protected static const string SLOT_TRIGGER_KITCHEN_TIMER = "TriggerKitchenTimer";
9 protected static const string SLOT_TRIGGER_REMOTE = "TriggerRemoteDetonator_Receiver";
10
11 protected static const string SLOT_EXPLOSIVE_A = "IEDExplosiveA";
12 protected static const string SLOT_EXPLOSIVE_B = "IEDExplosiveB";
13
14 protected const int SLOT_EXPLOSIVE_COUNT = 2;
19
20 protected const int SLOT_TRIGGERS_COUNT = 3;
26
27 protected const string ANIM_PHASE_TRIGGER_EMPTY = "TriggerEmpty";
28 protected const string ANIM_PHASE_TRIGGER_TIMER = "TriggerTimer";
29 protected const string ANIM_PHASE_TRIGGER_CLOCK = "TriggerClock";
30 protected const string ANIM_PHASE_TRIGGER_REMOTE = "TriggerRemote";
31
33
35 {
37
38 RegisterNetSyncVariableInt("m_RAIB.m_PairDeviceNetIdLow");
39 RegisterNetSyncVariableInt("m_RAIB.m_PairDeviceNetIdHigh");
40 }
41
42 override void EOnInit(IEntity other, int extra)
43 {
44 if (!g_Game.IsMultiplayer())
46 }
47
48 override bool HasLockedTriggerSlots()
49 {
50 foreach (string triggerSlot : SLOT_TRIGGERS)
51 return GetInventory().GetSlotLock(InventorySlots.GetSlotIdFromString(triggerSlot));
52
53 return false;
54 }
55
56 override void LockTriggerSlots()
57 {
58 foreach (string triggerSlotName : SLOT_TRIGGERS)
59 GetInventory().SetSlotLock(InventorySlots.GetSlotIdFromString(triggerSlotName), true);
60 }
61
62 override void UnlockTriggerSlots()
63 {
64 foreach (string triggerSlotName : SLOT_TRIGGERS)
65 GetInventory().SetSlotLock(InventorySlots.GetSlotIdFromString(triggerSlotName), false);
66 }
67
68 override void LockExplosivesSlots()
69 {
70 foreach (string explosiveSlotName : SLOT_EXPLOSIVES)
71 GetInventory().SetSlotLock(InventorySlots.GetSlotIdFromString(explosiveSlotName), true);
72 }
73
74 override void UnlockExplosivesSlots()
75 {
76 foreach (string explosiveSlotName : SLOT_EXPLOSIVES)
77 GetInventory().SetSlotLock(InventorySlots.GetSlotIdFromString(explosiveSlotName), false);
78 }
79
80 override bool OnStoreLoad(ParamsReadContext ctx, int version)
81 {
82 if (!super.OnStoreLoad(ctx, version))
83 return false;
84
85 if (version <= 134) // up to 1.21
86 {
87 foreach (string triggerSlotName : SLOT_TRIGGERS)
88 {
89 int slotId = InventorySlots.GetSlotIdFromString(triggerSlotName);
90 bool locked = GetInventory().GetSlotLock(slotId);
91 while (locked)
92 {
93 GetInventory().SetSlotLock(slotId, false);
94 locked = GetInventory().GetSlotLock(slotId);
95 }
96 }
97 }
98
99 return true;
100 }
101
103 {
104 super.OnStoreSave(ctx);
105
107 }
108
110 {
111 super.OnVariablesSynchronized();
112
113 if (m_RAIB)
114 {
115 m_RAIB.OnVariableSynchronized();
116 }
117
118
119 foreach (string slotName : SLOT_TRIGGERS)
120 {
121 EntityAI trigger = GetInventory().FindAttachmentByName(slotName);
122 if (trigger)
123 {
124 UpdateVisuals(trigger);
125 break;
126 }
127 }
128 }
129
130 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
131 {
132 super.OnPlacementComplete(player, position, orientation);
133
134 if (g_Game.IsServer())
135 {
136 SetOrientation(vector.Up);
137 }
138 }
139
140 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
141 {
142 super.EEItemLocationChanged(oldLoc, newLoc);
143
144 if (m_RAIB)
145 {
146 m_RAIB.Pair();
147 }
148 }
149
154
155 override void PairRemote(notnull EntityAI trigger)
156 {
157 m_RAIB.Pair(trigger);
158 }
159
161 {
162 return m_RAIB.GetPairDevice();
163 }
164
165 override bool CanBeArmed()
166 {
167 if (GetArmed())
168 return false;
169
171 return false;
172
173 foreach (string slotName : SLOT_EXPLOSIVES)
174 {
175 EntityAI explosive = GetInventory().FindAttachmentByName(slotName);
176 if (explosive)
177 return true;
178 }
179
180 return false;
181 }
182
183 override bool CanBeDisarmed()
184 {
185 return true;
186 }
187
188
189 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
190 {
192 GetInventory().GetCurrentInventoryLocation(il);
193
194 foreach (string slotName : SLOT_TRIGGERS)
195 {
197 {
198 if (il.GetType() == InventoryLocationType.HANDS)
199 return false;
200 }
201 }
202
203 return !GetArmed();
204 }
205
206 override bool CanDisplayAttachmentSlot(int slot_id)
207 {
208 string slotName = InventorySlots.GetSlotName(slot_id);
209
210 switch (slotName)
211 {
215 return FindAttachmentBySlotName(slotName) != null;
216 break;
217 }
218
219 return true;
220 }
221
222 override bool IsTimerDetonable()
223 {
224 return true;
225 }
226
227 override bool IsTakeable()
228 {
229 return !GetArmed() && super.IsTakeable();
230 }
231
232 override bool IsDeployable()
233 {
234 return !GetArmed();
235 }
236
237 override void SetActions()
238 {
239 super.SetActions();
240
243 }
244
245 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
246 {
247 super.EEHealthLevelChanged(oldLevel, newLevel, zone);
248
249 if (g_Game.IsServer())
250 {
251 if (newLevel == GameConstants.STATE_RUINED)
252 {
253 for (int attachmentIdx = 0; attachmentIdx < GetInventory().AttachmentCount(); attachmentIdx++)
254 {
255 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(attachmentIdx));
256 if (attachment)
257 {
258 attachment.UnlockFromParent();
259 attachment.SetHealth("", "", 0.0);
260 }
261 }
262
263 SetArmed(false);
264 SetTakeable(true);
265 }
266 }
267 }
268
269 override void OnActivatedByItem(notnull ItemBase item)
270 {
271 if (g_Game.IsServer() && GetArmed())
272 {
273 bool isTimeTriggered = false;
274
275 array<ItemBase> attachmentsCache = new array<ItemBase>();
276 for (int attachmentIdx = 0; attachmentIdx < GetInventory().AttachmentCount(); attachmentIdx++)
277 {
278 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(attachmentIdx));
279 if (attachment)
280 attachmentsCache.Insert(attachment);
281 }
282
283 foreach (ItemBase attachment1 : attachmentsCache)
284 attachment1.UnlockFromParent();
285
287 foreach (ItemBase attachment2 : attachmentsCache)
288 {
289 if (attachment2.IsInherited(ClockBase))
290 {
291 isTimeTriggered = true;
292 break;
293 }
294 }
295
297 foreach (ItemBase attachment3 : attachmentsCache)
298 {
299 if (attachment3)
300 {
301 vector dropExtents = "0.5 0.0 0.5";
302 if (isTimeTriggered)
303 dropExtents[1] = 0.15;
304
305 GetInventory().DropEntityInBounds(InventoryMode.SERVER, this, attachment3, dropExtents, 0, 0, 0);
306 attachment3.SetAnimationPhase(ANIM_PHASE_VISIBILITY, 1.0);
307 attachment3.SetTakeable(false);
308 }
309 }
310
311 float delayFor = TIME_TRIGGER_INITIAL_DELAY_SECS;
312 if (isTimeTriggered)
313 {
316 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(DeleteSafe, delayFor * 1000, false);
317 }
318 else
319 {
320 DeleteSafe();
321 }
322
324 foreach (ItemBase attachment4 : attachmentsCache)
325 {
326 if (attachment4.IsAnyInherited({RemoteDetonator, ClockBase}))
327 {
329 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(attachment4.DeleteSafe, delayFor * 1000, false);
330 }
331
332 if (attachment4 && !attachment4.IsAnyInherited({RemoteDetonator, ClockBase}))
333 {
334 Param1<ItemBase> params = new Param1<ItemBase>(attachment4);
335 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLaterByName(attachment4, "OnActivatedByItem", delayFor * 1000, false, params);
336 delayFor += TIME_TRIGGER_DELAY_SECS;
337 }
338 }
339 }
340 }
341
343 override protected void InitiateExplosion();
344
345 override void EEItemAttached(EntityAI item, string slot_name)
346 {
347 super.EEItemAttached(item, slot_name);
348
349 switch (slot_name)
350 {
354 OnTriggerAttached(FindAttachmentBySlotName(slot_name));
355 break;
356 }
357 }
358
359 override void EEItemDetached(EntityAI item, string slot_name)
360 {
361 super.EEItemDetached(item, slot_name);
362
363 switch (slot_name)
364 {
368 OnTriggerDetached(FindAttachmentBySlotName(slot_name));
369 break;
370 }
371 }
372
373 override void OnBeforeDisarm()
374 {
376 }
377
378 override void OnDisarmed(bool pWithTool)
379 {
380 super.OnDisarmed(pWithTool);
381
382 UnpairRemote();
383
384 array<ItemBase> attachmentsCache = new array<ItemBase>();
385 for (int attachmentIdx = 0; attachmentIdx < GetInventory().AttachmentCount(); attachmentIdx++)
386 {
387 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(attachmentIdx));
388 if (attachment)
389 {
390 attachmentsCache.Insert(attachment);
391 }
392 }
393
394 foreach (ItemBase attachment1 : attachmentsCache)
395 attachment1.UnlockFromParent();
396
398 foreach (ItemBase attachment2 : attachmentsCache)
399 {
400 if (attachment2.IsInherited(ClockBase))
401 {
402 if (pWithTool)
403 GetInventory().DropEntity(InventoryMode.SERVER, this, attachment2);
404 }
405
406 if (attachment2.IsInherited(RemoteDetonator))
407 {
408 if (pWithTool)
409 {
410 GetInventory().DropEntity(InventoryMode.SERVER, this, attachment2);
411 attachment2.SetHealth("", "", 0.0);
412 }
413 else
414 {
415 attachment2.Delete();
416 }
417 }
418 }
419
421 SetTakeable(true);
422 }
423
424 override void UpdateLED(int pState)
425 {
426 RemoteDetonatorReceiver receiver = RemoteDetonatorReceiver.Cast(FindAttachmentBySlotName(SLOT_TRIGGER_REMOTE));
427 if (receiver)
428 receiver.UpdateLED(pState, true);
429 }
430
431 protected void OnTriggerAttached(EntityAI entity)
432 {
433 UpdateVisuals(entity);
435
436 if (entity.IsInherited(ClockBase))
437 Arm();
438
441 }
442
443 protected void OnTriggerDetached(EntityAI entity)
444 {
445 UpdateVisuals(null);
447 }
448
449 protected void UpdateVisuals(EntityAI entity)
450 {
451 if (entity)
452 {
453 if (entity.IsInherited(RemoteDetonator))
454 {
455 SetAnimationPhase(ANIM_PHASE_TRIGGER_EMPTY, 1.0);
456 SetAnimationPhase(ANIM_PHASE_TRIGGER_TIMER, 1.0);
457 SetAnimationPhase(ANIM_PHASE_TRIGGER_CLOCK, 1.0);
458 SetAnimationPhase(ANIM_PHASE_TRIGGER_REMOTE, 0.0);
459 }
460 else if (entity.IsInherited(AlarmClock_ColorBase))
461 {
462 SetAnimationPhase(ANIM_PHASE_TRIGGER_EMPTY, 1.0);
463 SetAnimationPhase(ANIM_PHASE_TRIGGER_TIMER, 1.0);
464 SetAnimationPhase(ANIM_PHASE_TRIGGER_CLOCK, 0.0);
465 SetAnimationPhase(ANIM_PHASE_TRIGGER_REMOTE, 1.0);
466 }
467 else if (entity.IsInherited(KitchenTimer))
468 {
469 SetAnimationPhase(ANIM_PHASE_TRIGGER_EMPTY, 1.0);
470 SetAnimationPhase(ANIM_PHASE_TRIGGER_TIMER, 0.0);
471 SetAnimationPhase(ANIM_PHASE_TRIGGER_CLOCK, 1.0);
472 SetAnimationPhase(ANIM_PHASE_TRIGGER_REMOTE, 1.0);
473 }
474 }
475 else
476 {
477 SetAnimationPhase(ANIM_PHASE_TRIGGER_EMPTY, 0.0);
478 SetAnimationPhase(ANIM_PHASE_TRIGGER_TIMER, 1.0);
479 SetAnimationPhase(ANIM_PHASE_TRIGGER_CLOCK, 1.0);
480 SetAnimationPhase(ANIM_PHASE_TRIGGER_REMOTE, 1.0);
481 }
482 }
483
484 override string GetDeploySoundset()
485 {
486 return "placeImprovisedExplosive_SoundSet";
487 }
488
489 override string GetLoopDeploySoundset()
490 {
491 return "improvisedexplosive_deploy_SoundSet";
492 }
493
494 override string GetArmSoundset()
495 {
496 return "ImprovisedExplosive_disarm_SoundSet";
497 }
498
499 override string GetDisarmSoundset()
500 {
501 return "ImprovisedExplosive_disarm_SoundSet";
502 }
503
504
505#ifdef DEVELOPER
506 override protected string GetDebugText()
507 {
508 string debug_output;
509 debug_output += string.Format("low net id: %1\n", m_RAIB.GetPairDeviceNetIdLow());
510 debug_output += string.Format("high net id: %1\n", m_RAIB.GetPairDeviceNetIdHigh());
511 debug_output += string.Format("pair device: %1\n", m_RAIB.GetPairDevice());
512
513 return debug_output;
514 }
515#endif
516}
517
518class ImprovisedExplosivePlacing : ImprovisedExplosive {}
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
PlaceObjectActionReciveData ActionReciveData ActionDeployObject()
Определения ActionDeployObject.c:9
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
PlayerSpawnPreset slotName
void ClockBase()
Определения ClockBase.c:27
void UpdateVisuals()
Определения Construction.c:188
DayZGame g_Game
Определения DayZGame.c:3942
void SetArmed(bool state)
Определения ExplosivesBase.c:279
bool GetArmed()
Определения ExplosivesBase.c:274
const string ANIM_PHASE_VISIBILITY
Определения ExplosivesBase.c:22
override void UnpairRemote()
Определения ExplosivesBase.c:127
void Arm()
Определения ExplosivesBase.c:245
void ExplosivesBase()
Определения ExplosivesBase.c:42
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
override void SetTakeable(bool pState)
Определения ItemBase.c:9284
string GetDebugText()
Определения ModifierBase.c:71
RemoteDetonatorTrigger RemoteDetonator RemoteDetonatorReceiver()
Определения RemoteDetonator.c:227
ERemoteDetonatorLEDState
Определения RemoteDetonator.c:2
ref RemotelyActivatedItemBehaviour m_RAIB
Определения RemoteDetonator.c:231
Определения AlarmClock.c:2
Определения EnEntity.c:165
const string ANIM_PHASE_TRIGGER_REMOTE
Определения ImprovisedExplosive.c:30
override void OnBeforeDisarm()
Определения ImprovisedExplosive.c:373
override void UnlockExplosivesSlots()
Определения ImprovisedExplosive.c:74
const float TIME_TRIGGER_DELAY_SECS
Определения ImprovisedExplosive.c:5
const int SLOT_EXPLOSIVE_COUNT
Определения ImprovisedExplosive.c:14
override void LockExplosivesSlots()
Определения ImprovisedExplosive.c:68
void OnTriggerDetached(EntityAI entity)
Определения ImprovisedExplosive.c:443
const string ANIM_PHASE_TRIGGER_CLOCK
Определения ImprovisedExplosive.c:29
override string GetDisarmSoundset()
Определения ImprovisedExplosive.c:499
override void SetActions()
Определения ImprovisedExplosive.c:237
static const string SLOT_TRIGGER_ALARM_CLOCK
Определения ImprovisedExplosive.c:7
override bool HasLockedTriggerSlots()
Определения ImprovisedExplosive.c:48
static const string SLOT_EXPLOSIVE_A
Определения ImprovisedExplosive.c:11
static const string SLOT_TRIGGER_KITCHEN_TIMER
Определения ImprovisedExplosive.c:8
void UpdateVisuals(EntityAI entity)
Определения ImprovisedExplosive.c:449
const float TIME_TRIGGER_INITIAL_DELAY_SECS
Определения ImprovisedExplosive.c:3
override void OnVariablesSynchronized()
Определения ImprovisedExplosive.c:109
override bool IsDeployable()
Определения ImprovisedExplosive.c:232
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Определения ImprovisedExplosive.c:245
const float TIME_TRIGGER_TIMER_BASED_DELAY_SECS
Определения ImprovisedExplosive.c:4
const string SLOT_EXPLOSIVES[SLOT_EXPLOSIVE_COUNT]
Определения ImprovisedExplosive.c:15
override void PairRemote(notnull EntityAI trigger)
Определения ImprovisedExplosive.c:155
const string SLOT_TRIGGERS[SLOT_TRIGGERS_COUNT]
Определения ImprovisedExplosive.c:21
override void EEItemDetached(EntityAI item, string slot_name)
Определения ImprovisedExplosive.c:359
override void EEItemAttached(EntityAI item, string slot_name)
Определения ImprovisedExplosive.c:345
const int SLOT_TRIGGERS_COUNT
Определения ImprovisedExplosive.c:20
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Определения ImprovisedExplosive.c:189
const string ANIM_PHASE_TRIGGER_EMPTY
Определения ImprovisedExplosive.c:27
override void UnlockTriggerSlots()
Определения ImprovisedExplosive.c:62
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения ImprovisedExplosive.c:140
override string GetLoopDeploySoundset()
Определения ImprovisedExplosive.c:489
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Определения ImprovisedExplosive.c:130
override void EOnInit(IEntity other, int extra)
Определения ImprovisedExplosive.c:42
static const string SLOT_EXPLOSIVE_B
Определения ImprovisedExplosive.c:12
const string ANIM_PHASE_TRIGGER_TIMER
Определения ImprovisedExplosive.c:28
static const string SLOT_TRIGGER_REMOTE
Определения ImprovisedExplosive.c:9
void ImprovisedExplosive()
Определения ImprovisedExplosive.c:34
ref RemotelyActivatedItemBehaviour m_RAIB
Определения ImprovisedExplosive.c:32
override bool IsTimerDetonable()
Определения ImprovisedExplosive.c:222
void InitiateExplosion()
not exploding itself, rely on attached explosives
override void LockTriggerSlots()
Определения ImprovisedExplosive.c:56
override bool CanDisplayAttachmentSlot(int slot_id)
Определения ImprovisedExplosive.c:206
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
Определения ImprovisedExplosive.c:150
override bool IsTakeable()
Определения ImprovisedExplosive.c:227
override void OnStoreSave(ParamsWriteContext ctx)
Определения ImprovisedExplosive.c:102
override string GetArmSoundset()
Определения ImprovisedExplosive.c:494
override string GetDeploySoundset()
Определения ImprovisedExplosive.c:484
override bool CanBeArmed()
Определения ImprovisedExplosive.c:165
void OnTriggerAttached(EntityAI entity)
Определения ImprovisedExplosive.c:431
override void OnDisarmed(bool pWithTool)
Определения ImprovisedExplosive.c:378
override void UpdateLED(int pState)
Определения ImprovisedExplosive.c:424
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения ImprovisedExplosive.c:80
override void OnActivatedByItem(notnull ItemBase item)
Определения ImprovisedExplosive.c:269
override bool CanBeDisarmed()
Определения ImprovisedExplosive.c:183
override EntityAI GetPairDevice()
Определения ImprovisedExplosive.c:160
proto native int GetType()
returns type of InventoryLocation
InventoryLocation.
Определения InventoryLocation.c:30
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
static proto native owned string GetSlotName(int id)
converts slot_id to string
provides access to slot configuration
Определения InventorySlots.c:6
Определения KitchenTimer.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static const vector Up
Определения EnConvert.c:120
Определения EnConvert.c:119
Serializer ParamsReadContext
Определения gameplay.c:15
Serializer ParamsWriteContext
Определения gameplay.c:16
const int STATE_RUINED
Определения 3_Game/DayZ/constants.c:851
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
Определения 3_Game/DayZ/tools/tools.c:8