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

Go to the source code of this file.

Classes

class  TrapTrigger
 Trigger used by traps. More...
 

Functions

TrapTrigger Trigger OnEnterServerEvent (TriggerInsider insider)
 
void TrapTrigger ()
 
void SetParentObject (TrapBase obj)
 
bool CanAddObjectAsInsider (Object object)
 
void OnLeaveServerEvent (TriggerInsider insider)
 
void SetEnabled ()
 prevents insider adding in the wrong position, HOTFIX
 

Variables

bool m_Enabled = false
 
TrapBase m_ParentObj
 

Function Documentation

◆ CanAddObjectAsInsider()

bool OnEnterServerEvent::CanAddObjectAsInsider ( Object object)
protected

Definition at line 85 of file TrapTrigger.c.

◆ OnEnterServerEvent()

TrapTrigger Trigger OnEnterServerEvent ( TriggerInsider insider)

Definition at line 1 of file TrapTrigger.c.

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 }
Object GetObject()
Definition Trigger.c:28
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597

◆ OnLeaveServerEvent()

void OnEnterServerEvent::OnLeaveServerEvent ( TriggerInsider insider)
protected

Definition at line 100 of file TrapTrigger.c.

101 : Trigger
102{
103 bool m_Enabled = false;
105
106#ifdef DEVELOPER
107 bool m_CanSendDbg = true;
108#endif
109
110 void TrapTrigger()
111 {
112 int mask = GetEventMask();
113 mask &= ~EntityEvent.INIT;
114 SetEventMask(mask);
115 }
116
117 void SetParentObject(TrapBase obj)
118 {
119 if (GetGame().IsServer())
120 m_ParentObj = obj;
121 }
122
123 override protected bool CanAddObjectAsInsider(Object object)
124 {
125 return m_Enabled && object.IsInherited(EntityAI) && m_ParentObj && m_ParentObj.IsActive() && m_ParentObj.GetTrapTrigger() == this;
126 }
127
128 override protected void OnEnterServerEvent(TriggerInsider insider)
129 {
130#ifdef DEVELOPER
131 m_CanSendDbg = false;
132#endif
133
134 if (m_ParentObj && m_ParentObj.IsActive())
135 m_ParentObj.SnapOnObject(EntityAI.Cast(insider.GetObject()));
136 }
137
138 override protected void OnLeaveServerEvent(TriggerInsider insider)
139 {
140 if (m_ParentObj && m_ParentObj.IsActive())
141 m_ParentObj.RemoveFromObject(EntityAI.Cast(insider.GetObject()));
142 }
143
145 void SetEnabled()
146 {
147 m_Enabled = true;
148 }
149
150#ifdef DEVELOPER
151 override void DebugSendDmgTrigger()
152 {
153 if (m_CanSendDbg)
154 super.DebugSendDmgTrigger();
155 }
156
157#endif
158}
159
160// Used for tripwire type traps, where we want to allow players to go through
162{
163 override protected void OnEnterServerEvent(TriggerInsider insider)
164 {
166
167 if (playerInsider)
168 {
169 // If the player is jogging / sprinting while standing with or without hands raised, tripwire will trigger
170 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);
171 bool isJogging = (playerInsider.m_MovementState.m_iMovement == DayZPlayerConstants.MOVEMENTIDX_RUN || playerInsider.m_MovementState.m_iMovement == DayZPlayerConstants.MOVEMENTIDX_SPRINT);
172 if (isJogging && isErect)
173 {
174 super.OnEnterServerEvent(insider);
175 return;
176 }
177
178 // Special handling of crouch sprint
179 if (playerInsider.m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_CROUCH && playerInsider.m_MovementState.m_iMovement == DayZPlayerConstants.MOVEMENTIDX_SPRINT)
180 {
181 super.OnEnterServerEvent(insider);
182 return;
183 }
184 }
185 else
186 super.OnEnterServerEvent(insider);
187 }
188}
override void OnEnterServerEvent(TriggerInsider insider)
void SetEnabled()
prevents insider adding in the wrong position, HOTFIX
TrapBase m_ParentObj
Definition TrapTrigger.c:66
bool m_Enabled
Definition TrapTrigger.c:65
bool CanAddObjectAsInsider(Object object)
Definition TrapTrigger.c:85
void OnLeaveServerEvent(TriggerInsider insider)
void TrapTrigger()
Definition TrapTrigger.c:72
TrapTrigger Trigger OnEnterServerEvent(TriggerInsider insider)
Definition TrapTrigger.c:64
void SetParentObject(TrapBase obj)
Definition TrapTrigger.c:79
Trigger used by traps.
Definition TrapTrigger.c:3
Scripted Trigger.
Definition Hologram.c:1518
The object which is in a trigger and its metadata.
Definition Trigger.c:3
proto native CGame GetGame()
EntityEvent
Entity events for event-mask, or throwing event from code.
Definition EnEntity.c:44

