DayZ 1.24
Loading...
Searching...
No Matches
TrapBase.c File Reference

Go to the source code of this file.

Enumerations

enum  SoundTypeTrap { ACTIVATING = 5 }
 

Functions

void TrapBase ()
 
void ~TrapBase ()
 
void OnUpdate (EntityAI victim)
 
TrapTrigger GetTrapTrigger ()
 
override void OnVariablesSynchronized ()
 this event is called all variables are synchronized on client
 
override void EEDelete (EntityAI parent)
 
override void OnStoreSave (ParamsWriteContext ctx)
 
override bool OnStoreLoad (ParamsReadContext ctx, int version)
 
bool IsActive ()
 
bool IsInactive ()
 
override bool IsTakeable ()
 
bool IsActivable ()
 
bool IsPlaceable ()
 
bool IsPlaceableAtPosition (vector position)
 
void Disarm ()
 
void OnDisarm ()
 also called from RPC on client
 
void SnapOnObject (EntityAI victim)
 
void RemoveFromObject (EntityAI victim)
 
void OnSteppedOn (EntityAI victim)
 
void OnSteppedOut (EntityAI victim)
 
void Synch (EntityAI victim)
 keeping "step" here for consistency only
 
override void OnRPC (PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
 
void RefreshState ()
 
void SetupTrap ()
 
void SetupTrapPlayer (PlayerBase player, bool set_position=true)
 
void AddDefect ()
 
void SetActive ()
 
void OnActivate ()
 HumanCommandScript fully scriptable command.
 
void StartActivate (PlayerBase player)
 
void StartDeactivate (PlayerBase player)
 
void SetInactive (bool stop_timer=true)
 
void CreateTrigger ()
 
void DeleteTrigger ()
 
void DeferredEnableTrigger ()
 
override void OnItemLocationChanged (EntityAI old_owner, EntityAI new_owner)
 
override void EEItemAttached (EntityAI item, string slot_name)
 
override void EEItemDetached (EntityAI item, string slot_name)
 
override void OnPlacementComplete (Man player, vector position="0 0 0", vector orientation="0 0 0")
 
override bool CanPutInCargo (EntityAI parent)
 
override bool CanPutIntoHands (EntityAI parent)
 
override bool CanRemoveFromHands (EntityAI parent)
 
override bool CanBePlaced (Man player, vector position)
 
bool CanBeClapped ()
 DEPRECATED Set if trap can be disarmed using ActionClapBearTrapWithThisItem.
 
bool CanBeDisarmed ()
 
void SetDisarmed (bool disarmed)
 DEPRECATED.
 
bool GetDisarmed ()
 DEPRECATED.
 
void PlayDeployLoopSound ()
 
void StopDeployLoopSound ()
 
override void SetActions ()
 
EntityAI GetClosestCarWheel (EntityAI victim)
 
void DamageClothing (PlayerBase player)
 

Variables

enum SoundTypeTrap SPAWN_FLAGS = ECE_LOCAL
 
const int DAMAGE_TRIGGER_MINE = 75
 
const float UPDATE_TIMER_INTERVAL = 0.05
 
float m_InitWaitTime
 
bool m_NeedActivation
 
float m_DefectRate
 
float m_DamagePlayers
 
float m_DamageOthers
 
bool m_AddActivationDefect
 
bool m_AddDeactivationDefect
 
bool m_IsActive
 
bool m_IsInProgress
 
bool m_Disarmed = false
 
bool m_WasActivatedOrDeactivated
 DEPRECATED Used for explosive traps to prevent detonation after destroying through disarm action.
 
string m_AnimationPhaseGrounded
 
string m_AnimationPhaseSet
 
string m_AnimationPhaseTriggered
 
string m_InfoSetup
 
string m_InfoDeactivated
 
string m_InfoDamageManipulation
 
string m_InfoDamage
 
string m_InfoActivationTime
 
ref Timer m_Timer
 
ref Timer m_UpdateTimer
 
TrapTrigger m_TrapTrigger
 
ref array< intm_ClothingDmg
 
ref EffectSound m_DeployLoopSound
 

Enumeration Type Documentation

◆ SoundTypeTrap

Enumerator
ACTIVATING 

Definition at line 1 of file TrapBase.c.

2{
3 ACTIVATING = 5,
4}
@ ACTIVATING
Definition TrapBase.c:3

Function Documentation

◆ AddDefect()

void AddDefect ( )
protected

Definition at line 403 of file TrapBase.c.

404 {
405 if (GetGame().IsServer())
406 DecreaseHealth("", "", m_DefectRate);
407 }
float m_DefectRate
Definition TrapBase.c:19
proto native CGame GetGame()

References GetGame(), and m_DefectRate.

Referenced by SetActive(), SetInactive(), and TrapSpawnBase::SpawnCatch().

◆ CanBeClapped()

bool CanBeClapped ( )
protected

DEPRECATED Set if trap can be disarmed using ActionClapBearTrapWithThisItem.

Definition at line 573 of file TrapBase.c.

574 {
575 return true;
576 }

◆ CanBeDisarmed()

bool CanBeDisarmed ( )
protected

Definition at line 579 of file TrapBase.c.

580 {
581 return false;
582 }

◆ CanBePlaced()

override bool CanBePlaced ( Man player,
vector position )
protected

Definition at line 567 of file TrapBase.c.

568 {
570 }
bool IsPlaceableAtPosition(vector position)
Definition TrapBase.c:199

References IsPlaceableAtPosition().

◆ CanPutInCargo()

override bool CanPutInCargo ( EntityAI parent)
protected

Definition at line 546 of file TrapBase.c.

547 {
548 if (!super.CanPutInCargo(parent))
549 return false;
550
551 return IsTakeable();
552 }
override bool IsTakeable()
Definition TrapBase.c:170

References IsTakeable().

◆ CanPutIntoHands()

override bool CanPutIntoHands ( EntityAI parent)
protected

Definition at line 554 of file TrapBase.c.

555 {
556 if (!super.CanPutIntoHands(parent))
557 return false;
558
559 return IsTakeable();
560 }

References IsTakeable().

◆ CanRemoveFromHands()

override bool CanRemoveFromHands ( EntityAI parent)
protected

Definition at line 562 of file TrapBase.c.

563 {
564 return IsTakeable();
565 }

References IsTakeable().

◆ CreateTrigger()

void CreateTrigger ( )
protected

Definition at line 468 of file TrapBase.c.

469 {
470 if (Class.CastTo(m_TrapTrigger, GetGame().CreateObjectEx("TrapTrigger", GetPosition(), SPAWN_FLAGS)))
471 {
472 vector mins = "-0.01 -0.05 -0.01";
473 vector maxs = "0.01 0.5 0.01";
474 m_TrapTrigger.SetOrientation(GetOrientation());
478 }
479 }
vector GetOrientation()
void DeferredEnableTrigger()
Definition TrapBase.c:490
enum SoundTypeTrap SPAWN_FLAGS
TrapTrigger m_TrapTrigger
Definition TrapBase.c:44
class JsonUndergroundAreaTriggerData GetPosition
Super root of all classes in Enforce script.
Definition EnScript.c:11
void SetParentObject(TrapBase obj)
Definition TrapTrigger.c:18
void SetExtents(vector mins, vector maxs)
Set the size of the Trigger, avoid using SetCollisionBox directly.
Definition Trigger.c:116
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8

References CALL_CATEGORY_SYSTEM, Class::CastTo(), DeferredEnableTrigger(), GetGame(), GetOrientation(), GetPosition, m_TrapTrigger, Trigger::SetExtents(), TrapTrigger::SetParentObject(), and SPAWN_FLAGS.

Referenced by InitZoneServer(), ContaminatedArea_Dynamic::InitZoneServer(), and SpookyArea::InitZoneServer().

◆ DamageClothing()

void DamageClothing ( PlayerBase player)
protected

Definition at line 649 of file TrapBase.c.

650 {
651 //Array used to find all relevant information about currently equipped clothes
653
654 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("LEGS")));
655 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("BACK")));
656 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("VEST")));
657 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("HeadGear")));
658 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("Mask")));
659 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("BODY")));
660 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("FEET")));
661 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("GLOVES")));
662
663 //Damage all currently equipped clothes
664 for (int i = 0; i < equippedClothes.Count(); i++)
665 {
666 //If no item is equipped on slot, slot is ignored
667 if (equippedClothes[i] == null)
668 continue;
669
670 equippedClothes[i].DecreaseHealth(m_ClothingDmg[i], false);
671 }
672 }
ref array< int > m_ClothingDmg
Definition TrapBase.c:46

