DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ SpawnEntityInPlayerInventory()

EntityAI PluginBase::SpawnEntityInPlayerInventory ( PlayerBase player,
string item_name,
float health,
float quantity,
bool special = false,
string presetName = "",
FindInventoryLocationType locationType = FindInventoryLocationType.ANY )
inlineprotected

См. определение в файле PluginDeveloper.c строка 603

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
642 InventoryLocation il = new InventoryLocation;
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 }
class LogManager EntityAI
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
DayZGame g_Game
Определения DayZGame.c:3942
ERPCs
Определения ERPCs.c:2
class GP5GasMask extends MaskBase ItemBase
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:18
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4931
Param7< EntityAI, string, float, float, bool, string, FindInventoryLocationType > DevSpawnItemParams
Определения PluginDeveloper.c:1
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
void OnSpawnErrorReport(string name)
Определения PluginDeveloper.c:294
EntityAI SpawnEntityInPlayerInventory(PlayerBase player, string item_name, float health, float quantity, bool special=false, string presetName="", FindInventoryLocationType locationType=FindInventoryLocationType.ANY)
Определения PluginDeveloper.c:603
EntityAI SpawnEntityOnGroundPos(PlayerBase player, string object_name, vector pos)
Определения PluginDeveloper.c:429
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/DayZ/tools/tools.c:8

Перекрестные ссылки CALL_CATEGORY_SYSTEM, ECE_IN_INVENTORY, g_Game, InventoryLocation::GetParent(), InventoryLocation::GetSlot(), OnSpawnErrorReport(), RF_DEFAULT, SetupSpawnedItem(), SpawnEntity(), SpawnEntityInPlayerInventory() и SpawnEntityOnGroundPos().

Используется в SpawnEntityInInventory() и SpawnEntityInPlayerInventory().