mirror of
https://github.com/EpochModTeam/Epoch.git
synced 2024-08-30 18:22:13 +00:00
87c23b106f
* first build for 0.3.8 * 0.3.8.0190 * 0.3.8.0202 * 0.3.8.0213 * 0.3.7.0214 * 0.3.8.0222 * 0.3.8.0246 * 0.3.8.0247 fixed typo * 0.3.8.0249 more fixes for server compiler * 0.3.8.0256 * add build number and simple batch file for packing * match build number with internal * add build numbers to server pbo's and mission files also reworked build script for more options * 0.3.8.0261 * 0.3.8.0261 * 0.3.8.0283 * 0.3.8.0284 * changelog * 0.3.8.0307 * 0.3.8.0311 * remove old BEC plugin * update redis-server.exe to latest build and full config * 0.3.8.0314 * 0.3.8.0315 * inverse logic This should correctly prevent spawning these units nearby jammer or protection zones * use pushbackUnique here * optimized loot function by using selectRandom instead of slower sqf logic * 0.3.8.0316 * make use of new getDir functionality instead of BIS fnc * add lower disconnect value to server.cfg * use new getpos functionality * 0.3.8.0317 * 0.3.8.0319 * 0.3.8.0327 * 0.3.8.0338 changelog update tba * changelog * 0.3.8.0341 * BE update * 0.3.8.0353 * changelog * removed duplicates * 0.3.8.0355 fixed error in getIDC * 0.3.8.0356 revert to BIS_fnc_param as params threw errors * 0.3.8.0357 fixes for #496 #497 * 0.3.8.0359 fixed #497 fixed #496 * 0.3.8.0365 * 0.3.8.0371 * 0.3.8.0373 * 0.3.8.0379 * 0.3.8.0381 * 0.3.8.0386 * 0.3.8.0393 * 0.3.8.0395 * 0.3.8.0396 * 0.3.8.0397 * 0.3.8.0406 * 0.3.8.0409 * 0.3.8.0410 loot balance suppress error in spawnloot make near object check based on building size * 0.3.8.0412 * 0.3.8.0414 removed classes with scope 0 test remove loot trash on gear for #498 fixed #501 * 0.3.8.0415 * same
104 lines
3.5 KiB
Plaintext
104 lines
3.5 KiB
Plaintext
/*
|
|
Author: Aaron Clark - EpochMod.com
|
|
|
|
Contributors:
|
|
|
|
Description:
|
|
Runs chances to spawn loot objects on building
|
|
|
|
Licence:
|
|
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
|
|
|
|
Github:
|
|
https://github.com/EpochModTeam/Epoch/tree/master/Sources/epoch_code/compile/looting/EPOCH_spawnLoot.sqf
|
|
|
|
Example:
|
|
[_building] call EPOCH_spawnLoot;
|
|
|
|
Parameter(s):
|
|
_this select 0: OBJECT - building
|
|
_this select 1: NUMBER - Number of buildings checked before a building in the array can reattempt looting. Default: 333
|
|
_this select 2: NUMBER - Limit of loot objects, as new are created old ones will be removed. Default: 33
|
|
|
|
Returns:
|
|
BOOL
|
|
*/
|
|
params [["_building",objNull,[objNull]], ["_lootCheckBufferLimit",333], ["_lootObjectLimit",33]];
|
|
|
|
_masterConfig = 'CfgBuildingLootPos' call EPOCH_returnConfig;
|
|
_config = _masterConfig >> (typeOf _building);
|
|
|
|
// exit with false if building is not lootable
|
|
_return = false;
|
|
if !(isClass(_config)) exitWith {_return};
|
|
|
|
_lootBias = getNumber(_config >> "lootBias");
|
|
_lootType = getText(_config >> "lootType");
|
|
_loots = getArray(_config >> _lootType);
|
|
_lootLimit = ceil random(getNumber(_config >> "limit"));
|
|
|
|
EPOCH_LootedBlds pushBackUnique _building;
|
|
if (count EPOCH_LootedBlds >= _lootCheckBufferLimit) then {
|
|
EPOCH_LootedBlds deleteAt 0;
|
|
};
|
|
|
|
if ((random 100) < _lootBias) then {
|
|
_possibleLoots = [];
|
|
{
|
|
_x params ["_posName","_class","_randomColor"];
|
|
_positions = getArray(_config >> _posName);
|
|
{
|
|
_possibleLoots pushBack [_class,_randomColor,_x];
|
|
} forEach _positions;
|
|
} forEach _loots;
|
|
|
|
if !(_possibleLoots isEqualTo []) then {
|
|
for "_i" from 1 to _lootLimit do
|
|
{
|
|
_return = true;
|
|
_possibleCount = count _possibleLoots;
|
|
if (_possibleCount > 0) then {
|
|
_randomIndex = (floor random(_possibleCount));
|
|
|
|
_selectedLoot = _possibleLoots deleteAt _randomIndex;
|
|
//
|
|
_selectedLoot params ["_class","_randomColor","_position"];
|
|
_position params ["_m2WPos","_relDir"];
|
|
_pos = _building modelToWorld _m2WPos;
|
|
// force item to ground level if resulting z pos is below ground.
|
|
if (_pos select 2 < 0) then {
|
|
_pos set[2, 0];
|
|
};
|
|
if (_class isEqualType []) then {
|
|
_class = selectRandom _class;
|
|
};
|
|
_dir = _relDir + (getDir _building);
|
|
_item = createVehicle[_class, _pos, [], 0.0, "CAN_COLLIDE"];
|
|
_item setDir _dir;
|
|
|
|
EPOCH_lootObjects pushBack _item;
|
|
if (count EPOCH_lootObjects > _lootObjectLimit) then {
|
|
deleteVehicle (EPOCH_lootObjects deleteAt 0);
|
|
};
|
|
|
|
if (surfaceIsWater _pos) then {
|
|
_item setPosASL _pos;
|
|
} else {
|
|
_item setPosATL _pos;
|
|
};
|
|
|
|
if (_randomColor isEqualTo "true") then {
|
|
_colors = getArray(configFile >> "CfgVehicles" >> _class >> "availableTextures");
|
|
if !(_colors isEqualTo[]) then {
|
|
_color = selectRandom _colors;
|
|
_item setObjectTextureGlobal[0, _color];
|
|
};
|
|
};
|
|
};
|
|
};
|
|
} else {
|
|
diag_log format["DEBUG: no positions for: %1",_posName];
|
|
};
|
|
};
|
|
_return
|