mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-14 12:12:34 +03:00
readd custom loot codes and DZE_missionloot
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
#include "CfgLootSmall.hpp"
|
||||||
class CfgLoot {
|
class CfgLoot {
|
||||||
trash[] = {
|
trash[] = {
|
||||||
{"TrashTinCan",0.5}
|
{"TrashTinCan",0.5}
|
||||||
|
|||||||
@@ -1,14 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
Created exclusively for ArmA2:OA - DayZMod.
|
Created exclusively for ArmA2:OA - DayZMod
|
||||||
Please request permission to use/alter/distribute from project leader (R4Z0R49)
|
Please request permission to use/alter/distribute from project leader (R4Z0R49)
|
||||||
|
Modified for DayZ Epoch by [VB]AWOL vbawol@veteranbastards.com.
|
||||||
*/
|
*/
|
||||||
private ["_lootChance"];
|
private ["_lootChance"];
|
||||||
_obj = _this;
|
_obj = _this;
|
||||||
_type = configName (configFile >> "CfgBuildingLoot" >> (typeOf _obj)); //make sure we return the same case
|
|
||||||
_config = configFile >> "CfgBuildingLoot" >> _type;
|
// lower case to prevent issues with differing case for buildings from map to map.
|
||||||
|
_type = toLower(typeOf _obj);
|
||||||
|
|
||||||
|
_config = configFile >> "CfgBuildingLoot" >> _type;
|
||||||
|
if (DZE_MissionLootTable) then {
|
||||||
|
_config = missionConfigFile >> "CfgBuildingLoot" >> _type;
|
||||||
|
};
|
||||||
|
|
||||||
_pos = [] + getArray (_config >> "lootPos");
|
_pos = [] + getArray (_config >> "lootPos");
|
||||||
_itemTypes = [] + getArray (_config >> "lootType");
|
_itemTypes = [] + getArray (_config >> "lootType");
|
||||||
_lootChance = getNumber (_config >> "lootChance");
|
_lootChance = getNumber (_config >> "lootChance");
|
||||||
|
|
||||||
//_countPositions = count _pos;
|
//_countPositions = count _pos;
|
||||||
_qty = 0; // effective quantity of spawned weaponholder
|
_qty = 0; // effective quantity of spawned weaponholder
|
||||||
_lootSpawnBias = 67; //67 between 50 and 100. The lower it is, the lower chance some of the lootpiles will spawn
|
_lootSpawnBias = 67; //67 between 50 and 100. The lower it is, the lower chance some of the lootpiles will spawn
|
||||||
@@ -61,13 +70,45 @@ _bias = (_bias + random(100 - _bias)) / 100;
|
|||||||
// diag_log (format["SpawnLoot: Pos: %1, LootType: %2/%3,",_iPos,_itemType select 0,_itemType select 1]);
|
// diag_log (format["SpawnLoot: Pos: %1, LootType: %2/%3,",_iPos,_itemType select 0,_itemType select 1]);
|
||||||
dayz_currentWeaponHolders = dayz_currentWeaponHolders +1;
|
dayz_currentWeaponHolders = dayz_currentWeaponHolders +1;
|
||||||
//loclout system
|
//loclout system
|
||||||
_islocal = _obj getVariable ["", false]; // object created locally via TownGenerator. See stream_locationFill.sqf
|
_obj setVariable ["looted",diag_tickTime + dayz_tickTimeOffset];
|
||||||
_obj setVariable ["looted",diag_tickTime + dayz_tickTimeOffset,!_islocal];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
//sleep 0.002;
|
|
||||||
};
|
};
|
||||||
} forEach _positions;
|
} forEach _positions;
|
||||||
|
|
||||||
//dayz_currentWeaponHolders;
|
// small loot
|
||||||
|
_posSmall = [] + getArray (_config >> "lootPosSmall");
|
||||||
|
_itemTypesSmall = [] + getArray (_config >> "itemTypeSmall");
|
||||||
|
|
||||||
|
_positionsSmall = _posSmall call _ShuffleArray;
|
||||||
|
|
||||||
|
{
|
||||||
|
if (count _x == 3) then {
|
||||||
|
_rnd = (random 1) / _bias;
|
||||||
|
_iPos = _obj modelToWorld _x;
|
||||||
|
_nearBy = nearestObjects [_iPos, ["ReammoBox"], 2];
|
||||||
|
|
||||||
|
if (count _nearBy > 0) then {
|
||||||
|
_lootChance = _lootChance + 0.05;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (dayz_currentWeaponHolders < dayz_maxMaxWeaponHolders) then {
|
||||||
|
if (_rnd <= _lootChance) then {
|
||||||
|
if (count _nearBy == 0) then {
|
||||||
|
_index = dayzE_CBLSBase find _type;
|
||||||
|
_weights = dayzE_CBLSChances select _index;
|
||||||
|
_cntWeights = count _weights;
|
||||||
|
_index = floor(random _cntWeights);
|
||||||
|
_index = _weights select _index;
|
||||||
|
_itemType = _itemTypesSmall select _index;
|
||||||
|
[_itemType select 0, _itemType select 1 , _iPos, 0.0] call spawn_loot;
|
||||||
|
// diag_log (format["SpawnLoot: Pos: %1, LootType: %2/%3,",_iPos,_itemType select 0,_itemType select 1]);
|
||||||
|
dayz_currentWeaponHolders = dayz_currentWeaponHolders +1;
|
||||||
|
//loclout system
|
||||||
|
_obj setVariable ["looted",diag_tickTime + dayz_tickTimeOffset];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} forEach _positionsSmall;
|
||||||
@@ -12,10 +12,11 @@ if (isNil "_iClass") exitWith {diag_log "_iClass isNil, exiting loot spawn!";};
|
|||||||
switch (_iClass) do {
|
switch (_iClass) do {
|
||||||
default {
|
default {
|
||||||
_itemTypes = [];
|
_itemTypes = [];
|
||||||
{
|
if (DZE_MissionLootTable) then {
|
||||||
_itemTypes set [count _itemTypes, _x select 0]
|
_itemTypes = ((getArray (missionConfigFile >> "cfgLoot" >> _iClass)) select 0);
|
||||||
} foreach getArray (configFile >> "cfgLoot" >> _iClass);
|
} else {
|
||||||
|
_itemTypes = ((getArray (configFile >> "cfgLoot" >> _iClass)) select 0);
|
||||||
|
};
|
||||||
_qty = 0;
|
_qty = 0;
|
||||||
_max = ceil(random 2) + 1;
|
_max = ceil(random 2) + 1;
|
||||||
if (_iClass in ["trash","civilian","office","office2","food","generic","medical","hospital","military","militarypilot","policeman","hunter","worker"]) then {
|
if (_iClass in ["trash","civilian","office","office2","food","generic","medical","hospital","military","militarypilot","policeman","hunter","worker"]) then {
|
||||||
@@ -73,12 +74,86 @@ switch (_iClass) do {
|
|||||||
_item = createVehicle [_item2, _iPos, [], _radius, "CAN_COLLIDE"];
|
_item = createVehicle [_item2, _iPos, [], _radius, "CAN_COLLIDE"];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
case "weapon": {
|
case "single":
|
||||||
|
{
|
||||||
|
//Item is sigle, add 1 item from cfgloot
|
||||||
|
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
|
||||||
|
_itemTypes = [];
|
||||||
|
if (DZE_MissionLootTable) then {
|
||||||
|
_itemTypes = ((getArray (missionConfigFile >> "cfgLoot" >> _iItem)) select 0);
|
||||||
|
} else {
|
||||||
|
_itemTypes = ((getArray (configFile >> "cfgLoot" >> _iItem)) select 0);
|
||||||
|
};
|
||||||
|
_index = dayz_CLBase find _iItem;
|
||||||
|
_weights = dayz_CLChances select _index;
|
||||||
|
_cntWeights = count _weights;
|
||||||
|
|
||||||
|
_index = floor(random _cntWeights);
|
||||||
|
_index = _weights select _index;
|
||||||
|
_canType = _itemTypes select _index;
|
||||||
|
_item addMagazineCargoGlobal [_canType,1];
|
||||||
|
};
|
||||||
|
case "backpack":
|
||||||
|
{
|
||||||
|
//Item is single backpack
|
||||||
|
if (DZE_MissionLootTable) then {
|
||||||
|
_itemTypes = ((getArray (missionConfigFile >> "cfgLoot" >> _iItem)) select 0);
|
||||||
|
} else {
|
||||||
|
_itemTypes = ((getArray (configFile >> "cfgLoot" >> _iItem)) select 0);
|
||||||
|
};
|
||||||
|
_index = dayz_CLBase find _iItem;
|
||||||
|
_weights = dayz_CLChances select _index;
|
||||||
|
_cntWeights = count _weights;
|
||||||
|
_index = floor(random _cntWeights);
|
||||||
|
_index = _weights select _index;
|
||||||
|
_iItem = _itemTypes select _index;
|
||||||
|
|
||||||
|
_item = createVehicle [_iItem, _iPos, [], _radius, "CAN_COLLIDE"];
|
||||||
|
};
|
||||||
|
case "cfglootweapon":
|
||||||
|
{
|
||||||
|
if (DZE_MissionLootTable) then {
|
||||||
|
_itemTypes = ((getArray (missionConfigFile >> "cfgLoot" >> _iItem)) select 0);
|
||||||
|
} else {
|
||||||
|
_itemTypes = ((getArray (configFile >> "cfgLoot" >> _iItem)) select 0);
|
||||||
|
};
|
||||||
|
_index = dayz_CLBase find _iItem;
|
||||||
|
_weights = dayz_CLChances select _index;
|
||||||
|
_cntWeights = count _weights;
|
||||||
|
|
||||||
|
_index = floor(random _cntWeights);
|
||||||
|
_index = _weights select _index;
|
||||||
|
_iItem = _itemTypes select _index;
|
||||||
|
|
||||||
|
if (_iItem == "Chainsaw") then {
|
||||||
|
_iItem = ["ChainSaw","ChainSawB","ChainSawG","ChainSawP","ChainSawR"] call BIS_fnc_selectRandom;
|
||||||
|
};
|
||||||
|
|
||||||
|
//Item is a weapon, add it and a random quantity of magazines
|
||||||
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
|
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
|
||||||
_item addWeaponCargoGlobal [_iItem,1];
|
_item addWeaponCargoGlobal [_iItem,1];
|
||||||
_mags = [] + getArray (configFile >> "cfgWeapons" >> _iItem >> "magazines");
|
_mags = [] + getArray (configFile >> "cfgWeapons" >> _iItem >> "magazines");
|
||||||
if ((count _mags) > 0) then {
|
if ((count _mags) > 0) then
|
||||||
|
{
|
||||||
|
if (_mags select 0 == "Quiver") then { _mags set [0, "WoodenArrow"] }; // Prevent spawning a Quiver
|
||||||
|
if (_mags select 0 == "20Rnd_556x45_Stanag") then { _mags set [0, "30Rnd_556x45_Stanag"] };
|
||||||
|
if (_mags select 0 == "30Rnd_556x45_G36") then { _mags set [0, "30Rnd_556x45_Stanag"] };
|
||||||
|
if (_mags select 0 == "30Rnd_556x45_G36SD") then { _mags set [0, "30Rnd_556x45_StanagSD"] };
|
||||||
|
_item addMagazineCargoGlobal [(_mags select 0), (round(random 2))];
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
case "weapon":
|
||||||
|
{
|
||||||
|
//Item is a weapon, add it and a random quantity of magazines
|
||||||
|
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
|
||||||
|
_item addWeaponCargoGlobal [_iItem,1];
|
||||||
|
_mags = [] + getArray (configFile >> "cfgWeapons" >> _iItem >> "magazines");
|
||||||
|
if ((count _mags) > 0) then
|
||||||
|
{
|
||||||
|
if (_mags select 0 == "Quiver") then { _mags set [0, "WoodenArrow"] }; // Prevent spawning a Quiver
|
||||||
if (_mags select 0 == "20Rnd_556x45_Stanag") then { _mags set [0, "30Rnd_556x45_Stanag"] };
|
if (_mags select 0 == "20Rnd_556x45_Stanag") then { _mags set [0, "30Rnd_556x45_Stanag"] };
|
||||||
if (_mags select 0 == "30Rnd_556x45_G36") then { _mags set [0, "30Rnd_556x45_Stanag"] };
|
if (_mags select 0 == "30Rnd_556x45_G36") then { _mags set [0, "30Rnd_556x45_Stanag"] };
|
||||||
if (_mags select 0 == "30Rnd_556x45_G36SD") then { _mags set [0, "30Rnd_556x45_StanagSD"] };
|
if (_mags select 0 == "30Rnd_556x45_G36SD") then { _mags set [0, "30Rnd_556x45_StanagSD"] };
|
||||||
@@ -90,7 +165,15 @@ switch (_iClass) do {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
case "magazine": {
|
case "weaponnomags":
|
||||||
|
{
|
||||||
|
//Item is a weapon, and spawns no mags
|
||||||
|
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
|
||||||
|
_item addWeaponCargoGlobal [_iItem,1];
|
||||||
|
};
|
||||||
|
case "magazine":
|
||||||
|
{
|
||||||
|
//Item is one magazine
|
||||||
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
|
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
|
||||||
_item addMagazineCargoGlobal [_iItem,1];
|
_item addMagazineCargoGlobal [_iItem,1];
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user