Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
plugindevelopersync.c
Go to the documentation of this file.
2 {
3  STATS = 1,
4  LEVELS = 2,
5  MODS = 4,
6  AGENTS = 8,
7  STOMACH = 16,
9  TEMPERATURE = 64,
10 }
11 
12 
14 {
15  int m_Bitmask;
17 
19  {
20  m_Bitmask = 0;
22  }
23 }
24 
25 class PluginDeveloperSync extends PluginBase
26 {
27  int m_DetailedInfoRequested = 0;
28  ref Timer m_UpdateTimer;
29  ref map<PlayerBase, ref RegisterPlayerData> m_RegisteredPlayers;
30 
31  ref array<ref SyncedValue> m_PlayerStatsSynced;
32  ref array<ref Param> m_PlayerStomachSynced;
33  ref array<ref SyncedValueLevel> m_PlayerLevelsSynced;
34  ref array<ref SyncedValueModifier> m_PlayerModsSynced;
35  string m_PlayerModsDetailedSynced;
36  string m_EnvironmentDebugMessage;
37  ref array<ref SyncedValueAgent> m_PlayerAgentsSynced;
38 
39  bool m_StatsUpdateStatus;
40  bool m_LevelsUpdateStatus;
41  bool m_ModsUpdateStatus;
42  bool m_AgentsUpdateStatus;
43  bool m_StomachUpdateStatus;
44 
45  void PluginDeveloperSync()
46  {
47  m_RegisteredPlayers = new map<PlayerBase, ref RegisterPlayerData>;
48  m_PlayerStatsSynced = new array<ref SyncedValue>;
49  m_PlayerLevelsSynced = new array<ref SyncedValueLevel>;
50  m_PlayerModsSynced = new array<ref SyncedValueModifier>;
51  m_PlayerAgentsSynced = new array<ref SyncedValueAgent>;
52  m_PlayerStomachSynced = new array<ref Param>;
53 
54  m_StatsUpdateStatus = false;
55  m_LevelsUpdateStatus = false;
56  m_ModsUpdateStatus = false;
57  m_AgentsUpdateStatus = false;
58  m_StomachUpdateStatus = false;
59  }
60 
61  //================================================================
62  // Init / Update
63  //================================================================
64  override void OnInit()
65  {
66  super.OnInit();
67 
68  if ( GetGame().IsServer() )
69  {
70  //create timer
72  }
73  }
74 
75 
76  void EnableUpdate( bool enable, int type, PlayerBase player )
77  {
78  //set update by type
79  if ( !IsPlayerRegistered(player))
80  RegisterPlayer( player );
81 
82 
83  switch ( type )
84  {
85  case ERPCs.DEV_STATS_UPDATE:
86  {
87  SetSystemInBitmask(player, PDS_SYSTEMS.STATS, enable);
88  break;
89  }
90 
91  case ERPCs.DEV_LEVELS_UPDATE:
92  {
93  SetSystemInBitmask(player, PDS_SYSTEMS.LEVELS, enable);
94  break;
95  }
96 
97  case ERPCs.DEV_MODS_UPDATE:
98  {
99  SetSystemInBitmask(player, PDS_SYSTEMS.MODS, enable);
100  break;
101  }
102 
103  case ERPCs.DEV_AGENTS_UPDATE:
104  {
105  SetSystemInBitmask(player, PDS_SYSTEMS.AGENTS, enable);
106  break;
107  }
108 
109  case ERPCs.DEV_STOMACH_UPDATE:
110  {
111  SetSystemInBitmask(player, PDS_SYSTEMS.STOMACH, enable);
112  break;
113  }
114  case ERPCs.DEV_TEMP_UPDATE:
115  {
116  SetSystemInBitmask(player, PDS_SYSTEMS.TEMPERATURE, enable);
117  break;
118  }
119  }
120 
121  //remove players with empty mask
122  for (int i = 0; i < m_RegisteredPlayers.Count(); i++)
123  {
124  if (m_RegisteredPlayers.GetElement(i).m_Bitmask == 0)
125  {
126  m_RegisteredPlayers.RemoveElement(i);
127  i = 0;
128  }
129  }
130 
131  //start/stop the tick based on existence/absence of players registered
132  if ( m_UpdateTimer )
133  {
134  if ( m_RegisteredPlayers.Count() == 0)
135  {
136  m_UpdateTimer.Stop();
137  }
138  else if (!m_UpdateTimer.IsRunning())
139  {
140  m_UpdateTimer.Run( 1, this, "Update", NULL, true );
141  }
142  }
143  }
144 
145 
146  void Update()
147  {
148  if ( !GetDayZGame().IsMultiplayer() || GetDayZGame().IsServer() )
149  {
150  for ( int i = 0; i < m_RegisteredPlayers.Count(); i++ )
151  {
152  PlayerBase player = m_RegisteredPlayers.GetKey( i );
153  if ( !player || !player.IsAlive() )
154  {
155  m_RegisteredPlayers.RemoveElement(i);
156  i--;
157  }
158  else
159  {
160  int bit_mask = m_RegisteredPlayers.Get( player ).m_Bitmask;
161 
162  if ((PDS_SYSTEMS.MODS & bit_mask) != 0 )
163  {
164  SendRPCMods( player);
165  if ( PDS_SYSTEMS.MODS_DETAILED & bit_mask )
166  SendRPCModsDetail( player);
167  }
168  if ((PDS_SYSTEMS.LEVELS & bit_mask) != 0 )
169  {
170  SendRPCLevels( player );
171  }
172 
173  if ((PDS_SYSTEMS.STATS & bit_mask) != 0 )
174  {
175  SendRPCStats( player );
176  }
177  if ((PDS_SYSTEMS.STOMACH & bit_mask) != 0 )
178  {
179  SendRPCStomach( player );
180  }
181  if ((PDS_SYSTEMS.AGENTS & bit_mask) != 0 )
182  {
183  SendRPCAgents( player );
184  }
185  if ((PDS_SYSTEMS.TEMPERATURE & bit_mask) )
186  {
187  SendRPCTemp( player );
188  }
189  }
190  }
191  }
192  }
193 
194  //turns on/off a bit for a given system marking it active/inactive
195  void SetSystemInBitmask( PlayerBase player, int system_bit, bool state)
196  {
197  if ( IsPlayerRegistered(player) )
198  {
199  int current_mask = m_RegisteredPlayers.Get(player).m_Bitmask;
200  if (state)
201  m_RegisteredPlayers.Get(player).m_Bitmask = current_mask | system_bit;
202  else
203  m_RegisteredPlayers.Get(player).m_Bitmask = current_mask & ~system_bit;
204  }
205 
206  }
207 
208  //turns on/off a bit for a given system marking it active/inactive
209  bool IsSetSystemInBitmask( PlayerBase player, int system_bit)
210  {
211  if ( IsPlayerRegistered(player) )
212  {
213  return (m_RegisteredPlayers.Get(player).m_Bitmask & system_bit);
214  }
215  return false;
216  }
217 
218 
219 
220 
221  //--- Register / Unregister player
222  void RegisterPlayer( PlayerBase player )
223  {
224  if ( !IsPlayerRegistered( player ) )
225  {
226  m_RegisteredPlayers.Insert( player, new RegisterPlayerData );
227  }
228  }
229 
230  /*
231  void UnregisterPlayer( PlayerBase player )
232  {
233  if ( IsPlayerRegistered( player ) )
234  {
235  m_RegisteredPlayers.Remove( player );
236  }
237  }
238 */
239  bool IsPlayerRegistered( PlayerBase player )
240  {
241  if ( m_RegisteredPlayers.Contains( player ))
242  {
243  return true;
244  }
245 
246  return false;
247  }
248 
249  //================================================================
250  // RPC
251  //================================================================
252  void OnRPC( PlayerBase player, int rpc_type, ParamsReadContext ctx )
253  {
254  if ( !GetGame().IsDebug() )
255  {
256  return;
257  }
258 
259  switch ( rpc_type )
260  {
261  case ERPCs.DEV_STATS_UPDATE:
262  {
263  EnableUpdate( GetRPCUpdateState( ctx ), ERPCs.DEV_STATS_UPDATE, player ); break;
264  }
265 
266  case ERPCs.DEV_LEVELS_UPDATE:
267  {
268  EnableUpdate( GetRPCUpdateState( ctx ), ERPCs.DEV_LEVELS_UPDATE, player ); break;
269  }
270 
271  case ERPCs.DEV_MODS_UPDATE:
272  {
273  EnableUpdate( GetRPCUpdateState( ctx ), ERPCs.DEV_MODS_UPDATE, player ); break;
274  }
275 
276  case ERPCs.DEV_AGENTS_UPDATE:
277  {
278  EnableUpdate( GetRPCUpdateState( ctx ), ERPCs.DEV_AGENTS_UPDATE, player ); break;
279  }
280 
281  case ERPCs.DEV_STOMACH_UPDATE:
282  {
283  EnableUpdate( GetRPCUpdateState( ctx ), ERPCs.DEV_STOMACH_UPDATE, player ); break;
284  }
285 
286  case ERPCs.DEV_RPC_STATS_DATA:
287  {
288  OnRPCStats( ctx ); break;
289  }
290 
291  case ERPCs.DEV_RPC_LEVELS_DATA:
292  {
293  OnRPCLevels( ctx ); break;
294  }
295 
296  case ERPCs.DEV_RPC_MODS_DATA:
297  {
298  OnRPCMods( ctx ); break;
299  }
300 
301  case ERPCs.DEV_RPC_MODS_DATA_DETAILED:
302  {
303  OnRPCModsDetailed( ctx ); break;
304  }
305 
306  case ERPCs.DEV_RPC_AGENTS_DATA:
307  {
308  OnRPCAgents( ctx ); break;
309  }
310  case ERPCs.DEV_RPC_STOMACH_DATA:
311  {
312  OnRPCStomach( ctx ); break;
313  }
314 
315  case ERPCs.DEV_RPC_MODS_ACTIVATE:
316  {
317  ActivateModifier( GetRPCModifierID( ctx ), player ); break;
318  }
319  case ERPCs.DEV_RPC_MODS_DETAILED:
320  {
321  RequestDetailedInfo( GetRPCModifierID( ctx ), player ); break;
322  }
323 
324  case ERPCs.DEV_RPC_MODS_DEACTIVATE:
325  {
326  DeactivateModifier( GetRPCModifierID( ctx ), player ); break;
327  }
328 
329  case ERPCs.DEV_RPC_MODS_LOCK:
330  {
331  int id;
332  bool lock;
333  GetRPCModifierLock( ctx, id, lock );
334  LockModifier( id, lock, player ); break;
335  }
336 
337  case ERPCs.DEV_RPC_MODS_RESET:
338  {
339  player.GetModifiersManager().DeactivateAllModifiers();
340  break;
341  }
342 
343  case ERPCs.DEV_RPC_STATS_RESET:
344  {
345  player.GetPlayerStats().ResetAllStats();
346  break;
347  }
348 
349  case ERPCs.DEV_RPC_STAT_SET:
350  {
351  OnRPCStatSet(ctx, player);
352  break;
353  }
354  case ERPCs.DEV_TEMP_UPDATE:
355  {
356  OnRPCTemp(ctx, player);
357  break;
358  }
359  }
360  }
361 
362  //get update status from ctx data
363  bool GetRPCUpdateState( ParamsReadContext ctx )
364  {
365  Param1<bool> p = new Param1<bool>( 0 );
366  if ( ctx.Read( p ) )
367  {
368  return p.param1;
369  }
370 
371  return false;
372  }
373 
374  //get modifier id from ctx data
375  int GetRPCModifierID( ParamsReadContext ctx )
376  {
377  Param1<int> p = new Param1<int>( 0 );
378  if ( ctx.Read( p ) )
379  {
380  return p.param1;
381  }
382 
383  return 0;
384  }
385 
386  //get modifier lock state from lock ctx data
387  void GetRPCModifierLock( ParamsReadContext ctx, out int id, out bool lock )
388  {
389  Param2<int, bool> p = new Param2<int, bool>( 0, false );
390  if ( ctx.Read( p ) )
391  {
392  id = p.param1;
393  lock = p.param2;
394  }
395  }
396 
397  //============================================
398  // STATS
399  //============================================
400  //send player stats through RPC
401  void SendRPCStats( PlayerBase player )
402  {
403  //write and send values
404  if ( player )
405  {
406  array<ref Param> rpc_params = new array<ref Param>;
407 
408  //param count
409  for ( int i = 0; i < player.m_PlayerStats.GetPCO().Get().Count(); i++ )
410  {
411  string label = player.m_PlayerStats.GetPCO().Get().Get( i ).GetLabel();
412  float value = (float) player.m_PlayerStats.GetPCO().Get().Get( i ).Get();
413  float value_norm = (float) player.m_PlayerStats.GetPCO().Get().Get( i ).GetNormalized();
414  rpc_params.Insert( new Param3<string, float, float>( label, value, value_norm ) );
415  }
416  rpc_params.Insert(new Param3<string, float, float>( "(NaS)Immunity", player.GetImmunity(),0 ));
417  rpc_params.Insert(new Param3<string, float, float>( "(NaS)BrokenLegs", player.m_BrokenLegState,0 ));
418 
419  rpc_params.InsertAt( new Param1<int>(rpc_params.Count() ), 0);// param count
420  //send params
421  GetDayZGame().RPC( player, ERPCs.DEV_RPC_STATS_DATA, rpc_params, true, player.GetIdentity() );
422  }
423  }
424 
425  //Display player stats
426  void OnRPCStats( ParamsReadContext ctx )
427  {
428  //clear values
429  m_PlayerStatsSynced.Clear();
430 
431 
432  Param1<int> p_count = new Param1<int>(0);
433 
435 
436  //get param count
437  int param_count = 0;
438  if ( ctx.Read(p_count) )
439  {
440  param_count = p_count.param1;
441  }
442 
443  //read values and set
444  for ( int i = 0; i < param_count; i++ )
445  {
446  ctx.Read(p);
447  m_PlayerStatsSynced.Insert( new SyncedValue( p.param1, p.param2, false, p.param3 ) );
448  }
449  }
450 
451  //Update data on local
452  void UpdateStatsLocal()
453  {
454  PlayerBase player = PlayerBase.Cast( GetDayZGame().GetPlayer() );
455 
456  //clear values
457  m_PlayerStatsSynced.Clear();
458 
459  //set values
460  for ( int i = 0; i < player.m_PlayerStats.GetPCO().Get().Count(); i++ )
461  {
462  string label = player.m_PlayerStats.GetPCO().Get().Get( i ).GetLabel();
463  float value = player.m_PlayerStats.GetPCO().Get().Get( i ).Get();
464  float value_norm = player.m_PlayerStats.GetPCO().Get().Get( i ).GetNormalized();
465  m_PlayerStatsSynced.Insert( new SyncedValue( label, value, false, value_norm ) );
466  }
467 
468  m_PlayerStatsSynced.Insert(new SyncedValue( "(NaS)Immunity", player.GetImmunity() , false, 0));
469  m_PlayerStatsSynced.Insert(new SyncedValue( "(NaS) BrokenLegs", player.m_BrokenLegState, false, 0));
470  }
471 
472  void OnRPCStatSet( ParamsReadContext ctx , PlayerBase player)
473  {
475  if ( ctx.Read(p) )
476  {
477  for ( int i = 0; i < player.m_PlayerStats.GetPCO().Get().Count(); i++ )
478  {
479  string label = player.m_PlayerStats.GetPCO().Get().Get( i ).GetLabel();
480  if ( label == p.param1 )
481  {
482  player.m_PlayerStats.GetPCO().Get().Get( i).SetByFloatEx(p.param2);
483  }
484 
485  }
486  }
487 
488  }
489 
490  //============================================
491  // LEVELS
492  //============================================
493  //send player stats through RPC
494  void SendRPCLevels( PlayerBase player )
495  {
496  //write and send values
497  if ( player )
498  {
499  array<ref Param> rpc_params = new array<ref Param>;
500 
501  rpc_params.Insert(new Param3<string, float, float>( "Immunity: "+ typename.EnumToString(EStatLevels, player.GetImmunityLevel() ),player.GetImmunityLevel(), player.GetBordersImmunity()));
502  rpc_params.Insert(new Param3<string, float, float>( "Blood: "+ typename.EnumToString(EStatLevels, player.GetStatLevelBlood()),player.GetStatLevelBlood(), player.GetStatBordersBlood()));
503  rpc_params.Insert(new Param3<string, float, float>( "Health: "+ typename.EnumToString(EStatLevels, player.GetStatLevelHealth() ),player.GetStatLevelHealth(), player.GetStatBordersHealth()));
504  rpc_params.Insert(new Param3<string, float, float>( "Energy: "+ typename.EnumToString(EStatLevels, player.GetStatLevelEnergy() ),player.GetStatLevelEnergy(), player.GetStatBordersEnergy()));
505  rpc_params.Insert(new Param3<string, float, float>( "Water: "+ typename.EnumToString(EStatLevels, player.GetStatLevelWater() ),player.GetStatLevelWater(), player.GetStatBordersWater()));
506 
507  int param_count = rpc_params.Count();
508  rpc_params.InsertAt( new Param3<string, float, float>( "PARAM_COUNT", param_count,0 ), 0);
509  //send params
510  GetDayZGame().RPC( player, ERPCs.DEV_RPC_LEVELS_DATA, rpc_params, true, player.GetIdentity() );
511  }
512  }
513 
514  //Display player stats
515  void OnRPCLevels( ParamsReadContext ctx )
516  {
517  //clear values
518  m_PlayerLevelsSynced.Clear();
519 
521 
522  //get param count
523  int param_count = 0;
524  if ( ctx.Read(p3) )
525  {
526  param_count = p3.param2;
527  }
528 
529  //read values and set
530  for ( int i = 0; i < param_count; i++ )
531  {
532  if ( ctx.Read(p3) )
533  m_PlayerLevelsSynced.Insert( new SyncedValueLevel( p3.param1, p3.param2, p3.param3 ) );
534  }
535  }
536 
537 
538  void SendRPCMods( PlayerBase player )
539  {
540  //write and send values
541  if ( player )
542  {
543  array<ref Param> rpc_params = new array<ref Param>;
544 
545  //get modifiers
546  ModifiersManager mods_manager = player.GetModifiersManager();
547 
548  //param count
550  mods_manager.DbgGetModifiers( modifiers );
551 
552  float param_count = ( float ) modifiers.Count();
553  rpc_params.Insert( new Param1<int>( param_count ));
554 
555  //set modifiers
556  for ( int i = 0; i < modifiers.Count(); ++i )
557  {
558  int id = modifiers.Get(i).GetID();
559  string name = modifiers.Get(i).GetName();
560  bool active = modifiers.Get(i).IsActive();
561  bool locked = modifiers.Get(i).IsLocked();
562 
563  rpc_params.Insert( new Param4<int, string, bool, bool>( id, name, active, locked ) );
564  }
565 
566  //send params
567  GetDayZGame().RPC( player, ERPCs.DEV_RPC_MODS_DATA, rpc_params, true, player.GetIdentity() );
568  }
569  }
570 
571  //============================================
572  // MODS
573  //============================================
574  //send player mods through RPC
575  void SendRPCModsDetail( PlayerBase player )
576  {
577  //write and send values
578  if ( player )
579  {
580  Param1<string> p1 = new Param1<string>("");
581  ModifiersManager mods_manager = player.GetModifiersManager();
582  int mod_id = m_RegisteredPlayers.Get(player).m_DetailedModifierIndex;
583  p1.param1 = mods_manager.GetModifier(mod_id).GetDebugText();
584  //send params
585  if (p1.param1 != "")
586  GetDayZGame().RPCSingleParam( player, ERPCs.DEV_RPC_MODS_DATA_DETAILED, p1, true, player.GetIdentity() );
587  }
588  }
589 
590  //Display player modifiers
591  void OnRPCMods( ParamsReadContext ctx )
592  {
593  //clear values
594  m_PlayerModsSynced.Clear();
595 
596  //ref Param3<string, float, bool> p = new Param3<string, float, bool>( "", 0, false );
597  Param1<int> p1 = new Param1<int>(0);
598  Param4<int, string, bool, bool> p4 = new Param4<int, string, bool, bool>( 0,"", false, false );
599  //get param count
600  int param_count = 0;
601  if ( ctx.Read(p1) )
602  {
603  param_count = (int) p1.param1;
604  }
605 
606  //read values and set
607  for ( int i = 0; i < param_count; i++ )
608  {
609  if (ctx.Read(p4))
610  {
611  m_PlayerModsSynced.Insert( new SyncedValueModifier( p4.param1, p4.param2, p4.param3, p4.param4 ) );
612  }
613  }
614  }
615 
616  void OnRPCModsDetailed( ParamsReadContext ctx )
617  {
618  Param1<string> p1 = new Param1<string>("");
619 
620  //get param count
621  if ( ctx.Read(p1) )
622  {
623  m_PlayerModsDetailedSynced = p1.param1;
624  }
625  }
626 
627 
628  /*
629  //Activates modifier with given ID
630  void RequestDetailedInfo( int id, PlayerBase player = NULL )
631  {
632  int modifier_id = Math.AbsInt( id );
633  if(id == m_DetailedInfoRequested)
634  {
635  m_DetailedInfoRequested = 0;//repeated request --> disable
636  }
637  else
638  {
639  m_DetailedInfoRequested = modifier_id;
640  }
641  }
642  */
643  //Activates modifier with given ID
644  void RequestDetailedInfo( int id, notnull PlayerBase player)
645  {
646  int modifier_id = Math.AbsInt( id );
647  m_RegisteredPlayers.Get(player).m_DetailedModifierIndex = modifier_id;
648 
649  if (IsSetSystemInBitmask(player, PDS_SYSTEMS.MODS_DETAILED ))
650  {
651  SetSystemInBitmask(player, PDS_SYSTEMS.MODS_DETAILED, false);
652  }
653  else
654  {
655  SetSystemInBitmask(player, PDS_SYSTEMS.MODS_DETAILED, true);
656  }
657  }
658 
659 
660  //Activates modifier with given ID
661  void ActivateModifier( int id, PlayerBase player = NULL )
662  {
663  if ( !player )
664  {
665  player = PlayerBase.Cast( GetDayZGame().GetPlayer() );
666  }
667  ModifiersManager mods_manager = player.GetModifiersManager();
668  mods_manager.ActivateModifier( Math.AbsInt( id ) );
669  }
670 
671  //Activates modifier with given ID
672  void DeactivateModifier( int id, PlayerBase player = NULL )
673  {
674  if ( !player )
675  {
676  player = PlayerBase.Cast( GetDayZGame().GetPlayer() );
677  }
678  ModifiersManager mods_manager = player.GetModifiersManager();
679  mods_manager.DeactivateModifier( Math.AbsInt( id ) );
680  }
681 
682  //Activates modifier with given ID
683  void LockModifier( int id, bool lock, PlayerBase player = NULL )
684  {
685  if ( !player )
686  {
687  player = PlayerBase.Cast( GetDayZGame().GetPlayer() );
688  }
689  ModifiersManager mods_manager = player.GetModifiersManager();
690  mods_manager.SetModifierLock( Math.AbsInt( id ), lock );
691  }
692 
693  bool IsModifierLocked( int id, PlayerBase player = NULL )
694  {
695  if ( !player )
696  {
697  player = PlayerBase.Cast( GetDayZGame().GetPlayer() );
698  }
699  ModifiersManager mods_manager = player.GetModifiersManager();
700 
701  return mods_manager.GetModifierLock( Math.AbsInt( id ) );
702  }
703 
704  //============================================
705  // TEMPERATURE
706  //============================================
707 
708  void SendRPCTemp( PlayerBase player )
709  {
710  if ( player )
711  {
712  CachedObjectsParams.PARAM1_STRING.param1 = player.m_Environment.GetDebugMessage();
713  GetDayZGame().RPCSingleParam( player, ERPCs.DEV_TEMP_UPDATE, CachedObjectsParams.PARAM1_STRING, true, player.GetIdentity() );
714  }
715  }
716 
717  void OnRPCTemp( ParamsReadContext ctx , PlayerBase player)
718  {
719  if (GetGame().IsServer() && GetGame().IsMultiplayer())
720  {
721  EnableUpdate( GetRPCUpdateState( ctx ), ERPCs.DEV_TEMP_UPDATE, player );
722  }
723  else if (!GetGame().IsMultiplayer() || GetGame().IsClient())
724  {
725  if ( ctx.Read(CachedObjectsParams.PARAM1_STRING) )
726  {
727  m_EnvironmentDebugMessage = CachedObjectsParams.PARAM1_STRING.param1;
728  }
729  }
730 
731  }
732 
733  //============================================
734  // AGENTS
735  //============================================
736  //send player mods through RPC
737  void SendRPCAgents( PlayerBase player )
738  {
739  //write and send values
740  if ( ( player && player.GetIdentity() && player.m_AgentPool != null ) || ( player && !GetGame().IsMultiplayer() && player.m_AgentPool != null ) )
741  {
742 
743  //get agent pool data
744  array<ref Param> agent_pool = new array<ref Param>;
745  player.m_AgentPool.GetDebugObject( agent_pool );
746 
747  GetDayZGame().RPC( player, ERPCs.DEV_RPC_AGENTS_DATA, agent_pool, true, player.GetIdentity() );
748  }
749  }
750 
751  //Display player modifiers
752  void OnRPCAgents( ParamsReadContext ctx )
753  {
754  //clear values
755  m_PlayerAgentsSynced.Clear();
756 
758  Param1<int> p1 = new Param1<int>(0);
759 
760  //get param count
761  int param_count = 0;
762  if ( ctx.Read(p1) )
763  {
764  param_count = p1.param1;
765  }
766 
767  //read values and set
768  for ( int i = 0; i < param_count; i++ )
769  {
770  ctx.Read(p3);
771  m_PlayerAgentsSynced.Insert( new SyncedValueAgent( p3.param1, p3.param2, p3.param3 ) );
772  }
773  }
774 
775  //============================================
776  // STOMACH
777  //============================================
778 
779  void SendRPCStomach( PlayerBase player )
780  {
781  //write and send values
782  if ( player )
783  {
784  array<ref Param> stomach = new array<ref Param>;
785  int count = player.m_PlayerStomach.GetDebugObject( stomach );
786  stomach.InsertAt(new Param1<int>(count), 0);
787 
788  GetDayZGame().RPC( player, ERPCs.DEV_RPC_STOMACH_DATA, stomach, true, player.GetIdentity() );
789  }
790  }
791 
792 
793  void OnRPCStomach( ParamsReadContext ctx )
794  {
795  //clear values
796  m_PlayerStomachSynced.Clear();
797 
798  Param1<int> p1 = new Param1<int>(0);
799  int param_count = 0;
800  if ( ctx.Read(p1) )
801  {
802  param_count = p1.param1;
803  }
804 
805  if (param_count)
806  {
807  //invidividual stomach items
808  for ( int i = 0; i < param_count; i++ )
809  {
810  Param4<int,int,int,float> p4 = new Param4<int,int,int,float>(0,0,0,0);
811  ctx.Read(p4);
812  m_PlayerStomachSynced.Insert(p4);
813  }
814  //volume
815  Param1<float> p1b = new Param1<float>(0);
816  ctx.Read(p1b);
817  m_PlayerStomachSynced.Insert(p1b);
818  }
819  }
820 
821  //Update data on local
822  /*
823  void UpdateAgentsLocal()
824  {
825  PlayerBase player = PlayerBase.Cast( GetDayZGame().GetPlayer() );
826 
827  if ( player )
828  {
829  //clear values
830  m_PlayerAgentsSynced.Clear();
831 
832  //get agent pool data
833  array<ref Param> agent_pool = new array<ref Param>;
834  player.m_AgentPool.GetDebugObject( agent_pool );
835 
836  //get agents count
837  Param1<int> p1 = Param1<int>.Cast( agent_pool.Get( 0 ) );
838  int agents_count = p1.param1;
839 
840  //set synced data
841  for ( int i = 0; i < agents_count; i++ )
842  {
843  string name = Param2<string,string>.Cast(agent_pool.Get(i+1)).param1;
844  string count = Param2<string,string>.Cast(agent_pool.Get(i+1)).param2;
845  m_PlayerAgentsSynced.Insert( new SyncedValueAgent( name, count, false ) );
846  }
847  }
848  }
849  */
850  //================================================================
851  // FOCUS
852  //================================================================
853  void CaptureFocus()
854  {
855  GetGame().GetInput().ChangeGameFocus( 1 );
856  GetGame().GetUIManager().ShowUICursor( true );
857  }
858 
859  void ReleaseFocus()
860  {
861  GetGame().GetInput().ChangeGameFocus( -1 );
862  GetGame().GetUIManager().ShowUICursor( false );
863  }
864 
865  void ToggleFocus()
866  {
867  if ( GetGame().GetInput().HasGameFocus() )
868  {
869  GetGame().GetInput().ChangeGameFocus( 1 );
870  GetGame().GetUIManager().ShowUICursor( true );
871  }
872  else
873  {
874  GetGame().GetInput().ResetGameFocus();
875  GetGame().GetUIManager().ShowUICursor( false );
876  }
877  }
878 }
Param2
Definition: ppeconstants.c:66
GetGame
proto native CGame GetGame()
LEVELS
@ LEVELS
Definition: plugindevelopersync.c:4
CALL_CATEGORY_GAMEPLAY
const int CALL_CATEGORY_GAMEPLAY
Definition: tools.c:10
GetDayZGame
DayZGame GetDayZGame()
Definition: dayzgame.c:3729
STATS
@ STATS
Definition: plugindevelopersync.c:3
ReleaseFocus
void ReleaseFocus()
Definition: plugindayzplayerdebug.c:374
CachedObjectsParams
Definition: utilityclasses.c:9
RegisterPlayerData
void RegisterPlayerData()
Definition: plugindevelopersync.c:18
m_DetailedModifierIndex
int m_DetailedModifierIndex
Definition: plugindevelopersync.c:16
Param3
Definition: entityai.c:95
PluginBase
Definition: pluginadminlog.c:1
STOMACH
@ STOMACH
Definition: plugindevelopersync.c:7
MODS_DETAILED
@ MODS_DETAILED
Definition: plugindevelopersync.c:8
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
OnRPC
void OnRPC(ParamsReadContext ctx)
Definition: displaystatus.c:216
AGENTS
@ AGENTS
Definition: plugindevelopersync.c:6
PlayerBase
Definition: playerbaseclient.c:1
map
map
Definition: controlsxboxnew.c:3
ModifiersManager
void ModifiersManager(PlayerBase player)
Definition: modifiersmanager.c:80
SyncedValue
Definition: syncedvalue.c:1
Get
array< ref PlayerStatBase > Get()
Definition: playerstatspco.c:103
array< ref SyncedValue >
Update
proto native volatile void Update()
Definition: playersoundmanager.c:125
TEMPERATURE
@ TEMPERATURE
Definition: plugindevelopersync.c:9
m_Bitmask
enum PDS_SYSTEMS m_Bitmask
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
EStatLevels
EStatLevels
Definition: estatlevels.c:1
int
Param3 int
GetPlayer
protected void GetPlayer()
Definition: crosshairselector.c:127
RequestDetailedInfo
void RequestDetailedInfo(int id)
Definition: huddebugwincharmodifiers.c:340
SyncedValueAgent
void SyncedValueAgent(string name, string value, int id)
Definition: syncedvalue.c:110
LockModifier
void LockModifier(int id, bool state)
Definition: huddebugwincharmodifiers.c:403
ERPCs
ERPCs
Definition: erpcs.c:1
OnInit
void OnInit()
Definition: aibehaviour.c:49
Timer
Definition: dayzplayerimplement.c:62
ActivateModifier
void ActivateModifier(int id)
Definition: huddebugwincharmodifiers.c:361
GetInput
ActionInput GetInput()
Definition: actionbase.c:1066
CaptureFocus
void CaptureFocus()
Definition: plugindayzplayerdebug.c:363
Math
Definition: enmath.c:6
SyncedValueModifier
Definition: syncedvalue.c:67
DeactivateModifier
void DeactivateModifier(int id)
Definition: huddebugwincharmodifiers.c:382
MODS
@ MODS
Definition: plugindevelopersync.c:5
PDS_SYSTEMS
PDS_SYSTEMS
Definition: plugindevelopersync.c:1
SyncedValueLevel
void SyncedValueLevel(string name, float value, float value2)
Definition: syncedvalue.c:43
Count
@ Count
Definition: randomgeneratorsyncmanager.c:7
float
Definition: enconvert.c:96
m_UpdateTimer
protected ref Timer m_UpdateTimer
Definition: radialmenu.c:20