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