◆ SetEnabled()

void OnEnterServerEvent::SetEnabled ( )
protected

prevents insider adding in the wrong position, HOTFIX

Definition at line 107 of file TrapTrigger.c.

108 : Trigger
109{
110 bool m_Enabled = false;
112
113#ifdef DEVELOPER
114 bool m_CanSendDbg = true;
115#endif
116
117 void TrapTrigger()
118 {
119 int mask = GetEventMask();
120 mask &= ~EntityEvent.INIT;
121 SetEventMask(mask);
122 }
123
124 void SetParentObject(TrapBase obj)
125 {
126 if (GetGame().IsServer())
127 m_ParentObj = obj;
128 }
129
130 override protected bool CanAddObjectAsInsider(Object object)
131 {
132 return m_Enabled && object.IsInherited(EntityAI) && m_ParentObj && m_ParentObj.IsActive() && m_ParentObj.GetTrapTrigger() == this;
133 }
134
135 override protected void OnEnterServerEvent(TriggerInsider insider)
136 {
137#ifdef DEVELOPER
138 m_CanSendDbg = false;
139#endif
140
141 if (m_ParentObj && m_ParentObj.IsActive())
142 m_ParentObj.SnapOnObject(EntityAI.Cast(insider.GetObject()));
143 }
144
145 override protected void OnLeaveServerEvent(TriggerInsider insider)
146 {
147 if (m_ParentObj && m_ParentObj.IsActive())
148 m_ParentObj.RemoveFromObject(EntityAI.Cast(insider.GetObject()));
149 }
150
152 void SetEnabled()
153 {
154 m_Enabled = true;
155 }
156
157#ifdef DEVELOPER
158 override void DebugSendDmgTrigger()
159 {
160 if (m_CanSendDbg)
161 super.DebugSendDmgTrigger();
162 }
163
164#endif
165}
166
167// Used for tripwire type traps, where we want to allow players to go through
169{
170 override protected void OnEnterServerEvent(TriggerInsider insider)
171 {
173
174 if (playerInsider)
175 {
176 // If the player is jogging / sprinting while standing with or without hands raised, tripwire will trigger
177 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);
178 bool isJogging = (playerInsider.m_MovementState.m_iMovement == DayZPlayerConstants.MOVEMENTIDX_RUN || playerInsider.m_MovementState.m_iMovement == DayZPlayerConstants.MOVEMENTIDX_SPRINT);
179 if (isJogging && isErect)
180 {
181 super.OnEnterServerEvent(insider);
182 return;
183 }
184
185 // Special handling of crouch sprint
186 if (playerInsider.m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_CROUCH && playerInsider.m_MovementState.m_iMovement == DayZPlayerConstants.MOVEMENTIDX_SPRINT)
187 {
188 super.OnEnterServerEvent(insider);
189 return;
190 }
191 }
192 else
193 super.OnEnterServerEvent(insider);
194 }
195}

Referenced by EntityLightSource::CheckIfParentIsInCargo(), EntityLightSource::Destroy(), SpotLightBase::PerformVisibilityCheck(), and EntityLightSource::ScriptedLightBase().

◆ SetParentObject()

void OnEnterServerEvent::SetParentObject ( TrapBase obj)

Definition at line 79 of file TrapTrigger.c.

81 {
82 super.OnEnterServerEvent(insider);
83 return;

◆ TrapTrigger()

void OnEnterServerEvent::TrapTrigger ( )

Definition at line 72 of file TrapTrigger.c.

74 {
75 super.OnEnterServerEvent(insider);
76 return;
77 }

Variable Documentation

◆ m_Enabled

◆ m_ParentObj

TrapBase m_ParentObj

Definition at line 66 of file TrapTrigger.c.

Referenced by Trigger::OnEnter(), Trigger::OnLeave(), and Trigger::SetParentObject().