Dayz Explorer 1.29.162510
Loading...
Searching...
No Matches
statebase.c
Go to the documentation of this file.
1class SymptomBase
2{
3 const float MAX_TIME_ACTIVE_SAVEGUARD = 20;
4 int m_Priority;
5 SoundOnVehicle m_SoundObject;
6 bool m_PlayedSound;
7 bool m_IsActivated;
8 PlayerBase m_Player;
9 float m_ServerUpdateInterval = 1;
10 float m_ServerUpdateDelta;
11 bool m_IsTemplate = true;
12 float m_ActivatedTime;
13 int m_ID;//ID for the type of Symptom
14 int m_UID;//unique ID
15 bool m_IsClientOnly;
16 bool m_DestroyOnAnimFinish = true;
17 bool m_DestroyRequested = false;
18 int m_SymptomType = -1;
19 bool m_IsPersistent = false;
20 SymptomManager m_Manager;
21 bool m_SyncToClient = false;
22 float m_Duration;
23 bool m_AnimPlayRequested;
24 int m_MaxCount = -1;//how many symptoms of this type can be queued up at the same time, '-1' for unlimited
25
26 SymptomCB m_AnimCallback;
27
28 ref array<Param> m_PersistentParams = new array<Param>;
29
30 void SymptomBase()
31 {
32 }
33
34 void ~SymptomBase()
35 {
36
37 }
38
39 void Init(SymptomManager manager, PlayerBase player, int uid)
40 {
41 m_Manager = manager;
42 m_Player = player;
43 m_UID = uid;
44 m_IsTemplate = false;
45 OnInit();
46 }
47
48 int GetMaxCount()
49 {
50 return m_MaxCount;
51 }
52
53 int GetUID()
54 {
55 return m_UID;
56 }
57
58 void OnOwnerKilled()
59 {
60
61
62 }
63
64 bool CanBeInterupted()
65 {
66 if (m_AnimPlayRequested)
67 {
68 //Print("--------- preventing interrupt ---------");
69 return false;
70 }
71 return true;
72 }
73
74 bool IsClientOnly()
75 {
76 return m_IsClientOnly;
77 }
78
79
80 void SetDuration(float duration)
81 {
82 m_Duration = duration;
83 }
84
85 float GetDuration()
86 {
87 return m_Duration;
88 }
89
90 string GetName()
91 {
92 return this.ClassName();
93 }
94
96 {
97 return m_Manager;
98 }
99
100 int GetType()
101 {
102 return m_ID;
103 }
104
105 void SetParam(Param p)
106 {
107
108 }
109
110 bool IsSyncToClient()
111 {
112 return m_SyncToClient;
113 }
114
116 bool IsSyncToRemotes()
117 {
118 return false;
119 }
120
121 void GetPersistentParams(array<Param> params)
122 {
123 for (int i = 0; i < m_PersistentParams.Count(); i++)
124 {
125 params.Insert(m_PersistentParams.Get(i));
126 }
127 }
128
129 void MakeParamObjectPersistent(Param object)
130 {
131 if ( !g_Game.IsServer() && !g_Game.IsMultiplayer() ) return;
132
133 m_PersistentParams.Insert(object);
134 }
135
136 bool IsPersistent()
137 {
138 return m_IsPersistent;
139 }
140
141 bool IsPrimary()
142 {
143 if ( m_SymptomType == SymptomTypes.PRIMARY)
144 return true;
145 else return false;
146 }
147
148 // override this if you want the symptom to be played also while the player is unconscious
149 bool AllowInUnconscious()
150 {
151 return false;
152 }
153
155 {
156 return m_Player;
157 }
158
159 int GetPriority()
160 {
161 return m_Priority;
162 }
163
164 bool OnConstructed(SymptomManager manager)
165 {
166
167 }
168
169 void OnDestructed()
170 {
171 if ( IsActivated() ) Deactivate();
172 if ( GetManager() ) m_Manager.OnSymptomExit(this, m_UID);
173 }
174
175 void Activate()
176 {
177 m_IsActivated = true;
178 if ( g_Game && g_Game.IsServer() )
179 {
180 OnGetActivatedServer(m_Player);
181 if ( g_Game.IsMultiplayer() )
182 {
183 if ( IsSyncToClient() )
184 SyncToClientActivated( GetType(), GetUID() );
185 #ifdef DIAG_DEVELOPER
186 GetManager().SendServerDebugToClient();
187 #endif
188 }
189 }
190 if ( !g_Game.IsDedicatedServer() )
191 {
192 OnGetActivatedClient(m_Player);
193 }
194 }
195
196 void Deactivate()
197 {
198 if ( !g_Game ) return;
199 m_IsActivated = false;
200 if ( g_Game.IsServer() )
201 {
202 OnGetDeactivatedServer(m_Player);
203 if ( g_Game.IsMultiplayer() && IsSyncToClient() )
204 {
205 SyncToClientDeactivated( GetType(), GetUID() );
206 }
207 }
208 if ( !g_Game.IsDedicatedServer() )
209 {
210 OnGetDeactivatedClient(m_Player);
211 }
212
213 }
214
215 bool IsActivated()
216 {
217 return m_IsActivated;
218 }
219
220
221
222 void Update(float deltatime)
223 {
224 if ( g_Game.IsServer() )
225 {
226 m_ServerUpdateDelta += deltatime;
227 if (m_ServerUpdateDelta > m_ServerUpdateInterval )
228 {
229 m_ActivatedTime += m_ServerUpdateDelta;
230 OnUpdateServer(m_Player, m_ServerUpdateDelta);
231 m_ServerUpdateDelta = 0;
232 }
233 }
234 if ( g_Game.IsClient() )
235 {
236 OnUpdateClient(m_Player, deltatime);
237 }
238 if ( g_Game.IsServer() && !g_Game.IsMultiplayer() && !g_Game.IsMissionMainMenu() )
239 {
240 OnUpdateClient(m_Player, deltatime);
241 }
242 CheckDestroy();
243 }
244
245 void PlayAnimationFB(int animation, int stance_mask, float running_time = -1)
246 {
247 DayZPlayerSyncJunctures.SendPlayerSymptomFB(m_Player, animation, GetType() , stance_mask, running_time );
248 m_AnimPlayRequested = true;
249 }
250
251 void PlayAnimationADD(int type)
252 {
253 DayZPlayerSyncJunctures.SendPlayerSymptomADD(m_Player, type, GetType());
254 m_AnimPlayRequested = true;
255 }
256
258 {
259 GetPlayer().RequestSoundEvent(id);
260 m_PlayedSound = true;
261 }
262
263 void StopSound(EPlayerSoundEventID id)
264 {
265 GetPlayer().RequestSoundEventStop(id);
266 m_PlayedSound = false;
267 }
268
269 void SyncToClientActivated( int SYMPTOM_id, int uid )
270 {
271 if ( !GetPlayer() ) return;
272
273 CachedObjectsParams.PARAM2_INT_INT.param1 = SYMPTOM_id;
274 CachedObjectsParams.PARAM2_INT_INT.param2 = uid;
275 g_Game.RPCSingleParam(GetPlayer(), ERPCs.RPC_PLAYER_SYMPTOM_ON, CachedObjectsParams.PARAM2_INT_INT,true,GetPlayer().GetIdentity() );
276 }
277
278 void SyncToClientDeactivated( int SYMPTOM_id, int uid )
279 {
280 if ( !GetPlayer() ) return;
281 CachedObjectsParams.PARAM2_INT_INT.param1 = SYMPTOM_id;
282 CachedObjectsParams.PARAM2_INT_INT.param2 = uid;
283 g_Game.RPCSingleParam(GetPlayer(), ERPCs.RPC_PLAYER_SYMPTOM_OFF, CachedObjectsParams.PARAM2_INT_INT,true,GetPlayer().GetIdentity() );
284 }
285
286 void CheckSoundFinished()
287 {
288 if (g_Game.IsServer())
289 {
290 if (m_PlayedSound && m_ActivatedTime >= m_Duration)
291 RequestDestroy();
292 }
293 }
294
295 void CheckDestroy()
296 {
297 CheckSoundFinished();
298 if ( IsPrimary() && m_ActivatedTime > MAX_TIME_ACTIVE_SAVEGUARD)
299 {
300 RequestDestroy();
301 }
302
303 if (m_DestroyRequested)
304 Destroy();
305 }
306
308 {
309 return null;
310 }
311
312
313 void RequestDestroy()
314 {
315 m_DestroyRequested = true;
316 //if(!IsActivated() ) Destroy();
317 }
318
319 void Destroy()
320 {
321 if (!m_IsTemplate)
322 OnDestructed();
323 }
324
326 void AnimationFinish()
327 {
328 //Print("*********** OnAnimationFinish ************");
329 if ( m_DestroyOnAnimFinish ) RequestDestroy();
331 }
332
333 void AnimationPlayFailed()
334 {
336 AnimationFinish();
337 }
338
339 void AnimationStart()
340 {
342 }
343
344 protected void OnAnimationFinish();
345 protected void OnAnimationStart();
346 protected void OnAnimationPlayFailed();
347
348
350 void OnInit();
351
353 void OnUpdateServer(PlayerBase player, float deltatime);
354 bool CanActivate(){return true;}//server only
356 void OnUpdateClient(PlayerBase player, float deltatime);
363}
eBleedingSourceType GetType()
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
void OnAnimationStart()
void OnGetActivatedServer(PlayerBase player)
gets called once on an Symptom which is being activated
bool CanActivate()
Definition statebase.c:354
void OnGetActivatedClient(PlayerBase player)
void OnInit()
this is just for the Symptom parameters set-up and is called even if the Symptom doesn't execute,...
void OnAnimationPlayFailed()
void OnAnimationFinish()
void OnGetDeactivatedClient(PlayerBase player)
void OnUpdateClient(PlayerBase player, float deltatime)
gets called every frame
void OnUpdateServer(PlayerBase player, float deltatime)
gets called every frame
void OnGetDeactivatedServer(PlayerBase player)
only gets called once on an active Symptom that is being deactivated
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZGame g_Game
Definition dayzgame.c:3942
override Widget Init()
Definition dayzgame.c:127
ERPCs
Definition erpcs.c:2
override SmptAnimMetaBase SpawnAnimMetaObject()
proto native void Destroy()
Cleans up the Effect, including unregistering if needed.
Definition effect.c:216
proto string GetName()
Suite class name getter. Strictly for UI porposes!
Definition syncedvalue.c:50
float GetDuration()
Definition tools.c:313
void Update()
Definition radialmenu.c:518
void PlaySound()
PlayerBase GetPlayer()
bool IsPersistent()
void Activate()
PlayerStats GetManager()
SymptomTypes