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

◆ SpawnConstructionMaterialPiles()

static void StaticConstructionMethods::SpawnConstructionMaterialPiles ( notnull EntityAI entity,
Man player,
string cfg_path,
string main_part_name,
string damagezone_name = "",
bool is_base = false )
inlinestaticprivate

spawns material from any construction; 'player' parameter optional

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

1234 {
1235 int child_count = GetGame().ConfigGetChildrenCount( cfg_path );
1236
1237 for ( int i = 0; i < child_count; i++ )
1238 {
1239 string child_name;
1240 GetGame().ConfigGetChildName( cfg_path, i, child_name );
1241
1242 //get type, quantity from material
1243 string config_path;
1244 string type;
1245 string slot_name;
1246 config_path = cfg_path + " " + child_name + " " + "type";
1247 GetGame().ConfigGetText( config_path, type );
1248 config_path = cfg_path + " " + child_name + " " + "slot_name";
1249 GetGame().ConfigGetText( config_path, slot_name );
1250 config_path = cfg_path + " " + child_name + " " + "quantity";
1251 float quantity = GetGame().ConfigGetFloat( config_path );
1252 config_path = cfg_path + " " + child_name + " " + "lockable";
1253 bool lockable = GetGame().ConfigGetInt( config_path );
1254
1255 //receive material quantity
1256 ItemBase attachment = ItemBase.Cast( entity.FindAttachmentBySlotName( slot_name ) );
1257 int slot_id;
1258
1259 //material still attached
1260 if ( lockable ) //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 //detach if base
1270 if ( is_base )
1271 {
1272 if ( GetGame().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 //placed on helper memory point, if available
1291 if ( entity.MemoryPointExists("" + main_part_name + "_materials") )
1292 {
1293 destination = entity.GetMemoryPointPos("" + main_part_name + "_materials");
1294 destination = GetGame().ObjectModelToWorld(entity,destination);
1295 }
1296 else if ( entity.MemoryPointExists(main_part_name) )
1297 {
1298 destination = entity.GetMemoryPointPos(main_part_name);
1299 destination = GetGame().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.
Определения Inventory.c:22
class BaseBuildingBase extends ItemBase bsbDebugPrint(string s)
Определения BaseBuildingBase.c:1292
void Construction(BaseBuildingBase parent)
Определения Construction.c:26
class GP5GasMask extends MaskBase ItemBase
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native float ConfigGetFloat(string path)
Get float value from config on path.
proto native int ConfigGetInt(string path)
Get int value from config on path.
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto native vector ObjectModelToWorld(Object obj, vector modelPos)
proto native int GetSlot()
returns slot id if current type is Attachment
proto native EntityAI GetItem()
returns item of current inventory location
class LOD Object
proto native CGame GetGame()

Перекрестные ссылки bsbDebugPrint(), CGame::ConfigGetChildName(), CGame::ConfigGetChildrenCount(), CGame::ConfigGetFloat(), CGame::ConfigGetInt(), CGame::ConfigGetText(), Construction(), Math::Floor(), GetGame(), InventoryLocation::GetItem(), InventoryLocation::GetSlot(), LogManager::IsBaseBuildingLogEnable(), Math::Max(), UAItemsSpreadRadius::NARROW, CGame::ObjectModelToWorld() и GameInventory::SetGroundPosByOwner().

Используется в TentBase::Deconstruct() и ReceiveMaterialsServer().