References m_ClothingDmg.

Referenced by OnSteppedOn().

◆ DeferredEnableTrigger()

void DeferredEnableTrigger ( )
protected

Definition at line 490 of file TrapBase.c.

491 {
492 if (m_TrapTrigger)
494 }
void SetEnabled()
prevents insider adding in the wrong position, HOTFIX
Definition TrapTrigger.c:46

References m_TrapTrigger, and TrapTrigger::SetEnabled().

Referenced by CreateTrigger().

◆ DeleteTrigger()

void DeleteTrigger ( )
protected

Definition at line 481 of file TrapBase.c.

482 {
483 if (m_TrapTrigger)
484 {
486 m_TrapTrigger.DeleteSafe();
487 }
488 }

References m_TrapTrigger, and TrapTrigger::SetParentObject().

Referenced by EEItemLocationChanged(), SetInactive(), and StartDeactivate().

◆ Disarm()

void Disarm ( )
protected

Definition at line 209 of file TrapBase.c.

210 {
211 SetInactive(false);
212 RefreshState();
213 GetGame().RPCSingleParam(this, ERPCs.RPC_TRAP_DISARM, null, true);
214
215 OnDisarm();
216 }
ERPCs
Definition ERPCs.c:2
void RefreshState()
Definition TrapBase.c:336
void SetInactive(bool stop_timer=true)
Definition TrapBase.c:452
void OnDisarm()
also called from RPC on client

