mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-14 04:02:37 +03:00
AFAIK there is no performance difference between configFile and missionConfigFile. Using missionConfigFile by default simplifies loot scripts and makes the extra config variable unnecessary. It's one less step for admins to customize their tables.
90 lines
2.2 KiB
Plaintext
90 lines
2.2 KiB
Plaintext
/*
|
|
Spawns loot at the given building.
|
|
|
|
Single parameter:
|
|
object building to spawn loot at
|
|
|
|
Author:
|
|
Foxy
|
|
*/
|
|
|
|
#include "\z\addons\dayz_code\util\Vector.hpp"
|
|
#include "\z\addons\dayz_code\loot\Loot.hpp"
|
|
|
|
private
|
|
[
|
|
"_vectorUp",
|
|
"_type",
|
|
"_config",
|
|
"_lootChance",
|
|
"_lootPos",
|
|
"_lootGroup",
|
|
"_worldPos",
|
|
"_existingPile",
|
|
"_loot"
|
|
];
|
|
|
|
_vectorUp = vectorUp _this;
|
|
if (Vector_Angle(Vector_UP,_vectorUp) > 20) exitWith { 0 };
|
|
|
|
_type = typeOf _this;
|
|
_config = missionConfigFile >> "CfgLoot" >> "Buildings" >> _type;
|
|
|
|
if (!isClass _config) exitWith {};
|
|
|
|
_lootChance = getNumber (_config >> "lootChance");
|
|
|
|
if (_lootChance <= 0) exitWith {};
|
|
|
|
_lootPos = getArray (_config >> "lootPos");
|
|
_lootGroup = Loot_GetGroup(getText(_config >> "lootGroup"));
|
|
|
|
{
|
|
//Get the world position of the spawn position
|
|
_worldPos = _this modelToWorld _x;
|
|
_worldPos set [2, 0 max (_worldPos select 2)];
|
|
|
|
//Delete existing lootpiles within 1m of spawn location
|
|
{
|
|
deleteVehicle _x;
|
|
dayz_currentWeaponHolders = dayz_currentWeaponHolders - 1;
|
|
}
|
|
foreach (_worldPos nearObjects ["ReammoBox", 1]);
|
|
|
|
if (_lootChance > random 1 && {dayz_currentWeaponHolders < dayz_maxMaxWeaponHolders}) then
|
|
{
|
|
Loot_SpawnGroup(_lootGroup, _worldPos);
|
|
};
|
|
}
|
|
foreach _lootPos;
|
|
|
|
// EPOCH ADDITION
|
|
// lootPosSmall are additional positions in lockers, on shelves, etc. for small objects only.
|
|
// Example: soda cans, small ammo, pistols, bandage, etc.
|
|
|
|
if (isArray (_config >> "lootPosSmall")) then {
|
|
_lootPos = getArray (_config >> "lootPosSmall");
|
|
_lootGroup = Loot_GetGroup((getText(_config >> "lootGroup")) + "Small");
|
|
if (_lootGroup >= 1) then {
|
|
{
|
|
//Get the world position of the spawn position
|
|
_worldPos = _this modelToWorld _x;
|
|
_worldPos set [2, 0 max (_worldPos select 2)];
|
|
|
|
//Delete existing lootpiles within 1m of spawn location
|
|
{
|
|
deleteVehicle _x;
|
|
dayz_currentWeaponHolders = dayz_currentWeaponHolders - 1;
|
|
}
|
|
foreach (_worldPos nearObjects ["ReammoBox", 1]);
|
|
|
|
if (_lootChance > random 1 && {dayz_currentWeaponHolders < dayz_maxMaxWeaponHolders}) then
|
|
{
|
|
Loot_SpawnGroup(_lootGroup, _worldPos);
|
|
};
|
|
}
|
|
foreach _lootPos;
|
|
} else {
|
|
diag_log format["Loot group small: %1 does not exist", ((getText(_config >> "lootGroup")) + "Small")];
|
|
};
|
|
}; |