1 typedef Param7<EntityAI, string, float, float, bool, string, FindInventoryLocationType>
DevSpawnItemParams;
4 protected bool m_IsWinHolding;
5 protected int m_FeaturesMask;
8 static PluginDeveloper GetInstance()
10 return PluginDeveloper.Cast(
GetPlugin( PluginDeveloper ) );
14 void TeleportAtCursor()
26 void ToggleFreeCameraBackPos()
32 void ToggleFreeCamera()
37 bool IsEnabledFreeCamera()
43 void PluginDeveloper()
60 case ERPCs.DEV_RPC_SPAWN_ITEM_ON_GROUND:
62 OnRPCSpawnEntityOnGround(player, ctx);
break;
64 case ERPCs.DEV_RPC_SPAWN_ITEM_ON_GROUND_PATTERN_GRID:
66 OnRPCSpawnEntityOnGroundPatternGrid(player, ctx);
break;
68 case ERPCs.DEV_RPC_SPAWN_ITEM_ON_CURSOR:
70 OnRPCSpawnEntityOnCursorDir(player, ctx);
break;
72 case ERPCs.DEV_RPC_SPAWN_ITEM_IN_INVENTORY:
74 OnRPCSpawnEntity(player, ctx);
break;
76 case ERPCs.DEV_RPC_CLEAR_INV:
78 OnRPCClearInventory(player);
break;
80 case ERPCs.DEV_RPC_SEND_SERVER_LOG:
82 OnRPCServerLogRecieved( ctx );
break;
84 case ERPCs.RPC_SYNC_SCENE_OBJECT:
86 OnRPCSyncSceneObject( ctx );
break;
88 case ERPCs.DEV_RPC_PLUGIN_DZCREATURE_DEBUG:
90 OnRPCPluginDayzCreatureDebug(player, rpc_type, ctx);
break;
92 case ERPCs.DEV_RPC_SPAWN_PRESET:
100 HandlePresetSpawn(player,presetName, target);
break;
102 case ERPCs.DEV_RPC_SET_TIME:
104 HandleSetTime(player,ctx);
break;
114 void PrintLogClient(
string msg_log)
118 Param1<string> msg_p =
new Param1<string>(msg_log);
124 void SendServerLogToClient(
string msg)
129 GetGame().GetPlayers( players );
131 for (
int i = 0; i < players.Count(); ++i )
133 Param1<string> param =
new Param1<string>( msg );
134 Man player = players.Get(i);
136 if ( player && player.HasNetworkID() )
138 player.RPCSingleParam(
ERPCs.DEV_RPC_SEND_SERVER_LOG, param,
true, player.GetIdentity());
148 if ( ctx.Read( par ) )
150 PluginSceneManager module_scene_editor = PluginSceneManager.Cast(
GetPlugin( PluginSceneManager ) );
151 SceneData scene_data = module_scene_editor.GetLoadedScene();
152 SceneObject scene_object = scene_data.GetSceneObjectByEntityAI( par.param2 );
161 if (pluginDZCreatureDebug)
163 pluginDZCreatureDebug.OnRpc(player, rpc_type, ctx);
171 Param5<int,int,int,int,int> p5 =
new Param5<int,int,int,int,int>(0,0,0,0,0);
173 if ( ctx.Read( p5 ) )
178 int year = p5.param1;
179 int month = p5.param2;
181 int hour = p5.param4;
182 int minute = p5.param5;
186 GetGame().GetWorld().SetDate(year,month, day, hour, minute);
212 targetPlayer.m_PresetSpawned =
true;
218 PresetSpawnBase presetObj = PresetSpawnBase.Cast(type.Spawn());
222 presetObj.Init(targetPlayer);
233 Param1<string> param =
new Param1<string>(
"" );
235 if ( ctx.Read(param) && param.param1 !=
"" )
237 Debug.ReceivedLogMessageFromServer(param.param1);
249 Param7<string, float, float, float, bool, string, bool> p =
new Param7<string, float, float, float, bool, string, bool>(
"", 0, 0, 0,
false,
"",
false);
252 SpawnEntityOnCursorDir(player, p.param1, p.param2, p.param3, p.param4, p.param5, p.param6, p.param7);
258 Param6<string, float, float, vector, bool, bool> p =
new Param6<string, float, float, vector, bool, bool>(
"", 0, 0,
"0 0 0",
false,
false);
261 SpawnEntityOnGroundPos(player, p.param1, p.param2, p.param3, p.param4, p.param5, p.param6);
267 auto p =
new Param10<string,int, float, float, int, int, float, float, bool, bool>(
"",0,0,0,0,0,0,0,
false,
false);
270 SpawnEntityOnGroundPatternGrid(player, p.param1, p.param2, p.param3, p.param4, p.param5, p.param6, p.param7, p.param8, p.param9, p.param10);
282 EntityAI ent = SpawnEntityInInventory( target, p.param2, p.param3, p.param4, p.param5,
"", p.param7);
283 if (playerTarget && p.param5)
285 if (playerTarget.m_PresetSpawned)
287 playerTarget.m_PresetSpawned =
false;
288 playerTarget.m_PresetItems.Clear();
292 playerTarget.m_PresetItems.Insert(ent);
299 void OnSetFreeCameraEvent(
PlayerBase player, FreeDebugCamera camera )
304 void OnSpawnErrorReport (
string name)
306 PrintString(
"PluginDeveloper.SpawnEntity() Warning- Cant spawn object: " +
name);
308 PrintString(
"PluginDeveloper.SpawnEntity() Warning END");
311 void SetupSpawnedEntity(
PlayerBase player,
EntityAI entity,
float health,
float quantity = -1,
bool special =
false,
string presetName =
"")
314 if (presetName && player.m_PresetSpawned)
316 player.m_PresetItems.Clear();
317 player.m_PresetSpawned =
false;
322 plr.OnSpawnedFromConsole();
324 else if ( entity.IsInherited(
ItemBase) )
329 else if (entity.IsInherited(
House))
331 entity.PlaceOnSurface();
332 vector pos = entity.GetPosition();
333 vector ori =
GetGame().GetSurfaceOrientation(pos[0], pos[2]);
334 entity.SetOrientation(ori);
338 player.m_PresetItems.Insert(entity);
343 auto debugParams = DebugSpawnParams.WithPlayer(player);
344 entity.OnDebugSpawnEx(debugParams);
350 void SpawnEntityOnGroundPatternGrid(
PlayerBase player,
string item_name,
int count,
float health,
float quantity,
int rows,
int columns,
float gapRow = 1,
float gapColumn = 1,
bool special=
false,
bool withPhysics =
false)
359 float columnDist = 0;
361 vector playerPos = player.GetPosition();
362 vector camDirForward = player.GetDirection();
363 vector camDirRight = camDirForward.Perpend() * -1;
365 for (
int i = 0; i < rows; i++)
367 vector posRow = playerPos + camDirForward * rowDist;
370 for (
int j = 0; j < columns; j++)
372 offsetSide = camDirRight * columnDist;
373 vector placement = posRow + offsetSide;
374 float hlth = health * MiscGameplayFunctions.GetTypeMaxGlobalHealth( item_name );
375 EntityAI ent = SpawnEntityOnGroundPos(player, item_name, hlth, quantity, placement, special );
376 ent.PlaceOnSurface();
379 if (
Class.CastTo(item, ent) && withPhysics)
380 item.ThrowPhysically(
null,
"0 0 0");
383 if (countLoop == count)
387 columnDist += gapColumn;
394 auto params =
new Param10<string, int, float, float, int, int, float, float, bool, bool>(item_name, count, health, quantity, rows, columns, gapRow, gapColumn, special, withPhysics);
395 player.RPCSingleParam(
ERPCs.DEV_RPC_SPAWN_ITEM_ON_GROUND_PATTERN_GRID, params,
true);
399 void SpawnItemOnCrosshair(notnull
PlayerBase player,
string itemName,
float health,
float quantity,
float maxDist = 100,
bool allowFreeflight =
false,
bool special =
false,
bool withPhysics =
false)
402 if (allowFreeflight && FreeDebugCamera.GetInstance().IsActive())
404 from = FreeDebugCamera.GetInstance().GetPosition();
405 to = from + FreeDebugCamera.GetInstance().GetDirection() * maxDist;
409 from =
GetGame().GetCurrentCameraPosition();
410 to = from +
GetGame().GetCurrentCameraDirection() * maxDist;
421 DayZPhysics.RayCastBullet(from, to, hitMask, player, obj, hitPos, hitNormal, hitFraction);
424 if (hitPos !=
vector.Zero)
426 SpawnEntityOnGroundPos(player, itemName, health, quantity, hitPos, special, withPhysics);
438 EntityAI SpawnEntityOnGroundPos(
PlayerBase player,
string item_name,
float health,
float quantity,
vector pos,
bool special =
false,
bool withPhysics =
false)
442 EntityAI entity = player.SpawnEntityOnGroundPos(item_name, pos);
444 SetupSpawnedEntity(player, entity, health, quantity, special);
446 OnSpawnErrorReport(item_name);
449 if (
Class.CastTo(item, entity) && withPhysics)
450 item.ThrowPhysically(
null,
"0 0 0");
456 Param6<string, float, float, vector, bool, bool> params =
new Param6<string, float, float, vector, bool, bool>(item_name, health, quantity, pos, special, withPhysics);
457 player.RPCSingleParam(
ERPCs.DEV_RPC_SPAWN_ITEM_ON_GROUND, params,
true);
469 EntityAI SpawnEntityOnCursorDir(
PlayerBase player,
string item_name,
float quantity,
float distance,
float health = -1,
bool special =
false,
string presetName =
"",
bool withPhysics =
false)
475 EntityAI entity = player.SpawnEntityOnGroundOnCursorDir(item_name, distance);
479 if ( !entity.IsBuilding() && health < 0 && entity.GetMaxHealth() > 0)
481 health = entity.GetMaxHealth();
483 SetupSpawnedEntity( player,entity, health, quantity, special, presetName );
486 OnSpawnErrorReport( item_name );
489 if (
Class.CastTo(item, entity) && withPhysics)
490 item.ThrowPhysically(
null,
"0 0 0");
497 Param7<string, float, float, float, bool, string, bool> params =
new Param7<string, float, float, float, bool, string, bool>(item_name, quantity, distance, health, special, presetName, withPhysics);
498 player.RPCSingleParam(
ERPCs.DEV_RPC_SPAWN_ITEM_ON_CURSOR, params,
true);
514 if (target.IsPlayer())
516 return SpawnEntityInPlayerInventory(
PlayerBase.Cast(target), className, health, quantity, special, presetName, locationType);
521 if (target.GetInventory() && target.GetInventory().FindFirstFreeLocationForNewEntity(className,
FindInventoryLocationType.ANY, il))
524 if ( eai && eai.IsInherited(
ItemBase) )
528 health = eai.GetMaxHealth();
534 auto debugParams = DebugSpawnParams.WithPlayer(
null);
535 eai.OnDebugSpawnEx(debugParams);
557 if (!
GetGame().IsMultiplayer())
558 player.DropItem(player.GetItemInHands());
560 player.ServerDropEntity(player.GetItemInHands());
561 GetGame().GetCallQueue(
CALL_CATEGORY_SYSTEM).CallLater(SpawnEntityInPlayerInventory,100,
false, player, item_name, health, quantity, special, presetName, locationType);
567 if (
GetGame().IsKindOf(item_name,
"Transport"))
569 EntityAI car = SpawnEntityOnGroundPos(player, item_name, 1, quantity, player.GetPosition());
571 auto debugParams = DebugSpawnParams.WithPlayer(player);
572 car.OnDebugSpawnEx(debugParams);
580 player.SetGetInVehicleDebug(car);
588 if (player.GetInventory() && player.GetInventory().FindFirstFreeLocationForNewEntity(item_name, locationType, il))
594 vector pos = player.GetPosition();
595 EntityAI eai_gnd = SpawnEntityOnGroundPos(player, item_name, health, quantity, pos);
596 Magazine mag_gnd = Magazine.Cast(eai_gnd);
597 if (mag_gnd && player.GetWeaponManager().CanAttachMagazine(wpn, mag_gnd))
599 player.GetWeaponManager().AttachMagazine(mag_gnd);
606 if ( eai && eai.IsInherited(
ItemBase) )
610 health = eai.GetMaxHealth();
616 auto debugParams2 = DebugSpawnParams.WithPlayer(player);
617 eai.OnDebugSpawnEx(debugParams2);
624 OnSpawnErrorReport(item_name);
631 player.RPCSingleParam(
ERPCs.DEV_RPC_SPAWN_ITEM_IN_INVENTORY, params,
true);
651 return inventory.CreateInInventory(att_name);
665 EntityAI eai = parent.GetInventory().CreateAttachment(att_name);
676 OnSpawnErrorReport(att_name);
684 player.RPCSingleParam(
ERPCs.DEV_RPC_SPAWN_ITEM_AS_ATTACHMENT, params,
true);
693 if ( menu_curr == NULL )
698 if ( !
GetGame().GetWorld().Is3rdPersonDisabled() )
700 player.SetIsInThirdPerson(!player.IsInThirdPerson());
703 vector pos_player = player.GetPosition();
707 GetGame().CopyFromClipboard(clipboard);
709 if (!clipboard.Contains(
","))
713 SpawnItemOnCrosshair(player, clipboard.Trim(), -1, 1, 40,
true );
715 SpawnEntityOnCursorDir(player, clipboard.Trim(), 1, 1);
720 clipboard.Split(
",", items );
722 foreach (
string item:items)
725 SpawnItemOnCrosshair(player, item.Trim(), -1, 1, 40,
true );
727 SpawnEntityOnCursorDir(player, item.Trim(), 1, 1);
742 entity.ClearInventory();
746 Param1<int> params =
new Param1<int>(0);
747 entity.RPCSingleParam(
ERPCs.DEV_RPC_CLEAR_INV, params,
true);
751 void ToggleHelpScreen()
753 if (
g_Game.GetUIManager().GetMenu() == NULL )
759 g_Game.GetUIManager().Back();
763 void ToggleScriptConsole()
767 if (
g_Game.GetUIManager().GetMenu() == NULL )
770 GetGame().GetMission().AddActiveInputExcludes({
"menu"});
775 g_Game.GetUIManager().Back();
776 GetGame().GetMission().RemoveActiveInputExcludes({
"menu"},
true);
782 void ToggleMissionLoader()
786 g_Game.GetUIManager().Back();
787 GetGame().GetMission().RemoveActiveInputExcludes({
"menu"},
true);
791 if (
g_Game.GetUIManager().GetMenu() )
792 g_Game.GetUIManager().GetMenu().Close();
795 GetGame().GetMission().AddActiveInputExcludes({
"menu"});
801 private void ScriptHistoryNext()
810 private void ScriptHistoryBack()
819 private bool IsIngame()
823 if ( menu_curr == NULL )
831 private bool IsInConsole()
844 int QuickSortPartition(
TStringArray arr,
int left,
int right )
846 string pivot = arr.Get( left );
856 if ( i > right || arr.Get(i) > pivot )
865 if ( arr.Get(j) <= pivot )
877 arr.Set( i, arr.Get(j) );
881 temp = arr.Get( left );
882 arr.Set( left, arr.Get(j) );
894 j = QuickSortPartition( arr, left, right );
895 QuickSort( arr, left, j - 1 );
896 QuickSort( arr, j + 1, right );
902 QuickSort( arr, 0, arr.Count() - 1 );
909 GetGame().GetMission().ResetGUI();
913 static void SetDeveloperItemClientEx(notnull
Object entity,
bool getFocus =
false)
919 GetGame().GetInput().ChangeGameFocus(1);
920 GetGame().GetUIManager().ShowUICursor(
true);
930 mid2.RegisterDebugItem(entity, player);
933 SetDebugDeveloper_item(entity);
937 void SetDeveloperItemClient()
943 FreeDebugCamera debugCam = FreeDebugCamera.GetInstance();
944 if (debugCam && debugCam.GetCurrentCamera())
946 entity = debugCam.GetCrosshairObject();
951 if (player && player.GetActionManager())
953 ActionTarget at = player.GetActionManager().FindActionTarget();
954 entity = at.GetObject();
960 SetDeveloperItemClientEx(entity,
true);