DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
PluginDeveloper.c
См. документацию.
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
36
42
47
48 // System Public Events
50 {
51
52 }
53
54 override void OnInit()
55 {
56 super.OnInit();
57
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 {
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 {
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 }
451
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 }
492
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 }
627
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
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 {
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();
766 }
767 }
768 }
769
770 // Mission Editor
772 {
773 if ( g_Game.GetUIManager().IsMenuOpen(MENU_MISSION_LOADER) )
774 {
775 g_Game.GetUIManager().Back();
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);
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
890 {
891 QuickSort( arr, 0, arr.Count() - 1 );
892 }
893
894 void ResetGUI()
895 {
896 if ( GetGame() && GetGame().GetMission() )
897 {
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 {
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
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}
class ActionTargets ActionTarget
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
const int ECE_IN_INVENTORY
Определения CentralEconomy.c:36
const int RF_DEFAULT
Определения CentralEconomy.c:65
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
DayZGame g_Game
Определения DayZGame.c:3868
PhxInteractionLayers
Определения DayZPhysics.c:2
const CallID CALL_ID_SCR_CNSL_HISTORY_NEXT
Определения Dispatcher.c:5
const CallID CALL_ID_SCR_CNSL_HISTORY_BACK
Определения Dispatcher.c:4
const CallID CALL_ID_SCR_CNSL_ADD_PRINT
Определения Dispatcher.c:6
Param CallMethod(CallID call_id, Param params)
Определения Dispatcher.c:36
ERPCs
Определения ERPCs.c:2
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4803
override void ClearInventory()
Определения ItemBase.c:8257
PlayerBase GetPlayer()
Определения ModifierBase.c:51
class OptionSelectorMultistate extends OptionSelector class_name
void PluginDayZCreatureAIDebug()
Определения PluginDayZCreatureAIDebug.c:101
Param7< EntityAI, string, float, float, bool, string, FindInventoryLocationType > DevSpawnItemParams
Определения PluginDeveloper.c:1
void PluginItemDiagnostic()
Определения PluginItemDiagnostic.c:74
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:316
proto native UIManager GetUIManager()
proto native void GetPlayers(out array< Man > players)
proto native void RPCSingleParam(Object target, int rpc_type, Param param, bool guaranteed, PlayerIdentity recipient=null)
see CGame.RPC
proto native World GetWorld()
override ScriptCallQueue GetCallQueue(int call_category)
Определения DayZGame.c:1187
proto native DayZPlayer GetPlayer()
proto native vector GetCurrentCameraPosition()
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 ...
Определения Game.c:1143
proto native vector GetCurrentCameraDirection()
proto void CopyFromClipboard(out string text)
proto native Input GetInput()
proto native Mission GetMission()
Super root of all classes in Enforce script.
Определения EnScript.c:11
static proto bool RayCastBullet(vector begPos, vector endPos, PhxInteractionLayers layerMask, Object ignoreObj, out Object hitObject, out vector hitPosition, out vector hitNormal, out float hitFraction)
Определения DayZPhysics.c:124
static void ReceivedLogMessageFromServer(string message)
Определения Debug.c:271
Определения Debug.c:2
static void OnSetFreeCameraEvent(PlayerBase player, FreeDebugCamera camera)
Определения DeveloperFreeCamera.c:67
static void OnInit()
static bool IsFreeCameraEnabled()
Определения DeveloperFreeCamera.c:23
static void FreeCameraToggle(PlayerBase player, bool teleport_player=false)
Enable / Disable Free camera (Fly mod) - disable of camera will teleport player at current free camer...
Определения DeveloperFreeCamera.c:6
static void OnRPC(PlayerBase player, int rpc_type, ParamsReadContext ctx)
Определения DeveloperTeleport.c:168
static void TeleportAtCursorEx()
Определения DeveloperTeleport.c:45
static void SetPlayerDirection(PlayerBase player, vector direction)
Определения DeveloperTeleport.c:153
static void SetPlayerPosition(PlayerBase player, vector position, bool breakSync=false)
Определения DeveloperTeleport.c:115
override bool IsBuilding()
Определения Building.c:219
Определения Building.c:6
EntityAI CreateInInventory(string type)
creates entity somewhere in inventory
Определения Inventory.c:874
script counterpart to engine's class Inventory
Определения Inventory.c:79
Определения CrashBase.c:2
proto native void ChangeGameFocus(int add, int input_device=-1)
Change game focus number.
Определения ItemBase.c:15
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
InventoryLocation.
Определения InventoryLocation.c:29
provides access to slot configuration
Определения InventorySlots.c:6
Определения InventoryItem.c:731
void AddActiveInputExcludes(array< string > excludes)
void ResetGUI()
Определения gameplay.c:718
void RemoveActiveInputExcludes(array< string > excludes, bool bForceSupress=false)
deprecated
Определения ObjectTyped.c:2
Определения EntityAI.c:95
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Определения param.c:12
Определения PlayerBaseClient.c:2
EntityAI SpawnEntityAsAttachment(PlayerBase player, EntityAI parent, string att_name, float health, float quantity)
tries to spawn item as attachment
Определения PluginDeveloper.c:634
void ToggleFreeCamera()
Enable / Disable Free camera (Fly mod) - disable of camera will teleport player at current free camer...
Определения PluginDeveloper.c:38
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
Определения PluginDeveloper.c:459
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
Определения PluginDeveloper.c:502
void HandlePresetSpawn(PlayerBase player, string presetName, EntityAI target)
Определения PluginDeveloper.c:189
void OnRPCSpawnEntityOnCursorDir(PlayerBase player, ParamsReadContext ctx)
Определения PluginDeveloper.c:237
override void OnInit()
Определения PluginDeveloper.c:54
void PrintLogClient(string msg_log)
Определения PluginDeveloper.c:119
void ToggleScriptConsole()
Определения PluginDeveloper.c:754
void OnSpawnErrorReport(string name)
Определения PluginDeveloper.c:294
int m_FeaturesMask
Определения PluginDeveloper.c:5
void OnRPCSyncSceneObject(ParamsReadContext ctx)
Определения PluginDeveloper.c:149
bool m_IsWinHolding
Определения PluginDeveloper.c:4
int QuickSortPartition(TStringArray arr, int left, int right)
Определения PluginDeveloper.c:833
EntityAI SpawnFromClipboard()
Определения PluginDeveloper.c:680
void SpawnItemOnCrosshair(notnull PlayerBase player, string itemName, float health, float quantity, float maxDist=100, bool allowFreeflight=false, bool special=false, bool withPhysics=false)
Определения PluginDeveloper.c:389
void SortStringArray(TStringArray arr)
Определения PluginDeveloper.c:889
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)
Определения PluginDeveloper.c:340
void SetDirection(PlayerBase player, vector direction)
Set player direction.
Определения PluginDeveloper.c:26
void OnSetFreeCameraEvent(PlayerBase player, FreeDebugCamera camera)
Определения PluginDeveloper.c:289
void PluginSceneManager()
Определения PluginSceneManager.c:21
void HandleSetTime(PlayerBase player, ParamsReadContext ctx)
Определения PluginDeveloper.c:172
void ToggleFreeCameraBackPos()
Enable / Disable Free camera (Fly mod)
Определения PluginDeveloper.c:32
void ScriptHistoryBack()
Определения PluginDeveloper.c:799
UIScriptedMenu m_ScriptConsole
Определения PluginDeveloper.c:6
EntityAI SpawnEntityInPlayerInventory(PlayerBase player, string item_name, float health, float quantity, bool special=false, string presetName="", FindInventoryLocationType locationType=FindInventoryLocationType.ANY)
Определения PluginDeveloper.c:539
void ResetGUI()
Определения PluginDeveloper.c:894
static PluginDeveloper GetInstance()
Определения PluginDeveloper.c:8
void ToggleHelpScreen()
Определения PluginDeveloper.c:742
void OnRPCSpawnEntity(PlayerBase player, ParamsReadContext ctx)
Определения PluginDeveloper.c:263
void OnRPCSpawnEntityOnGroundPatternGrid(PlayerBase player, ParamsReadContext ctx)
Определения PluginDeveloper.c:255
EntityAI SpawnEntityOnGroundPos(PlayerBase player, string item_name, float health, float quantity, vector pos, bool special=false, bool withPhysics=false)
spawns entity on exact position
Определения PluginDeveloper.c:428
void OnRPCServerLogRecieved(ParamsReadContext ctx)
Определения PluginDeveloper.c:221
void TeleportAtCursor()
Set Player position at his cursor position in the world.
Определения PluginDeveloper.c:14
bool IsInConsole()
Определения PluginDeveloper.c:820
void PluginDeveloper()
Определения PluginDeveloper.c:49
void OnRPCSpawnEntityOnGround(PlayerBase player, ParamsReadContext ctx)
Определения PluginDeveloper.c:246
static void SetDeveloperItemClientEx(notnull Object entity, bool getFocus=false)
Определения PluginDeveloper.c:902
void OnRPC(PlayerBase player, int rpc_type, ParamsReadContext ctx)
Определения PluginDeveloper.c:61
void OnRPCPluginDayzCreatureDebug(PlayerBase player, int rpc_type, ParamsReadContext ctx)
Определения PluginDeveloper.c:163
void ToggleMissionLoader()
Определения PluginDeveloper.c:771
void SetupSpawnedEntity(PlayerBase player, EntityAI entity, float health, float quantity=-1, bool special=false, string presetName="")
Определения PluginDeveloper.c:301
void ClearInventory(EntityAI entity)
Определения PluginDeveloper.c:729
void SetDeveloperItemClient()
Определения PluginDeveloper.c:926
bool IsIngame()
Определения PluginDeveloper.c:808
bool IsEnabledFreeCamera()
Определения PluginDeveloper.c:43
void OnRPCClearInventory(PlayerBase player)
Определения PluginDeveloper.c:231
void SendServerLogToClient(string msg)
Определения PluginDeveloper.c:129
void Teleport(PlayerBase player, vector position)
Teleport player at position.
Определения PluginDeveloper.c:20
void QuickSort(TStringArray arr, int left, int right)
Определения PluginDeveloper.c:877
void ScriptHistoryNext()
Определения PluginDeveloper.c:790
Определения PluginBase.c:2
SceneObject GetSceneObjectByEntityAI(EntityAI e)
Определения SceneData.c:348
Определения SceneData.c:2
Определения SceneObject.c:2
proto void CallByName(Class obj, string fnName, Param params=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
proto void CallLater(func fn, int delay=0, bool repeat=false, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
proto bool Read(void value_in)
proto native UIScriptedMenu GetMenu()
Returns most-top open menu.
void ShowUICursor(bool visible)
Определения UIManager.c:244
Определения DayZGame.c:64
shorthand
Определения BoltActionRifle_Base.c:6
proto native void SetDate(int year, int month, int day, int hour, int minute)
Sets actual ingame world time.
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static const vector Zero
Определения EnConvert.c:110
vector Perpend()
Returns perpendicular vector. Perpendicular vector is computed as cross product between input vector ...
Определения EnConvert.c:209
Определения EnConvert.c:106
Serializer ParamsReadContext
Определения gameplay.c:15
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
array< string > TStringArray
Определения EnScript.c:685
void PrintString(string s)
Helper for printing out string expression. Example: PrintString("Hello " + var);.
Определения EnScript.c:345
const int MENU_HELP_SCREEN
Определения constants.c:193
const int MENU_SCRIPTCONSOLE
Определения constants.c:185
const int MENU_MISSION_LOADER
Определения constants.c:214
proto string Trim()
Returns trimmed string with removed leading and trailing whitespaces.
bool Contains(string sample)
Returns true if sample is substring of string.
Определения EnString.c:286
void Split(string sample, out array< string > output)
Splits string into array of strings separated by 'sample'.
Определения EnString.c:396
const int CALL_CATEGORY_SYSTEM
Определения tools.c:8