Dayz Explorer 1.29.162510
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
9 {
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( g_Game.GetPlayer() ), false );
35 }
36
39 {
40 DeveloperFreeCamera.FreeCameraToggle( PlayerBase.Cast( g_Game.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 ( g_Game )
132 {
133 array<Man> players = new array<Man>;
134 g_Game.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 g_Game.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 g_Game.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 && 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 = g_Game.GetSurfaceOrientation(pos[0], pos[2]);
324 entity.SetOrientation(ori);
325 }
326 if (player && presetName)
327 {
328 player.m_PresetItems.Insert(entity);
329 }
330
331 if (special)
332 {
333 if (player)
334 {
335 auto debugParamsPlayer = DebugSpawnParams.WithPlayer(player);
336 entity.OnDebugSpawnEx(debugParamsPlayer);
337 }
338 else
339 {
340 auto debugParamsNone = DebugSpawnParams.None();
341 entity.OnDebugSpawnEx(debugParamsNone);
342 }
343 }
344 #endif
345 }
346
347
348 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)
349 {
350 if (!item_name)
351 {
352 return;
353 }
354 if ( g_Game.IsServer() )
355 {
356 float rowDist = 0;
357 float columnDist = 0;
358
359 vector playerPos;
360 vector camDirForward;
361
362 GetCameraDirections(player, false, playerPos, camDirForward);
363
364 vector camDirRight = camDirForward.Perpend() * -1;
365 int countLoop = 0;
366 for (int i = 0; i < rows; i++)
367 {
368 vector posRow = playerPos + camDirForward * rowDist;
369 vector offsetSide;
370 columnDist = 0;
371 for (int j = 0; j < columns; j++)
372 {
373 offsetSide = camDirRight * columnDist;
374 vector placement = posRow + offsetSide;
375 float hlth = health * MiscGameplayFunctions.GetTypeMaxGlobalHealth( item_name );
376 EntityAI ent = SpawnEntityOnGroundPos(player, item_name, hlth, quantity, placement, special );
377 ent.PlaceOnSurface();
378
379 InventoryItem item;
380 if (Class.CastTo(item, ent) && withPhysics)
381 item.ThrowPhysically(null, "0 0 0");
382
383 countLoop++;
384 if (countLoop == count)
385 {
386 return;
387 }
388 columnDist += gapColumn;
389 }
390 rowDist += gapRow;
391 }
392 }
393 else
394 {
395 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);
396 player.RPCSingleParam(ERPCs.DEV_RPC_SPAWN_ITEM_ON_GROUND_PATTERN_GRID, params, true);
397 }
398 }
399
400 EntityAI SpawnAI(string object_name, vector pos)
401 {
402 bool is_ai = g_Game.IsKindOf(object_name, "DZ_LightAI");
403 if (is_ai)
404 {
405 return EntityAI.Cast(g_Game.CreateObjectEx(object_name, pos, ECE_PLACE_ON_SURFACE|ECE_INITAI|ECE_EQUIP_ATTACHMENTS));
406 }
407 return NULL;
408 }
409
410 void GetCameraDirections(Man player, bool allowFreeflight, out vector position, out vector direction)
411 {
412 position = g_Game.GetCurrentCameraPosition();
413 direction = g_Game.GetCurrentCameraDirection();
414
415 if ((g_Game.IsDedicatedServer() || allowFreeflight) && FreeDebugCamera.GetInstance().IsActive())
416 {
417 position = FreeDebugCamera.GetInstance().GetPosition();
418 direction = FreeDebugCamera.GetInstance().GetDirection();
419 return;
420 }
421
422 if (player && !allowFreeflight)
423 {
424 position = player.GetPosition();
425 direction = player.GetDirection();
426 }
427 }
428
429 EntityAI SpawnEntityOnGroundPos(PlayerBase player, string object_name, vector pos)
430 {
431 if (player)
432 {
433 return player.SpawnEntityOnGroundPos(object_name, pos);
434 }
435
436 bool is_AI = g_Game.IsKindOf(object_name, "DZ_LightAI");
437 if (is_AI)
438 {
439 return SpawnAI(object_name, pos);
440 }
441 else
442 {
444 vector mtx[4];
445 Math3D.MatrixIdentity4(mtx);
446 mtx[3] = pos;
447 inv_loc.SetGround(null, mtx);
448
449 int flags = ECE_PLACE_ON_SURFACE;
450 #ifdef DEVELOPER
451 if (g_Game.IsKindOf(object_name, "Boat"))
452 flags = ECE_KEEPHEIGHT;
453 #endif
454
455 return EntityAI.Cast(g_Game.CreateObjectEx(object_name, inv_loc.GetPos(), flags));
456 }
457
458 return null;
459 }
460
461 void SpawnItemOnCrosshair(PlayerBase player, string itemName, float health, float quantity, float maxDist = 100, bool allowFreeflight = false, bool special = false, bool withPhysics = false)
462 {
463 vector from, to, dir;
464 GetCameraDirections(player, true, from, dir);
465 to = from + (dir * maxDist);
466
467 float hitFraction;
468 vector start, end;
469 vector direction;
470
471 vector hitPos, hitNormal;
472 Object obj;
473
475 DayZPhysics.RayCastBullet(from, to, hitMask, player, obj, hitPos, hitNormal, hitFraction);
476
477 // something is hit
478 if (hitPos != vector.Zero)
479 {
480 SpawnEntityOnGroundPos(player, itemName, health, quantity, hitPos, special, withPhysics);
481 }
482 }
483
492 EntityAI SpawnEntityOnGroundPos( PlayerBase player, string item_name, float health, float quantity, vector pos, bool special = false, bool withPhysics = false)
493 {
494 if ( g_Game.IsServer() )
495 {
496 EntityAI entity = SpawnEntityOnGroundPos(player, item_name, pos);
497 if (entity)
498 SetupSpawnedEntity(player, entity, health, quantity, special);
499 else
500 OnSpawnErrorReport(item_name);
501
502 InventoryItem item;
503 if (Class.CastTo(item, entity) && withPhysics)
504 item.ThrowPhysically(null, "0 0 0");
505
506 return entity;
507 }
508 else
509 {
510 Param6<string, float, float, vector, bool, bool> params = new Param6<string, float, float, vector, bool, bool>(item_name, health, quantity, pos, special, withPhysics);
511 player.RPCSingleParam(ERPCs.DEV_RPC_SPAWN_ITEM_ON_GROUND, params, true);
512 }
513 return NULL;
514 }
515
523 EntityAI SpawnEntityOnCursorDir( PlayerBase player, string item_name, float quantity, float distance, float health = -1, bool special = false, string presetName = "", bool withPhysics = false)
524 {
525
526 if ( g_Game.IsServer() )
527 {
528 // Client -> Server Spawning: Server Side
529 EntityAI entity = player.SpawnEntityOnGroundOnCursorDir(item_name, distance);
530
531 if ( entity )
532 {
533 if ( !entity.IsBuilding() && health < 0 && entity.GetMaxHealth() > 0)//check for default (-1)
534 {
535 health = entity.GetMaxHealth();
536 }
537 SetupSpawnedEntity( player,entity, health, quantity, special, presetName );
538 }
539 else
540 OnSpawnErrorReport( item_name );
541
542 InventoryItem item;
543 if (Class.CastTo(item, entity) && withPhysics)
544 item.ThrowPhysically(null, "0 0 0");
545
546 return entity;
547 }
548 else
549 {
550 // Client -> Server Spawning: Client Side
551 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);
552 player.RPCSingleParam(ERPCs.DEV_RPC_SPAWN_ITEM_ON_CURSOR, params, true);
553 }
554 return NULL;
555 }
556
566 EntityAI SpawnEntityInInventory( notnull EntityAI target, string className, float health, float quantity, bool special = false, string presetName = "", FindInventoryLocationType locationType = FindInventoryLocationType.ANY)
567 {
568 if (target.IsPlayer())
569 {
570 return SpawnEntityInPlayerInventory(PlayerBase.Cast(target), className, health, quantity, special, presetName, locationType);
571 }
572 if ( g_Game.IsServer() )
573 {
575 if (target.GetInventory() && target.GetInventory().FindFirstFreeLocationForNewEntity(className, FindInventoryLocationType.ANY, il))
576 {
577 EntityAI eai = SpawnEntity(className, il, ECE_IN_INVENTORY, RF_DEFAULT);
578 if ( eai && eai.IsInherited(ItemBase) )
579 {
580 if ( health < 0 )//check for default (-1)
581 {
582 health = eai.GetMaxHealth();
583 }
584 ItemBase i = ItemBase.Cast( eai );
585 SetupSpawnedItem(i, health, quantity);
586 if ( special )
587 {
588 auto debugParams = DebugSpawnParams.WithPlayer(null);
589 eai.OnDebugSpawnEx(debugParams);
590 }
591 }
592 return eai;
593 }
594 }
595 else
596 {
597 DevSpawnItemParams params = new DevSpawnItemParams(target, className, health, quantity, special, presetName, 0 );
598 g_Game.GetPlayer().RPCSingleParam(ERPCs.DEV_RPC_SPAWN_ITEM_IN_INVENTORY, params, true, g_Game.GetPlayer().GetIdentity());
599 }
600 return null;
601 }
602
603 EntityAI SpawnEntityInPlayerInventory(PlayerBase player, string item_name, float health, float quantity, bool special = false, string presetName = "", FindInventoryLocationType locationType = FindInventoryLocationType.ANY)
604 {
605 if (player)
606 {
607 if (g_Game.IsServer())
608 {
609 if (locationType == FindInventoryLocationType.HANDS && player.GetItemInHands())
610 {
611 if (!g_Game.IsMultiplayer())
612 player.DropItem(player.GetItemInHands());
613 else
614 player.ServerDropEntity(player.GetItemInHands());
615
616 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(SpawnEntityInPlayerInventory, 500, false, player, item_name, health, quantity, special, presetName, locationType);
617
618 return null;
619 }
620
621
622 #ifdef DEVELOPER
623 if (g_Game.IsKindOf(item_name, "Transport"))
624 {
625 EntityAI vehicle = SpawnEntityOnGroundPos(player, item_name, 1, quantity, player.GetPosition());
626 auto debugParams = DebugSpawnParams.WithPlayer(player);
627 vehicle.OnDebugSpawnEx(debugParams);
628
629 if (g_Game.IsMultiplayer())
630 {
631 DayZPlayerSyncJunctures.SendGetInVehicle(player, vehicle);
632 }
633 else
634 {
635 player.SetGetInVehicleDebug(vehicle);
636 }
637
638 return vehicle;
639 }
640 #endif
641
643 if (player.GetInventory() && player.GetInventory().FindFirstFreeLocationForNewEntity(item_name, locationType, il))
644 {
645 Weapon_Base wpn = Weapon_Base.Cast(il.GetParent());
646 bool is_mag = il.GetSlot() == InventorySlots.MAGAZINE || il.GetSlot() == InventorySlots.MAGAZINE2 || il.GetSlot() == InventorySlots.MAGAZINE3;
647 if (wpn && is_mag)
648 {
649 vector pos = player.GetPosition();
650 EntityAI eai_gnd = SpawnEntityOnGroundPos(player, item_name, health, quantity, pos);
651 Magazine mag_gnd = Magazine.Cast(eai_gnd);
652 if (mag_gnd && player.GetWeaponManager().CanAttachMagazine(wpn, mag_gnd))
653 {
654 player.GetWeaponManager().AttachMagazine(mag_gnd);
655 }
656 return eai_gnd;
657 }
658 else
659 {
660 EntityAI eai = SpawnEntity(item_name, il, ECE_IN_INVENTORY, RF_DEFAULT);
661 if ( eai && eai.IsInherited(ItemBase) )
662 {
663 if ( health < 0 )//check for default (-1)
664 {
665 health = eai.GetMaxHealth();
666 }
667 ItemBase i = ItemBase.Cast( eai );
668 SetupSpawnedItem(i, health, quantity);
669 if ( special )
670 {
671 auto debugParams2 = DebugSpawnParams.WithPlayer(player);
672 eai.OnDebugSpawnEx(debugParams2);
673 }
674 }
675 return eai;
676 }
677 }
678 else
679 OnSpawnErrorReport(item_name);
680 return NULL;
681 }
682 else
683 {
684 // Client -> Server Spawning: Client Side
685 DevSpawnItemParams params = new DevSpawnItemParams(player, item_name, health, quantity, special, presetName, locationType );
686 player.RPCSingleParam(ERPCs.DEV_RPC_SPAWN_ITEM_IN_INVENTORY, params, true);
687 }
688 }
689 return NULL;
690 }
691
698 EntityAI SpawnEntityAsAttachment (PlayerBase player, EntityAI parent, string att_name, float health, float quantity)
699 {
700 if ( g_Game.IsServer() )
701 {
702 Weapon_Base wpn = Weapon_Base.Cast(parent);
703 if (wpn)
704 {
705 GameInventory inventory = parent.GetInventory();
706 return inventory.CreateInInventory(att_name);
707 /*
708 vector pos = player.GetPosition();
709 EntityAI eai_gnd = SpawnEntityOnGroundPos(player, att_name, health, quantity, pos);
710 Magazine mag_gnd = Magazine.Cast(eai_gnd);
711 if (mag_gnd && player.GetWeaponManager().CanAttachMagazine(wpn, mag_gnd))
712 {
713 player.GetWeaponManager().AttachMagazine(mag_gnd);
714 }
715 return eai_gnd;
716 */
717 }
718 else
719 {
720 EntityAI eai = parent.GetInventory().CreateAttachment(att_name);
721 if (eai)
722 {
723 if ( eai.IsInherited(ItemBase) )
724 {
725 ItemBase i = ItemBase.Cast( eai );
726 SetupSpawnedItem(ItemBase.Cast( eai ), health, quantity);
727 }
728 return eai;
729 }
730 else
731 OnSpawnErrorReport(att_name);
732 }
733 return NULL;
734 }
735 else
736 {
737 // Client -> Server Spawning: Client Side
738 Param3<string, float, float> params = new Param3<string, float, float>(att_name, health, quantity);
739 player.RPCSingleParam(ERPCs.DEV_RPC_SPAWN_ITEM_AS_ATTACHMENT, params, true);
740 }
741 return NULL;
742 }
743
745 {
746 UIScriptedMenu menu_curr = g_Game.GetUIManager().GetMenu();
747
748 if ( menu_curr == NULL )
749 {
750 PlayerBase player = PlayerBase.Cast( g_Game.GetPlayer() );
751
752 if ( player && !g_Game.GetWorld().Is3rdPersonDisabled() )
753 {
754 player.SetIsInThirdPerson(!player.IsInThirdPerson());//this counters the effect of switching camera through pressing the 'V' key
755 }
756
757 vector pos_player, pos_direction;
758 GetCameraDirections(player, false, pos_player, pos_direction);
759
760 // Get item from clipboard
761 string clipboard;
762 g_Game.CopyFromClipboard(clipboard);
763
764 if (!clipboard.Contains(","))
765 {
766 //single item
767 if (DeveloperFreeCamera.IsFreeCameraEnabled())
768 SpawnItemOnCrosshair(player, clipboard.Trim(), -1, 1, 40, true );
769 else
770 SpawnEntityOnCursorDir(player, clipboard.Trim(), 1, 1);
771 }
772 else
773 {
774 TStringArray items = new TStringArray;
775 clipboard.Split( ",", items );
776
777 foreach (string item:items)
778 {
779 if (DeveloperFreeCamera.IsFreeCameraEnabled())
780 SpawnItemOnCrosshair(player, item.Trim(), -1, 1, 40, true );
781 else
782 SpawnEntityOnCursorDir(player, item.Trim(), 1, 1);
783 }
784 }
785
786 }
787
788 return NULL;
789 }
790
791 // Clear Entity Inventory
793 {
794 if ( g_Game.IsServer() )
795 {
796 entity.ClearInventory();
797 }
798 else
799 {
800 Param1<int> params = new Param1<int>(0);
801 entity.RPCSingleParam(ERPCs.DEV_RPC_CLEAR_INV, params, true);
802 }
803 }
804
806 {
807 if ( g_Game.GetUIManager().GetMenu() == NULL )
808 {
809 g_Game.GetUIManager().EnterScriptedMenu(MENU_HELP_SCREEN, NULL);
810 }
811 else if ( g_Game.GetUIManager().IsMenuOpen(MENU_HELP_SCREEN) )
812 {
813 g_Game.GetUIManager().Back();
814 }
815 }
816
818 {
819 if (g_Game != null && !g_Game.IsLoading() && g_Game.GetMission())
820 {
821 if ( g_Game.GetUIManager().GetMenu() == NULL )
822 {
823 m_ScriptConsole = g_Game.GetUIManager().EnterScriptedMenu(MENU_SCRIPTCONSOLE, NULL);
824 }
825 else if ( g_Game.GetUIManager().IsMenuOpen(MENU_SCRIPTCONSOLE) )
826 {
827 g_Game.GetUIManager().Back();
828 g_Game.GetMission().RemoveActiveInputExcludes({"menu"},true);
829 }
830 }
831 }
832
833 // Mission Editor
835 {
836 if ( g_Game.GetUIManager().IsMenuOpen(MENU_MISSION_LOADER) )
837 {
838 g_Game.GetUIManager().Back();
839 g_Game.GetMission().RemoveActiveInputExcludes({"menu"},true);
840 return;
841 }
842
843 if ( g_Game.GetUIManager().GetMenu() )
844 g_Game.GetUIManager().GetMenu().Close();
845
846 g_Game.GetUIManager().EnterScriptedMenu(MENU_MISSION_LOADER, NULL);
847 g_Game.GetMission().AddActiveInputExcludes({"menu"});
848
849
850 }
851
852 // Script Editor History
853 private void ScriptHistoryNext()
854 {
855 // Console key press
856 if ( g_Game.GetUIManager().IsMenuOpen(MENU_SCRIPTCONSOLE) )
857 {
859 }
860 }
861
862 private void ScriptHistoryBack()
863 {
864 // Console key press
865 if ( g_Game.GetUIManager().IsMenuOpen(MENU_SCRIPTCONSOLE) )
866 {
868 }
869 }
870
871 private bool IsIngame()
872 {
873 UIScriptedMenu menu_curr = g_Game.GetUIManager().GetMenu();
874
875 if ( menu_curr == NULL )
876 {
877 return true;
878 }
879
880 return false;
881 }
882
883 private bool IsInConsole()
884 {
885 UIScriptedMenu menu_curr = g_Game.GetUIManager().GetMenu();
886
887 if ( menu_curr != NULL && menu_curr.GetID() == MENU_SCRIPTCONSOLE )
888 {
889 return true;
890 }
891
892 return false;
893 }
894
895 // Tools
896 int QuickSortPartition( TStringArray arr, int left, int right )
897 {
898 string pivot = arr.Get( left );
899 int i = left;
900 int j = right + 1;
901 string temp;
902
903 while ( true )
904 {
905 while ( true )
906 {
907 i++;
908 if ( i > right || arr.Get(i) > pivot )
909 {
910 break;
911 }
912 }
913
914 while ( true )
915 {
916 j--;
917 if ( arr.Get(j) <= pivot )
918 {
919 break;
920 }
921 }
922
923 if ( i >= j )
924 {
925 break;
926 }
927
928 temp = arr.Get( i );
929 arr.Set( i, arr.Get(j) );
930 arr.Set( j, temp );
931 }
932
933 temp = arr.Get( left );
934 arr.Set( left, arr.Get(j) );
935 arr.Set( j, temp );
936
937 return j;
938 }
939
940 void QuickSort( TStringArray arr, int left, int right )
941 {
942 int j;
943
944 if ( left < right )
945 {
946 j = QuickSortPartition( arr, left, right );
947 QuickSort( arr, left, j - 1 );
948 QuickSort( arr, j + 1, right );
949 }
950 }
951
952 void SortStringArray( TStringArray arr )
953 {
954 QuickSort( arr, 0, arr.Count() - 1 );
955 }
956
957 void ResetGUI()
958 {
959 if ( g_Game && g_Game.GetMission() )
960 {
961 g_Game.GetMission().ResetGUI();
962 }
963 }
964
965 static void SetDeveloperItemClientEx(notnull Object entity, bool getFocus = false)
966 {
967 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
968
969 if (getFocus)
970 {
971 g_Game.GetInput().ChangeGameFocus(1);
972 g_Game.GetUIManager().ShowUICursor(true);
973 }
974
975 if (g_Game.IsMultiplayer())
976 {
977 g_Game.RPCSingleParam(g_Game.GetPlayer(), ERPCs.DEV_SET_DEV_ITEM, new Param1<Object>(entity), true, g_Game.GetPlayer().GetIdentity());
978 }
979 else
980 {
982 mid2.RegisterDebugItem(entity, player);
983 }
984 #ifdef DEVELOPER
985 SetDebugDeveloper_item(entity);
986 #endif
987 }
988
989 void SetDeveloperItemClient()
990 {
991 #ifdef DEVELOPER
992 Object entity;
993 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
994
995 FreeDebugCamera debugCam = FreeDebugCamera.GetInstance();
996 if (debugCam && debugCam.GetCurrentCamera())
997 {
998 entity = debugCam.GetCrosshairObject();
999 }
1000 else
1001 {
1002
1003 if (player && player.GetActionManager())
1004 {
1005 ActionTarget at = player.GetActionManager().FindActionTarget();
1006 entity = at.GetObject();
1007 }
1008 }
1009
1010 if (entity)
1011 {
1012 SetDeveloperItemClientEx(entity, true);
1013 }
1014 #endif
1015 }
1016}
const int ECE_EQUIP_ATTACHMENTS
const int ECE_PLACE_ON_SURFACE
const int ECE_INITAI
const int ECE_KEEPHEIGHT
const int ECE_IN_INVENTORY
const int RF_DEFAULT
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
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:81
EntityAI CreateInInventory(string type)
creates entity somewhere in inventory
Definition inventory.c:876
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)
void SpawnItemOnCrosshair(PlayerBase player, string itemName, float health, float quantity, float maxDist=100, bool allowFreeflight=false, bool special=false, bool withPhysics=false)
override void OnInit()
void PrintLogClient(string msg_log)
void ToggleScriptConsole()
void OnSpawnErrorReport(string name)
void OnRPCSyncSceneObject(ParamsReadContext ctx)
bool m_IsWinHolding
EntityAI SpawnFromClipboard()
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)
EntityAI SpawnEntityOnGroundPos(PlayerBase player, string object_name, vector pos)
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)
void OnRPCServerLogRecieved(ParamsReadContext ctx)
void TeleportAtCursor()
Set Player position at his cursor position in the world.
void GetCameraDirections(Man player, bool allowFreeflight, out vector position, out vector direction)
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)
EntityAI SpawnAI(string object_name, vector pos)
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
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZGame g_Game
Definition dayzgame.c:3942
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
Serializer ParamsReadContext
Definition gameplay.c:15
class LOD Object
array< string > TStringArray
Definition enscript.c:712
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:4931
override void ClearInventory()
Definition itembase.c:8504
class OptionSelectorMultistate extends OptionSelector class_name
void PluginDayZCreatureAIDebug()
Param7< EntityAI, string, float, float, bool, string, FindInventoryLocationType > DevSpawnItemParams
void PluginItemDiagnostic()
PluginBase GetPlugin(typename plugin_type)