1234 {
1235 int child_count =
g_Game.ConfigGetChildrenCount( cfg_path );
1236
1237 for ( int i = 0; i < child_count; i++ )
1238 {
1239 string child_name;
1240 g_Game.ConfigGetChildName( cfg_path, i, child_name );
1241
1242
1243 string config_path;
1244 string type;
1245 string slot_name;
1246 config_path = cfg_path + " " + child_name + " " + "type";
1247 g_Game.ConfigGetText( config_path, type );
1248 config_path = cfg_path + " " + child_name + " " + "slot_name";
1249 g_Game.ConfigGetText( config_path, slot_name );
1250 config_path = cfg_path + " " + child_name + " " + "quantity";
1251 float quantity =
g_Game.ConfigGetFloat( config_path );
1252 config_path = cfg_path + " " + child_name + " " + "lockable";
1253 bool lockable =
g_Game.ConfigGetInt( config_path );
1254
1255
1256 ItemBase attachment =
ItemBase.Cast( entity.FindAttachmentBySlotName( slot_name ) );
1257 int slot_id;
1258
1259
1260 if ( lockable )
1261 {
1262 if ( attachment )
1263 {
1264 InventoryLocation src = new InventoryLocation;
1265 attachment.GetInventory().GetCurrentInventoryLocation( src );
1266 if (LogManager.IsBaseBuildingLogEnable())
bsbDebugPrint(
"[bsb] " +
Object.GetDebugName( entity) +
" DropNonUsableMaterials UNlocking slot=" + src.
GetSlot() );
1267 entity.GetInventory().SetSlotLock( src.
GetSlot() ,
false );
1268
1269
1270 if ( is_base )
1271 {
1272 if (
g_Game.IsMultiplayer() && player )
1273 {
1274 InventoryLocation dst = new InventoryLocation;
1275 GameInventory.SetGroundPosByOwner( player, src.
GetItem(), dst );
1276 player.ServerTakeToDst( src, dst );
1277 }
1278 else
1279 {
1280 entity.GetInventory().DropEntity(
InventoryMode.PREDICTIVE, entity, attachment );
1281 }
1282 }
1283 }
1284 }
1285 else
1286 {
1287 float pile_health;
1288 float qty_coef;
1289 vector destination = entity.GetPosition();
1290
1291 if ( entity.MemoryPointExists("" + main_part_name + "_materials") )
1292 {
1293 destination = entity.GetMemoryPointPos("" + main_part_name + "_materials");
1294 destination =
g_Game.ObjectModelToWorld(entity,destination);
1295 }
1296 else if ( entity.MemoryPointExists(main_part_name) )
1297 {
1298 destination = entity.GetMemoryPointPos(main_part_name);
1299 destination =
g_Game.ObjectModelToWorld(entity,destination);
1300 }
1301 pile_health = entity.GetHealth01(damagezone_name,"Health") * MiscGameplayFunctions.GetTypeMaxGlobalHealth(type);
1302 qty_coef = 1 - (entity.GetHealthLevel(damagezone_name) *
Construction.DECONSTURCT_MATERIAL_LOSS) -
Construction.DECONSTURCT_MATERIAL_LOSS;
1303 quantity *= qty_coef;
1304 quantity = Math.Max(Math.Floor(quantity),1);
1305
1306 if (player)
1307 {
1308 vector posHead;
1309 MiscGameplayFunctions.GetHeadBonePos(PlayerBase.Cast(player),posHead);
1310 MiscGameplayFunctions.CreateItemBasePilesDispersed(type,posHead,destination,UAItemsSpreadRadius.NARROW,quantity,pile_health,player);
1311 }
1312 else
1313 {
1314 MiscGameplayFunctions.CreateItemBasePiles(type,destination,quantity,pile_health,true);
1315 }
1316 }
1317 }
1318 }
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
class BaseBuildingBase extends ItemBase bsbDebugPrint(string s)
void Construction(BaseBuildingBase parent)
class GP5GasMask extends MaskBase ItemBase
proto native int GetSlot()
returns slot id if current type is Attachment
proto native EntityAI GetItem()
returns item of current inventory location