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;
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";
11 protected static const string SLOT_EXPLOSIVE_A =
"IEDExplosiveA";
12 protected static const string SLOT_EXPLOSIVE_B =
"IEDExplosiveB";
14 protected const int SLOT_EXPLOSIVE_COUNT = 2;
15 protected const string SLOT_EXPLOSIVES[SLOT_EXPLOSIVE_COUNT] = {
20 protected const int SLOT_TRIGGERS_COUNT = 3;
21 protected const string SLOT_TRIGGERS[SLOT_TRIGGERS_COUNT] = {
22 SLOT_TRIGGER_ALARM_CLOCK,
23 SLOT_TRIGGER_KITCHEN_TIMER,
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";
38 RegisterNetSyncVariableInt(
"m_RAIB.m_PairDeviceNetIdLow");
39 RegisterNetSyncVariableInt(
"m_RAIB.m_PairDeviceNetIdHigh");
42 override void EOnInit(
IEntity other,
int extra)
44 if (!
g_Game.IsMultiplayer())
48 override bool HasLockedTriggerSlots()
50 foreach (
string triggerSlot : SLOT_TRIGGERS)
51 return GetInventory().GetSlotLock(
InventorySlots.GetSlotIdFromString(triggerSlot));
56 override void LockTriggerSlots()
58 foreach (
string triggerSlotName : SLOT_TRIGGERS)
59 GetInventory().SetSlotLock(
InventorySlots.GetSlotIdFromString(triggerSlotName),
true);
62 override void UnlockTriggerSlots()
64 foreach (
string triggerSlotName : SLOT_TRIGGERS)
65 GetInventory().SetSlotLock(
InventorySlots.GetSlotIdFromString(triggerSlotName),
false);
68 override void LockExplosivesSlots()
70 foreach (
string explosiveSlotName : SLOT_EXPLOSIVES)
71 GetInventory().SetSlotLock(
InventorySlots.GetSlotIdFromString(explosiveSlotName),
true);
74 override void UnlockExplosivesSlots()
76 foreach (
string explosiveSlotName : SLOT_EXPLOSIVES)
77 GetInventory().SetSlotLock(
InventorySlots.GetSlotIdFromString(explosiveSlotName),
false);
82 if (!super.OnStoreLoad(ctx, version))
87 foreach (
string triggerSlotName : SLOT_TRIGGERS)
90 bool locked = GetInventory().GetSlotLock(slotId);
93 GetInventory().SetSlotLock(slotId,
false);
94 locked = GetInventory().GetSlotLock(slotId);
104 super.OnStoreSave(ctx);
109 override void OnVariablesSynchronized()
111 super.OnVariablesSynchronized();
115 m_RAIB.OnVariableSynchronized();
119 foreach (
string slotName : SLOT_TRIGGERS)
124 UpdateVisuals(trigger);
130 override void OnPlacementComplete(Man player,
vector position =
"0 0 0",
vector orientation =
"0 0 0")
132 super.OnPlacementComplete(player, position, orientation);
136 SetOrientation(
vector.Up);
142 super.EEItemLocationChanged(oldLoc, newLoc);
155 override void PairRemote(notnull
EntityAI trigger)
162 return m_RAIB.GetPairDevice();
165 override bool CanBeArmed()
170 if (!HasLockedTriggerSlots())
173 foreach (
string slotName : SLOT_EXPLOSIVES)
183 override bool CanBeDisarmed()
189 override bool CanReceiveAttachment(
EntityAI attachment,
int slotId)
192 GetInventory().GetCurrentInventoryLocation(il);
194 foreach (
string slotName : SLOT_TRIGGERS)
206 override bool CanDisplayAttachmentSlot(
int slot_id)
212 case SLOT_TRIGGER_ALARM_CLOCK:
213 case SLOT_TRIGGER_KITCHEN_TIMER:
214 case SLOT_TRIGGER_REMOTE:
215 return FindAttachmentBySlotName(
slotName) !=
null;
222 override bool IsTimerDetonable()
227 override bool IsTakeable()
229 return !
GetArmed() && super.IsTakeable();
232 override bool IsDeployable()
237 override void SetActions()
245 override void EEHealthLevelChanged(
int oldLevel,
int newLevel,
string zone)
247 super.EEHealthLevelChanged(oldLevel, newLevel, zone);
253 for (
int attachmentIdx = 0; attachmentIdx < GetInventory().AttachmentCount(); attachmentIdx++)
255 ItemBase attachment =
ItemBase.Cast(GetInventory().GetAttachmentFromIndex(attachmentIdx));
258 attachment.UnlockFromParent();
259 attachment.SetHealth(
"",
"", 0.0);
269 override void OnActivatedByItem(notnull
ItemBase item)
273 bool isTimeTriggered =
false;
276 for (
int attachmentIdx = 0; attachmentIdx < GetInventory().AttachmentCount(); attachmentIdx++)
278 ItemBase attachment =
ItemBase.Cast(GetInventory().GetAttachmentFromIndex(attachmentIdx));
280 attachmentsCache.Insert(attachment);
283 foreach (
ItemBase attachment1 : attachmentsCache)
284 attachment1.UnlockFromParent();
287 foreach (
ItemBase attachment2 : attachmentsCache)
291 isTimeTriggered =
true;
297 foreach (
ItemBase attachment3 : attachmentsCache)
301 vector dropExtents =
"0.5 0.0 0.5";
303 dropExtents[1] = 0.15;
305 GetInventory().DropEntityInBounds(
InventoryMode.SERVER,
this, attachment3, dropExtents, 0, 0, 0);
307 attachment3.SetTakeable(
false);
311 float delayFor = TIME_TRIGGER_INITIAL_DELAY_SECS;
314 delayFor = TIME_TRIGGER_INITIAL_DELAY_SECS + TIME_TRIGGER_TIMER_BASED_DELAY_SECS;
324 foreach (
ItemBase attachment4 : attachmentsCache)
326 if (attachment4.IsAnyInherited({RemoteDetonator, ClockBase}))
332 if (attachment4 && !attachment4.IsAnyInherited({RemoteDetonator, ClockBase}))
334 Param1<ItemBase> params =
new Param1<ItemBase>(attachment4);
336 delayFor += TIME_TRIGGER_DELAY_SECS;
343 override protected void InitiateExplosion();
345 override void EEItemAttached(
EntityAI item,
string slot_name)
347 super.EEItemAttached(item, slot_name);
351 case SLOT_TRIGGER_ALARM_CLOCK:
352 case SLOT_TRIGGER_KITCHEN_TIMER:
353 case SLOT_TRIGGER_REMOTE:
354 OnTriggerAttached(FindAttachmentBySlotName(slot_name));
359 override void EEItemDetached(
EntityAI item,
string slot_name)
361 super.EEItemDetached(item, slot_name);
365 case SLOT_TRIGGER_ALARM_CLOCK:
366 case SLOT_TRIGGER_KITCHEN_TIMER:
367 case SLOT_TRIGGER_REMOTE:
368 OnTriggerDetached(FindAttachmentBySlotName(slot_name));
373 override void OnBeforeDisarm()
375 UnlockExplosivesSlots();
378 override void OnDisarmed(
bool pWithTool)
380 super.OnDisarmed(pWithTool);
385 for (
int attachmentIdx = 0; attachmentIdx < GetInventory().AttachmentCount(); attachmentIdx++)
387 ItemBase attachment =
ItemBase.Cast(GetInventory().GetAttachmentFromIndex(attachmentIdx));
390 attachmentsCache.Insert(attachment);
394 foreach (
ItemBase attachment1 : attachmentsCache)
395 attachment1.UnlockFromParent();
398 foreach (
ItemBase attachment2 : attachmentsCache)
403 GetInventory().DropEntity(
InventoryMode.SERVER,
this, attachment2);
406 if (attachment2.IsInherited(RemoteDetonator))
410 GetInventory().DropEntity(
InventoryMode.SERVER,
this, attachment2);
411 attachment2.SetHealth(
"",
"", 0.0);
415 attachment2.Delete();
424 override void UpdateLED(
int pState)
428 receiver.UpdateLED(pState,
true);
431 protected void OnTriggerAttached(
EntityAI entity)
433 UpdateVisuals(entity);
440 LockExplosivesSlots();
443 protected void OnTriggerDetached(
EntityAI entity)
449 protected void UpdateVisuals(
EntityAI entity)
453 if (entity.IsInherited(RemoteDetonator))
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);
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);
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);
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);
484 override string GetDeploySoundset()
486 return "placeImprovisedExplosive_SoundSet";
489 override string GetLoopDeploySoundset()
491 return "improvisedexplosive_deploy_SoundSet";
494 override protected bool UsesGlobalDeploy()
503 debug_output +=
string.Format(
"low net id: %1\n",
m_RAIB.GetPairDeviceNetIdLow());
504 debug_output +=
string.Format(
"high net id: %1\n",
m_RAIB.GetPairDeviceNetIdHigh());
505 debug_output +=
string.Format(
"pair device: %1\n",
m_RAIB.GetPairDevice());