References GetGame(), TrapBase::OnDisarm(), RefreshState(), and SetInactive().

◆ EEDelete()

override void EEDelete ( EntityAI parent)
protected

Definition at line 117 of file TrapBase.c.

118 {
119 super.EEDelete(parent);
120
121 if (GetGame() && m_TrapTrigger)
122 {
123 GetGame().ObjectDelete(m_TrapTrigger);
125 }
126 }

References GetGame(), and m_TrapTrigger.

◆ EEItemAttached()

override void EEItemAttached ( EntityAI item,
string slot_name )
protected

Definition at line 517 of file TrapBase.c.

518 {
519 super.EEItemAttached(item, slot_name);
520
521 if (GetGame().IsServer())
522 RefreshState();
523 }

References GetGame(), and RefreshState().

◆ EEItemDetached()

override void EEItemDetached ( EntityAI item,
string slot_name )
protected

Definition at line 525 of file TrapBase.c.

526 {
527 super.EEItemDetached(item, slot_name);
528
529 if (GetGame().IsServer())
530 RefreshState();
531 }

References GetGame(), and RefreshState().

◆ GetClosestCarWheel()

EntityAI GetClosestCarWheel ( EntityAI victim)
protected

carscript specific handling (not all traps are uses this)

ruined wheel, bail out

ignore all spare wheel

actual, healthy wheel, let it pass

Definition at line 612 of file TrapBase.c.

613 {
616 trapPosXZ[1] = 0;
617
618 GameInventory inv = victim.GetInventory();
619 for (int i = 0; i < inv.AttachmentCount(); i++)
620 {
622 EntityAI wheelEntity = inv.GetAttachmentFromIndex(i);
623 if (wheelEntity && wheelEntity.Type() == CarWheel_Ruined)
624 continue;
625
627 int slotId;
628 string slotName;
629 wheelEntity.GetInventory().GetCurrentAttachmentSlotInfo(slotId, slotName);
630 slotName.ToLower();
631 if (slotName.Contains("spare"))
632 {
633 continue
634 }
635
637 if (wheelEntity && wheelEntity.IsInherited(CarWheel))
638 {
639 vector entPosXZ = wheelEntity.GetPosition();
640 entPosXZ[1] = 0;
642 return wheelEntity;
643 }
644 }
645
646 return null;
647 }
PlayerSpawnPreset slotName
script counterpart to engine's class Inventory
Definition Inventory.c:79
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.

References vector::Distance(), GetPosition, and slotName.

Referenced by OnUpdate(), and TrapBase::OnUpdate().

◆ GetDisarmed()

bool GetDisarmed ( )
protected

DEPRECATED.

Definition at line 591 of file TrapBase.c.

592 {
593 return m_Disarmed;
594 }
bool m_Disarmed
Definition TrapBase.c:28

References m_Disarmed.

◆ GetTrapTrigger()

TrapTrigger GetTrapTrigger ( )
protected

Definition at line 88 of file TrapBase.c.

89 {
90 return m_TrapTrigger;
91 }

References m_TrapTrigger.

◆ IsActivable()

bool IsActivable ( )
protected

Definition at line 178 of file TrapBase.c.

179 {
180 return !IsActive() && GetHierarchyRootPlayer() == null && GetHierarchyParent() == null && m_IsInProgress == false && !IsRuined() && m_NeedActivation;
181 }
bool m_NeedActivation
Definition TrapBase.c:18
bool m_IsInProgress
Definition TrapBase.c:26
bool IsActive()
Definition TrapBase.c:159

References IsActive(), m_IsInProgress, and m_NeedActivation.

◆ IsActive()

bool IsActive ( )
protected

Definition at line 159 of file TrapBase.c.

160 {
161 return m_IsActive && m_IsInProgress == false && GetHierarchyRootPlayer() == null;
162 }
bool m_IsActive
Definition TrapBase.c:25

References m_IsActive, and m_IsInProgress.

◆ IsInactive()

bool IsInactive ( )
protected

Definition at line 164 of file TrapBase.c.

165 {
166 return !IsActive() && m_IsInProgress == false && GetHierarchyRootPlayer() == null;
167 }

References IsActive(), and m_IsInProgress.

Referenced by RefreshState().

◆ IsPlaceable()

bool IsPlaceable ( )
protected

Definition at line 183 of file TrapBase.c.

184 {
185 if (GetHierarchyRootPlayer() != null && GetHierarchyRootPlayer().GetHumanInventory().GetEntityInHands() == this)
186 {
187 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
188
189 vector player_pos = player.GetPosition();
190 vector aim_pos = player.GetAimPosition();
191
194 }
195
196 return false;
197 }
Definition EnMath.c:7
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
static proto float SqrFloat(float f)
Returns squared value.

References vector::DistanceSq(), IsPlaceableAtPosition(), and Math::SqrFloat().

