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

◆ ThrowEntityFromInventory()

static void ThrowEntityFromInventory ( notnull EntityAI entity,
vector position,
float direction[4],
vector force,
int flags )
staticprotected

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

1162 {
1163 InventoryMode invMode = InventoryMode.SERVER;
1164 if ( !GetGame().IsMultiplayer() )
1165 invMode = InventoryMode.LOCAL;
1166
1167 ItemBase entityIB;
1168 if (CastTo(entityIB, entity))
1169 {
1171 dst.SetGroundEx(entity, position, direction);
1172
1173 if ( (flags & ThrowEntityFlags.SPLIT) && entityIB.CanBeSplit() )
1174 {
1175 for (int l = 0; l < entityIB.GetQuantity(); ++l)
1176 {
1177 ItemBase new_item = ItemBase.Cast( GameInventory.LocationCreateEntity( dst, entityIB.GetType(), ECE_NONE, RF_DEFAULT ) );
1178
1179 if ( new_item )
1180 {
1181 MiscGameplayFunctions.TransferItemProperties(entityIB, new_item);
1182 entityIB.AddQuantity( -1 );
1183 new_item.SetQuantity( 1 );
1184 new_item.ThrowPhysically(null, force, false);
1185 }
1186 }
1187 }
1188 else
1189 {
1190 float stackable = entityIB.GetTargetQuantityMax();
1191 if ( !(stackable == 0 || stackable >= entityIB.GetQuantity()) )
1192 {
1193 while (entityIB.GetQuantity() > stackable)
1194 {
1196 position[1] = position[1] + 0.1;
1197 spltDst.SetGroundEx(entity, position, direction);
1198
1199 ItemBase splitItem = entityIB.SplitIntoStackMaxToInventoryLocationEx( spltDst );
1200 splitItem.ThrowPhysically(null, force, false);
1201 }
1202 }
1203
1205 entity.GetInventory().GetCurrentInventoryLocation(src);
1206
1207 entity.GetInventory().TakeToDst(invMode, src, dst);
1208 entityIB.ThrowPhysically(null, force, false);
1209 }
1210 }
1211 else
1212 {
1213 entity.GetInventory().DropEntity(invMode, entity.GetHierarchyRoot(), entity);
1214 dBodyApplyImpulse(entity, force);
1215 }
1216 }
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
const int ECE_NONE
Определения CentralEconomy.c:7
const int RF_DEFAULT
Определения CentralEconomy.c:65
ThrowEntityFlags
Определения MiscGameplayFunctions.c:208
static proto native EntityAI LocationCreateEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
creates new item directly at location
script counterpart to engine's class Inventory
proto native void SetGroundEx(EntityAI e, vector pos, float dir[4])
sets current inventory location type to Ground with transformation mat
InventoryLocation.
Определения InventoryLocation.c:29
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
override bool CanBeSplit()
Определения Rag.c:34
proto native CGame GetGame()
proto void dBodyApplyImpulse(notnull IEntity body, vector impulse)
Applies impuls on a rigidbody (origin)

Перекрестные ссылки ItemBase::CanBeSplit(), dBodyApplyImpulse(), ECE_NONE, GetGame(), GameInventory::LocationCreateEntity(), RF_DEFAULT, InventoryLocation::SetGroundEx() и ItemBase::SetQuantity().

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