mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-13 19:52:38 +03:00
Add DZE_MissionLootTable
This commit is contained in:
@@ -28,7 +28,7 @@ _vectorUp = vectorUp _this;
|
||||
if (Vector_Angle(Vector_UP,_vectorUp) > 20) exitWith { 0 };
|
||||
|
||||
_type = typeOf _this;
|
||||
_config = (configFile >> "CfgLoot" >> "Buildings" >> _type);
|
||||
_config = if (DZE_MissionLootTable) then {missionConfigFile >> "CfgLoot" >> "Buildings" >> _type} else {configFile >> "CfgLoot" >> "Buildings" >> _type};
|
||||
|
||||
if (!isClass _config) exitWith {};
|
||||
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
Created exclusively for ArmA2:OA - DayZMod
|
||||
Please request permission to use/alter/distribute from project leader (R4Z0R49)
|
||||
Modified for DayZ Epoch by [VB]AWOL vbawol@veteranbastards.com.
|
||||
*/
|
||||
private ["_lootChance"];
|
||||
_obj = _this;
|
||||
|
||||
// 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");
|
||||
_itemTypes = [] + getArray (_config >> "lootType");
|
||||
_lootChance = getNumber (_config >> "lootChance");
|
||||
|
||||
//_countPositions = count _pos;
|
||||
_qty = 0; // effective quantity of spawned weaponholder
|
||||
_lootSpawnBias = 67; //67 between 50 && 100. The lower it is, the lower chance some of the lootpiles will spawn
|
||||
|
||||
|
||||
// shuffles an array
|
||||
// parameters: array
|
||||
// example: _myrandomarray = _myNormalArray call _ShuffleArray;
|
||||
_ShuffleArray = {
|
||||
private ["_ar","_rand_array","_rand"];
|
||||
_ar = _this;
|
||||
_rand_array = [];
|
||||
while {count _ar > 0} do {
|
||||
_rand = (count _ar);
|
||||
_rand = floor (random _rand);
|
||||
_rand_array set [count _rand_array, _ar select _rand];
|
||||
_ar set [_rand, "randarray_del"];
|
||||
_ar = _ar - ["randarray_del"];
|
||||
};
|
||||
_rand_array;
|
||||
};
|
||||
_positions = _pos call _ShuffleArray;
|
||||
|
||||
// bias for this building. The lower it is, the lower chance some of the lootpiles will spawn
|
||||
_bias = 50 max _lootSpawnBias;
|
||||
_bias = 100 min _bias;
|
||||
_bias = (_bias + random(100 - _bias)) / 100;
|
||||
//diag_log(format["BIAS:%1 LOOTCHANCE:%2", _bias, _lootChance]);
|
||||
|
||||
{
|
||||
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 = dayz_CBLBase find _type;
|
||||
_weights = dayz_CBLChances select _index;
|
||||
_cntWeights = count _weights;
|
||||
_index = floor(random _cntWeights);
|
||||
_index = _weights select _index;
|
||||
_itemType = _itemTypes 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];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
} count _positions;
|
||||
|
||||
// small loot
|
||||
_posSmall = [] + getArray (_config >> "lootPosSmall");
|
||||
_itemTypesSmall = [] + getArray (_config >> "lootTypeSmall");
|
||||
|
||||
_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;
|
||||
|
||||
//diag_log format["building_spawnLoot.sqf: %1", _itemTypesSmall];
|
||||
|
||||
_itemType = _itemTypesSmall select _index;
|
||||
[_itemType select 0, _itemType select 1, _iPos, 0.0] call spawn_loot_small;
|
||||
// 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];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
} count _positionsSmall;
|
||||
@@ -10,7 +10,7 @@ if (count _this > 1) then {
|
||||
};
|
||||
|
||||
_type = typeOf _obj;
|
||||
_config = configFile >> "CfgLoot" >> "Buildings" >> _type;
|
||||
_config = if (DZE_MissionLootTable) then {missionConfigFile >> "CfgLoot" >> "Buildings" >> _type} else {configFile >> "CfgLoot" >> "Buildings" >> _type};
|
||||
_canLoot = isClass (_config);
|
||||
_originalPos = getPosATL _obj;
|
||||
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
private ["_obj","_type","_config","_canLoot","_unitTypes","_min","_max","_num","_zombieChance","_rnd","_position","_positions","_iPos","_nearBy","_noOneNear"];
|
||||
//_t1 = diag_tickTime;
|
||||
|
||||
if (dayz_maxCurrentZeds > dayz_maxZeds) exitwith {};
|
||||
if (dayz_CurrentZombies > dayz_maxGlobalZombies) exitwith {};
|
||||
if (dayz_spawnZombies > dayz_maxLocalZombies) exitwith {};
|
||||
|
||||
_obj = _this select 0;
|
||||
_type = typeOf _obj;
|
||||
_config = configFile >> "CfgBuildingLoot" >> _type;
|
||||
if (DZE_MissionLootTable) then {
|
||||
_config = missionConfigFile >> "CfgBuildingLoot" >> _type;
|
||||
};
|
||||
_canLoot = isClass (_config);
|
||||
|
||||
if (_canLoot) then {
|
||||
|
||||
//Get zombie class
|
||||
_zombieChance = getNumber (_config >> "zombieChance");
|
||||
_rnd = random 1;
|
||||
|
||||
//Get zombie class
|
||||
_unitTypes = getArray (_config >> "zombieClass");
|
||||
_min = getNumber (_config >> "minRoaming");
|
||||
_max = getNumber (_config >> "maxRoaming");
|
||||
|
||||
//Walking Zombies
|
||||
_num = (round(random _max)) max _min;
|
||||
|
||||
_position = getPosATL _obj;
|
||||
|
||||
_noOneNear = (count (_position nearEntities ["CAManBase",30])) == 0;
|
||||
|
||||
if (_noOneNear) then {
|
||||
|
||||
_positions = getArray (_config >> "lootPosZombie");
|
||||
|
||||
if (count _positions > 0) then {
|
||||
|
||||
{
|
||||
if (random 1 < _zombieChance) then {
|
||||
_iPos = _obj modelToWorld _x;
|
||||
_nearBy = count (_iPos nearEntities ["zZombie_Base",1]) > 0;
|
||||
if (!_nearBy) then {
|
||||
[_iPos,true,_unitTypes] call zombie_generate;
|
||||
};
|
||||
};
|
||||
} count _positions;
|
||||
|
||||
} else {
|
||||
|
||||
for "_i" from 1 to _num do
|
||||
{
|
||||
if (random 1 < _zombieChance) then {
|
||||
[_position,true,_unitTypes] call zombie_generate;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
dayz_buildingMonitor set [count dayz_buildingMonitor,_obj];
|
||||
};
|
||||
Reference in New Issue
Block a user