◆ IsPlaceableAtPosition()

bool IsPlaceableAtPosition ( vector position)
protected

Definition at line 199 of file TrapBase.c.

200 {
201 if (GetGame().SurfaceIsSea(position[0], position[2]))
202 return false;
203 else if (GetGame().SurfaceIsPond(position[0], position[2]))
204 return false;
205
206 return true;
207 }

References GetGame().

Referenced by CanBePlaced(), and IsPlaceable().

◆ IsTakeable()

override bool IsTakeable ( )
protected

Definition at line 170 of file TrapBase.c.

171 {
172 if (m_IsInProgress == false && !IsActive())
173 return true;
174
175 return false;
176 }

References IsActive(), and m_IsInProgress.

◆ OnActivate()

void OnActivate ( )
protected

HumanCommandScript fully scriptable command.

Warning
NON-MANAGED, will be managed by C++ once it is sent to the CommandHandler through Human.StartCommand_Script
Note
So ideally, it is best to set up the HumanCommandScript, not create any instances and start it through Human.StartCommand_ScriptInst In case an instance needs to be created, it needs manual deletion if not sent to the CommandHandler But deleting it while it is in the CommandHandler will cause crashes constructor must have 1st parameter to be Human virtual to be overridden called when command starts

Definition at line 1105 of file human.c.

1167{ };

References GetGame(), GetPlayer(), m_TimerLoopSound, and PlaySoundActivate().

Referenced by Activate(), AntibioticsMdfr::OnReconnect(), CharcoalMdfr::OnReconnect(), FatigueMdfr::OnReconnect(), FeverMdfr::OnReconnect(), HemolyticReactionMdfr::OnReconnect(), PoisoningMdfr::OnReconnect(), WetMdfr::OnReconnect(), DisinfectionMdfr::OnReconnect(), DrowningMdfr::OnReconnect(), EpinephrineMdfr::OnReconnect(), FliesMdfr::OnReconnect(), ImmunityBoost::OnReconnect(), MaskMdfr::OnReconnect(), MorphineMdfr::OnReconnect(), PainKillersMdfr::OnReconnect(), and SalineMdfr::OnReconnect().

◆ OnDisarm()

void OnDisarm ( )
protected

also called from RPC on client

◆ OnItemLocationChanged()

override void OnItemLocationChanged ( EntityAI old_owner,
EntityAI new_owner )
protected

Definition at line 496 of file TrapBase.c.

497 {
498 super.OnItemLocationChanged(old_owner, new_owner);
499
500 if (GetGame().IsServer())
501 {
502 RefreshState();
503
504 // TAKE ACTIVE TRAP FROM VICINITY
505 if (old_owner == NULL && new_owner != NULL && IsActive())
506 {
507 // TAKE INTO HANDS
508 if (new_owner.IsPlayer())
510 else if (new_owner.GetHierarchyRootPlayer())
511 SnapOnObject(new_owner.GetHierarchyRootPlayer());
512 }
513 }
514
515 }
void SnapOnObject(EntityAI victim)
Definition TrapBase.c:221

References GetGame(), IsActive(), RefreshState(), and SnapOnObject().

◆ OnPlacementComplete()

override void OnPlacementComplete ( Man player,
vector position = "0 0 0",
vector orientation = "0 0 0" )
protected

Definition at line 533 of file TrapBase.c.

534 {
535 super.OnPlacementComplete(player, position, orientation);
536
537 if (GetGame().IsServer())
538 {
539 SetOrientation(orientation);
541 PlaceOnSurface();
542 SetSynchDirty();
543 }
544 }
proto native void SetPosition(vector position)
Set the world position of the Effect.
Definition Effect.c:420

References GetGame(), and SetPosition().

◆ OnRPC()

override void OnRPC ( PlayerIdentity sender,
int rpc_type,
ParamsReadContext ctx )
protected

Definition at line 294 of file TrapBase.c.

295 {
296 super.OnRPC(sender, rpc_type, ctx);
297
298 if (!GetGame().IsDedicatedServer())
299 {
300 switch (rpc_type)
301 {
302 case ERPCs.RPC_TRAP_VICTIM:
304
305 if (ctx.Read(victim))
306 {
307 if (victim.param1)
308 SnapOnObject(victim.param1);
309 }
310
311 break;
312
313 case ERPCs.RPC_TRAP_DISARM:
314 OnDisarm();
315 break;
316
317 case SoundTypeTrap.ACTIVATING:
318
319 Param1<bool> p = new Param1<bool>(false);
320
321 bool isActivating = false;
322 if (ctx.Read(p))
323 isActivating = p.param1;
324
325 if (isActivating)
327
328 if (!isActivating)
330
331 break;
332 }
333 }
334 }
void PlayDeployLoopSound()
void StopDeployLoopSound()
SoundTypeTrap
Definition TrapBase.c:2

References GetGame(), TrapBase::OnDisarm(), PlayDeployLoopSound(), SnapOnObject(), and StopDeployLoopSound().

