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

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 {
623 InventoryLocation il = new InventoryLocation;
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 }
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
EntityAI SpawnEntityInPlayerInventory(PlayerBase player, string item_name, float health, float quantity, bool special=false, string presetName="", FindInventoryLocationType locationType=FindInventoryLocationType.ANY)
Определения PluginDeveloper.c:652

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

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