Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
statemanager.c
Go to the documentation of this file.
1 enum AnimType
2 {
3  FULL_BODY = 1,
5 }
6 
7 enum SymptomIDs
8 {
9  SYMPTOM_COUGH = 1,
24 };
25 
27 {
30 };
31 
33 {
34  OK,
37 };
38 
39 const int DEBUG_PADDING_OFFSET = 2;
40 const int MAX_QUEUE_SIZE = 5;
41 
43 {
44  PlayerBase m_Player;
45  ref map<int, ref SymptomBase> m_AvailableSymptoms;
46  ref map<int, int> m_ActiveSymptomTypes;//for each type(symptom id), keep track of how many times it is in queue
47 
48  ref array<ref SymptomBase> m_SymptomQueuePrimary;
49  ref array<ref SymptomBase> m_SymptomQueueSecondary;
50 
51  ref map<int , SymptomBase > m_SymptomsUIDs;
52 
53 
54  ref array<ref Param> m_SymptomQueueServerDbg;
55  ref array<ref Param> m_SymptomQueueServerDbgPrimary;
56  ref array<ref Param> m_SymptomQueueServerDbgSecondary;
57  //ref array<string> m_SymptomQueueSecondaryServerDbg;
58  ref Timer m_Timer;
59 
60  int m_ActiveSymptomIndexPrimary = -1;
61  int m_CurrentCommandID;
62 
63  const int STORAGE_VERSION = 121;
64 
65  bool m_ShowDebug = false;
66  bool m_ShowDebug2 = false;
67 
68  ref SmptAnimMetaBase m_AnimMeta;
69 
70  void Init()
71  {
72  RegisterSymptom(new CoughSymptom);
73  RegisterSymptom(new VomitSymptom);
74  RegisterSymptom(new BlindnessSymptom);
75  RegisterSymptom(new SneezeSymptom);
76  RegisterSymptom(new FeverBlurSymptom);
77  RegisterSymptom(new BloodLoss);
78  RegisterSymptom(new LaughterSymptom);
79  RegisterSymptom(new FreezeSymptom);
80  RegisterSymptom(new HotSymptom);
81  RegisterSymptom(new PainLightSymptom);
82  RegisterSymptom(new PainHeavySymptom);
83  RegisterSymptom(new HandShiversSymptom);
84  //RegisterSymptom(new BulletHitSymptom);
85  }
86 
87  int GetStorageVersion()
88  {
89  return STORAGE_VERSION;
90  }
91 
92 
93  void AutoactivateSymptoms()
94  {
95  if ( GetGame().IsClient() )
96  {
97  return;
98  }
99 
100  QueueUpSecondarySymptom(SymptomIDs.SYMPTOM_BLOODLOSS);
101  }
102 
103  void SymptomManager(PlayerBase player)
104  {
105  m_ActiveSymptomTypes = new map<int, int>;
106  m_SymptomsUIDs = new map<int , SymptomBase >;
107  m_SymptomQueuePrimary = new array<ref SymptomBase>;
108  m_SymptomQueueSecondary = new array<ref SymptomBase>;
109  m_SymptomQueueServerDbg = new array<ref Param>;
110  m_SymptomQueueServerDbgPrimary = new array<ref Param>;
111  m_SymptomQueueServerDbgSecondary = new array<ref Param>;
112  m_AvailableSymptoms = new map<int, ref SymptomBase>;
113  m_Player = player;
114  Init();
115  AutoactivateSymptoms();
116  }
117 
118  void OnPlayerKilled()
119  {
120  for (int i = 0; i < m_SymptomQueuePrimary.Count(); i++)
121  {
122  m_SymptomQueuePrimary.Get(i).OnOwnerKilled();
123  }
124 
125  for (i = 0; i < m_SymptomQueueSecondary.Count(); i++)
126  {
127  if (m_SymptomQueueSecondary.Get(i)) m_SymptomQueueSecondary.Get(i).OnOwnerKilled();
128  }
129  }
130 
131  SymptomBase GetSymptomByUID(int SYMPTOM_uid)
132  {
133  return m_SymptomsUIDs.Get(SYMPTOM_uid);
134  }
135 
136 
137  void ~SymptomManager()
138  {
139  }
140 
141  PlayerBase GetPlayer()
142  {
143  return m_Player;
144  }
145 
146  void RegisterSymptom(SymptomBase Symptom)
147  {
148  Symptom.Init(this, m_Player,0);
149  int id = Symptom.GetType();
150 
151  if ( m_AvailableSymptoms.Contains(id) )
152  {
153  Error("SymptomBase Symptom already registered !");
154  return;
155  }
156 
157  m_AvailableSymptoms.Insert(id, Symptom);
158  //PrintString("inserting id: "+ToString(id));
159  }
160 
161  void OnAnimationFinished(eAnimFinishType type = eAnimFinishType.SUCCESS)
162  {
163  if ( m_AnimMeta )
164  {
165  m_AnimMeta.AnimFinished(type);
166  }
167  }
168 
169  void OnAnimationStarted()
170  {
171  if ( GetCurrentPrimaryActiveSymptom() )
172  GetCurrentPrimaryActiveSymptom().AnimationStart();
173  }
174 
175  int CreateUniqueID()
176  {
177  int uid = Math.RandomInt( 1, 2147483647);
178  if ( !IsUIDUsed(uid) ) return uid;
179  else return CreateUniqueID();
180  }
181 
182  bool IsUIDUsed(int uid)
183  {
184  return m_SymptomsUIDs.Contains(uid);
185  }
186 
187  string GetSymptomName(int symptom_id)
188  {
189  return m_AvailableSymptoms.Get(symptom_id).GetName();
190  }
191 
192  SmptAnimMetaBase SpawnAnimMetaObject(int symptom_id)
193  {
194  SmptAnimMetaBase animMeta = m_AvailableSymptoms.Get(symptom_id).SpawnAnimMetaObject();
195  animMeta.m_StateType = symptom_id;
196  return animMeta;
197  }
198 
200  void RequestSymptomExit(int SYMPTOM_uid)
201  {
202  if ( m_SymptomsUIDs.Get(SYMPTOM_uid) ) m_SymptomsUIDs.Get(SYMPTOM_uid).RequestDestroy();
203  }
204 
205  bool IsSymptomPrimary(int symptom_id)
206  {
207  return m_AvailableSymptoms.Get(symptom_id).IsPrimary();
208  }
209 
210  void OnInputUserDataReceived(ParamsReadContext ctx)
211  {
212  }
213 
214  int GetCurrentCommandID()
215  {
216  return m_CurrentCommandID;
217  }
218 
219  void OnTick(float deltatime, int pCurrentCommandID, HumanMovementState movement_state)
220  {
221  // pCurrentCommandID might be the initial value, but the system itself requires
222  // current value, so retrieve the current value from player instead
223  m_CurrentCommandID = m_Player.GetCurrentCommandID();
224  if (m_ActiveSymptomIndexPrimary == -1)
225  {
226  m_ActiveSymptomIndexPrimary = FindFirstAvailableSymptomIndex();
227  }
228 
229  UpdateActiveSymptoms(deltatime);
230 
231  if ( m_AnimMeta )
232  {
233  if ( m_AnimMeta.IsDestroyReqested() )
234  {
235  m_AnimMeta = null;
236  }
237  }
238 
239  if ( m_AnimMeta )
240  {
241 
242  //anim requested
243  if ( !m_AnimMeta.IsPlaying() )
244  {
245  // not playing yet and not possible to play
246  SymptomBase symptom = m_AvailableSymptoms.Get( m_AnimMeta.m_StateType );
247  if ( symptom && !symptom.CanActivate() )
248  {
249  m_AnimMeta = null;
250  }
251  else if ( m_AnimMeta.PlayRequest() == EAnimPlayState.FAILED )
252  {
253  OnAnimationFinished(eAnimFinishType.FAILURE);
254  }
255  }
256  else
257  {
258  m_AnimMeta.Update(movement_state);
259  }
260  }
261 
262  #ifdef DIAG_DEVELOPER
263  #ifndef SERVER //must be here !!!
264  if ( DiagMenu.GetBool(DiagMenuIDs.MISC_PLAYER_SYMPTOMS_SHOW) )
265  {
266  //DisplayDebug(true);
267  array<ref Param> primary_debug = PrepareClientDebug(m_SymptomQueuePrimary);
268  array<ref Param> secondary_debug = PrepareClientDebug(m_SymptomQueueSecondary);
269 
270  DisplayDebug1("Symptoms Client", 50, primary_debug, secondary_debug);
271  DisplayDebug2("Symptoms Server", 300, m_SymptomQueueServerDbgPrimary, m_SymptomQueueServerDbgSecondary);
272  ShowAvailableSymptoms();
273  }
274  else
275  {
276  CleanDebug1("Symptoms Client", 50);
277  CleanDebug2("Symptoms Server", 300);
278  CleanAvailableSymptoms();
279  }
280  #endif
281  #endif
282  }
283 
284  void SetAnimation(ParamsReadContext ctx)
285  {
286  if (m_AnimMeta)
287  {
288  // animation meta already exists
289  // pass
290  }
291  else
292  {
293  int state_type;
294  if (ctx.Read(state_type))
295  {
296  m_AnimMeta = SpawnAnimMetaObject(state_type);
297  if (m_AnimMeta)
298  {
299  m_AnimMeta.Init(ctx, this, m_Player);
300  }
301  }
302  }
303  }
304 
305  void UpdateActiveSymptoms(float deltatime)
306  {
307  //if( GetGame().IsClient() && !m_Player.IsPlayer() ) return;
308  //primary
309  if ( GetCurrentPrimaryActiveSymptom() )
310  {
311  if ( !GetCurrentPrimaryActiveSymptom().IsActivated() )
312  {
313  if ( GetCurrentPrimaryActiveSymptom().CanActivate() )
314  GetCurrentPrimaryActiveSymptom().Activate();
315  }
316  if ( GetCurrentPrimaryActiveSymptom().IsActivated() )
317  {
318  GetCurrentPrimaryActiveSymptom().Update(deltatime);
319  }
320  }
321  //secondary
322  for (int i = 0; i < m_SymptomQueueSecondary.Count(); i++)
323  {
324  if ( m_SymptomQueueSecondary.Get(i) && !m_SymptomQueueSecondary.Get(i).IsActivated() )
325  {
326  m_SymptomQueueSecondary.Get(i).Activate();
327  }
328  else
329  {
330  if (m_SymptomQueueSecondary.Get(i)) m_SymptomQueueSecondary.Get(i).Update(deltatime);
331  }
332  }
333  }
334 
335 
336  void OnSymptomExit(SymptomBase Symptom, int uid)
337  {
338  bool is_primary;
339  if ( Symptom )
340  {
341  is_primary = Symptom.IsPrimary();
342  DecreaseSymptomCount(Symptom.GetType());
343  }
344 
345  if ( m_SymptomsUIDs.Contains(uid) )
346  {
347  m_SymptomsUIDs.Remove(uid);
348  }
349  else
350  {
351  Debug.LogError("Symptom with this UID does not exist", "PlayerSymptoms");
352  }
353 
354  if (is_primary)
355  {
356  for (int i = 0; i < m_SymptomQueuePrimary.Count(); i++)
357  {
358  if ( m_SymptomQueuePrimary.Get(i) == Symptom )
359  {
360  m_SymptomQueuePrimary.RemoveOrdered(i);
361  break;
362  }
363  }
364  }
365  else
366  {
367  for (i = 0; i < m_SymptomQueueSecondary.Count(); i++)
368  {
369  if ( m_SymptomQueueSecondary.Get(i) == Symptom )
370  {
371  m_SymptomQueueSecondary.RemoveOrdered(i);
372  break;
373  }
374  }
375  }
376  m_ActiveSymptomIndexPrimary = -1;
377  #ifdef DIAG_DEVELOPER
378  if ( GetGame() ) SendServerDebugToClient();
379  #endif
380  }
381 
382 
383  int GetSymptomMaxCount(int symptom_id)
384  {
385  return m_AvailableSymptoms.Get(symptom_id).GetMaxCount();
386  }
387 
388 
389  int GetSymptomCount(int symptom_id)
390  {
391  if ( m_ActiveSymptomTypes.Contains(symptom_id) )
392  return m_ActiveSymptomTypes.Get(symptom_id);
393  else
394  return -1;
395  }
396 
397  void IncreaseSymptomCount(int symptom_id)
398  {
399  if ( m_ActiveSymptomTypes.Contains(symptom_id) )
400  {
401  m_ActiveSymptomTypes.Set(symptom_id, m_ActiveSymptomTypes.Get(symptom_id) + 1);
402  }
403  else
404  {
405  m_ActiveSymptomTypes.Insert(symptom_id, 1);
406  }
407  }
408 
409  void DecreaseSymptomCount(int symptom_id)
410  {
411  if ( m_ActiveSymptomTypes.Contains(symptom_id) )
412  {
413  if ( m_ActiveSymptomTypes.Get(symptom_id) == 1)
414  m_ActiveSymptomTypes.Remove(symptom_id);
415  else
416  m_ActiveSymptomTypes.Set(symptom_id, m_ActiveSymptomTypes.Get(symptom_id) - 1);
417  }
418  }
419 
420  SymptomBase SpawnSymptom( int symptom_id, int uid = -1 )
421  {
422  if ( m_AvailableSymptoms.Get(symptom_id) )
423  {
424  SymptomBase Symptom = SymptomBase.Cast(m_AvailableSymptoms.Get(symptom_id).ClassName().ToType().Spawn());
425  if (uid == -1)
426  {
427  uid = CreateUniqueID();
428  }
429  Symptom.Init(this, m_Player,uid);
430  if ( m_SymptomsUIDs.Contains(uid) )
431  Error("Symptoms: Unique ID already exists !");
432  m_SymptomsUIDs.Insert(uid, Symptom);
433  IncreaseSymptomCount(symptom_id);
434  return Symptom;
435  }
436 
437  if ( !Symptom )
438  {
439  Error("Symptom not registered");
440  }
441 
442  return NULL;
443  }
444 
445  void CleanUpPrimaryQueue()
446  {
447  for (int i = 0; i < m_SymptomQueuePrimary.Count(); i++)
448  {
449  m_SymptomQueuePrimary.Get(i).RequestDestroy();
450  }
451 
452  }
453 
454  SymptomBase QueueUpPrimarySymptom(int symptom_id, int uid = -1)
455  {
456  SymptomBase Symptom;
457  if ((GetSymptomCount(symptom_id) >= GetSymptomMaxCount(symptom_id)) && GetSymptomMaxCount(symptom_id) != -1)
458  return null;
459  for ( int i = 0; i < m_SymptomQueuePrimary.Count(); i++ )
460  {
461  if ( m_SymptomQueuePrimary.Get(i).CanBeInterupted() && ComparePriority( GetSymptomPriority(symptom_id), m_SymptomQueuePrimary.Get(i).GetPriority() ) == 1 )
462  {
463  Symptom = SpawnSymptom( symptom_id, uid );
464  m_SymptomQueuePrimary.InsertAt(Symptom,i);
465 
466  if ( m_SymptomQueuePrimary.Count() > MAX_QUEUE_SIZE )
467  {
468  m_SymptomQueuePrimary.Get(MAX_QUEUE_SIZE).RequestDestroy();// no need to remove from the array, that's done via Symptom callback on destruct
469  }
470  break;
471  }
472  }
473  if ( !Symptom && m_SymptomQueuePrimary.Count() < MAX_QUEUE_SIZE)
474  {
475  Symptom = SpawnSymptom( symptom_id, uid );
476  m_SymptomQueuePrimary.Insert(Symptom);
477  }
478  #ifdef DIAG_DEVELOPER
479  SendServerDebugToClient();
480  #endif
481  return Symptom;
482  }
483 
484  void QueueUpSecondarySymptom(int symptom_id, int uid = -1)
485  {
486  QueueUpSecondarySymptomEx(symptom_id, uid);
487  }
488 
489  SymptomBase QueueUpSecondarySymptomEx(int symptom_id, int uid = -1)
490  {
491  if ((GetSymptomCount(symptom_id) >= GetSymptomMaxCount(symptom_id)) && GetSymptomMaxCount(symptom_id) != -1)
492  return null;
493 
494  if ( m_AvailableSymptoms.Get(symptom_id).IsPrimary() )
495  return null;
496 
497  SymptomBase Symptom = SpawnSymptom( symptom_id, uid);
498 
499  m_SymptomQueueSecondary.Insert(Symptom);
500  return Symptom;
501  }
502 
504  void RemoveSecondarySymptom(int symptom_id)
505  {
506  for (int i = 0; i < m_SymptomQueueSecondary.Count();i++)
507  {
508  if ( m_SymptomQueueSecondary.Get(i) && m_SymptomQueueSecondary.Get(i).GetType() == symptom_id )
509  {
510  m_SymptomQueueSecondary.Get(i).RequestDestroy();
511  return;
512  }
513  }
514  }
515 
516  SymptomBase GetCurrentPrimaryActiveSymptom()
517  {
518  if ( GetGame().IsServer() )
519  {
520  if ( m_ActiveSymptomIndexPrimary >= 0 && m_ActiveSymptomIndexPrimary < m_SymptomQueuePrimary.Count() )
521  {
522  if ( m_SymptomQueuePrimary.Get(m_ActiveSymptomIndexPrimary) ) return m_SymptomQueuePrimary.Get(m_ActiveSymptomIndexPrimary);
523  }
524  }
525  if ( !GetGame().IsDedicatedServer() )
526  {
527  if ( m_SymptomQueuePrimary.Count() > 0 )
528  return m_SymptomQueuePrimary.Get(0);
529  }
530  return NULL;
531  }
532 
533  int FindFirstAvailableSymptomIndex()
534  {
535  for (int i = 0; i < m_SymptomQueuePrimary.Count();i++)
536  {
537  if ( m_SymptomQueuePrimary.Get(i).CanActivate() )
538  {
539  return i;
540  }
541  }
542  return -1;
543  }
544 
545  int ComparePriority( int prio1, int prio2 )
546  {
547  if ( prio1 > prio2 )
548  {
549  return 1;
550  }
551  else if ( prio2 > prio1 )
552  {
553  return 2;
554  }
555  return 0;
556  }
557 
558  int GetSymptomPriority(int symptom_id)
559  {
560  return m_AvailableSymptoms.Get(symptom_id).GetPriority();
561  }
562 
563  void OnRPC(int rpc_type, ParamsReadContext ctx)
564  {
565  ctx.Read(CachedObjectsParams.PARAM2_INT_INT);
566  int symptom_id = CachedObjectsParams.PARAM2_INT_INT.param1;
567  int uid = CachedObjectsParams.PARAM2_INT_INT.param2;
568 
569  bool is_primary = m_AvailableSymptoms.Get(symptom_id).IsPrimary();
570 
571  if ( rpc_type == ERPCs.RPC_PLAYER_SYMPTOM_ON )
572  {
573  if ( is_primary )
574  {
575  CleanUpPrimaryQueue();
576  QueueUpPrimarySymptom(symptom_id,uid);
577  }
578  else
579  {
580  QueueUpSecondarySymptom(symptom_id,uid);
581  }
582  }
583  else if ( rpc_type == ERPCs.RPC_PLAYER_SYMPTOM_OFF )
584  {
585  if ( is_primary )
586  {
587  CleanUpPrimaryQueue();
588  }
589  else
590  {
591  RemoveSecondarySymptom( symptom_id );
592  }
593  }
594  }
595 
596  void OnStoreSave( ParamsWriteContext ctx )
597  {
598  array<int> m_SaveQueue = new array<int>;
599 
600  for ( int i = 0; i < m_SymptomQueuePrimary.Count(); i++ )
601  {
602  if ( m_SymptomQueuePrimary.Get(i).IsPersistent() )
603  {
604  m_SaveQueue.Insert( m_SymptomQueuePrimary.Get(i).GetType() );
605  }
606  }
607 
608  for ( i = 0; i < m_SymptomQueueSecondary.Count(); i++ )
609  {
610  if ( m_SymptomQueueSecondary.Get(i).IsPersistent() )
611  {
612  m_SaveQueue.Insert( m_SymptomQueueSecondary.Get(i).GetType() );
613  }
614  }
615 
616  ctx.Write( m_SaveQueue );
617  }
618 
619  bool OnStoreLoad( ParamsReadContext ctx, int version )
620  {
621  array<int> m_SaveQueue;
622 
623  if (ctx.Read(m_SaveQueue))
624  {
625  for ( int i = 0; i < m_SaveQueue.Count(); i++ )
626  {
627  int id = m_SaveQueue.Get(i);
628 
629  if ( IsSymptomPrimary(id) )
630  {
631  QueueUpPrimarySymptom( id );
632  }
633  else
634  {
635  QueueUpSecondarySymptom( id );
636  }
637  }
638  return true;
639  }
640  else
641  {
642  return false;
643  }
644  }
645 
646 #ifdef DIAG_DEVELOPER
647  void OnRPCDebug(int rpc_type, ParamsReadContext ctx)
648  {
649  switch (rpc_type)
650  {
651  case ERPCs.DIAG_PLAYER_SYMPTOMS_DEBUG_ON:
652  {
653  if (ctx.Read(CachedObjectsParams.PARAM1_INT))
654  {
655  if (IsSymptomPrimary(CachedObjectsParams.PARAM1_INT.param1))
656  {
657  QueueUpPrimarySymptom(CachedObjectsParams.PARAM1_INT.param1);
658  }
659  else
660  {
661  QueueUpSecondarySymptom(CachedObjectsParams.PARAM1_INT.param1);
662  }
663  }
664  break;
665  }
666 
667  case ERPCs.DIAG_PLAYER_SYMPTOMS_DEBUG_OFF:
668  {
669  if (ctx.Read(CachedObjectsParams.PARAM1_INT))
670  RequestSymptomExit(CachedObjectsParams.PARAM1_INT.param1);
671  break;
672  }
673 
674  case ERPCs.DIAG_PLAYER_SYMPTOMS_DEBUG:
675  {
676  int primary_Symptoms_count;
677  int secondary_Symptoms_count;
678 
679  int symptom_id;
680 
681  if (ctx.Read(CachedObjectsParams.PARAM1_INT))
682  {
683  primary_Symptoms_count = CachedObjectsParams.PARAM1_INT.param1;
684  }
685 
686  if (ctx.Read(CachedObjectsParams.PARAM1_INT))
687  {
688  secondary_Symptoms_count = CachedObjectsParams.PARAM1_INT.param1;
689  }
690 
691  m_SymptomQueueServerDbg.Clear();
692  m_SymptomQueueServerDbgPrimary.Clear();
693  m_SymptomQueueServerDbgSecondary.Clear();
694 
695  int overall_count = primary_Symptoms_count + secondary_Symptoms_count;
696  for (int i = 0; i < overall_count ; ++i)
697  {
699  ctx.Read(p3);
700  bool is_primary = p3.param1;
701 
702  if (is_primary)
703  {
704  m_SymptomQueueServerDbgPrimary.Insert(p3);// m_SymptomQueueServerDbg.Insert(p3);
705  }
706  else
707  {
708  m_SymptomQueueServerDbgSecondary.Insert(p3);
709  }
710  //PrintString("elements m_SymptomQueueServerDbgPrimary:" + m_SymptomQueueServerDbgPrimary.Count());
711  //PrintString("elements m_SymptomQueueServerDbgSecondary:" + m_SymptomQueueServerDbgSecondary.Count());
712 
713  }
714  /*
715  for(i = 0; i < secondary_Symptoms_count; i++)
716  {
717  ctx.Read(CachedObjectsParams.PARAM1_STRING);
718  m_SymptomQueueSecondaryServerDbg.Insert(CachedObjectsParams.PARAM1_STRING.param1);
719  }*/
720  break;
721  }
722  }
723  }
724 
725  void SendServerDebugToClient()
726  {
727  array<ref Param> debug_list = new array<ref Param>;
728 
729  Param1<int> p1 = new Param1<int>(0);
730  Param1<int> p2 = new Param1<int>(0);
731 
732  p1.param1 = m_SymptomQueuePrimary.Count();
733  p2.param1 = m_SymptomQueueSecondary.Count();
734 
735  debug_list.Insert(p1);
736  debug_list.Insert(p2);
737 
739 
740  bool is_primary;
741  int symptom_id;
742  int SYMPTOM_uid;
743 
744  foreach ( SymptomBase symptom : m_SymptomQueuePrimary )
745  {
746  is_primary = symptom.IsPrimary();
747  symptom_id = symptom.GetType();
748  SYMPTOM_uid = symptom.GetUID();
749 
750  p = new Param3<bool,int,int>(is_primary, symptom_id, SYMPTOM_uid );
751  debug_list.Insert(p);
752  }
753 
754  foreach ( SymptomBase secSymptom : m_SymptomQueueSecondary )
755  {
756  is_primary = secSymptom.IsPrimary();
757  symptom_id = secSymptom.GetType();
758  SYMPTOM_uid = secSymptom.GetUID();
759 
760  p = new Param3<bool,int,int>(is_primary, symptom_id, SYMPTOM_uid );
761  debug_list.Insert(p);
762  }
763 
764  GetGame().RPC(GetPlayer(), ERPCs.DIAG_PLAYER_SYMPTOMS_DEBUG, debug_list, true);
765  }
766 
767  void DebugRequestExitSymptom(int SYMPTOM_uid)
768  {
769  CachedObjectsParams.PARAM1_INT.param1 = SYMPTOM_uid;
770  if (GetPlayer())
771  GetGame().RPCSingleParam(GetPlayer(), ERPCs.DIAG_PLAYER_SYMPTOMS_DEBUG_OFF, CachedObjectsParams.PARAM1_INT, true, GetPlayer().GetIdentity());
772  }
773 
774  array<ref Param> PrepareClientDebug(array<ref SymptomBase> Symptoms)
775  {
776  array<ref Param> debug_array = new array<ref Param>;
777 
779 
780  for (int i = 0; i < Symptoms.Count(); i++)
781  {
782  bool is_primary = Symptoms.Get(i).IsPrimary();
783  int symptom_id = Symptoms.Get(i).GetType();
784  int SYMPTOM_uid = Symptoms.Get(i).GetUID();
785 
786  p3 = new Param3<bool,int,int>(is_primary, symptom_id, SYMPTOM_uid );
787  debug_array.Insert(p3);
788  }
789  return debug_array;
790  }
791 
792  void DisplayDebug1(string name, int y_offset, array<ref Param> Symptoms_primary, array<ref Param> Symptoms_secondary)
793  {
794  string primary;
796 
797  DbgUI.BeginCleanupScope();
798  DbgUI.Begin(name, 50, y_offset);
799  DbgUI.Text("Primary: ");
800 
801  bool is_primary;
802  int symptom_id;
803  int SYMPTOM_uid;
804  string SYMPTOM_name;
805 
806  for (int i = 0; i < Symptoms_primary.Count(); i++)
807  {
808  p3 = Param3<bool, int, int>.Cast(Symptoms_primary.Get(i));
809 
810  is_primary = p3.param1;
811  symptom_id = p3.param2;
812  SYMPTOM_uid = p3.param3;
813  SYMPTOM_name = GetSymptomName(symptom_id);
814 
815  primary += SYMPTOM_name + " | ";
816  }
817 
818  DbgUI.Text(primary);
819  DbgUI.Text("Secondary: ");
820  for (i = 0; i < Symptoms_secondary.Count(); i++)
821  {
822  p3 = Param3<bool, int, int>.Cast(Symptoms_secondary.Get(i));
823 
824  is_primary = p3.param1;
825  symptom_id = p3.param2;
826  SYMPTOM_uid = p3.param3;
827  SYMPTOM_name = GetSymptomName(symptom_id);
828  DbgUI.Text(SYMPTOM_name);
829  }
830 
831  DbgUI.End();
832  DbgUI.EndCleanupScope();
833  }
834 
835  void DisplayDebug2(string name, int y_offset, array<ref Param> Symptoms_primary, array<ref Param> Symptoms_secondary)
836  {
837  string primary;
839 
840  DbgUI.BeginCleanupScope();
841  DbgUI.Begin(name, 50, y_offset);
842  DbgUI.Text("Primary: ");
843 
844  bool is_primary;
845  int symptom_id;
846  int SYMPTOM_uid;
847  string SYMPTOM_name;
848 
849  for (int i = 0; i < Symptoms_primary.Count(); i++)
850  {
851  p3 = Param3<bool, int, int>.Cast(Symptoms_primary.Get(i));
852 
853  is_primary = p3.param1;
854  symptom_id = p3.param2;
855  SYMPTOM_uid = p3.param3;
856  SYMPTOM_name = GetSymptomName(symptom_id);
857 
858  if (DbgUI.Button( i.ToString() + " " + SYMPTOM_name, 80))
859  {
860  DebugRequestExitSymptom(SYMPTOM_uid);
861  }
862  }
863 
864  DbgUI.Text("Secondary: ");
865  for (i = 0; i < Symptoms_secondary.Count(); i++)
866  {
867  p3 = Param3<bool, int, int>.Cast(Symptoms_secondary.Get(i));
868 
869  is_primary = p3.param1;
870  symptom_id = p3.param2;
871  SYMPTOM_uid = p3.param3;
872  SYMPTOM_name = GetSymptomName(symptom_id);
873 
874  if (DbgUI.Button( i.ToString() + " " + SYMPTOM_name, 80))
875  {
876  DebugRequestExitSymptom(SYMPTOM_uid);
877  }
878  }
879 
880  DbgUI.End();
881  DbgUI.EndCleanupScope();
882  }
883 
884  void ShowAvailableSymptoms()
885  {
886  DbgUI.BeginCleanupScope();
887  DbgUI.Begin("available Symptoms", 300, 50);
888 
889  for (int i = 0; i < m_AvailableSymptoms.Count(); i++)
890  {
891  SymptomBase Symptom = m_AvailableSymptoms.GetElement(i);
892  string SYMPTOM_name = Symptom.GetName();
893  int symptom_id = Symptom.GetType();
894 
895  if (DbgUI.Button( i.ToString() + " " + SYMPTOM_name, 80))
896  {
897  DebugRequestActivateSymptom(symptom_id);
898  }
899  }
900 
901  DbgUI.End();
902  DbgUI.EndCleanupScope();
903  }
904 
905  void CleanAvailableSymptoms()
906  {
907  DbgUI.BeginCleanupScope();
908  DbgUI.Begin("available Symptoms", 300, 50);
909  DbgUI.End();
910  DbgUI.EndCleanupScope();
911  }
912 
913  void CleanDebug1(string name, int y_offset)
914  {
915  DbgUI.BeginCleanupScope();
916  DbgUI.Begin(name, 50, y_offset);
917  DbgUI.End();
918  DbgUI.EndCleanupScope();
919  }
920 
921  void CleanDebug2(string name, int y_offset)
922  {
923  DbgUI.BeginCleanupScope();
924  DbgUI.Begin(name, 50, y_offset);
925  DbgUI.End();
926  DbgUI.EndCleanupScope();
927  }
928 
929  void DebugRequestActivateSymptom(int symptom_id)
930  {
931  CachedObjectsParams.PARAM1_INT.param1 = symptom_id;
932  if (GetPlayer())
933  GetGame().RPCSingleParam(GetPlayer(), ERPCs.DIAG_PLAYER_SYMPTOMS_DEBUG_ON, CachedObjectsParams.PARAM1_INT, true, GetPlayer().GetIdentity());
934  }
935 
936 #endif
937 }
GetGame
proto native CGame GetGame()
SYMPTOM_FREEZE
enum AnimType SYMPTOM_FREEZE
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
SYMPTOM_FEVERBLUR
enum AnimType SYMPTOM_FEVERBLUR
DbgUI
Definition: dbgui.c:59
DiagMenu
Definition: endebug.c:232
SYMPTOM_BLINDNESS
enum AnimType SYMPTOM_BLINDNESS
DEBUG_PADDING_OFFSET
const int DEBUG_PADDING_OFFSET
Definition: statemanager.c:39
CachedObjectsParams
Definition: utilityclasses.c:9
SymptomManager
Definition: statemanager.c:42
SymptomBase
Definition: statebase.c:1
Param3
Definition: entityai.c:95
SYMPTOM_SNEEZE
enum AnimType SYMPTOM_SNEEZE
HumanMovementState
Definition: human.c:1125
SECONDARY
@ SECONDARY
Definition: statemanager.c:29
AnimType
AnimType
Definition: statemanager.c:1
SYMPTOM_BLEEDING_SOURCE
enum AnimType SYMPTOM_BLEEDING_SOURCE
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
DiagMenuIDs
DiagMenuIDs
Definition: ediagmenuids.c:1
PlayerBase
Definition: playerbaseclient.c:1
map
map
Definition: controlsxboxnew.c:3
EAnimPlayState
EAnimPlayState
Definition: statemanager.c:32
SYMPTOM_VOMIT
enum AnimType SYMPTOM_VOMIT
OK
@ OK
Definition: statemanager.c:34
SYMPTOM_COUGH
enum AnimType SYMPTOM_COUGH
m_Player
DayZPlayer m_Player
Definition: hand_events.c:42
FULL_BODY
@ FULL_BODY
Definition: statemanager.c:3
array< ref SymptomBase >
SymptomTypes
SymptomTypes
Definition: statemanager.c:26
SYMPTOM_LAUGHTER
enum AnimType SYMPTOM_LAUGHTER
SYMPTOM_BLOODLOSS
enum AnimType SYMPTOM_BLOODLOSS
MAX_QUEUE_SIZE
const int MAX_QUEUE_SIZE
Definition: statemanager.c:40
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
SYMPTOM_HAND_SHIVER
enum AnimType SYMPTOM_HAND_SHIVER
Debug
Definition: debug.c:13
SYMPTOM_BULLET_HIT
enum AnimType SYMPTOM_BULLET_HIT
PRIMARY
@ PRIMARY
Definition: statemanager.c:28
SYMPTOM_PAIN_HEAVY
enum AnimType SYMPTOM_PAIN_HEAVY
SYMPTOM_PAIN_LIGHT
enum AnimType SYMPTOM_PAIN_LIGHT
ERPCs
ERPCs
Definition: erpcs.c:1
Timer
Definition: dayzplayerimplement.c:62
FAILED
@ FAILED
Definition: statemanager.c:36
POSTPONED
@ POSTPONED
Definition: statemanager.c:35
SYMPTOM_HOT
enum AnimType SYMPTOM_HOT
SYMPTOM_UNCONSCIOUS
enum AnimType SYMPTOM_UNCONSCIOUS
Math
Definition: enmath.c:6
eAnimFinishType
eAnimFinishType
Definition: smptanimmeta.c:1
SmptAnimMetaBase
Definition: smptanimmeta.c:82
STORAGE_VERSION
const int STORAGE_VERSION
Definition: modifiersmanager.c:79
ADDITIVE
@ ADDITIVE
Definition: statemanager.c:4