◆ OnSteppedOn()

void OnSteppedOn ( EntityAI victim)
protected

Definition at line 272 of file TrapBase.c.

273 {
274 SetInactive(false);
275 }

References SetInactive().

◆ OnSteppedOut()

void OnSteppedOut ( EntityAI victim)
protected

Definition at line 158 of file Trap_LandMine.c.

159 {
160 if (victim.IsInherited(CarScript))
161 {
162 if (m_UpdateTimer && m_UpdateTimer.IsRunning())
163 m_UpdateTimer.Stop();
164 }
165 }
ref Timer m_UpdateTimer
Definition RadialMenu.c:20

References m_UpdateTimer.

◆ OnStoreLoad()

override bool OnStoreLoad ( ParamsReadContext ctx,
int version )
protected

Definition at line 137 of file TrapBase.c.

138 {
139 if (!super.OnStoreLoad(ctx, version))
140 return false;
141
142 bool b_is_active = false;
143 if (!ctx.Read(b_is_active))
144 b_is_active = false;
145
146 bool b_is_in_progress = false;
147 if (!ctx.Read(b_is_in_progress))
148 b_is_in_progress = false;
149
150 if (b_is_active)
151 SetActive();
152
155
156 return true;
157 }
void SetActive()
Definition TrapBase.c:409
void StartActivate(PlayerBase player)
Definition TrapBase.c:431

References SetActive(), and StartActivate().

◆ OnStoreSave()

override void OnStoreSave ( ParamsWriteContext ctx)
protected

Definition at line 128 of file TrapBase.c.

129 {
130 super.OnStoreSave(ctx);
131
132 ctx.Write(m_IsActive);
133 ctx.Write(m_IsInProgress);
134 }

References m_IsActive, and m_IsInProgress.

◆ OnUpdate()

void OnUpdate ( EntityAI victim)
protected

Definition at line 87 of file Trap_LandMine.c.

88 {
89 if (victim && victim.IsInherited(CarScript))
90 {
92 if (wheel)
94 }
95 }
void OnServerSteppedOn(Object obj, string damageZone)
EntityAI GetClosestCarWheel(EntityAI victim)
Definition TrapBase.c:612

References GetClosestCarWheel(), and TrapBase::OnServerSteppedOn().

◆ OnVariablesSynchronized()

override void OnVariablesSynchronized ( )
protected

this event is called all variables are synchronized on client

Definition at line 94 of file TrapBase.c.

95 {
96 super.OnVariablesSynchronized();
97
98 if (IsDeploySound())
100
103
106
107 if (GetGame().IsMultiplayer())
108 {
110 SetActive();
111
114 }
115 }
bool CanPlayDeployLoopSound()
Definition ItemBase.c:9039
void PlayDeploySound()
Definition ItemBase.c:9003
bool IsDeploySound()
Definition ItemBase.c:8977
ref EffectSound m_DeployLoopSound
Definition TrapBase.c:47

References CanPlayDeployLoopSound(), GetGame(), IsDeploySound(), m_DeployLoopSound, m_IsActive, m_IsInProgress, PlayDeployLoopSound(), PlayDeploySound(), SetActive(), StartActivate(), and StopDeployLoopSound().

◆ PlayDeployLoopSound()

void PlayDeployLoopSound ( )
protected

◆ RefreshState()

void RefreshState ( )
protected

Definition at line 336 of file TrapBase.c.

337 {
339 return;
340
341 if (GetGame().IsServer())
342 {
343 // item is owned by player
344 if (GetHierarchyRootPlayer() != NULL && m_AnimationPhaseGrounded != "")
345 {
346 SetAnimationPhase(m_AnimationPhaseSet, 1);
348 SetAnimationPhase(m_AnimationPhaseTriggered, 1);
349 SetAnimationPhase(m_AnimationPhaseGrounded, 0);
350 }
351 // item is set active
352 else if (IsActive())
353 {
354 if (m_AnimationPhaseGrounded != "")
355 SetAnimationPhase(m_AnimationPhaseGrounded, 1);
357 {
358 SetAnimationPhase(m_AnimationPhaseTriggered, 1);
359 SetAnimationPhase(m_AnimationPhaseSet, 0);
360 }
361 }
362 // item is inactive and not owned by player (on the ground)
363 else if (IsInactive())
364 {
366 SetAnimationPhase(m_AnimationPhaseGrounded, 1);
368 {
369 SetAnimationPhase(m_AnimationPhaseSet, 1);
370 SetAnimationPhase(m_AnimationPhaseTriggered, 0);
371 }
372 }
373 }
374 }
string m_AnimationPhaseTriggered
Definition TrapBase.c:34
bool m_WasActivatedOrDeactivated
DEPRECATED Used for explosive traps to prevent detonation after destroying through disarm action.
Definition TrapBase.c:30
string m_AnimationPhaseGrounded
Definition TrapBase.c:32
string m_AnimationPhaseSet
Definition TrapBase.c:33
bool IsInactive()
Definition TrapBase.c:164

