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

◆ SpawnEntityInInventory()

EntityAI PluginBase::SpawnEntityInInventory ( notnull EntityAI target,
string className,
float health,
float quantity,
bool special = false,
string presetName = "",
FindInventoryLocationType locationType = FindInventoryLocationType.ANY )
inlineprotected

tries to spawn item somewhere in inventory

SpawnEntityInInventory queries future parent about free inventory location of the future item

Аргументы
[in]healthhealth of the item
[in]quantityquantity to set if item.HasQuantity() (-1 == set to max)
Возвращает
entity if ok, null otherwise

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

567 {
568 if (target.IsPlayer())
569 {
570 return SpawnEntityInPlayerInventory(PlayerBase.Cast(target), className, health, quantity, special, presetName, locationType);
571 }
572 if ( g_Game.IsServer() )
573 {
574 InventoryLocation il = new InventoryLocation;
575 if (target.GetInventory() && target.GetInventory().FindFirstFreeLocationForNewEntity(className, FindInventoryLocationType.ANY, il))
576 {
577 EntityAI eai = SpawnEntity(className, il, ECE_IN_INVENTORY, RF_DEFAULT);
578 if ( eai && eai.IsInherited(ItemBase) )
579 {
580 if ( health < 0 )//check for default (-1)
581 {
582 health = eai.GetMaxHealth();
583 }
584 ItemBase i = ItemBase.Cast( eai );
585 SetupSpawnedItem(i, health, quantity);
586 if ( special )
587 {
588 auto debugParams = DebugSpawnParams.WithPlayer(null);
589 eai.OnDebugSpawnEx(debugParams);
590 }
591 }
592 return eai;
593 }
594 }
595 else
596 {
597 DevSpawnItemParams params = new DevSpawnItemParams(target, className, health, quantity, special, presetName, 0 );
598 g_Game.GetPlayer().RPCSingleParam(ERPCs.DEV_RPC_SPAWN_ITEM_IN_INVENTORY, params, true, g_Game.GetPlayer().GetIdentity());
599 }
600 return null;
601 }
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
EntityAI SpawnEntityInPlayerInventory(PlayerBase player, string item_name, float health, float quantity, bool special=false, string presetName="", FindInventoryLocationType locationType=FindInventoryLocationType.ANY)
Определения PluginDeveloper.c:603

Перекрестные ссылки ECE_IN_INVENTORY, g_Game, RF_DEFAULT, SetupSpawnedItem(), SpawnEntity() и SpawnEntityInPlayerInventory().

Используется в OnRPCSpawnEntity().