DayZ 1.27
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 строка 539

540 {
541 if (player)
542 {
543 if (GetGame().IsServer())
544 {
545 if (locationType == FindInventoryLocationType.HANDS && player.GetItemInHands())
546 {
547 if (!GetGame().IsMultiplayer())
548 player.DropItem(player.GetItemInHands());
549 else
550 player.ServerDropEntity(player.GetItemInHands());
551
552 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(SpawnEntityInPlayerInventory, 500, false, player, item_name, health, quantity, special, presetName, locationType);
553
554 return null;
555 }
556
557
558 #ifdef DEVELOPER
559 if (GetGame().IsKindOf(item_name, "Transport"))
560 {
561 EntityAI vehicle = SpawnEntityOnGroundPos(player, item_name, 1, quantity, player.GetPosition());
562 auto debugParams = DebugSpawnParams.WithPlayer(player);
563 vehicle.OnDebugSpawnEx(debugParams);
564
565 if (GetGame().IsMultiplayer())
566 {
567 DayZPlayerSyncJunctures.SendGetInVehicle(player, vehicle);
568 }
569 else
570 {
571 player.SetGetInVehicleDebug(vehicle);
572 }
573
574 return vehicle;
575 }
576 #endif
577
578 InventoryLocation il = new InventoryLocation;
579 if (player.GetInventory() && player.GetInventory().FindFirstFreeLocationForNewEntity(item_name, locationType, il))
580 {
581 Weapon_Base wpn = Weapon_Base.Cast(il.GetParent());
582 bool is_mag = il.GetSlot() == InventorySlots.MAGAZINE || il.GetSlot() == InventorySlots.MAGAZINE2 || il.GetSlot() == InventorySlots.MAGAZINE3;
583 if (wpn && is_mag)
584 {
585 vector pos = player.GetPosition();
586 EntityAI eai_gnd = SpawnEntityOnGroundPos(player, item_name, health, quantity, pos);
587 Magazine mag_gnd = Magazine.Cast(eai_gnd);
588 if (mag_gnd && player.GetWeaponManager().CanAttachMagazine(wpn, mag_gnd))
589 {
590 player.GetWeaponManager().AttachMagazine(mag_gnd);
591 }
592 return eai_gnd;
593 }
594 else
595 {
596 EntityAI eai = SpawnEntity(item_name, il, ECE_IN_INVENTORY, RF_DEFAULT);
597 if ( eai && eai.IsInherited(ItemBase) )
598 {
599 if ( health < 0 )//check for default (-1)
600 {
601 health = eai.GetMaxHealth();
602 }
603 ItemBase i = ItemBase.Cast( eai );
604 SetupSpawnedItem(i, health, quantity);
605 if ( special )
606 {
607 auto debugParams2 = DebugSpawnParams.WithPlayer(player);
608 eai.OnDebugSpawnEx(debugParams2);
609 }
610 }
611 return eai;
612 }
613 }
614 else
615 OnSpawnErrorReport(item_name);
616 return NULL;
617 }
618 else
619 {
620 // Client -> Server Spawning: Client Side
621 DevSpawnItemParams params = new DevSpawnItemParams(player, item_name, health, quantity, special, presetName, locationType );
622 player.RPCSingleParam(ERPCs.DEV_RPC_SPAWN_ITEM_IN_INVENTORY, params, true);
623 }
624 }
625 return NULL;
626 }
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
ERPCs
Определения ERPCs.c:2
class GP5GasMask extends MaskBase ItemBase
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4803
Param7< EntityAI, string, float, float, bool, string, FindInventoryLocationType > DevSpawnItemParams
Определения PluginDeveloper.c:1
override ScriptCallQueue GetCallQueue(int call_category)
Определения DayZGame.c:1187
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:539
EntityAI SpawnEntityOnGroundPos(PlayerBase player, string item_name, float health, float quantity, vector pos, bool special=false, bool withPhysics=false)
spawns entity on exact position
Определения PluginDeveloper.c:428
proto void CallLater(func fn, int delay=0, bool repeat=false, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
proto native CGame GetGame()
const int CALL_CATEGORY_SYSTEM
Определения tools.c:8

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

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