References GetGame(), IsActive(), IsInactive(), m_AnimationPhaseGrounded, m_AnimationPhaseSet, m_AnimationPhaseTriggered, and m_WasActivatedOrDeactivated.

Referenced by Disarm(), EEHealthLevelChanged(), EEItemAttached(), EEItemDetached(), EEItemLocationChanged(), OnItemLocationChanged(), OnStoreLoad(), SetActive(), SetInactive(), and SnapOnObject().

◆ RemoveFromObject()

void RemoveFromObject ( EntityAI victim)
protected

Definition at line 267 of file TrapBase.c.

268 {
270 }
void OnSteppedOut(EntityAI victim)

References TrapBase::OnSteppedOut().

◆ SetActions()

override void SetActions ( )
protected

Definition at line 604 of file TrapBase.c.

605 {
606 super.SetActions();
607
609 }
ActionActivateTrapCB ActionContinuousBaseCB ActionActivateTrap()
void AddAction(typename actionName)

References ActionActivateTrap(), and AddAction().

◆ SetActive()

void SetActive ( )
protected

Definition at line 409 of file TrapBase.c.

410 {
412
413 m_IsInProgress = false;
414 m_IsActive = true;
415
417 AddDefect();
418
419 if (GetGame().IsServer())
420 {
422 RefreshState();
423 SetSynchDirty();
424 }
425
426 OnActivate();
427 }
void OnActivate()
HumanCommandScript fully scriptable command.
Definition human.c:1167
void CreateTrigger()
Definition TrapBase.c:468
void AddDefect()
Definition TrapBase.c:403
bool m_AddActivationDefect
Definition TrapBase.c:23

References AddDefect(), TrapBase::CreateTrigger(), GetGame(), m_AddActivationDefect, m_IsActive, m_IsInProgress, m_WasActivatedOrDeactivated, TrapBase::OnActivate(), and RefreshState().

Referenced by ItemBase::EEItemAttached(), EEItemLocationChanged(), Icon::Icon(), UniversalTemperatureSourceDebug::Init(), ItemBase::OnItemLocationChanged(), ItemBase::OnPlacementComplete(), OnStoreLoad(), ItemBase::OnStoreLoad(), OnVariablesSynchronized(), HandsContainer::Refresh(), Container::Select(), LayoutHolder::SetFirstActive(), Container::SetNextActive(), AttachmentsGroupContainer::SetNextActive(), LayoutHolder::SetNextActive(), Container::SetPreviousActive(), AttachmentsGroupContainer::SetPreviousActive(), LayoutHolder::SetPreviousActive(), TrapSpawnBase::SetupTrap(), SetupTrapPlayer(), SlotsIcon::SlotsIcon(), StartActivate(), RainProcurementComponentBase::StartRainProcurement(), and RainProcurementComponentBase::StopRainProcurement().

◆ SetDisarmed()

void SetDisarmed ( bool disarmed)
protected

DEPRECATED.

Definition at line 585 of file TrapBase.c.

586 {
588 }

References m_Disarmed.

◆ SetInactive()

void SetInactive ( bool stop_timer = true)
protected

◆ SetupTrap()

void SetupTrap ( )
protected

Definition at line 376 of file TrapBase.c.

377 {
378 if (GetGame().IsServer())
379 {
380 if (GetHierarchyRootPlayer() && GetHierarchyRootPlayer().CanDropEntity(this))
381 SetupTrapPlayer(PlayerBase.Cast(GetHierarchyRootPlayer()));
382 }
383 }
void SetupTrapPlayer(PlayerBase player, bool set_position=true)
Definition TrapBase.c:385

References GetGame(), and SetupTrapPlayer().

◆ SetupTrapPlayer()

void SetupTrapPlayer ( PlayerBase player,
bool set_position = true )
protected

Definition at line 385 of file TrapBase.c.

386 {
387 if (GetGame().IsServer())
388 {
389 if (set_position)
390 {
391 player.LocalDropEntity(this);
392
393 vector trapPos = player.GetDirection() * 1.5;
394 trapPos[1] = 0;
395 SetPosition(player.GetPosition() + trapPos);
396 }
397
398 if (m_NeedActivation == false)
399 SetActive();
400 }
401 }

References GetGame(), m_NeedActivation, SetActive(), and SetPosition().

Referenced by ItemBase::OnPlacementComplete(), SetupTrap(), and ItemBase::SetupTrap().

◆ SnapOnObject()

void SnapOnObject ( EntityAI victim)
protected

Definition at line 221 of file TrapBase.c.

