Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
plugindeveloper.c
Go to the documentation of this file.
1 typedef Param7<EntityAI, string, float, float, bool, string, FindInventoryLocationType> DevSpawnItemParams;//(target, item_name, health, quantity, special, presetName, locationType );
2 class PluginDeveloper extends PluginBase
3 {
4  protected bool m_IsWinHolding;
5  protected int m_FeaturesMask;
6  UIScriptedMenu m_ScriptConsole;
7 
8  static PluginDeveloper GetInstance()
9  {
10  return PluginDeveloper.Cast( GetPlugin( PluginDeveloper ) );
11  }
12 
14  void TeleportAtCursor()
15  {
16  DeveloperTeleport.TeleportAtCursorEx();
17  }
18 
20  void Teleport(PlayerBase player, vector position)
21  {
22  DeveloperTeleport.SetPlayerPosition(player, position);
23  }
24 
26  void ToggleFreeCameraBackPos()
27  {
28  DeveloperFreeCamera.FreeCameraToggle( PlayerBase.Cast( GetGame().GetPlayer() ), false );
29  }
30 
32  void ToggleFreeCamera()
33  {
34  DeveloperFreeCamera.FreeCameraToggle( PlayerBase.Cast( GetGame().GetPlayer() ), true );
35  }
36 
37  bool IsEnabledFreeCamera()
38  {
39  return DeveloperFreeCamera.IsFreeCameraEnabled();
40  }
41 
42  // System Public Events
43  void PluginDeveloper()
44  {
45 
46  }
47 
48  override void OnInit()
49  {
50  super.OnInit();
51 
52  DeveloperFreeCamera.OnInit();
53  }
54 
55  void OnRPC(PlayerBase player, int rpc_type, ParamsReadContext ctx)
56  {
57  #ifdef DIAG_DEVELOPER
58  switch (rpc_type)
59  {
60  case ERPCs.DEV_RPC_SPAWN_ITEM_ON_GROUND:
61  {
62  OnRPCSpawnEntityOnGround(player, ctx); break;
63  }
64  case ERPCs.DEV_RPC_SPAWN_ITEM_ON_GROUND_PATTERN_GRID:
65  {
66  OnRPCSpawnEntityOnGroundPatternGrid(player, ctx); break;
67  }
68  case ERPCs.DEV_RPC_SPAWN_ITEM_ON_CURSOR:
69  {
70  OnRPCSpawnEntityOnCursorDir(player, ctx); break;
71  }
72  case ERPCs.DEV_RPC_SPAWN_ITEM_IN_INVENTORY:
73  {
74  OnRPCSpawnEntity(player, ctx); break;
75  }
76  case ERPCs.DEV_RPC_CLEAR_INV:
77  {
78  OnRPCClearInventory(player); break;
79  }
80  case ERPCs.DEV_RPC_SEND_SERVER_LOG:
81  {
82  OnRPCServerLogRecieved( ctx ); break;
83  }
84  case ERPCs.RPC_SYNC_SCENE_OBJECT:
85  {
86  OnRPCSyncSceneObject( ctx ); break;
87  }
88  case ERPCs.DEV_RPC_PLUGIN_DZCREATURE_DEBUG:
89  {
90  OnRPCPluginDayzCreatureDebug(player, rpc_type, ctx); break;
91  }
92  case ERPCs.DEV_RPC_SPAWN_PRESET:
93  {
94  string presetName;
95  EntityAI target;
96 
97  ctx.Read(presetName);
98  ctx.Read(target);
99 
100  HandlePresetSpawn(player,presetName, target); break;
101  }
102  case ERPCs.DEV_RPC_SET_TIME:
103  {
104  HandleSetTime(player,ctx); break;
105  }
106  }
107 
108  DeveloperTeleport.OnRPC(player, rpc_type, ctx);
109  #endif
110  }
111 
112  // Public API
113  // Send Print to scripted console
114  void PrintLogClient(string msg_log)
115  {
116  if ( g_Game.GetUIManager().IsMenuOpen(MENU_SCRIPTCONSOLE) )
117  {
118  Param1<string> msg_p = new Param1<string>(msg_log);
120  }
121  }
122 
123  // Server Log Synch: Server Side
124  void SendServerLogToClient(string msg)
125  {
126  if ( GetGame() )
127  {
128  array<Man> players = new array<Man>;
129  GetGame().GetPlayers( players );
130 
131  for ( int i = 0; i < players.Count(); ++i )
132  {
133  Param1<string> param = new Param1<string>( msg );
134  Man player = players.Get(i);
135 
136  if ( player && player.HasNetworkID() )
137  {
138  player.RPCSingleParam(ERPCs.DEV_RPC_SEND_SERVER_LOG, param, true, player.GetIdentity());
139  }
140  }
141  }
142  }
143 
144  void OnRPCSyncSceneObject( ParamsReadContext ctx )
145  {
147 
148  if ( ctx.Read( par ) )
149  {
150  PluginSceneManager module_scene_editor = PluginSceneManager.Cast( GetPlugin( PluginSceneManager ) );
151  SceneData scene_data = module_scene_editor.GetLoadedScene();
152  SceneObject scene_object = scene_data.GetSceneObjectByEntityAI( par.param2 );
153 
154  GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).CallByName( scene_object, par.param1, par.param3 );
155  }
156  }
157 
158  void OnRPCPluginDayzCreatureDebug(PlayerBase player, int rpc_type, ParamsReadContext ctx)
159  {
161  if (pluginDZCreatureDebug)
162  {
163  pluginDZCreatureDebug.OnRpc(player, rpc_type, ctx);
164  }
165  }
166 
167  void HandleSetTime(PlayerBase player, ParamsReadContext ctx)
168  {
169  #ifdef DEVELOPER
170 
171  Param5<int,int,int,int,int> p5 = new Param5<int,int,int,int,int>(0,0,0,0,0);
172 
173  if ( ctx.Read( p5 ) )
174  {
175  //float time01 = p5.param4 / 100;
176  //int time_minutes = Math.Lerp(0, 24*60, time01 );
177 
178  int year = p5.param1;
179  int month = p5.param2;
180  int day = p5.param3;
181  int hour = p5.param4;
182  int minute = p5.param5;
183 
184 
185 
186  GetGame().GetWorld().SetDate(year,month, day, hour, minute);
187  /*
188  Debug.Log("year:" + year);
189  Debug.Log("month:" + month);
190  Debug.Log("day:" + day);
191  Debug.Log("hour:" + hour);
192  Debug.Log("minute:" + minute);
193  */
194  }
195 
196  #endif
197  }
198 
199  void HandlePresetSpawn(PlayerBase player, string presetName, EntityAI target)
200  {
201  #ifdef DEVELOPER
202 
203  PlayerBase targetPlayer = player;
204 
205  if (target)
206  {
207  targetPlayer = PlayerBase.Cast(target);
208  }
209  if (!targetPlayer)
210  return;
211 
212  targetPlayer.m_PresetSpawned = true;
213  string class_name = presetName + "_Preset";
214  typename type = class_name.ToType();
215 
216  if (type)
217  {
218  PresetSpawnBase presetObj = PresetSpawnBase.Cast(type.Spawn());
219 
220  if (presetObj)
221  {
222  presetObj.Init(targetPlayer);
223  }
224  }
225 
226  #endif
227  }
228 
229  // RPC Events
230  // Server Log Synch: Client Side
231  void OnRPCServerLogRecieved(ParamsReadContext ctx)
232  {
233  Param1<string> param = new Param1<string>( "" );
234 
235  if ( ctx.Read(param) && param.param1 != "" )
236  {
237  Debug.ReceivedLogMessageFromServer(param.param1);
238  }
239  }
240 
241  void OnRPCClearInventory(PlayerBase player)
242  {
243  ClearInventory(player);
244  }
245 
246  // Client -> Server Spawning: Server Side
247  void OnRPCSpawnEntityOnCursorDir(PlayerBase player, ParamsReadContext ctx)
248  {
249  Param7<string, float, float, float, bool, string, bool> p = new Param7<string, float, float, float, bool, string, bool>("", 0, 0, 0, false, "", false);
250  if ( ctx.Read(p) )
251  {
252  SpawnEntityOnCursorDir(player, p.param1, p.param2, p.param3, p.param4, p.param5, p.param6, p.param7);
253  }
254  }
255 
256  void OnRPCSpawnEntityOnGround(PlayerBase player, ParamsReadContext ctx)
257  {
258  Param6<string, float, float, vector, bool, bool> p = new Param6<string, float, float, vector, bool, bool>("", 0, 0, "0 0 0", false, false);
259  if ( ctx.Read(p) )
260  {
261  SpawnEntityOnGroundPos(player, p.param1, p.param2, p.param3, p.param4, p.param5, p.param6);
262  }
263  }
264 
265  void OnRPCSpawnEntityOnGroundPatternGrid(PlayerBase player, ParamsReadContext ctx)
266  {
267  auto p = new Param10<string,int, float, float, int, int, float, float, bool, bool>("",0,0,0,0,0,0,0, false, false);
268  if ( ctx.Read(p) )
269  {
270  SpawnEntityOnGroundPatternGrid(player, p.param1, p.param2, p.param3, p.param4, p.param5, p.param6, p.param7, p.param8, p.param9, p.param10);
271  }
272  }
273  void OnRPCSpawnEntity(PlayerBase player, ParamsReadContext ctx)
274  {
275  #ifdef DEVELOPER
276  DevSpawnItemParams p = new DevSpawnItemParams(null,"", 0, 0, false, "", FindInventoryLocationType.ANY);
277  if ( ctx.Read(p) )
278  {
279  EntityAI target = EntityAI.Cast(p.param1);
280  PlayerBase playerTarget = PlayerBase.Cast(target);
281 
282  EntityAI ent = SpawnEntityInInventory( target, p.param2, p.param3, p.param4, p.param5, "", p.param7);
283  if (playerTarget && p.param5)
284  {
285  if (playerTarget.m_PresetSpawned)
286  {
287  playerTarget.m_PresetSpawned = false;
288  playerTarget.m_PresetItems.Clear();
289  }
290  if (ent)
291  {
292  playerTarget.m_PresetItems.Insert(ent);
293  }
294  }
295  }
296  #endif
297  }
298 
299  void OnSetFreeCameraEvent( PlayerBase player, FreeDebugCamera camera )
300  {
301  DeveloperFreeCamera.OnSetFreeCameraEvent( player, camera );
302  }
303 
304  void OnSpawnErrorReport (string name)
305  {
306  PrintString("PluginDeveloper.SpawnEntity() Warning- Cant spawn object: " + name);
307  //DumpStack();
308  PrintString("PluginDeveloper.SpawnEntity() Warning END");
309  }
310 
311  void SetupSpawnedEntity(PlayerBase player, EntityAI entity, float health, float quantity = -1, bool special = false, string presetName = "")
312  {
313  #ifdef DEVELOPER
314  if (presetName && player.m_PresetSpawned)//this is how we ascertain this is the first item being spawned from a new preset after a previous preset was already spawned in
315  {
316  player.m_PresetItems.Clear();
317  player.m_PresetSpawned = false;//is set to 'true' elsewhere after all the items have been spawned in
318  }
319  if ( entity.IsInherited( PlayerBase ) )
320  {
321  PlayerBase plr = PlayerBase.Cast( entity );
322  plr.OnSpawnedFromConsole();
323  }
324  else if ( entity.IsInherited(ItemBase) )
325  {
326  ItemBase item = ItemBase.Cast( entity );
327  SetupSpawnedItem(item, health, quantity);
328  }
329  else if (entity.IsInherited(House))
330  {
331  entity.PlaceOnSurface();
332  vector pos = entity.GetPosition();
333  vector ori = GetGame().GetSurfaceOrientation(pos[0], pos[2]);
334  entity.SetOrientation(ori);
335  }
336  if (presetName)
337  {
338  player.m_PresetItems.Insert(entity);
339  }
340 
341  if ( special )
342  {
343  auto debugParams = DebugSpawnParams.WithPlayer(player);
344  entity.OnDebugSpawnEx(debugParams);
345  }
346  #endif
347  }
348 
349 
350  void SpawnEntityOnGroundPatternGrid( PlayerBase player, string item_name, int count, float health, float quantity, int rows, int columns, float gapRow = 1, float gapColumn = 1, bool special= false, bool withPhysics = false)
351  {
352  if (!item_name)
353  {
354  return;
355  }
356  if ( GetGame().IsServer() )
357  {
358  float rowDist = 0;
359  float columnDist = 0;
360 
361  vector playerPos = player.GetPosition();
362  vector camDirForward = player.GetDirection();
363  vector camDirRight = camDirForward.Perpend() * -1;
364  int countLoop = 0;
365  for (int i = 0; i < rows; i++)
366  {
367  vector posRow = playerPos + camDirForward * rowDist;
368  vector offsetSide;
369  columnDist = 0;
370  for (int j = 0; j < columns; j++)
371  {
372  offsetSide = camDirRight * columnDist;
373  vector placement = posRow + offsetSide;
374  float hlth = health * MiscGameplayFunctions.GetTypeMaxGlobalHealth( item_name );
375  EntityAI ent = SpawnEntityOnGroundPos(player, item_name, hlth, quantity, placement, special );
376  ent.PlaceOnSurface();
377 
378  InventoryItem item;
379  if (Class.CastTo(item, ent) && withPhysics)
380  item.ThrowPhysically(null, "0 0 0");
381 
382  countLoop++;
383  if (countLoop == count)
384  {
385  return;
386  }
387  columnDist += gapColumn;
388  }
389  rowDist += gapRow;
390  }
391  }
392  else
393  {
394  auto params = new Param10<string, int, float, float, int, int, float, float, bool, bool>(item_name, count, health, quantity, rows, columns, gapRow, gapColumn, special, withPhysics);
395  player.RPCSingleParam(ERPCs.DEV_RPC_SPAWN_ITEM_ON_GROUND_PATTERN_GRID, params, true);
396  }
397  }
398 
399  void SpawnItemOnCrosshair(notnull PlayerBase player, string itemName, float health, float quantity, float maxDist = 100, bool allowFreeflight = false, bool special = false, bool withPhysics = false)
400  {
401  vector from, to;
402  if (allowFreeflight && FreeDebugCamera.GetInstance().IsActive())
403  {
404  from = FreeDebugCamera.GetInstance().GetPosition();
405  to = from + FreeDebugCamera.GetInstance().GetDirection() * maxDist;
406  }
407  else
408  {
409  from = GetGame().GetCurrentCameraPosition();
410  to = from + GetGame().GetCurrentCameraDirection() * maxDist;
411  }
412 
413  float hitFraction;
414  vector start, end;
415  vector direction;
416 
417  vector hitPos, hitNormal;
418  Object obj;
419 
421  DayZPhysics.RayCastBullet(from, to, hitMask, player, obj, hitPos, hitNormal, hitFraction);
422 
423  // something is hit
424  if (hitPos != vector.Zero)
425  {
426  SpawnEntityOnGroundPos(player, itemName, health, quantity, hitPos, special, withPhysics);
427  }
428  }
429 
438  EntityAI SpawnEntityOnGroundPos( PlayerBase player, string item_name, float health, float quantity, vector pos, bool special = false, bool withPhysics = false)
439  {
440  if ( GetGame().IsServer() )
441  {
442  EntityAI entity = player.SpawnEntityOnGroundPos(item_name, pos);
443  if (entity)
444  SetupSpawnedEntity(player, entity, health, quantity, special);
445  else
446  OnSpawnErrorReport(item_name);
447 
448  InventoryItem item;
449  if (Class.CastTo(item, entity) && withPhysics)
450  item.ThrowPhysically(null, "0 0 0");
451 
452  return entity;
453  }
454  else
455  {
456  Param6<string, float, float, vector, bool, bool> params = new Param6<string, float, float, vector, bool, bool>(item_name, health, quantity, pos, special, withPhysics);
457  player.RPCSingleParam(ERPCs.DEV_RPC_SPAWN_ITEM_ON_GROUND, params, true);
458  }
459  return NULL;
460  }
469  EntityAI SpawnEntityOnCursorDir( PlayerBase player, string item_name, float quantity, float distance, float health = -1, bool special = false, string presetName = "", bool withPhysics = false)
470  {
471 
472  if ( GetGame().IsServer() )
473  {
474  // Client -> Server Spawning: Server Side
475  EntityAI entity = player.SpawnEntityOnGroundOnCursorDir(item_name, distance);
476 
477  if ( entity )
478  {
479  if ( !entity.IsBuilding() && health < 0 && entity.GetMaxHealth() > 0)//check for default (-1)
480  {
481  health = entity.GetMaxHealth();
482  }
483  SetupSpawnedEntity( player,entity, health, quantity, special, presetName );
484  }
485  else
486  OnSpawnErrorReport( item_name );
487 
488  InventoryItem item;
489  if (Class.CastTo(item, entity) && withPhysics)
490  item.ThrowPhysically(null, "0 0 0");
491 
492  return entity;
493  }
494  else
495  {
496  // Client -> Server Spawning: Client Side
497  Param7<string, float, float, float, bool, string, bool> params = new Param7<string, float, float, float, bool, string, bool>(item_name, quantity, distance, health, special, presetName, withPhysics);
498  player.RPCSingleParam(ERPCs.DEV_RPC_SPAWN_ITEM_ON_CURSOR, params, true);
499  }
500  return NULL;
501  }
512  EntityAI SpawnEntityInInventory( notnull EntityAI target, string className, float health, float quantity, bool special = false, string presetName = "", FindInventoryLocationType locationType = FindInventoryLocationType.ANY)
513  {
514  if (target.IsPlayer())
515  {
516  return SpawnEntityInPlayerInventory(PlayerBase.Cast(target), className, health, quantity, special, presetName, locationType);
517  }
518  if ( GetGame().IsServer() )
519  {
521  if (target.GetInventory() && target.GetInventory().FindFirstFreeLocationForNewEntity(className, FindInventoryLocationType.ANY, il))
522  {
523  EntityAI eai = SpawnEntity(className, il, ECE_IN_INVENTORY, RF_DEFAULT);
524  if ( eai && eai.IsInherited(ItemBase) )
525  {
526  if ( health < 0 )//check for default (-1)
527  {
528  health = eai.GetMaxHealth();
529  }
530  ItemBase i = ItemBase.Cast( eai );
531  SetupSpawnedItem(i, health, quantity);
532  if ( special )
533  {
534  auto debugParams = DebugSpawnParams.WithPlayer(null);
535  eai.OnDebugSpawnEx(debugParams);
536  }
537  }
538  return eai;
539  }
540  }
541  else
542  {
543  DevSpawnItemParams params = new DevSpawnItemParams(target, className, health, quantity, special, presetName, 0 );
544  GetGame().GetPlayer().RPCSingleParam(ERPCs.DEV_RPC_SPAWN_ITEM_IN_INVENTORY, params, true, GetGame().GetPlayer().GetIdentity());
545  }
546  return null;
547  }
548 
549  EntityAI SpawnEntityInPlayerInventory(PlayerBase player, string item_name, float health, float quantity, bool special = false, string presetName = "", FindInventoryLocationType locationType = FindInventoryLocationType.ANY)
550  {
551  if ( player )
552  {
553  if ( GetGame().IsServer() )
554  {
555  if (locationType == FindInventoryLocationType.HANDS && player.GetItemInHands())
556  {
557  if (!GetGame().IsMultiplayer())
558  player.DropItem(player.GetItemInHands());
559  else
560  player.ServerDropEntity(player.GetItemInHands());
561  GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(SpawnEntityInPlayerInventory,100, false, player, item_name, health, quantity, special, presetName, locationType);
562  return null;
563  }
564 
565 
566  #ifdef DEVELOPER
567  if (GetGame().IsKindOf(item_name, "Transport"))
568  {
569  EntityAI car = SpawnEntityOnGroundPos(player, item_name, 1, quantity, player.GetPosition());
570 
571  auto debugParams = DebugSpawnParams.WithPlayer(player);
572  car.OnDebugSpawnEx(debugParams);
573 
574  if (GetGame().IsMultiplayer())
575  {
576  DayZPlayerSyncJunctures.SendGetInCar(player, car);
577  }
578  else
579  {
580  player.SetGetInVehicleDebug(car);
581  }
582 
583  return car;
584  }
585  #endif
586 
588  if (player.GetInventory() && player.GetInventory().FindFirstFreeLocationForNewEntity(item_name, locationType, il))
589  {
590  Weapon_Base wpn = Weapon_Base.Cast(il.GetParent());
591  bool is_mag = il.GetSlot() == InventorySlots.MAGAZINE || il.GetSlot() == InventorySlots.MAGAZINE2 || il.GetSlot() == InventorySlots.MAGAZINE3;
592  if (wpn && is_mag)
593  {
594  vector pos = player.GetPosition();
595  EntityAI eai_gnd = SpawnEntityOnGroundPos(player, item_name, health, quantity, pos);
596  Magazine mag_gnd = Magazine.Cast(eai_gnd);
597  if (mag_gnd && player.GetWeaponManager().CanAttachMagazine(wpn, mag_gnd))
598  {
599  player.GetWeaponManager().AttachMagazine(mag_gnd);
600  }
601  return eai_gnd;
602  }
603  else
604  {
605  EntityAI eai = SpawnEntity(item_name, il, ECE_IN_INVENTORY, RF_DEFAULT);
606  if ( eai && eai.IsInherited(ItemBase) )
607  {
608  if ( health < 0 )//check for default (-1)
609  {
610  health = eai.GetMaxHealth();
611  }
612  ItemBase i = ItemBase.Cast( eai );
613  SetupSpawnedItem(i, health, quantity);
614  if ( special )
615  {
616  auto debugParams2 = DebugSpawnParams.WithPlayer(player);
617  eai.OnDebugSpawnEx(debugParams2);
618  }
619  }
620  return eai;
621  }
622  }
623  else
624  OnSpawnErrorReport(item_name);
625  return NULL;
626  }
627  else
628  {
629  // Client -> Server Spawning: Client Side
630  DevSpawnItemParams params = new DevSpawnItemParams(player, item_name, health, quantity, special, presetName, locationType );
631  player.RPCSingleParam(ERPCs.DEV_RPC_SPAWN_ITEM_IN_INVENTORY, params, true);
632  }
633  }
634  return NULL;
635  }
643  EntityAI SpawnEntityAsAttachment (PlayerBase player, EntityAI parent, string att_name, float health, float quantity)
644  {
645  if ( GetGame().IsServer() )
646  {
647  Weapon_Base wpn = Weapon_Base.Cast(parent);
648  if (wpn)
649  {
650  GameInventory inventory = parent.GetInventory();
651  return inventory.CreateInInventory(att_name);
652  /*
653  vector pos = player.GetPosition();
654  EntityAI eai_gnd = SpawnEntityOnGroundPos(player, att_name, health, quantity, pos);
655  Magazine mag_gnd = Magazine.Cast(eai_gnd);
656  if (mag_gnd && player.GetWeaponManager().CanAttachMagazine(wpn, mag_gnd))
657  {
658  player.GetWeaponManager().AttachMagazine(mag_gnd);
659  }
660  return eai_gnd;
661  */
662  }
663  else
664  {
665  EntityAI eai = parent.GetInventory().CreateAttachment(att_name);
666  if (eai)
667  {
668  if ( eai.IsInherited(ItemBase) )
669  {
670  ItemBase i = ItemBase.Cast( eai );
671  SetupSpawnedItem(ItemBase.Cast( eai ), health, quantity);
672  }
673  return eai;
674  }
675  else
676  OnSpawnErrorReport(att_name);
677  }
678  return NULL;
679  }
680  else
681  {
682  // Client -> Server Spawning: Client Side
683  Param3<string, float, float> params = new Param3<string, float, float>(att_name, health, quantity);
684  player.RPCSingleParam(ERPCs.DEV_RPC_SPAWN_ITEM_AS_ATTACHMENT, params, true);
685  }
686  return NULL;
687  }
688 
689  EntityAI SpawnFromClipboard()
690  {
691  UIScriptedMenu menu_curr = GetGame().GetUIManager().GetMenu();
692 
693  if ( menu_curr == NULL )
694  {
695  PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
696  if ( player )
697  {
698  if ( !GetGame().GetWorld().Is3rdPersonDisabled() )
699  {
700  player.SetIsInThirdPerson(!player.IsInThirdPerson());//this counters the effect of switching camera through pressing the 'V' key
701  }
702 
703  vector pos_player = player.GetPosition();
704 
705  // Get item from clipboard
706  string clipboard;
707  GetGame().CopyFromClipboard(clipboard);
708 
709  if (!clipboard.Contains(","))
710  {
711  //single item
712  if (DeveloperFreeCamera.IsFreeCameraEnabled())
713  SpawnItemOnCrosshair(player, clipboard.Trim(), -1, 1, 40, true );
714  else
715  SpawnEntityOnCursorDir(player, clipboard.Trim(), 1, 1);
716  }
717  else
718  {
719  TStringArray items = new TStringArray;
720  clipboard.Split( ",", items );
721 
722  foreach (string item:items)
723  {
724  if (DeveloperFreeCamera.IsFreeCameraEnabled())
725  SpawnItemOnCrosshair(player, item.Trim(), -1, 1, 40, true );
726  else
727  SpawnEntityOnCursorDir(player, item.Trim(), 1, 1);
728  }
729  }
730 
731  }
732  }
733 
734  return NULL;
735  }
736 
737  // Clear Entity Inventory
738  void ClearInventory(EntityAI entity)
739  {
740  if ( GetGame().IsServer() )
741  {
742  entity.ClearInventory();
743  }
744  else
745  {
746  Param1<int> params = new Param1<int>(0);
747  entity.RPCSingleParam(ERPCs.DEV_RPC_CLEAR_INV, params, true);
748  }
749  }
750 
751  void ToggleHelpScreen()
752  {
753  if ( g_Game.GetUIManager().GetMenu() == NULL )
754  {
755  g_Game.GetUIManager().EnterScriptedMenu(MENU_HELP_SCREEN, NULL);
756  }
757  else if ( g_Game.GetUIManager().IsMenuOpen(MENU_HELP_SCREEN) )
758  {
759  g_Game.GetUIManager().Back();
760  }
761  }
762 
763  void ToggleScriptConsole()
764  {
765  if (GetGame() != null && !g_Game.IsLoading() && GetGame().GetMission())
766  {
767  if ( g_Game.GetUIManager().GetMenu() == NULL )
768  {
769  m_ScriptConsole = g_Game.GetUIManager().EnterScriptedMenu(MENU_SCRIPTCONSOLE, NULL);
770  GetGame().GetMission().AddActiveInputExcludes({"menu"});
771 
772  }
773  else if ( g_Game.GetUIManager().IsMenuOpen(MENU_SCRIPTCONSOLE) )
774  {
775  g_Game.GetUIManager().Back();
776  GetGame().GetMission().RemoveActiveInputExcludes({"menu"},true);
777  }
778  }
779  }
780 
781  // Mission Editor
782  void ToggleMissionLoader()
783  {
784  if ( g_Game.GetUIManager().IsMenuOpen(MENU_MISSION_LOADER) )
785  {
786  g_Game.GetUIManager().Back();
787  GetGame().GetMission().RemoveActiveInputExcludes({"menu"},true);
788  return;
789  }
790 
791  if ( g_Game.GetUIManager().GetMenu() )
792  g_Game.GetUIManager().GetMenu().Close();
793 
794  g_Game.GetUIManager().EnterScriptedMenu(MENU_MISSION_LOADER, NULL);
795  GetGame().GetMission().AddActiveInputExcludes({"menu"});
796 
797 
798  }
799 
800  // Script Editor History
801  private void ScriptHistoryNext()
802  {
803  // Console key press
804  if ( g_Game.GetUIManager().IsMenuOpen(MENU_SCRIPTCONSOLE) )
805  {
807  }
808  }
809 
810  private void ScriptHistoryBack()
811  {
812  // Console key press
813  if ( g_Game.GetUIManager().IsMenuOpen(MENU_SCRIPTCONSOLE) )
814  {
816  }
817  }
818 
819  private bool IsIngame()
820  {
821  UIScriptedMenu menu_curr = GetGame().GetUIManager().GetMenu();
822 
823  if ( menu_curr == NULL )
824  {
825  return true;
826  }
827 
828  return false;
829  }
830 
831  private bool IsInConsole()
832  {
833  UIScriptedMenu menu_curr = GetGame().GetUIManager().GetMenu();
834 
835  if ( menu_curr != NULL && menu_curr.GetID() == MENU_SCRIPTCONSOLE )
836  {
837  return true;
838  }
839 
840  return false;
841  }
842 
843  // Tools
844  int QuickSortPartition( TStringArray arr, int left, int right )
845  {
846  string pivot = arr.Get( left );
847  int i = left;
848  int j = right + 1;
849  string temp;
850 
851  while ( true )
852  {
853  while ( true )
854  {
855  i++;
856  if ( i > right || arr.Get(i) > pivot )
857  {
858  break;
859  }
860  }
861 
862  while ( true )
863  {
864  j--;
865  if ( arr.Get(j) <= pivot )
866  {
867  break;
868  }
869  }
870 
871  if ( i >= j )
872  {
873  break;
874  }
875 
876  temp = arr.Get( i );
877  arr.Set( i, arr.Get(j) );
878  arr.Set( j, temp );
879  }
880 
881  temp = arr.Get( left );
882  arr.Set( left, arr.Get(j) );
883  arr.Set( j, temp );
884 
885  return j;
886  }
887 
888  void QuickSort( TStringArray arr, int left, int right )
889  {
890  int j;
891 
892  if ( left < right )
893  {
894  j = QuickSortPartition( arr, left, right );
895  QuickSort( arr, left, j - 1 );
896  QuickSort( arr, j + 1, right );
897  }
898  }
899 
900  void SortStringArray( TStringArray arr )
901  {
902  QuickSort( arr, 0, arr.Count() - 1 );
903  }
904 
905  void ResetGUI()
906  {
907  if ( GetGame() && GetGame().GetMission() )
908  {
909  GetGame().GetMission().ResetGUI();
910  }
911  }
912 
913  static void SetDeveloperItemClientEx(notnull Object entity, bool getFocus = false)
914  {
915  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
916 
917  if (getFocus)
918  {
919  GetGame().GetInput().ChangeGameFocus(1);
920  GetGame().GetUIManager().ShowUICursor(true);
921  }
922 
923  if (GetGame().IsMultiplayer())
924  {
925  GetGame().RPCSingleParam(GetGame().GetPlayer(), ERPCs.DEV_SET_DEV_ITEM, new Param1<Object>(entity), true, GetGame().GetPlayer().GetIdentity());
926  }
927  else
928  {
930  mid2.RegisterDebugItem(entity, player);
931  }
932  #ifdef DEVELOPER
933  SetDebugDeveloper_item(entity);
934  #endif
935  }
936 
937  void SetDeveloperItemClient()
938  {
939  #ifdef DEVELOPER
940  Object entity;
941  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
942 
943  FreeDebugCamera debugCam = FreeDebugCamera.GetInstance();
944  if (debugCam && debugCam.GetCurrentCamera())
945  {
946  entity = debugCam.GetCrosshairObject();
947  }
948  else
949  {
950 
951  if (player && player.GetActionManager())
952  {
953  ActionTarget at = player.GetActionManager().FindActionTarget();
954  entity = at.GetObject();
955  }
956  }
957 
958  if (entity)
959  {
960  SetDeveloperItemClientEx(entity, true);
961  }
962  #endif
963  }
964 }
ItemBase
Definition: inventoryitem.c:730
RF_DEFAULT
const int RF_DEFAULT
Definition: centraleconomy.c:65
GetGame
proto native CGame GetGame()
UIScriptedMenu
Definition: dayzgame.c:63
CALL_CATEGORY_SYSTEM
const int CALL_CATEGORY_SYSTEM
Definition: tools.c:8
MENU_HELP_SCREEN
const int MENU_HELP_SCREEN
Definition: constants.c:183
SetupSpawnedItem
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Definition: itembase.c:4700
Param
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition: param.c:11
DeveloperFreeCamera
Definition: developerfreecamera.c:1
InventorySlots
provides access to slot configuration
Definition: inventoryslots.c:5
TStringArray
array< string > TStringArray
Definition: enscript.c:685
DevSpawnItemParams
Param7< EntityAI, string, float, float, bool, string, FindInventoryLocationType > DevSpawnItemParams
Definition: plugindeveloper.c:1
SpawnEntity
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
CallMethod
Param CallMethod(CallID call_id, Param params)
Definition: dispatcher.c:36
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
MENU_SCRIPTCONSOLE
const int MENU_SCRIPTCONSOLE
Definition: constants.c:175
SceneObject
Definition: sceneobject.c:1
InventoryItem
Definition: itembase.c:13
Param3
Definition: entityai.c:95
PluginBase
Definition: pluginadminlog.c:1
GetPlugin
PluginBase GetPlugin(typename plugin_type)
Definition: pluginmanager.c:316
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
OnRPC
void OnRPC(ParamsReadContext ctx)
Definition: displaystatus.c:216
PlayerBase
Definition: playerbaseclient.c:1
vector
Definition: enconvert.c:105
ActionTarget
class ActionTargets ActionTarget
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
Object
Definition: objecttyped.c:1
CALL_ID_SCR_CNSL_HISTORY_BACK
const CallID CALL_ID_SCR_CNSL_HISTORY_BACK
Definition: dispatcher.c:4
PrintString
void PrintString(string s)
Helper for printing out string expression. Example: PrintString("Hello " + var);.
Definition: enscript.c:345
class_name
class OptionSelectorMultistate extends OptionSelector class_name
CALL_ID_SCR_CNSL_HISTORY_NEXT
const CallID CALL_ID_SCR_CNSL_HISTORY_NEXT
Definition: dispatcher.c:5
DayZPlayerSyncJunctures
Definition: dayzplayersyncjunctures.c:4
DeveloperTeleport
Definition: developerteleport.c:1
FindInventoryLocationType
FindInventoryLocationType
flags for searching locations in inventory
Definition: inventorylocation.c:15
House
Definition: crashbase.c:1
array< Man >
PluginDayZCreatureAIDebug
void PluginDayZCreatureAIDebug()
Definition: plugindayzcreatureaidebug.c:101
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
MENU_MISSION_LOADER
const int MENU_MISSION_LOADER
Definition: constants.c:204
GetPlayer
protected void GetPlayer()
Definition: crosshairselector.c:127
CALL_ID_SCR_CNSL_ADD_PRINT
const CallID CALL_ID_SCR_CNSL_ADD_PRINT
Definition: dispatcher.c:6
Debug
Definition: debug.c:13
Weapon_Base
shorthand
Definition: boltactionrifle_base.c:5
DayZPhysics
Definition: dayzphysics.c:123
PluginItemDiagnostic
void PluginItemDiagnostic()
Definition: pluginitemdiagnostic.c:83
ERPCs
ERPCs
Definition: erpcs.c:1
OnInit
void OnInit()
Definition: aibehaviour.c:49
ClearInventory
override void ClearInventory()
Definition: itembase.c:3440
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
EntityAI
Definition: building.c:5
PhxInteractionLayers
PhxInteractionLayers
Definition: dayzphysics.c:1
GameInventory
script counterpart to engine's class Inventory
Definition: inventory.c:78
ECE_IN_INVENTORY
const int ECE_IN_INVENTORY
Definition: centraleconomy.c:36
SceneData
Definition: scenedata.c:1