DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
PluginDeveloper.c
См. документацию.
2{
3 string m_Name;
5 int m_Scope;
6 int m_CategoryMask = -1;
7
8 void ScriptConsoleItem(string name, string displayName, int scope, int categoryMask = -1)
9 {
10 m_Name = name;
11 m_DisplayName = displayName;
12 m_Scope = scope;
13 m_CategoryMask = categoryMask;
14 }
15}
16
17typedef Param7<EntityAI, string, float, float, bool, string, FindInventoryLocationType> DevSpawnItemParams;//(target, item_name, health, quantity, special, presetName, locationType );
18class PluginDeveloper extends PluginBase
19{
20 protected bool m_IsWinHolding;
21 protected int m_FeaturesMask;
23
25
27 {
29 }
30
36
42
44 void SetDirection(PlayerBase player, vector direction)
45 {
46 DeveloperTeleport.SetPlayerDirection(player, direction);
47 }
48
51 {
52 DeveloperFreeCamera.FreeCameraToggle( PlayerBase.Cast( g_Game.GetPlayer() ), false );
53 }
54
57 {
58 DeveloperFreeCamera.FreeCameraToggle( PlayerBase.Cast( g_Game.GetPlayer() ), true );
59 }
60
65
66 // System Public Events
68 {
69
70 }
71
72 override void OnInit()
73 {
74 super.OnInit();
75
77
78 #ifdef DIAG_DEVELOPER
79 if (!m_Items || !m_Items.Count())
80 InitItems();
81 #endif
82 }
83
88
89 protected void InitItems()
90 {
91 for (int i = 0; i < GetItemClasses().Count(); i++)
92 {
93 string configPath = GetItemClasses().Get(i);
94
95 int objectsCount = g_Game.ConfigGetChildrenCount(configPath);
96 for (int j = 0; j < objectsCount; j++)
97 {
98 string childName;
99 g_Game.ConfigGetChildName(configPath, j, childName);
100 int scope = g_Game.ConfigGetInt(configPath + " " + childName + " scope");
101 int categoryMask = g_Game.ConfigGetInt(configPath + " " + childName + " debug_ItemCategory") - 1;
102 string displayName;
103 g_Game.ConfigGetText(configPath + " " + childName + " displayName", displayName);
104
105 m_Items.Insert(childName, new ScriptConsoleItem(childName, displayName, scope, categoryMask));
106 }
107 }
108 }
109
110 void OnRPC(PlayerBase player, int rpc_type, ParamsReadContext ctx)
111 {
112 #ifdef DIAG_DEVELOPER
113 switch (rpc_type)
114 {
115 case ERPCs.DEV_RPC_SPAWN_ITEM_ON_GROUND:
116 OnRPCSpawnEntityOnGround(player, ctx);
117 break;
118
119 case ERPCs.DEV_RPC_SPAWN_ITEM_ON_GROUND_PATTERN_GRID:
121 break;
122
123 case ERPCs.DEV_RPC_SPAWN_ITEM_ON_CURSOR:
124 OnRPCSpawnEntityOnCursorDir(player, ctx);
125 break;
126
127 case ERPCs.DEV_RPC_SPAWN_ITEM_IN_INVENTORY:
128 OnRPCSpawnEntity(player, ctx);
129 break;
130
131 case ERPCs.DEV_RPC_CLEAR_INV:
132 OnRPCClearInventory(player);
133 break;
134
135 case ERPCs.DEV_RPC_SEND_SERVER_LOG:
137 break;
138
139 case ERPCs.RPC_SYNC_SCENE_OBJECT:
141 break;
142
143 case ERPCs.DEV_RPC_PLUGIN_DZCREATURE_DEBUG:
144 OnRPCPluginDayzCreatureDebug(player, rpc_type, ctx);
145 break;
146
147 case ERPCs.DEV_RPC_SPAWN_PRESET:
148 string presetName;
149 EntityAI target;
150
151 ctx.Read(presetName);
152 ctx.Read(target);
153
154 HandlePresetSpawn(player,presetName, target);
155 break;
156
157 case ERPCs.DEV_RPC_SET_TIME:
158 HandleSetTime(player,ctx);
159 break;
160 }
161
162 DeveloperTeleport.OnRPC(player, rpc_type, ctx);
163 #endif
164 }
165
166 // Public API
167 // Send Print to scripted console
168 void PrintLogClient(string msg_log)
169 {
170 if ( g_Game.GetUIManager().IsMenuOpen(MENU_SCRIPTCONSOLE) )
171 {
172 Param1<string> msg_p = new Param1<string>(msg_log);
174 }
175 }
176
177 // Server Log Synch: Server Side
178 void SendServerLogToClient(string msg)
179 {
180 if ( g_Game )
181 {
182 array<Man> players = new array<Man>;
183 g_Game.GetPlayers( players );
184
185 for ( int i = 0; i < players.Count(); ++i )
186 {
187 Param1<string> param = new Param1<string>( msg );
188 Man player = players.Get(i);
189
190 if ( player && player.HasNetworkID() )
191 {
192 player.RPCSingleParam(ERPCs.DEV_RPC_SEND_SERVER_LOG, param, true, player.GetIdentity());
193 }
194 }
195 }
196 }
197
199 {
200 Param3<string, EntityAI, Param> par = new Param3<string, EntityAI, Param>( "", NULL, new Param );
201
202 if ( ctx.Read( par ) )
203 {
204 PluginSceneManager module_scene_editor = PluginSceneManager.Cast( GetPlugin( PluginSceneManager ) );
205 SceneData scene_data = module_scene_editor.GetLoadedScene();
206 SceneObject scene_object = scene_data.GetSceneObjectByEntityAI( par.param2 );
207
208 g_Game.GetCallQueue( CALL_CATEGORY_SYSTEM ).CallByName( scene_object, par.param1, par.param3 );
209 }
210 }
211
213 {
215 if (pluginDZCreatureDebug)
216 {
217 pluginDZCreatureDebug.OnRpc(player, rpc_type, ctx);
218 }
219 }
220
222 {
223 #ifdef DEVELOPER
224 Param5<int,int,int,int,int> p5 = new Param5<int,int,int,int,int>(0,0,0,0,0);
225 if (ctx.Read(p5))
226 {
227 int year = p5.param1;
228 int month = p5.param2;
229 int day = p5.param3;
230 int hour = p5.param4;
231 int minute = p5.param5;
232
233 g_Game.GetWorld().SetDate(year,month, day, hour, minute);
234 }
235 #endif
236 }
237
238 void HandlePresetSpawn(PlayerBase player, string presetName, EntityAI target)
239 {
240 #ifdef DEVELOPER
241
242 PlayerBase targetPlayer = player;
243
244 if (target)
245 {
246 targetPlayer = PlayerBase.Cast(target);
247 }
248 if (!targetPlayer)
249 return;
250
251 targetPlayer.m_PresetSpawned = true;
252 string class_name = presetName + "_Preset";
253 typename type = class_name.ToType();
254
255 if (type)
256 {
257 PresetSpawnBase presetObj = PresetSpawnBase.Cast(type.Spawn());
258
259 if (presetObj)
260 {
261 presetObj.Init(targetPlayer);
262 }
263 }
264
265 #endif
266 }
267
268 // RPC Events
269 // Server Log Synch: Client Side
271 {
272 Param1<string> param = new Param1<string>( "" );
273
274 if ( ctx.Read(param) && param.param1 != "" )
275 {
277 }
278 }
279
281 {
282 ClearInventory(player);
283 }
284
285 // Client -> Server Spawning: Server Side
287 {
289 if ( ctx.Read(p) )
290 {
291 SpawnEntityOnCursorDir(player, p.param1, p.param2, p.param3, p.param4, p.param5, p.param6, p.param7);
292 }
293 }
294
296 {
297 Param6<string, float, float, vector, bool, bool> p = new Param6<string, float, float, vector, bool, bool>("", 0, 0, "0 0 0", false, false);
298 if ( ctx.Read(p) )
299 {
300 SpawnEntityOnGroundPos(player, p.param1, p.param2, p.param3, p.param4, p.param5, p.param6);
301 }
302 }
303
305 {
306 auto p = new Param10<string,int, float, float, int, int, float, float, bool, bool>("",0,0,0,0,0,0,0, false, false);
307 if ( ctx.Read(p) )
308 {
309 SpawnEntityOnGroundPatternGrid(player, p.param1, p.param2, p.param3, p.param4, p.param5, p.param6, p.param7, p.param8, p.param9, p.param10);
310 }
311 }
313 {
314 #ifdef DEVELOPER
315 DevSpawnItemParams p = new DevSpawnItemParams(null,"", 0, 0, false, "", FindInventoryLocationType.ANY);
316 if ( ctx.Read(p) )
317 {
318 EntityAI target = EntityAI.Cast(p.param1);
319 PlayerBase playerTarget = PlayerBase.Cast(target);
320
321 EntityAI ent = SpawnEntityInInventory( target, p.param2, p.param3, p.param4, p.param5, "", p.param7);
322 if (playerTarget && p.param5)
323 {
324 if (playerTarget.m_PresetSpawned)
325 {
326 playerTarget.m_PresetSpawned = false;
327 playerTarget.m_PresetItems.Clear();
328 }
329 if (ent)
330 {
331 playerTarget.m_PresetItems.Insert(ent);
332 }
333 }
334 }
335 #endif
336 }
337
338 void OnSetFreeCameraEvent( PlayerBase player, FreeDebugCamera camera )
339 {
341 }
342
344 {
345 PrintString("PluginDeveloper.SpawnEntity() Warning- Cant spawn object: " + name);
346 //DumpStack();
347 PrintString("PluginDeveloper.SpawnEntity() Warning END");
348 }
349
350 void SetupSpawnedEntity(PlayerBase player, EntityAI entity, float health, float quantity = -1, bool special = false, string presetName = "")
351 {
352 #ifdef DEVELOPER
353 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
354 {
355 player.m_PresetItems.Clear();
356 player.m_PresetSpawned = false;//is set to 'true' elsewhere after all the items have been spawned in
357 }
358 if ( entity.IsInherited( PlayerBase ) )
359 {
360 PlayerBase plr = PlayerBase.Cast( entity );
361 plr.OnSpawnedFromConsole();
362 }
363 else if ( entity.IsInherited(ItemBase) )
364 {
365 ItemBase item = ItemBase.Cast( entity );
366 SetupSpawnedItem(item, health, quantity);
367 }
368 else if (entity.IsInherited(House))
369 {
370 entity.PlaceOnSurface();
371 vector pos = entity.GetPosition();
372 vector ori = g_Game.GetSurfaceOrientation(pos[0], pos[2]);
373 entity.SetOrientation(ori);
374 }
375 if (player && presetName)
376 {
377 player.m_PresetItems.Insert(entity);
378 }
379
380 if (special)
381 {
382 if (player)
383 {
384 auto debugParamsPlayer = DebugSpawnParams.WithPlayer(player);
385 entity.OnDebugSpawnEx(debugParamsPlayer);
386 }
387 else
388 {
389 auto debugParamsNone = DebugSpawnParams.None();
390 entity.OnDebugSpawnEx(debugParamsNone);
391 }
392 }
393 #endif
394 }
395
396
397 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)
398 {
399 if (!item_name)
400 {
401 return;
402 }
403 if ( g_Game.IsServer() )
404 {
405 float rowDist = 0;
406 float columnDist = 0;
407
408 vector playerPos;
409 vector camDirForward;
410
411 GetCameraDirections(player, false, playerPos, camDirForward);
412
413 vector camDirRight = camDirForward.Perpend() * -1;
414 int countLoop = 0;
415 for (int i = 0; i < rows; i++)
416 {
417 vector posRow = playerPos + camDirForward * rowDist;
418 vector offsetSide;
419 columnDist = 0;
420 for (int j = 0; j < columns; j++)
421 {
422 offsetSide = camDirRight * columnDist;
423 vector placement = posRow + offsetSide;
424 float hlth = health * MiscGameplayFunctions.GetTypeMaxGlobalHealth( item_name );
425 EntityAI ent = SpawnEntityOnGroundPos(player, item_name, hlth, quantity, placement, special );
426 ent.PlaceOnSurface();
427
428 InventoryItem item;
429 if (Class.CastTo(item, ent) && withPhysics)
430 item.ThrowPhysically(null, "0 0 0");
431
432 countLoop++;
433 if (countLoop == count)
434 {
435 return;
436 }
437 columnDist += gapColumn;
438 }
439 rowDist += gapRow;
440 }
441 }
442 else
443 {
444 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);
445 player.RPCSingleParam(ERPCs.DEV_RPC_SPAWN_ITEM_ON_GROUND_PATTERN_GRID, params, true);
446 }
447 }
448
449 EntityAI SpawnAI(string object_name, vector pos)
450 {
451 bool is_ai = g_Game.IsKindOf(object_name, "DZ_LightAI");
452 if (is_ai)
453 {
454 return EntityAI.Cast(g_Game.CreateObjectEx(object_name, pos, ECE_PLACE_ON_SURFACE|ECE_INITAI|ECE_EQUIP_ATTACHMENTS));
455 }
456 return NULL;
457 }
458
459 void GetCameraDirections(Man player, bool allowFreeflight, out vector position, out vector direction)
460 {
461 position = g_Game.GetCurrentCameraPosition();
462 direction = g_Game.GetCurrentCameraDirection();
463
464 if ((g_Game.IsDedicatedServer() || allowFreeflight) && FreeDebugCamera.GetInstance().IsActive())
465 {
466 position = FreeDebugCamera.GetInstance().GetPosition();
467 direction = FreeDebugCamera.GetInstance().GetDirection();
468 return;
469 }
470
471 if (player && !allowFreeflight)
472 {
473 position = player.GetPosition();
474 direction = player.GetDirection();
475 }
476 }
477
478 EntityAI SpawnEntityOnGroundPos(PlayerBase player, string object_name, vector pos)
479 {
480 if (player)
481 {
482 return player.SpawnEntityOnGroundPos(object_name, pos);
483 }
484
485 bool is_AI = g_Game.IsKindOf(object_name, "DZ_LightAI");
486 if (is_AI)
487 {
488 return SpawnAI(object_name, pos);
489 }
490 else
491 {
493 vector mtx[4];
495 mtx[3] = pos;
496 inv_loc.SetGround(null, mtx);
497
498 int flags = ECE_PLACE_ON_SURFACE;
499 #ifdef DEVELOPER
500 if (g_Game.IsKindOf(object_name, "Boat"))
501 flags = ECE_KEEPHEIGHT;
502 #endif
503
504 return EntityAI.Cast(g_Game.CreateObjectEx(object_name, inv_loc.GetPos(), flags));
505 }
506
507 return null;
508 }
509
510 void SpawnItemOnCrosshair(PlayerBase player, string itemName, float health, float quantity, float maxDist = 100, bool allowFreeflight = false, bool special = false, bool withPhysics = false)
511 {
512 vector from, to, dir;
513 GetCameraDirections(player, true, from, dir);
514 to = from + (dir * maxDist);
515
516 float hitFraction;
517 vector start, end;
518 vector direction;
519
520 vector hitPos, hitNormal;
521 Object obj;
522
524 DayZPhysics.RayCastBullet(from, to, hitMask, player, obj, hitPos, hitNormal, hitFraction);
525
526 // something is hit
527 if (hitPos != vector.Zero)
528 {
529 SpawnEntityOnGroundPos(player, itemName, health, quantity, hitPos, special, withPhysics);
530 }
531 }
532
541 EntityAI SpawnEntityOnGroundPos( PlayerBase player, string item_name, float health, float quantity, vector pos, bool special = false, bool withPhysics = false)
542 {
543 if ( g_Game.IsServer() )
544 {
545 EntityAI entity = SpawnEntityOnGroundPos(player, item_name, pos);
546 if (entity)
547 SetupSpawnedEntity(player, entity, health, quantity, special);
548 else
549 OnSpawnErrorReport(item_name);
550
551 InventoryItem item;
552 if (Class.CastTo(item, entity) && withPhysics)
553 item.ThrowPhysically(null, "0 0 0");
554
555 return entity;
556 }
557 else
558 {
559 Param6<string, float, float, vector, bool, bool> params = new Param6<string, float, float, vector, bool, bool>(item_name, health, quantity, pos, special, withPhysics);
560 player.RPCSingleParam(ERPCs.DEV_RPC_SPAWN_ITEM_ON_GROUND, params, true);
561 }
562 return NULL;
563 }
564
572 EntityAI SpawnEntityOnCursorDir( PlayerBase player, string item_name, float quantity, float distance, float health = -1, bool special = false, string presetName = "", bool withPhysics = false)
573 {
574
575 if ( g_Game.IsServer() )
576 {
577 // Client -> Server Spawning: Server Side
578 EntityAI entity = player.SpawnEntityOnGroundOnCursorDir(item_name, distance);
579
580 if ( entity )
581 {
582 if ( !entity.IsBuilding() && health < 0 && entity.GetMaxHealth() > 0)//check for default (-1)
583 {
584 health = entity.GetMaxHealth();
585 }
586 SetupSpawnedEntity( player,entity, health, quantity, special, presetName );
587 }
588 else
589 OnSpawnErrorReport( item_name );
590
591 InventoryItem item;
592 if (Class.CastTo(item, entity) && withPhysics)
593 item.ThrowPhysically(null, "0 0 0");
594
595 return entity;
596 }
597 else
598 {
599 // Client -> Server Spawning: Client Side
600 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);
601 player.RPCSingleParam(ERPCs.DEV_RPC_SPAWN_ITEM_ON_CURSOR, params, true);
602 }
603 return NULL;
604 }
605
615 EntityAI SpawnEntityInInventory( notnull EntityAI target, string className, float health, float quantity, bool special = false, string presetName = "", FindInventoryLocationType locationType = FindInventoryLocationType.ANY)
616 {
617 if (target.IsPlayer())
618 {
619 return SpawnEntityInPlayerInventory(PlayerBase.Cast(target), className, health, quantity, special, presetName, locationType);
620 }
621 if ( g_Game.IsServer() )
622 {
624 if (target.GetInventory() && target.GetInventory().FindFirstFreeLocationForNewEntity(className, FindInventoryLocationType.ANY, il))
625 {
626 EntityAI eai = SpawnEntity(className, il, ECE_IN_INVENTORY, RF_DEFAULT);
627 if ( eai && eai.IsInherited(ItemBase) )
628 {
629 if ( health < 0 )//check for default (-1)
630 {
631 health = eai.GetMaxHealth();
632 }
633 ItemBase i = ItemBase.Cast( eai );
634 SetupSpawnedItem(i, health, quantity);
635 if ( special )
636 {
637 auto debugParams = DebugSpawnParams.WithPlayer(null);
638 eai.OnDebugSpawnEx(debugParams);
639 }
640 }
641 return eai;
642 }
643 }
644 else
645 {
646 DevSpawnItemParams params = new DevSpawnItemParams(target, className, health, quantity, special, presetName, 0 );
647 g_Game.GetPlayer().RPCSingleParam(ERPCs.DEV_RPC_SPAWN_ITEM_IN_INVENTORY, params, true, g_Game.GetPlayer().GetIdentity());
648 }
649 return null;
650 }
651
652 EntityAI SpawnEntityInPlayerInventory(PlayerBase player, string item_name, float health, float quantity, bool special = false, string presetName = "", FindInventoryLocationType locationType = FindInventoryLocationType.ANY)
653 {
654 if (player)
655 {
656 if (g_Game.IsServer())
657 {
658 if (locationType == FindInventoryLocationType.HANDS && player.GetItemInHands())
659 {
660 if (!g_Game.IsMultiplayer())
661 player.DropItem(player.GetItemInHands());
662 else
663 player.ServerDropEntity(player.GetItemInHands());
664
665 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(SpawnEntityInPlayerInventory, 500, false, player, item_name, health, quantity, special, presetName, locationType);
666
667 return null;
668 }
669
670
671 #ifdef DEVELOPER
672 if (g_Game.IsKindOf(item_name, "Transport"))
673 {
674 EntityAI vehicle = SpawnEntityOnGroundPos(player, item_name, 1, quantity, player.GetPosition());
675 auto debugParams = DebugSpawnParams.WithPlayer(player);
676 vehicle.OnDebugSpawnEx(debugParams);
677
678 if (g_Game.IsMultiplayer())
679 {
680 DayZPlayerSyncJunctures.SendGetInVehicle(player, vehicle);
681 }
682 else
683 {
684 player.SetGetInVehicleDebug(vehicle);
685 }
686
687 return vehicle;
688 }
689 #endif
690
692 if (player.GetInventory() && player.GetInventory().FindFirstFreeLocationForNewEntity(item_name, locationType, il))
693 {
694 Weapon_Base wpn = Weapon_Base.Cast(il.GetParent());
695 bool is_mag = il.GetSlot() == InventorySlots.MAGAZINE || il.GetSlot() == InventorySlots.MAGAZINE2 || il.GetSlot() == InventorySlots.MAGAZINE3;
696 if (wpn && is_mag)
697 {
698 vector pos = player.GetPosition();
699 EntityAI eai_gnd = SpawnEntityOnGroundPos(player, item_name, health, quantity, pos);
700 Magazine mag_gnd = Magazine.Cast(eai_gnd);
701 if (mag_gnd && player.GetWeaponManager().CanAttachMagazine(wpn, mag_gnd))
702 {
703 player.GetWeaponManager().AttachMagazine(mag_gnd);
704 }
705 return eai_gnd;
706 }
707 else
708 {
709 EntityAI eai = SpawnEntity(item_name, il, ECE_IN_INVENTORY, RF_DEFAULT);
710 if ( eai && eai.IsInherited(ItemBase) )
711 {
712 if ( health < 0 )//check for default (-1)
713 {
714 health = eai.GetMaxHealth();
715 }
716 ItemBase i = ItemBase.Cast( eai );
717 SetupSpawnedItem(i, health, quantity);
718 if ( special )
719 {
720 auto debugParams2 = DebugSpawnParams.WithPlayer(player);
721 eai.OnDebugSpawnEx(debugParams2);
722 }
723 }
724 return eai;
725 }
726 }
727 else
728 OnSpawnErrorReport(item_name);
729 return NULL;
730 }
731 else
732 {
733 // Client -> Server Spawning: Client Side
734 DevSpawnItemParams params = new DevSpawnItemParams(player, item_name, health, quantity, special, presetName, locationType );
735 player.RPCSingleParam(ERPCs.DEV_RPC_SPAWN_ITEM_IN_INVENTORY, params, true);
736 }
737 }
738 return NULL;
739 }
740
747 EntityAI SpawnEntityAsAttachment (PlayerBase player, EntityAI parent, string att_name, float health, float quantity)
748 {
749 if ( g_Game.IsServer() )
750 {
751 Weapon_Base wpn = Weapon_Base.Cast(parent);
752 if (wpn)
753 {
754 GameInventory inventory = parent.GetInventory();
755 return inventory.CreateInInventory(att_name);
756 /*
757 vector pos = player.GetPosition();
758 EntityAI eai_gnd = SpawnEntityOnGroundPos(player, att_name, health, quantity, pos);
759 Magazine mag_gnd = Magazine.Cast(eai_gnd);
760 if (mag_gnd && player.GetWeaponManager().CanAttachMagazine(wpn, mag_gnd))
761 {
762 player.GetWeaponManager().AttachMagazine(mag_gnd);
763 }
764 return eai_gnd;
765 */
766 }
767 else
768 {
769 EntityAI eai = parent.GetInventory().CreateAttachment(att_name);
770 if (eai)
771 {
772 if ( eai.IsInherited(ItemBase) )
773 {
774 ItemBase i = ItemBase.Cast( eai );
775 SetupSpawnedItem(ItemBase.Cast( eai ), health, quantity);
776 }
777 return eai;
778 }
779 else
780 OnSpawnErrorReport(att_name);
781 }
782 return NULL;
783 }
784 else
785 {
786 // Client -> Server Spawning: Client Side
787 Param3<string, float, float> params = new Param3<string, float, float>(att_name, health, quantity);
788 player.RPCSingleParam(ERPCs.DEV_RPC_SPAWN_ITEM_AS_ATTACHMENT, params, true);
789 }
790 return NULL;
791 }
792
794 {
795 UIScriptedMenu menu_curr = g_Game.GetUIManager().GetMenu();
796
797 if ( menu_curr == NULL )
798 {
799 PlayerBase player = PlayerBase.Cast( g_Game.GetPlayer() );
800
801 if ( player && g_Game.GetWorld().GetThirdPersonViewMode() == ThirdPersonMode.ENABLED )
802 {
803 player.SetIsInThirdPerson(!player.IsInThirdPerson());//this counters the effect of switching camera through pressing the 'V' key
804 }
805
806 vector pos_player, pos_direction;
807 GetCameraDirections(player, false, pos_player, pos_direction);
808
809 // Get item from clipboard
810 string clipboard;
811 g_Game.CopyFromClipboard(clipboard);
812
813 if (!clipboard.Contains(","))
814 {
815 //single item
817 SpawnItemOnCrosshair(player, clipboard.Trim(), -1, 1, 40, true );
818 else
819 SpawnEntityOnCursorDir(player, clipboard.Trim(), 1, 1);
820 }
821 else
822 {
823 TStringArray items = new TStringArray;
824 clipboard.Split( ",", items );
825
826 foreach (string item:items)
827 {
829 SpawnItemOnCrosshair(player, item.Trim(), -1, 1, 40, true );
830 else
831 SpawnEntityOnCursorDir(player, item.Trim(), 1, 1);
832 }
833 }
834
835 }
836
837 return NULL;
838 }
839
840 // Clear Entity Inventory
842 {
843 if ( g_Game.IsServer() )
844 {
845 entity.ClearInventory();
846 }
847 else
848 {
849 Param1<int> params = new Param1<int>(0);
850 entity.RPCSingleParam(ERPCs.DEV_RPC_CLEAR_INV, params, true);
851 }
852 }
853
855 {
856 if ( g_Game.GetUIManager().GetMenu() == NULL )
857 {
858 g_Game.GetUIManager().EnterScriptedMenu(MENU_HELP_SCREEN, NULL);
859 }
860 else if ( g_Game.GetUIManager().IsMenuOpen(MENU_HELP_SCREEN) )
861 {
862 g_Game.GetUIManager().Back();
863 }
864 }
865
867 {
868 if (g_Game != null && !g_Game.IsLoading() && g_Game.GetMission())
869 {
870 if ( g_Game.GetUIManager().GetMenu() == NULL )
871 {
872 m_ScriptConsole = g_Game.GetUIManager().EnterScriptedMenu(MENU_SCRIPTCONSOLE, NULL);
873 }
874 else if ( g_Game.GetUIManager().IsMenuOpen(MENU_SCRIPTCONSOLE) )
875 {
876 g_Game.GetUIManager().Back();
877 g_Game.GetMission().RemoveActiveInputExcludes({"menu"},true);
878 }
879 }
880 }
881
882 // Mission Editor
884 {
885 if ( g_Game.GetUIManager().IsMenuOpen(MENU_MISSION_LOADER) )
886 {
887 g_Game.GetUIManager().Back();
888 g_Game.GetMission().RemoveActiveInputExcludes({"menu"},true);
889 return;
890 }
891
892 if ( g_Game.GetUIManager().GetMenu() )
893 g_Game.GetUIManager().GetMenu().Close();
894
895 g_Game.GetUIManager().EnterScriptedMenu(MENU_MISSION_LOADER, NULL);
896 g_Game.GetMission().AddActiveInputExcludes({"menu"});
897
898
899 }
900
901 // Script Editor History
902 private void ScriptHistoryNext()
903 {
904 // Console key press
905 if ( g_Game.GetUIManager().IsMenuOpen(MENU_SCRIPTCONSOLE) )
906 {
908 }
909 }
910
911 private void ScriptHistoryBack()
912 {
913 // Console key press
914 if ( g_Game.GetUIManager().IsMenuOpen(MENU_SCRIPTCONSOLE) )
915 {
917 }
918 }
919
920 private bool IsIngame()
921 {
922 UIScriptedMenu menu_curr = g_Game.GetUIManager().GetMenu();
923
924 if ( menu_curr == NULL )
925 {
926 return true;
927 }
928
929 return false;
930 }
931
932 private bool IsInConsole()
933 {
934 UIScriptedMenu menu_curr = g_Game.GetUIManager().GetMenu();
935
936 if ( menu_curr != NULL && menu_curr.GetID() == MENU_SCRIPTCONSOLE )
937 {
938 return true;
939 }
940
941 return false;
942 }
943
944 // Tools
945 int QuickSortPartition( TStringArray arr, int left, int right )
946 {
947 string pivot = arr.Get( left );
948 int i = left;
949 int j = right + 1;
950 string temp;
951
952 while ( true )
953 {
954 while ( true )
955 {
956 i++;
957 if ( i > right || arr.Get(i) > pivot )
958 {
959 break;
960 }
961 }
962
963 while ( true )
964 {
965 j--;
966 if ( arr.Get(j) <= pivot )
967 {
968 break;
969 }
970 }
971
972 if ( i >= j )
973 {
974 break;
975 }
976
977 temp = arr.Get( i );
978 arr.Set( i, arr.Get(j) );
979 arr.Set( j, temp );
980 }
981
982 temp = arr.Get( left );
983 arr.Set( left, arr.Get(j) );
984 arr.Set( j, temp );
985
986 return j;
987 }
988
989 void QuickSort( TStringArray arr, int left, int right )
990 {
991 int j;
992
993 if ( left < right )
994 {
995 j = QuickSortPartition( arr, left, right );
996 QuickSort( arr, left, j - 1 );
997 QuickSort( arr, j + 1, right );
998 }
999 }
1000
1002 {
1003 QuickSort( arr, 0, arr.Count() - 1 );
1004 }
1005
1007 {
1008 if ( g_Game && g_Game.GetMission() )
1009 {
1010 g_Game.GetMission().ResetGUI();
1011 }
1012 }
1013
1014 static void SetDeveloperItemClientEx(notnull Object entity, bool getFocus = false)
1015 {
1016 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
1017
1018 if (getFocus)
1019 {
1020 g_Game.GetInput().ChangeGameFocus(1);
1021 g_Game.GetUIManager().ShowUICursor(true);
1022 }
1023
1024 if (g_Game.IsMultiplayer())
1025 {
1026 g_Game.RPCSingleParam(g_Game.GetPlayer(), ERPCs.DEV_SET_DEV_ITEM, new Param1<Object>(entity), true, g_Game.GetPlayer().GetIdentity());
1027 }
1028 else
1029 {
1031 mid2.RegisterDebugItem(entity, player);
1032 }
1033 #ifdef DEVELOPER
1034 SetDebugDeveloper_item(entity);
1035 #endif
1036 }
1037
1039 {
1040 #ifdef DEVELOPER
1041 Object entity;
1042 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
1043
1044 FreeDebugCamera debugCam = FreeDebugCamera.GetInstance();
1045 if (debugCam && debugCam.GetCurrentCamera())
1046 {
1047 entity = debugCam.GetCrosshairObject();
1048 }
1049 else
1050 {
1051
1052 if (player && player.GetActionManager())
1053 {
1054 ActionTarget at = player.GetActionManager().FindActionTarget();
1055 entity = at.GetObject();
1056 }
1057 }
1058
1059 if (entity)
1060 {
1061 SetDeveloperItemClientEx(entity, true);
1062 }
1063 #endif
1064 }
1065
1070}
void ActionTarget(Object object, Object parent, int componentIndex, vector cursorHitPos, float utility, string surfaceName="")
Определения ActionTargets.c:125
const int ECE_EQUIP_ATTACHMENTS
Определения CentralEconomy.c:21
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:38
const int ECE_INITAI
Определения CentralEconomy.c:18
const int ECE_KEEPHEIGHT
Определения CentralEconomy.c:28
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
const int ECE_IN_INVENTORY
Определения CentralEconomy.c:37
const int RF_DEFAULT
Определения CentralEconomy.c:66
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
DayZGame g_Game
Определения DayZGame.c:4074
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
float hitFraction
Определения DustKickupEffects.c:23
vector position
Определения DustKickupEffects.c:20
ERPCs
Определения ERPCs.c:2
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:18
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4972
override void ClearInventory()
Определения ItemBase.c:3592
class OptionSelectorMultistate extends OptionSelector class_name
void PluginDayZCreatureAIDebug()
Определения PluginDayZCreatureAIDebug.c:101
Param7 DevSpawnItemParams
void PluginItemDiagnostic()
Определения PluginItemDiagnostic.c:74
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:326
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)
Определения 3_Game/DayZ/tools/Debug.c:347
Определения 3_Game/DayZ/tools/Debug.c:2
static void OnSetFreeCameraEvent(PlayerBase player, FreeDebugCamera camera)
Определения DeveloperFreeCamera.c:76
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
EntityAI CreateInInventory(string type)
creates entity somewhere in inventory
script counterpart to engine's class Inventory
Определения CrashBase.c:2
Определения Feet.c:1
proto native EntityAI GetParent()
returns parent of current inventory location
proto native vector GetPos()
returns position of item in world if type is Ground
proto native int GetSlot()
returns slot id if current type is Attachment
proto native void SetGround(EntityAI e, vector mat[4])
sets current inventory location type to Ground with transformation mat
InventoryLocation.
Определения InventoryLocation.c:30
provides access to slot configuration
Определения InventorySlots.c:6
Определения EnMath3D.c:28
Определения ObjectTyped.c:2
void ScriptConsoleItem(string name, string displayName, int scope, int categoryMask=-1)
Определения PluginDeveloper.c:8
string m_DisplayName
Определения PluginDeveloper.c:4
string m_Name
Определения PluginDeveloper.c:3
int m_Scope
Определения PluginDeveloper.c:5
int m_CategoryMask
Определения PluginDeveloper.c:6
Определения PluginDeveloper.c:2
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:747
void ToggleFreeCamera()
Enable / Disable Free camera (Fly mod) - disable of camera will teleport player at current free camer...
Определения PluginDeveloper.c:56
static ref map< string, ref ScriptConsoleItem > m_Items
Определения PluginDeveloper.c:24
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:572
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:615
void HandlePresetSpawn(PlayerBase player, string presetName, EntityAI target)
Определения PluginDeveloper.c:238
void InitItems()
Определения PluginDeveloper.c:89
void OnRPCSpawnEntityOnCursorDir(PlayerBase player, ParamsReadContext ctx)
Определения PluginDeveloper.c:286
void SpawnItemOnCrosshair(PlayerBase player, string itemName, float health, float quantity, float maxDist=100, bool allowFreeflight=false, bool special=false, bool withPhysics=false)
Определения PluginDeveloper.c:510
override void OnInit()
Определения PluginDeveloper.c:72
void PrintLogClient(string msg_log)
Определения PluginDeveloper.c:168
void ToggleScriptConsole()
Определения PluginDeveloper.c:866
void OnSpawnErrorReport(string name)
Определения PluginDeveloper.c:343
int m_FeaturesMask
Определения PluginDeveloper.c:21
void OnRPCSyncSceneObject(ParamsReadContext ctx)
Определения PluginDeveloper.c:198
bool m_IsWinHolding
Определения PluginDeveloper.c:20
int QuickSortPartition(TStringArray arr, int left, int right)
Определения PluginDeveloper.c:945
EntityAI SpawnFromClipboard()
Определения PluginDeveloper.c:793
void SortStringArray(TStringArray arr)
Определения PluginDeveloper.c:1001
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:397
void SetDirection(PlayerBase player, vector direction)
Set player direction.
Определения PluginDeveloper.c:44
void OnSetFreeCameraEvent(PlayerBase player, FreeDebugCamera camera)
Определения PluginDeveloper.c:338
void PluginSceneManager()
Определения PluginSceneManager.c:21
void HandleSetTime(PlayerBase player, ParamsReadContext ctx)
Определения PluginDeveloper.c:221
void ToggleFreeCameraBackPos()
Enable / Disable Free camera (Fly mod)
Определения PluginDeveloper.c:50
void ScriptHistoryBack()
Определения PluginDeveloper.c:911
UIScriptedMenu m_ScriptConsole
Определения PluginDeveloper.c:22
EntityAI SpawnEntityInPlayerInventory(PlayerBase player, string item_name, float health, float quantity, bool special=false, string presetName="", FindInventoryLocationType locationType=FindInventoryLocationType.ANY)
Определения PluginDeveloper.c:652
void ResetGUI()
Определения PluginDeveloper.c:1006
static PluginDeveloper GetInstance()
Определения PluginDeveloper.c:26
void ToggleHelpScreen()
Определения PluginDeveloper.c:854
void OnRPCSpawnEntity(PlayerBase player, ParamsReadContext ctx)
Определения PluginDeveloper.c:312
EntityAI SpawnEntityOnGroundPos(PlayerBase player, string object_name, vector pos)
Определения PluginDeveloper.c:478
void OnRPCSpawnEntityOnGroundPatternGrid(PlayerBase player, ParamsReadContext ctx)
Определения PluginDeveloper.c:304
EntityAI SpawnEntityOnGroundPos(PlayerBase player, string item_name, float health, float quantity, vector pos, bool special=false, bool withPhysics=false)
Определения PluginDeveloper.c:541
void OnRPCServerLogRecieved(ParamsReadContext ctx)
Определения PluginDeveloper.c:270
void TeleportAtCursor()
Set Player position at his cursor position in the world.
Определения PluginDeveloper.c:32
bool IsInConsole()
Определения PluginDeveloper.c:932
void GetCameraDirections(Man player, bool allowFreeflight, out vector position, out vector direction)
Определения PluginDeveloper.c:459
void PluginDeveloper()
Определения PluginDeveloper.c:67
void OnRPCSpawnEntityOnGround(PlayerBase player, ParamsReadContext ctx)
Определения PluginDeveloper.c:295
static void SetDeveloperItemClientEx(notnull Object entity, bool getFocus=false)
Определения PluginDeveloper.c:1014
TStringArray GetItemClasses()
Определения PluginDeveloper.c:84
void OnRPC(PlayerBase player, int rpc_type, ParamsReadContext ctx)
Определения PluginDeveloper.c:110
void OnRPCPluginDayzCreatureDebug(PlayerBase player, int rpc_type, ParamsReadContext ctx)
Определения PluginDeveloper.c:212
void ToggleMissionLoader()
Определения PluginDeveloper.c:883
void SetupSpawnedEntity(PlayerBase player, EntityAI entity, float health, float quantity=-1, bool special=false, string presetName="")
Определения PluginDeveloper.c:350
void ClearInventory(EntityAI entity)
Определения PluginDeveloper.c:841
void SetDeveloperItemClient()
Определения PluginDeveloper.c:1038
bool IsIngame()
Определения PluginDeveloper.c:920
EntityAI SpawnAI(string object_name, vector pos)
Определения PluginDeveloper.c:449
bool IsEnabledFreeCamera()
Определения PluginDeveloper.c:61
void OnRPCClearInventory(PlayerBase player)
Определения PluginDeveloper.c:280
void SendServerLogToClient(string msg)
Определения PluginDeveloper.c:178
map< string, ref ScriptConsoleItem > GetItems()
Определения PluginDeveloper.c:1066
void Teleport(PlayerBase player, vector position)
Teleport player at position.
Определения PluginDeveloper.c:38
void QuickSort(TStringArray arr, int left, int right)
Определения PluginDeveloper.c:989
void ScriptHistoryNext()
Определения PluginDeveloper.c:902
Plugin interface for controlling of agent pool system.
Определения PluginBase.c:2
SceneObject GetSceneObjectByEntityAI(EntityAI e)
Определения SceneData.c:348
Определения SceneData.c:2
Определения SceneObject.c:2
proto bool Read(void value_in)
Определения DayZGame.c:64
shorthand
Определения BoltActionRifle_Base.c:6
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения Transport.c:70
static const vector Zero
Определения EnConvert.c:123
vector Perpend()
Returns perpendicular vector. Perpendicular vector is computed as cross product between input vector ...
Определения EnConvert.c:222
Определения EnConvert.c:119
Serializer ParamsReadContext
Определения gameplay.c:15
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
Obsolete Managed PrintString(string s)
Helper for printing out string expression. Example: PrintString("Hello " + var);.
Определения EnScript.c:369
class array< Class T > TStringArray
static void MatrixIdentity4(out vector mat[4])
Creates identity matrix.
Определения EnMath3D.c:256
const int MENU_HELP_SCREEN
Определения 3_Game/DayZ/constants.c:199
const int MENU_SCRIPTCONSOLE
Определения 3_Game/DayZ/constants.c:191
const string CFG_AMMO
Определения 3_Game/DayZ/constants.c:231
const string CFG_VEHICLESPATH
Определения 3_Game/DayZ/constants.c:228
const int MENU_MISSION_LOADER
Определения 3_Game/DayZ/constants.c:220
const string CFG_WEAPONSPATH
Определения 3_Game/DayZ/constants.c:229
const string CFG_MAGAZINESPATH
Определения 3_Game/DayZ/constants.c:230
proto string Trim()
Returns trimmed string with removed leading and trailing whitespaces.
proto string Get(int index)
Gets n-th character from string.
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
proto void Set(int index, string input)
Sets the n-th character in string with the input, replacing previous value.
ThirdPersonMode
Определения World.c:302
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/DayZ/tools/tools.c:8