222 {
223 if (GetGame().IsServer())
224 {
225 if (m_Timer)
226 m_Timer.Stop();
227
228 RefreshState();
229
230 if (m_DamagePlayers > 0)
231 {
232 if (victim)
233 {
234 if (victim.IsInherited(SurvivorBase))
235 victim.DecreaseHealth("", "", m_DamagePlayers);
236 else if (victim.IsInherited(DayZCreatureAI))
237 victim.DecreaseHealth("", "", m_DamageOthers);
238 else if (victim.IsInherited(ItemBase))
239 {
241 float damage_coef = 1;
242
243 if (victim_item.HasQuantity() && victim_item.GetQuantityMax() != 0 && victim_item.GetQuantity() > 0)
244 {
245 damage_coef = victim_item.GetQuantityMax() / victim_item.GetQuantity(); // Lower quantity increases damage exposure
246 }
247
248 if (damage_coef > 0)
249 {
250 int item_size_x = 1;
251 int item_size_y = 1;
252 GetGame().GetInventoryItemSize(victim_item, item_size_x, item_size_y);
253
254 float add_damage = 300 * damage_coef / Math.Clamp(item_size_x * item_size_y, 1, int.MAX);
255 victim_item.DecreaseHealth("", "", add_damage);
256 }
257 }
258 }
259 }
260
261 Synch(victim);
262 }
263
265 }
const int MAX
Definition EnConvert.c:27
void Synch(EntityAI victim)
keeping "step" here for consistency only
Definition TrapBase.c:280
void OnSteppedOn(EntityAI victim)
Definition TrapBase.c:272
float m_DamagePlayers
Definition TrapBase.c:20
float m_DamageOthers
Definition TrapBase.c:21
do not process rotations !
Definition DayZAnimal.c:573
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.

References Math::Clamp(), GetGame(), m_DamageOthers, m_DamagePlayers, m_Timer, MAX, TrapBase::OnSteppedOn(), RefreshState(), and Synch().

Referenced by OnItemLocationChanged(), and OnRPC().

◆ StartActivate()

void StartActivate ( PlayerBase player)
protected

Definition at line 431 of file TrapBase.c.

432 {
433 if (GetGame().IsServer())
434 {
436 HideSelection("safety_pin");
437
438 if (m_InitWaitTime > 0)
439 {
440 m_IsInProgress = true;
441 m_Timer.Run(m_InitWaitTime, this, "SetActive");
442
443 SetSynchDirty();
444 }
445 else
446 SetActive();
447 }
448 }
float m_InitWaitTime
Definition TrapBase.c:17

References CALL_CATEGORY_SYSTEM, GetGame(), m_InitWaitTime, m_IsInProgress, m_Timer, and SetActive().

Referenced by TrapBase::OnPlacementComplete(), OnPlacementComplete(), OnStoreLoad(), ItemBase::OnStoreLoad(), and OnVariablesSynchronized().

◆ StartDeactivate()

void StartDeactivate ( PlayerBase player)
protected

Definition at line 208 of file Trap_TripWire.c.

209 {
210 super.StartDeactivate(player);
211
214 }
enum eWireMaterial FOLDED
void SetState(int state_ID)

References DeleteTrigger(), FOLDED, and SetState().

Referenced by EEKilled(), and OnItemLocationChanged().

◆ StopDeployLoopSound()

void StopDeployLoopSound ( )
protected

◆ Synch()

void Synch ( EntityAI victim)
protected

keeping "step" here for consistency only

Definition at line 280 of file TrapBase.c.

281 {
282 if (GetGame().IsServer())
283 {
284 if (victim && !victim.GetAllowDamage())
285 return;
286
288 GetGame().RPCSingleParam(this, ERPCs.RPC_TRAP_VICTIM, p, true);
289 }
290
291 }

References GetGame().

Referenced by TrapBase::OnServerSteppedOn(), OnServerSteppedOn(), and SnapOnObject().

◆ TrapBase()

void TrapBase ( )
protected

timer calling OnUpdate in configured interval

Definition at line 49 of file TrapBase.c.

50 {
51 m_IsInProgress = false;
52 m_NeedActivation = true;
53 m_InitWaitTime = 5; //After this time after deployment, the trap is activated
54 m_DefectRate = 15; //Added damage after trap activation
55 m_DamagePlayers = 25; //How much damage player gets when caught
56 m_DamageOthers = 100; //How much damage others gets when caught
57
60
62
66
67 m_InfoSetup = "#STR_TrapBase0";
68 m_InfoDeactivated = "#STR_TrapBase1";
69 m_InfoDamageManipulation = "#STR_TrapBase2";
70 m_InfoDamage = "#STR_TrapBase3";
71 m_InfoActivationTime = "#STR_TrapBase4" + m_InitWaitTime.ToString() + "#STR_TrapBase5";
72
73 m_UpdateTimer = new ref Timer();
74
75 RegisterNetSyncVariableBool("m_IsActive");
76 RegisterNetSyncVariableBool("m_IsInProgress");
77 RegisterNetSyncVariableBool("m_IsSoundSynchRemote");
78 RegisterNetSyncVariableBool("m_IsDeploySound");
79 }
string m_InfoDamageManipulation
Definition TrapBase.c:38
string m_InfoActivationTime
Definition TrapBase.c:40
string m_InfoSetup
Definition TrapBase.c:36
string m_InfoDeactivated
Definition TrapBase.c:37
string m_InfoDamage
Definition TrapBase.c:39
ref Timer m_UpdateTimer
Definition TrapBase.c:43
proto string ToString()

