DayZ 1.30
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 строка 652

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
691 InventoryLocation il = new InventoryLocation;
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 }
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:37
const int RF_DEFAULT
Определения CentralEconomy.c:66
DayZGame g_Game
Определения DayZGame.c:4074
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:4972
Param7 DevSpawnItemParams
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:343
EntityAI SpawnEntityInPlayerInventory(PlayerBase player, string item_name, float health, float quantity, bool special=false, string presetName="", FindInventoryLocationType locationType=FindInventoryLocationType.ANY)
Определения PluginDeveloper.c:652
EntityAI SpawnEntityOnGroundPos(PlayerBase player, string object_name, vector pos)
Определения PluginDeveloper.c:478
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().