DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
EffectTrigger.c
Go to the documentation of this file.
1// Base class for "Effect triggers"
2// Registers in TriggerEffectManager and handles parameter setting through cfgEffectArea.json file
4{
5 int m_AroundPartId; // The main particles spawned around player when in trigger
6 int m_TinyPartId; // The smaller particles spawned around player when in trigger
7 int m_PPERequester; // The Post Processing used when player is in trigger
12
14 {
15 RegisterNetSyncVariableInt("m_AroundPartId");
16 RegisterNetSyncVariableInt("m_TinyPartId");
17 RegisterNetSyncVariableInt("m_PPERequester");
18
21 }
22
23 // ----------------------------------------------
24 // CUSTOM EVENTS
25 // ----------------------------------------------
26
27 void SetLocalEffects( int aroundPartId, int tinyPartId, int ppeRequesterIdx )
28 {
29 m_AroundPartId = aroundPartId;
30 m_TinyPartId = tinyPartId;
31 m_PPERequester = ppeRequesterIdx;
32
33 SetSynchDirty();
34 }
35
36
38 {
39 return "";
40 }
41
42 void SetupClientEffects(bool enable, notnull PlayerBase player)
43 {
44 if ( !m_Manager.IsPlayerInTriggerType( player, this ) )
45 {
46 if (enable)
47 {
48 player.SetContaminatedEffectEx( true, m_PPERequester, m_AroundPartId, m_TinyPartId, GetAmbientSoundsetName() );
49 }
50 else
51 {
52 player.SetContaminatedEffectEx( false, m_PPERequester );
53 }
54 }
55 }
56
57
58 // ----------------------------------------------
59 // TRIGGER EVENTS
60 // ----------------------------------------------
61
62 override void EOnFrame(IEntity other, float timeSlice)
63 {
64 m_DeltaTime = timeSlice;
65 }
66
67 override bool CanAddObjectAsInsider(Object object)
68 {
69 DayZCreatureAI creature = DayZCreatureAI.Cast( object );
70 if(creature)
71 {
72 return !creature.ResistContaminatedEffect();
73 }
74 else
75 {
76 PlayerBase player = PlayerBase.Cast(object);
77 return player != null;
78 }
79 }
80
81
82
83 override void OnEnterServerEvent( TriggerInsider insider )
84 {
85 super.OnEnterServerEvent( insider );
86
87 // We don't need to test the trigger count as Modifiers handle such cases already
88 if ( insider )
89 {
90 PlayerBase playerInsider = PlayerBase.Cast( insider.GetObject() );
91
92 if(playerInsider)
93 {
94
95 m_Manager.OnPlayerEnter( playerInsider, this );
96 }
97
98 }
99
100 }
101
102 override void OnEnterClientEvent( TriggerInsider insider )
103 {
104 super.OnEnterClientEvent( insider );
105
106 if ( insider )
107 {
108 PlayerBase playerInsider = PlayerBase.Cast( insider.GetObject() );
109
110 // We will only handle the controlled player, as effects are only relevant to this player instance
111 if (playerInsider && playerInsider.IsControlledPlayer() )
112 {
113 SetupClientEffects(true, playerInsider);
114 // We then handle the update of player trigger state in manager
115 m_Manager.OnPlayerEnter( playerInsider, this );
116 }
117 }
118 }
119
120
121 override void OnLeaveServerEvent( TriggerInsider insider )
122 {
123 super.OnLeaveServerEvent( insider );
124
125 if ( insider )
126 {
127 PlayerBase playerInsider = PlayerBase.Cast( insider.GetObject() );
128
129 if ( playerInsider )
130 m_Manager.OnPlayerExit( playerInsider, this );
131 }
132 }
133
134
135
136 override void OnLeaveClientEvent( TriggerInsider insider )
137 {
138 super.OnLeaveClientEvent( insider );
139
140 if ( insider )
141 {
142 // Make sure you pass the set variable for PPE effect
143 // It will not remove the correct one if START and STOP don't point to the same Requester
144 PlayerBase playerInsider = PlayerBase.Cast( insider.GetObject() );
145
146 // We will only handle the controlled player, as effects are only relevant to this player instance
147 if ( playerInsider && playerInsider.IsControlledPlayer() )
148 {
149 // We first handle the update of player trigger state in manager
150 m_Manager.OnPlayerExit( playerInsider, this );
151 SetupClientEffects(false, playerInsider);
152 }
153 }
154 }
155
156 // We remove from trigger update DEAD or RESISTANT entities to limit the amount of entities to update
157 override bool ShouldRemoveInsider( TriggerInsider insider )
158 {
159 return !insider.GetObject().IsAlive();
160 }
161
162 // Used to apply the desired effect to all entities present in one trigger of the specified type
163 // NOTE : This is really not optimal, if you want to add new trigger types, you will have to test for them...
164 static void TriggerEffect( EntityAI insider, typename triggerType ) {}
165}
Trigger with cylinder shape.
do not process rotations !
Definition DayZAnimal.c:437
static void TriggerEffect(EntityAI insider, typename triggerType)
void SetLocalEffects(int aroundPartId, int tinyPartId, int ppeRequesterIdx)
void SetupClientEffects(bool enable, notnull PlayerBase player)
void EffectTrigger()
float m_TimeAccuStay
override void OnLeaveClientEvent(TriggerInsider insider)
override bool CanAddObjectAsInsider(Object object)
string GetAmbientSoundsetName()
override string GetAmbientSoundsetName()
override void OnEnterServerEvent(TriggerInsider insider)
TriggerEffectManager m_Manager
override bool ShouldRemoveInsider(TriggerInsider insider)
override void OnLeaveServerEvent(TriggerInsider insider)
override void EOnFrame(IEntity other, float timeSlice)
override void OnEnterClientEvent(TriggerInsider insider)
void OnPlayerExit(notnull PlayerBase player, notnull EffectTrigger trigger)
bool IsPlayerInTriggerType(notnull PlayerBase player, notnull EffectTrigger trigger)
void OnPlayerEnter(notnull PlayerBase player, notnull EffectTrigger trigger)
void RegisterTriggerType(EffectTrigger effectTrigger)
static TriggerEffectManager GetInstance()
The object which is in a trigger and its metadata.
Definition Trigger.c:3
Object GetObject()
Definition Trigger.c:28