DayZ
1.24
Loading...
Searching...
No Matches
TrapTrigger.c
Go to the documentation of this file.
1
2
class
TrapTrigger
:
Trigger
3
{
4
bool
m_Enabled
=
false
;
5
TrapBase
m_ParentObj
;
6
7
#ifdef DEVELOPER
8
bool
m_CanSendDbg
=
true
;
9
#endif
10
11
void
TrapTrigger
()
12
{
13
int
mask
= GetEventMask();
14
mask
&=
~EntityEvent
.INIT;
15
SetEventMask(
mask
);
16
}
17
18
void
SetParentObject
(
TrapBase
obj)
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
46
void
SetEnabled
()
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
62
class
TripWireTrigger
:
TrapTrigger
63
{
64
override
protected
void
OnEnterServerEvent
(
TriggerInsider
insider)
65
{
66
PlayerBase
playerInsider
=
PlayerBase
.Cast(insider.
GetObject
());
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
}
OnEnterServerEvent
override void OnEnterServerEvent(TriggerInsider insider)
Definition
AreaDamageManager.c:107
EntityAI
Definition
Building.c:6
Object
Definition
ObjectTyped.c:2
Param3
Definition
EntityAI.c:95
PlayerBase
Definition
PlayerBaseClient.c:2
TrapBase
Definition
Trap_Bear.c:2
TrapTrigger
Trigger used by traps.
Definition
TrapTrigger.c:3
TrapTrigger::m_ParentObj
TrapBase m_ParentObj
Definition
TrapTrigger.c:5
TrapTrigger::OnEnterServerEvent
void OnEnterServerEvent(TriggerInsider insider)
Definition
TrapTrigger.c:29
TrapTrigger::m_Enabled
bool m_Enabled
Definition
TrapTrigger.c:4
TrapTrigger::TrapTrigger
void TrapTrigger()
Definition
TrapTrigger.c:11
TrapTrigger::SetEnabled
void SetEnabled()
prevents insider adding in the wrong position, HOTFIX
Definition
TrapTrigger.c:46
TrapTrigger::SetParentObject
void SetParentObject(TrapBase obj)
Definition
TrapTrigger.c:18
TrapTrigger::CanAddObjectAsInsider
bool CanAddObjectAsInsider(Object object)
Definition
TrapTrigger.c:24
TrapTrigger::OnLeaveServerEvent
void OnLeaveServerEvent(TriggerInsider insider)
Definition
TrapTrigger.c:39
Trigger
Scripted Trigger.
Definition
Hologram.c:1518
TriggerInsider
The object which is in a trigger and its metadata.
Definition
Trigger.c:3
TriggerInsider::GetObject
Object GetObject()
Definition
Trigger.c:28
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition
dayzplayer.c:597
GetGame
proto native CGame GetGame()
EntityEvent
EntityEvent
Entity events for event-mask, or throwing event from code.
Definition
EnEntity.c:44
scripts
4_World
Entities
ScriptedEntities
Triggers
TrapTrigger.c
Generated by
1.10.0