References m_AddActivationDefect, m_AddDeactivationDefect, m_AnimationPhaseGrounded, m_AnimationPhaseSet, m_AnimationPhaseTriggered, m_DamageOthers, m_DamagePlayers, m_DefectRate, m_InfoActivationTime, m_InfoDamage, m_InfoDamageManipulation, m_InfoDeactivated, m_InfoSetup, m_InitWaitTime, m_IsInProgress, m_NeedActivation, m_UpdateTimer, m_WasActivatedOrDeactivated, and float::ToString().

◆ ~TrapBase()

void ~TrapBase ( )
protected

Definition at line 81 of file TrapBase.c.

82 {
84 }
Manager class for managing Effect (EffectParticle, EffectSound)
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.

References SEffectManager::DestroyEffect(), and m_DeployLoopSound.

Variable Documentation

◆ DAMAGE_TRIGGER_MINE

const int DAMAGE_TRIGGER_MINE = 75
protected

Definition at line 14 of file TrapBase.c.

Referenced by OnSteppedOn().

◆ m_AddActivationDefect

bool m_AddActivationDefect
protected

Definition at line 23 of file TrapBase.c.

Referenced by SetActive(), and TrapBase().

◆ m_AddDeactivationDefect

bool m_AddDeactivationDefect
protected

Definition at line 24 of file TrapBase.c.

Referenced by LandMineTrap(), SetInactive(), and TrapBase().

◆ m_AnimationPhaseGrounded

string m_AnimationPhaseGrounded
protected

Definition at line 32 of file TrapBase.c.

Referenced by TrapBase::BearTrap(), FoldTripWire(), RefreshState(), TrapBase(), and TripwireTrap().

◆ m_AnimationPhaseSet

◆ m_AnimationPhaseTriggered

◆ m_ClothingDmg

ref array<int> m_ClothingDmg
protected

Definition at line 46 of file TrapBase.c.

Referenced by DamageClothing(), and LandMineTrap().

◆ m_DamageOthers

float m_DamageOthers
protected

Definition at line 21 of file TrapBase.c.

Referenced by TrapBase::BearTrap(), SnapOnObject(), and TrapBase().

◆ m_DamagePlayers

float m_DamagePlayers
protected

Definition at line 20 of file TrapBase.c.

Referenced by TrapBase::BearTrap(), LandMineTrap(), SnapOnObject(), TrapBase(), and TripwireTrap().

◆ m_DefectRate

◆ m_DeployLoopSound

◆ m_Disarmed

bool m_Disarmed = false
protected

Definition at line 28 of file TrapBase.c.

Referenced by GetDisarmed(), and SetDisarmed().

◆ m_InfoActivationTime

string m_InfoActivationTime
protected

Definition at line 40 of file TrapBase.c.

Referenced by LandMineTrap(), TrapBase(), and TripwireTrap().

◆ m_InfoDamage

string m_InfoDamage
protected

Definition at line 39 of file TrapBase.c.

Referenced by TrapBase().

◆ m_InfoDamageManipulation

string m_InfoDamageManipulation
protected

Definition at line 38 of file TrapBase.c.

Referenced by TrapBase().

◆ m_InfoDeactivated

string m_InfoDeactivated
protected

Definition at line 37 of file TrapBase.c.

Referenced by TrapBase().

◆ m_InfoSetup

string m_InfoSetup
protected

Definition at line 36 of file TrapBase.c.

Referenced by TrapBase().

◆ m_InitWaitTime

◆ m_IsActive

bool m_IsActive
protected

Definition at line 25 of file TrapBase.c.

◆ m_IsInProgress

◆ m_NeedActivation

bool m_NeedActivation
protected

Definition at line 18 of file TrapBase.c.

Referenced by IsActivable(), SetupTrapPlayer(), TrapBase(), and TripwireTrap().

◆ m_Timer

ref Timer m_Timer
protected

Definition at line 42 of file TrapBase.c.

◆ m_TrapTrigger

◆ m_UpdateTimer

ref Timer m_UpdateTimer
protected

Definition at line 43 of file TrapBase.c.

◆ m_WasActivatedOrDeactivated

bool m_WasActivatedOrDeactivated
protected

DEPRECATED Used for explosive traps to prevent detonation after destroying through disarm action.

Definition at line 30 of file TrapBase.c.

Referenced by RefreshState(), SetActive(), SetInactive(), and TrapBase().

◆ SPAWN_FLAGS

enum SoundTypeTrap SPAWN_FLAGS = ECE_LOCAL

Referenced by CreateTrigger().

◆ UPDATE_TIMER_INTERVAL

const float UPDATE_TIMER_INTERVAL = 0.05
protected

Definition at line 15 of file TrapBase.c.

Referenced by TrapBase::OnSteppedOn(), and OnSteppedOn().