DayZ 1.24
Loading...
Searching...
No Matches
TrapTrigger.c
Go to the documentation of this file.
3{
4 bool m_Enabled = false;
6
7#ifdef DEVELOPER
8 bool m_CanSendDbg = true;
9#endif
10
12 {
13 int mask = GetEventMask();
14 mask &= ~EntityEvent.INIT;
15 SetEventMask(mask);
16 }
17
19 {
20 if (GetGame().IsServer())
21 m_ParentObj = obj;
22 }
23
24 override protected bool CanAddObjectAsInsider(Object object)
25 {
26 return m_Enabled && object.IsInherited(EntityAI) && m_ParentObj && m_ParentObj.IsActive() && m_ParentObj.GetTrapTrigger() == this;
27 }
28
29 override protected void OnEnterServerEvent(TriggerInsider insider)
30 {
31#ifdef DEVELOPER
32 m_CanSendDbg = false;
33#endif
34
35 if (m_ParentObj && m_ParentObj.IsActive())
36 m_ParentObj.SnapOnObject(EntityAI.Cast(insider.GetObject()));
37 }
38
39 override protected void OnLeaveServerEvent(TriggerInsider insider)
40 {
41 if (m_ParentObj && m_ParentObj.IsActive())
42 m_ParentObj.RemoveFromObject(EntityAI.Cast(insider.GetObject()));
43 }
44
47 {
48 m_Enabled = true;
49 }
50
51#ifdef DEVELOPER
52 override void DebugSendDmgTrigger()
53 {
54 if (m_CanSendDbg)
55 super.DebugSendDmgTrigger();
56 }
57
58#endif
59}
60
61// Used for tripwire type traps, where we want to allow players to go through
63{
64 override protected void OnEnterServerEvent(TriggerInsider insider)
65 {
67
68 if (playerInsider)
69 {
70 // If the player is jogging / sprinting while standing with or without hands raised, tripwire will trigger
71 bool isErect = (playerInsider.m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_ERECT || playerInsider.m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDERECT || playerInsider.m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDCROUCH);
72 bool isJogging = (playerInsider.m_MovementState.m_iMovement == DayZPlayerConstants.MOVEMENTIDX_RUN || playerInsider.m_MovementState.m_iMovement == DayZPlayerConstants.MOVEMENTIDX_SPRINT);
73 if (isJogging && isErect)
74 {
75 super.OnEnterServerEvent(insider);
76 return;
77 }
78
79 // Special handling of crouch sprint
80 if (playerInsider.m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_CROUCH && playerInsider.m_MovementState.m_iMovement == DayZPlayerConstants.MOVEMENTIDX_SPRINT)
81 {
82 super.OnEnterServerEvent(insider);
83 return;
84 }
85 }
86 else
87 super.OnEnterServerEvent(insider);
88 }
89}
override void OnEnterServerEvent(TriggerInsider insider)
Trigger used by traps.
Definition TrapTrigger.c:3
TrapBase m_ParentObj
Definition TrapTrigger.c:5
void OnEnterServerEvent(TriggerInsider insider)
Definition TrapTrigger.c:29
bool m_Enabled
Definition TrapTrigger.c:4
void TrapTrigger()
Definition TrapTrigger.c:11
void SetEnabled()
prevents insider adding in the wrong position, HOTFIX
Definition TrapTrigger.c:46
void SetParentObject(TrapBase obj)
Definition TrapTrigger.c:18
bool CanAddObjectAsInsider(Object object)
Definition TrapTrigger.c:24
void OnLeaveServerEvent(TriggerInsider insider)
Definition TrapTrigger.c:39
Scripted Trigger.
Definition Hologram.c:1518
The object which is in a trigger and its metadata.
Definition Trigger.c:3
Object GetObject()
Definition Trigger.c:28
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()
EntityEvent
Entity events for event-mask, or throwing event from code.
Definition EnEntity.c:44