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

◆ SplitIntoStackMax()

void InventoryItem::SplitIntoStackMax ( EntityAI destination_entity,
int slot_id,
PlayerBase player )
inlineprotected

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

1657 {
1658 float split_quantity_new;
1659 ItemBase new_item;
1660 float quantity = GetQuantity();
1661 float stack_max = GetTargetQuantityMax(slot_id);
1662 InventoryLocation loc = new InventoryLocation;
1663
1664 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
1665 {
1666 if (stack_max <= GetQuantity())
1667 split_quantity_new = stack_max;
1668 else
1669 split_quantity_new = GetQuantity();
1670
1671 if (ShouldSplitQuantity(split_quantity_new))
1672 {
1673 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
1674 if (new_item)
1675 {
1676 new_item.SetResultOfSplit(true);
1677 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1678 AddQuantity(-split_quantity_new, false, true);
1679 new_item.SetQuantity(split_quantity_new, false, true);
1680 }
1681 }
1682 }
1683 else if (destination_entity && slot_id == -1)
1684 {
1685 if (quantity > stack_max)
1686 split_quantity_new = stack_max;
1687 else
1688 split_quantity_new = quantity;
1689
1690 if (ShouldSplitQuantity(split_quantity_new))
1691 {
1692 GameInventory destinationInventory = destination_entity.GetInventory();
1693 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
1694 {
1695 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
1696 new_item = ItemBase.Cast(o);
1697 }
1698
1699 if (new_item)
1700 {
1701 new_item.SetResultOfSplit(true);
1702 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1703 AddQuantity(-split_quantity_new, false, true);
1704 new_item.SetQuantity(split_quantity_new, false, true);
1705 }
1706 }
1707 }
1708 else
1709 {
1710 if (stack_max != 0)
1711 {
1712 if (stack_max < GetQuantity())
1713 {
1714 split_quantity_new = GetQuantity() - stack_max;
1715 }
1716
1717 if (split_quantity_new == 0)
1718 {
1719 if (!g_Game.IsMultiplayer())
1720 player.PhysicalPredictiveDropItem(this);
1721 else
1722 player.ServerDropEntity(this);
1723 return;
1724 }
1725
1726 if (ShouldSplitQuantity(split_quantity_new))
1727 {
1728 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
1729
1730 if (new_item)
1731 {
1732 new_item.SetResultOfSplit(true);
1733 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1734 SetQuantity(split_quantity_new, false, true);
1735 new_item.SetQuantity(stack_max, false, true);
1736 new_item.PlaceOnSurface();
1737 }
1738 }
1739 }
1740 }
1741 }
eBleedingSourceType GetType()
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
const int ECE_IN_INVENTORY
Определения CentralEconomy.c:36
const int RF_DEFAULT
Определения CentralEconomy.c:65
DayZGame g_Game
Определения DayZGame.c:3942
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:18
static proto native EntityAI LocationCreateEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
creates new item directly at location
proto native bool FindFreeLocationFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc)
FindFreeLocationFor.
override float GetQuantity()
Определения ItemBase.c:3508
bool AddQuantity(float value, bool destroy_config=true, bool destroy_forced=false)
add item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Определения ItemBase.c:3413
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Set item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Определения ItemBase.c:3340
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:3473
bool ShouldSplitQuantity(float quantity)
Определения ItemBase.c:1613
void ItemBase()
Определения ItemBase.c:148
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfWoodenPlanks.c:88
class LOD Object

Перекрестные ссылки AddQuantity(), ECE_IN_INVENTORY, ECE_PLACE_ON_SURFACE, GameInventory::FindFreeLocationFor(), g_Game, GetQuantity(), GetTargetQuantityMax(), GetType(), InventorySlots::IsSlotIdValid(), ItemBase(), GameInventory::LocationCreateEntity(), RF_DEFAULT, ItemBase::SetQuantity() и ShouldSplitQuantity().