DayZ 1.27
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 cfg_animal_class_path = "cfgVehicles " + body.GetType() + " " + "Skinning ";
255 vector bodyPosition = body.GetPosition();
256
257 if (!g_Game.ConfigIsExisting(cfg_animal_class_path))
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 child_count = g_Game.ConfigGetChildrenCount(cfg_animal_class_path);
265
266 string item_to_spawn;
267 string cfg_skinning_organ_class;
268 // Parsing of the 'Skinning' class in the config of the dead body
269 for (int i1 = 0; i1 < child_count; i1++)
270 {
271 // To make configuration as convenient as possible, all classes are parsed and parameters are read
272 g_Game.ConfigGetChildName(cfg_animal_class_path, i1, cfg_skinning_organ_class); // out cfg_skinning_organ_class
273 cfg_skinning_organ_class = cfg_animal_class_path + cfg_skinning_organ_class + " ";
274 g_Game.ConfigGetText(cfg_skinning_organ_class + "item", item_to_spawn); // out item_to_spawn
275
276 if (item_to_spawn != "") // 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 item_count = g_Game.ConfigGetInt(cfg_skinning_organ_class + "count");
280
281 array<string> itemZones = new array<string>;
282 array<float> itemCount = new array<float>;
283 float zoneDmg = 0;
284
285 GetGame().ConfigGetTextArray(cfg_skinning_organ_class + "itemZones", itemZones);
286 GetGame().ConfigGetFloatArray(cfg_skinning_organ_class + "countByZone", itemCount);
287
288 if (itemCount.Count() > 0)
289 {
290 item_count = 0;
291 for (int z = 0; z < itemZones.Count(); z++)
292 {
293 zoneDmg = body.GetHealth01(itemZones[z], "Health");
294 zoneDmg *= itemCount[z]; //just re-using variable
295 item_count += Math.Floor(zoneDmg);
296 }
297 }
298
299 for (int i2 = 0; i2 < item_count; i2++)
300 {
301 ItemBase spawn_result = CreateOrgan(action_data.m_Player, bodyPosition, item_to_spawn, cfg_skinning_organ_class, action_data.m_MainItem);
302
303 //Damage pelts based on the average values on itemZones
304 //It only works if the "quantityCoef" in the config is more than 0
305 float qtCoeff = GetGame().ConfigGetFloat(cfg_skinning_organ_class + "quantityCoef");
306 if (qtCoeff > 0)
307 {
308 float avgDmgZones = 0;
309 for (int c2 = 0; c2 < itemZones.Count(); c2++)
310 {
311 avgDmgZones += body.GetHealth01(itemZones[c2], "Health");
312 }
313
314 avgDmgZones = avgDmgZones/itemZones.Count(); // Evaluate the average Health
315
316 if (spawn_result)
317 spawn_result.SetHealth01("","", avgDmgZones);
318 }
319
320 // inherit temperature
321 if (body.CanHaveTemperature() && spawn_result.CanHaveTemperature())
322 {
323 spawn_result.SetTemperatureDirect(body.GetTemperature());
324 spawn_result.SetFrozen(body.GetIsFrozen());
325 }
326
327 // handle fat/guts from human bodies
328 if ((item_to_spawn == "Lard") || (item_to_spawn == "Guts"))
329 {
330 if (body.IsKindOf("SurvivorBase"))
331 {
332 spawn_result.InsertAgent(eAgents.BRAIN, 1);
333 }
334 }
335 }
336 }
337 }
338 }
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:3868
eAgents
Определения EAgents.c:3
proto native float ConfigGetFloat(string path)
Get float value from config on path.
proto native void ConfigGetTextArray(string path, out TStringArray values)
Get array of strings from config on path.
proto native void ConfigGetFloatArray(string path, out TFloatArray values)
Get array of floats from config on path.
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.
Определения Debug.c:122
Определения Debug.c:2
Определения Building.c:6
Определения InventoryItem.c:731
Определения EnMath.c:7
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения EnConvert.c:106
proto native CGame GetGame()
static proto float Floor(float f)
Returns floor of value.

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

Используется в OnFinishProgressServer().