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

◆ SpawnItems()

void SpawnItems ( ActionData action_data)

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

250 {
251 EntityAI body = EntityAI.Cast(action_data.m_Target.GetObject());
252
253 // Get config path to the animal
254 string cfgAnimalClassPath = "cfgVehicles " + body.GetType() + " " + "Skinning ";
255 vector bodyPosition = body.GetPosition();
256
257 if (!g_Game.ConfigIsExisting(cfgAnimalClassPath))
258 {
259 Debug.Log("Failed to find class 'Skinning' in the config of: " + body.GetType());
260 return;
261 }
262
263 // Getting item type from the config
264 int childCount = g_Game.ConfigGetChildrenCount(cfgAnimalClassPath);
265
266 string itemToSpawn;
267 string cfgSkinningOrganClass;
268 // Parsing of the 'Skinning' class in the config of the dead body
269 for (int i1 = 0; i1 < childCount; i1++)
270 {
271 // To make configuration as convenient as possible, all classes are parsed and parameters are read
272 g_Game.ConfigGetChildName(cfgAnimalClassPath, i1, cfgSkinningOrganClass); // out cfgSkinningOrganClass
273 cfgSkinningOrganClass = cfgAnimalClassPath + cfgSkinningOrganClass + " ";
274 g_Game.ConfigGetText(cfgSkinningOrganClass + "item", itemToSpawn); // out itemToSpawn
275
276 if (itemToSpawn != "") // Makes sure to ignore incompatible parameters in the Skinning class of the agent
277 {
278 // Spawning items in action_data.m_Player's inventory
279 int itemSpawnCount = g_Game.ConfigGetInt(cfgSkinningOrganClass + "count");
280
281 array<string> itemZones = new array<string>;
282 array<float> itemCount = new array<float>;
283 float zoneDmg = 0;
284
285 GetGame().ConfigGetTextArray(cfgSkinningOrganClass + "itemZones", itemZones);
286 GetGame().ConfigGetFloatArray(cfgSkinningOrganClass + "countByZone", itemCount);
287 float transferedPartDmgCoef = GetGame().ConfigGetFloat(cfgSkinningOrganClass + "transferPartDamageCoef");
288
289 if (itemCount.Count() > 0)
290 {
291 itemSpawnCount = 0;
292 for (int z = 0; z < itemZones.Count(); z++)
293 {
294 zoneDmg = body.GetHealth01(itemZones[z], "Health");
295 zoneDmg *= itemCount[z]; //just re-using variable
296 itemSpawnCount += Math.Floor(zoneDmg);
297 }
298 }
299
300 if (transferedPartDmgCoef > 0 && itemSpawnCount <= 0) // Special behavior for headdress
301 itemSpawnCount = 1;
302
303 for (int i2 = 0; i2 < itemSpawnCount; i2++)
304 {
305 ItemBase spawnResult = CreateOrgan(action_data.m_Player, bodyPosition, itemToSpawn, cfgSkinningOrganClass, action_data.m_MainItem);
306 if (!spawnResult)
307 continue;
308
309 // Damage spawned result item based on the average health value of the body part
310 // It only works if the "transferPartDamageCoef" value in the config is higher than 0 and result item is from type Headdress
311 if (transferedPartDmgCoef > 0)
312 {
313 float partHealth = 0;
314 float partMaxHealth = 0;
315 for (int z2 = 0; z2 < itemZones.Count(); z2++)
316 {
317 partHealth = body.GetHealth(itemZones[z2], "Health");
318 partMaxHealth = body.GetMaxHealth(itemZones[z2], "Health");
319 break;
320 }
321
322 if (partMaxHealth > 0)
323 {
324 float itemMaxHealth = spawnResult.GetMaxHealth("", "Health");
325 float partHealthPercent = (partHealth / partMaxHealth) * 100;
326 float itemHealth = (itemMaxHealth / 100) * partHealthPercent;
327
328 if (transferedPartDmgCoef > 1) // Makes sure to adjust incompatible parameter in the Skinning class of the agent
329 transferedPartDmgCoef = 1;
330
331 float itemHealthCoef = itemHealth * transferedPartDmgCoef;
332 spawnResult.SetHealth("", "Health", itemHealthCoef);
333 }
334 }
335
336 //Damage pelts based on the average values on itemZones
337 //It only works if the "quantityCoef" in the config is more than 0
338 float qtCoeff = GetGame().ConfigGetFloat(cfgSkinningOrganClass + "quantityCoef");
339 if (qtCoeff > 0)
340 {
341 float avgDmgZones = 0;
342 for (int c2 = 0; c2 < itemZones.Count(); c2++)
343 {
344 avgDmgZones += body.GetHealth01(itemZones[c2], "Health");
345 }
346
347 avgDmgZones = avgDmgZones/itemZones.Count(); // Evaluate the average Health
348 spawnResult.SetHealth01("","", avgDmgZones);
349 }
350
351 // inherit temperature
352 if (body.CanHaveTemperature() && spawnResult.CanHaveTemperature())
353 {
354 spawnResult.SetTemperatureDirect(body.GetTemperature());
355 spawnResult.SetFrozen(body.GetIsFrozen());
356 }
357
358 // handle fat/guts from human bodies
359 if ((itemToSpawn == "Lard") || (itemToSpawn == "Guts"))
360 {
361 if (body.IsKindOf("SurvivorBase"))
362 {
363 spawnResult.InsertAgent(eAgents.BRAIN, 1);
364 }
365 }
366 }
367 }
368 }
369 }
ItemBase CreateOrgan(PlayerBase player, vector body_pos, string item_to_spawn, string cfg_skinning_organ_class, ItemBase tool)
Определения ActionSkinning.c:91
DayZGame g_Game
Определения DayZGame.c:3942
eAgents
Определения EAgents.c:3
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Определения 3_Game/DayZ/tools/Debug.c:182
Определения 3_Game/DayZ/tools/Debug.c:2
Определения EnMath.c:7
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения EnConvert.c:119
DayZGame GetGame()
Определения gameplay.c:636
static proto float Floor(float f)
Returns floor of value.

Перекрестные ссылки ActionData, CreateOrgan(), Math::Floor(), g_Game, GetGame() и Debug::Log().