We only use the first dmg zone to get and set the result item health based of zone health
250 {
252
253
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
264 int childCount =
g_Game.ConfigGetChildrenCount(cfgAnimalClassPath);
265
266 string itemToSpawn;
267 string cfgSkinningOrganClass;
268
269 for (int i1 = 0; i1 < childCount; i1++)
270 {
271
272 g_Game.ConfigGetChildName(cfgAnimalClassPath, i1, cfgSkinningOrganClass);
273 cfgSkinningOrganClass = cfgAnimalClassPath + cfgSkinningOrganClass + " ";
274 g_Game.ConfigGetText(cfgSkinningOrganClass +
"item", itemToSpawn);
275
276 if (itemToSpawn != "")
277 {
278
279 int itemSpawnCount =
g_Game.ConfigGetInt(cfgSkinningOrganClass +
"count");
280
283 float zoneDmg = 0;
284
285 g_Game.ConfigGetTextArray(cfgSkinningOrganClass +
"itemZones", itemZones);
286 g_Game.ConfigGetFloatArray(cfgSkinningOrganClass +
"countByZone", itemCount);
287
288 if (itemCount.Count() > 0)
289 {
290 itemSpawnCount = 0;
291 for (int z = 0; z < itemZones.Count(); z++)
292 {
293 zoneDmg = body.GetHealth01(itemZones[z], "Health");
294 zoneDmg *= itemCount[z];
296 }
297 }
298
299 float transferedPartDmgCoef =
g_Game.ConfigGetFloat(cfgSkinningOrganClass +
"transferPartDamageCoef");
300 if (transferedPartDmgCoef > 0 && itemSpawnCount <= 0)
301 itemSpawnCount = 1;
302
303 for (int i2 = 0; i2 < itemSpawnCount; i2++)
304 {
306 if (!spawnResult)
307 continue;
308
309
310
311 if (transferedPartDmgCoef > 0)
312 {
313 float partHealth = 0;
314 float partMaxHealth = 0;
315
317 for (int z2 = 0; z2 < itemZones.Count(); z2++)
318 {
319 partHealth = body.GetHealth(itemZones[z2], "Health");
320 partMaxHealth = body.GetMaxHealth(itemZones[z2], "Health");
321 break;
322 }
323
324 if (partMaxHealth > 0)
325 {
326 float itemMaxHealth = spawnResult.GetMaxHealth("", "Health");
327 float partHealthPercent = (partHealth / partMaxHealth) * 100;
328 float itemHealth = (itemMaxHealth / 100) * partHealthPercent;
329
330 if (transferedPartDmgCoef > 1)
331 transferedPartDmgCoef = 1;
332
333 float itemHealthCoef = itemHealth * transferedPartDmgCoef;
334 spawnResult.SetHealth("", "Health", itemHealthCoef);
335 }
336 }
337
338
339
340 float qtCoeff =
g_Game.ConfigGetFloat(cfgSkinningOrganClass +
"quantityCoef");
341 if (qtCoeff > 0)
342 {
343 float avgDmgZones = 0;
344 for (int c2 = 0; c2 < itemZones.Count(); c2++)
345 {
346 avgDmgZones += body.GetHealth01(itemZones[c2], "Health");
347 }
348
349 avgDmgZones = avgDmgZones/itemZones.Count();
350 spawnResult.SetHealth01("","", avgDmgZones);
351 }
352
353
354 if (body.CanHaveTemperature() && spawnResult.CanHaveTemperature())
355 {
356 spawnResult.SetTemperatureDirect(body.GetTemperature());
357 spawnResult.SetFrozen(body.GetIsFrozen());
358 }
359
360
361 if ((itemToSpawn == "Lard") || (itemToSpawn == "Guts"))
362 {
363 if (body.IsKindOf("SurvivorBase"))
364 {
365 spawnResult.InsertAgent(
eAgents.BRAIN, 1);
366 }
367 }
368 }
369 }
370 }
371 }
ItemBase CreateOrgan(PlayerBase player, vector body_pos, string item_to_spawn, string cfg_skinning_organ_class, ItemBase tool)
ref ActionTarget m_Target
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.
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto float Floor(float f)
Returns floor of value.