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 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];
297 }
298 }
299
300 if (transferedPartDmgCoef > 0 && itemSpawnCount <= 0)
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
310
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)
329 transferedPartDmgCoef = 1;
330
331 float itemHealthCoef = itemHealth * transferedPartDmgCoef;
332 spawnResult.SetHealth("", "Health", itemHealthCoef);
333 }
334 }
335
336
337
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();
348 spawnResult.SetHealth01("","", avgDmgZones);
349 }
350
351
352 if (body.CanHaveTemperature() && spawnResult.CanHaveTemperature())
353 {
354 spawnResult.SetTemperatureDirect(body.GetTemperature());
355 spawnResult.SetFrozen(body.GetIsFrozen());
356 }
357
358
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)
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.