mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-20 18:36:29 +03:00
Remove some unused legacy code
This commit is contained in:
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
Created exclusively for ArmA2:OA - DayZMod.
|
||||
Please request permission to use/alter/distribute from project leader (R4Z0R49) AND the author (facoptere@gmail.com)
|
||||
*/
|
||||
|
||||
private ["_antiwallhack","_houseType","_houseList","_tmp","_patchList","_house","_o","_nbhouses","_nbpatchs","_pos"];
|
||||
|
||||
_antiwallhack=[
|
||||
[
|
||||
"Land_A_Hospital", // building type
|
||||
[
|
||||
[6414.05,2760.21,0], [6817.3,2702.03,0], [10517.9,2287.55,0], [11956.7,9120.21,0] // optional precomputed building positions
|
||||
],
|
||||
[
|
||||
[17.6182,-1.8418,3.23178,"Land_CncBlock_D",0],[15.7192,-1.84277,3.22177,"Land_CncBlock_D",0],[-17.4,-0.38,-4.25,"Land_CncBlock_D",90],[-17.4,2.25,-4.25,"Land_CncBlock_D",90],[-17.4,4.22,-4.25,"Land_CncBlock_D",90],[-17.42,-3.55,-7.63,"Land_CncBlock_D",90],[-13.27,2.83,-4.25,"Fort_RazorWire",180],[-13.23,4.28,-4.25,"Fort_RazorWire",180],[-16.81,1.38,-4.25,"Hedgehog",85],[-16.82,-0.6,-4.25,"Hedgehog",90],[-7.45,4.26,-4.25,"Fort_RazorWire",180] // what to add on building (coordinates/type/angle)
|
||||
]
|
||||
],
|
||||
[
|
||||
"Land_HouseB_Tenement",
|
||||
[
|
||||
[6855.66,2496.78,0]
|
||||
],
|
||||
[
|
||||
[-9.66602,7.66602,18.3236,"Fort_RazorWire",0], [-1.30273,7.66602,18.3236,"Fort_RazorWire",0], [-9.66602,0.814453,18.3236,"Fort_RazorWire",0], [-1.30273,0.814453,18.3236,"Fort_RazorWire",0], [-15.0029,4.18359,18.3236,"Fort_RazorWire",90], [3.62109,3.95117,18.3236,"Fort_RazorWire",270], [-7.42,8.15,-20.57,"Fort_RazorWire",180], [-4.67,9.92,-21.55,"Fort_RazorWire",180]
|
||||
]
|
||||
],
|
||||
[
|
||||
"Land_A_Office02",
|
||||
[[6552.96,2807.47,0], [7036.05,2526.13,0], [10028.6,1832.52,0]],
|
||||
[
|
||||
[2.17627, 1.98828, 5.31387, "Land_CncBlock_D" , 0], [2.85547, 3.02246, 5.38394, "Land_CncBlock_D" , 0], [-15.7412, 3.98145, 5.38394, "Land_CncBlock_D" , 270], [-20.2915, 4.01563, 5.35391, "Land_CncBlock_D" , 90], [-20.291, 1.22559, 5.36392, "Land_CncBlock_D" , 90], [-19.0527, -0.318359, 5.38394, "Land_CncBlock_D" , 0], [-16.6426, -0.321289, 5.38394, "Land_CncBlock_D" , 0], [-15.4575, 1.01563, 5.35391, "Land_CncBlock_D" , 270], [-16.7344, 5.30762, 5.38394, "Land_CncBlock_D" , 180], [-19.0361, 5.30859, 5.38394, "Land_CncBlock_D" , 180]
|
||||
]
|
||||
],
|
||||
[
|
||||
"Land_A_Office01",
|
||||
[[3804.1,8924.83,-0.15], [10481.5,2358.45,0], [12742.4,9593.23,0]],
|
||||
[
|
||||
[0.837891, -1.13086, 5.93463, "Land_CncBlock_D", 90], [2.30957, -2.65918, 6.02472, "Land_CncBlock_D", 0], [3.68457, -1.2168, 6.06476, "Land_CncBlock_D", 270], [2.36914, -1.09863, 6.01471, "Land_CncBlock_D", 225], [2.4043, 0.155273, 6.14484, "Land_CncBlock_D", 180], [2.18359, -1.36035, 6.01471, "Land_CncBlock_D", 135]
|
||||
]
|
||||
],
|
||||
[
|
||||
"Land_A_statue01",
|
||||
[[3796.36,8838.01,0], [6531.07,2804.09,0], [6811.04,2455.16,0]],
|
||||
[
|
||||
[1.50049,2.14844,-3.6926,"Land_CncBlock_D",180], [2.86523,0.0966797,-3.69263,"Land_CncBlock_D",270], [1.38232,-2.17578,-3.69305,"Land_CncBlock_D",0]
|
||||
]
|
||||
],
|
||||
[
|
||||
"Land_Barn_Metal",
|
||||
[[2860.45,9746.05,0.682495],[4565.07,4528.81,0.199997], [6339.55,7693.31,0.0499878],[11329.8,6646.15,0.331261]],
|
||||
[
|
||||
[7.02,17.13,-5.74,"Misc_TyreHeap",36], [-5.4,7.85,-5.44,"SKODAWreck",181], [-7.5,8.87,-5.44,"SKODAWreck",181], [-0.99,-9.31,-5.44,"UralWreck",320],
|
||||
[8.33,8.43,-5.44,"datsun01Wreck",176], [4.13,10.16,-5.44,"SKODAWreck",176], [-7.21,-15.37,-5.44,"SKODAWreck",8], [3.3,15.19,-5.44,"UralWreck",210],
|
||||
[-5.76,12.87,-5.44,"SKODAWreck",150], [6.76,-6.86,-5.54,"LADAWreck",85], [-0.42,-21.9,-5.75,"Misc_TyreHeap",95]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
_nbhouses = 0;
|
||||
_nbpatchs = 0;
|
||||
{
|
||||
_houseType = _x select 0;
|
||||
_houseList = _x select 1;
|
||||
if (count _houseList == 0) then {
|
||||
_houseList = dayz_centerMarker nearObjects [_houseType, 20000];
|
||||
}
|
||||
else {
|
||||
_tmp = [];
|
||||
{
|
||||
_tmp set [count _tmp, _x nearestObject _houseType];
|
||||
} forEach _houseList;
|
||||
_houseList = _tmp;
|
||||
};
|
||||
_patchList = _x select 2;
|
||||
{
|
||||
_nbhouses = _nbhouses +1;
|
||||
_house = _x;
|
||||
{
|
||||
_pos = +(_x);
|
||||
_pos resize 3;
|
||||
_pos = _house modelToWorld _pos;
|
||||
_o = (_x select 3) createVehicle [0,0,0];
|
||||
_o setDir ((getDir _house)+(_x select 4));
|
||||
_o setPosATL _pos;
|
||||
diag_log [ typeOf _o, getPosATL _o, getDir _o, 0, nil];
|
||||
_nbpatchs = _nbpatchs +1;
|
||||
} forEach _patchList;
|
||||
//diag_log format["Found building %1 at %2", _houseType, getPosATL _house ];
|
||||
} forEach _houseList;
|
||||
} forEach _antiwallhack;
|
||||
|
||||
diag_log(format["%1: %2 buildings patched with %3 objects", __FILE__, _nbhouses, _nbpatchs]);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
Not Used Test System
|
||||
*/
|
||||
|
||||
|
||||
//_vehicle = _this select 0;
|
||||
//_engineState = _this select 1;
|
||||
|
||||
_rate = getNumber (configFile >> "CfgVehicles" >> (typeOf (_this select 0)) >> "fuelconsumptionrate");
|
||||
|
||||
if (_this select 1) then {
|
||||
//[_vehicle, _rate] spawn {
|
||||
while {isEngineOn (_this select 0)} do {
|
||||
(_this select 0) setFuel ( Fuel (_this select 0) - (_this select 1));
|
||||
sleep 1;
|
||||
};
|
||||
//};
|
||||
};
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
Created exclusively for ArmA2:OA - DayZMod.
|
||||
Please request permission to use/alter/distribute from project leader (R4Z0R49) AND the author (facoptere@gmail.com)
|
||||
*/
|
||||
|
||||
//// TENTS CHECK ////
|
||||
|
||||
// Proceed to empty tents check: extra empty tents will be ignored (tents won't be created on map)
|
||||
// comment this out if you don't want any check
|
||||
//#define EMPTY_TENTS_CHECK
|
||||
|
||||
// Max number of empty tents
|
||||
#define EMPTY_TENTS_GLOBAL_LIMIT 100
|
||||
|
||||
// Keep a least this number of empty tents per user
|
||||
#define EMPTY_TENTS_USER_LIMIT 3
|
||||
|
||||
|
||||
|
||||
//// OUT-OF-MAP CHECK ////
|
||||
|
||||
// Move out-of-map tents and other crafted/installed objects next to map boundary.
|
||||
//#define OBJECTS_FIX_OUTOFMAP
|
||||
|
||||
// Move out-of-map vehicle next to map boundary.
|
||||
//#define VEH_MAINTENANCE_FIX_OUTOFMAP
|
||||
|
||||
// Move out-of-map player next to map boundary during playerSetup
|
||||
//#define PLAYERS_FIX_OUTOFMAP
|
||||
|
||||
|
||||
|
||||
//// VEHICLE MAINTENANCE /////
|
||||
|
||||
// Ignore (don't create on map) vehicles not decribed in Cfg file, or outnumbered ones
|
||||
//#define VEH_MAINTENANCE_IGNORE_UNKNOWN
|
||||
|
||||
// Add missing vehicles, as described in Cfg file. Respawn damaged vehicles.
|
||||
//#define VEH_MAINTENANCE_ADD_MISSING
|
||||
|
||||
// Don't look for a suitable place anywhere on map if current place is not safe
|
||||
#define VEH_MAINTENANCE_DONT_BE_SMART
|
||||
|
||||
// Damage the vehicle for 1 startup over 5
|
||||
// don't define if you don't want any damage
|
||||
//#define VEH_MAINTENANCE_ROTTEN_AT_STARTUP 5
|
||||
|
||||
// How the damage is computed. Here, a 0% damaged vehicle would be respawned after 100 restarts
|
||||
#define VEH_MAINTENANCE_ROTTEN_LOGIC (_damage * 1.04 + 0.03)
|
||||
|
||||
// How initial fuel level is set when a vehicle is created/spawned
|
||||
#define VEH_MAINTENANCE_SPAWN_FUEL_LOGIC (0.1 + floor(random 3) / 10)
|
||||
|
||||
|
||||
|
||||
|
||||
// where the config is described
|
||||
#define CONFIGBASE_VEHMAINTENANCE configFile >> "CfgPatches" >> "vehMaint"
|
||||
@@ -1,382 +0,0 @@
|
||||
/*
|
||||
Created exclusively for ArmA2:OA - DayZMod.
|
||||
Please request permission to use/alter/distribute from project leader (R4Z0R49) AND the author (facoptere@gmail.com)
|
||||
*/
|
||||
|
||||
#include "fa_hiveMaintenance.hpp"
|
||||
|
||||
// coor2str: convert position to a GPS coordinates
|
||||
fa_coor2str = {
|
||||
private["_pos","_res","_nearestCity","_town"];
|
||||
|
||||
_pos = +(_this);
|
||||
if (count _pos < 1) then { _pos = [0,0]; }
|
||||
else { if (count _pos < 2) then { _pos = [_pos select 0,0]; };
|
||||
};
|
||||
_nearestCity = nearestLocations [_pos, ["NameCityCapital","NameCity","NameVillage","NameLocal"],1000];
|
||||
_town = "Wilderness";
|
||||
if (count _nearestCity > 0) then {_town = text (_nearestCity select 0)};
|
||||
_res = format["%1 [%2:%3]", _town, round((_pos select 0)/100), round((15360-(_pos select 1))/100)];
|
||||
|
||||
_res
|
||||
};
|
||||
|
||||
// print vehicle OID and name. if OID is unknown, it should be an hacked vehicle so print hacker PID.
|
||||
fa_veh2str = {
|
||||
private["_res","_oid", "_type"];
|
||||
|
||||
_res = "anything";
|
||||
if (!isNil "_this") then {
|
||||
_oid = _this getVariable ["ObjectID", nil];
|
||||
if (isNil "_oid" OR {(_oid == "")}) then {
|
||||
_oid = "Hacked vehicle owned by PID#" + str(owner _this);
|
||||
}
|
||||
else {
|
||||
_oid = "OID#" + _oid;
|
||||
};
|
||||
_type = getText(configFile >> "CfgVehicles" >> (typeOf _this) >> "displayName");
|
||||
if (_type == "") then { _type = typeOf _this; };
|
||||
_res = format["%1(%2)", _oid, _type ];
|
||||
};
|
||||
|
||||
_res
|
||||
};
|
||||
|
||||
// print player player PID and name. If name unknown then print UID.
|
||||
fa_plr2str = {
|
||||
private["_x","_res","_name"];
|
||||
_x = _this;
|
||||
_res = "nobody";
|
||||
if (!isNil "_x") then {
|
||||
_name = _x getVariable ["bodyName", nil];
|
||||
if ((isNil "_name" OR {(_name == "")}) AND ({alive _x})) then { _name = name _x; };
|
||||
if (isNil "_name" OR {(_name == "")}) then { _name = "UID#"+(getPlayerUID _x); };
|
||||
_res = format["PID#%1(%2)", owner _x, _name ];
|
||||
};
|
||||
_res
|
||||
};
|
||||
|
||||
|
||||
// isoutofmap: return true if position is out of map
|
||||
fa_isoutofmap = {
|
||||
private ["_SWcorner","_NEcorner"];
|
||||
_SWcorner = getArray(CONFIGBASE_VEHMAINTENANCE >> (worldName) >> "SWcorner");
|
||||
_NEcorner = getArray(CONFIGBASE_VEHMAINTENANCE >> (worldName) >> "NEcorner");
|
||||
(!((((_this select 0 >= _SWcorner select 0) AND {(_this select 0 <= _NEcorner select 0)})
|
||||
AND {(_this select 1 >= _SWcorner select 1)}) AND {(_this select 1 <= _NEcorner select 1)}))
|
||||
};
|
||||
|
||||
// spawninventory: draw preexisting loot in the vehicle. helicrash loot type is taken here + parts taken as arg
|
||||
fa_spawninventory = {
|
||||
private["_partType","_partChance","_lootWeight","_config","_itemType","_itemChance","_weights",
|
||||
"_index","_y","_partWeight","_spawnType","_spawnChance","_inventory","_weaponType","_weaponQty" ];
|
||||
|
||||
_partType = _this select 0;
|
||||
_partChance = _this select 1;
|
||||
_config = configFile >> "CfgLoot" >> "Buildings" >> "HeliCrash";
|
||||
// append parts to loot item
|
||||
_itemType = (getArray (_config >> "itemType"));
|
||||
{ _itemType set [count _itemType, [_x,"object"]] } forEach _partType;
|
||||
_itemChance = getArray (_config >> "itemChance");
|
||||
//diag_log (format["FACO _itemType:%1 _itemChance:%2", _itemType, _itemChance]);
|
||||
// _partWeight : sum of weights of parts list
|
||||
_partWeight = 0; { _partWeight = _partWeight + _x; } forEach _partChance;
|
||||
// _lootWeight : sum of weights of loot list
|
||||
_lootWeight = 0; { _lootWeight = _lootWeight + _x; } forEach _itemChance;
|
||||
// multiply parts weight so that parts have same chance to be chosen as regular loot
|
||||
// and append parts chance to loot item weight array
|
||||
{ _itemChance set [count _itemChance, _x * _lootWeight / _partWeight]; } forEach _partChance;
|
||||
// _partWeight : now, number of item to be chosen
|
||||
_partWeight = ceil(random(_partWeight));
|
||||
// lets choose the inventory
|
||||
_spawnType = [];
|
||||
_spawnQty = [];
|
||||
_weaponType = [];
|
||||
_weaponQty = [];
|
||||
_weights = [_itemType,_itemChance] call fnc_buildWeightedArray;
|
||||
for "_x" from 0 to _partWeight do {
|
||||
_index = _weights call BIS_fnc_selectRandom;
|
||||
if (_index < count _itemType) then {
|
||||
_y=(_itemType select _index) select 0;
|
||||
if (_y != "") then {
|
||||
if (_y isKindOf "Pistol" OR _y isKindOf "RifleCore" OR _y isKindOf "Binocular") then {
|
||||
_weaponType set [count _weaponType, _y ];
|
||||
_weaponType set [count _weaponType, 1];
|
||||
}
|
||||
else {
|
||||
_spawnType set [count _spawnType, _y ];
|
||||
_spawnQty set [count _spawnQty, 1];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
_inventory = [[_weaponType,_weaponQty],[_spawnType,_spawnQty],[[],[]]];
|
||||
_inventory
|
||||
};
|
||||
|
||||
// populateCargo: add item and quantity to the 3 cargos (magazines,weapons,backpack) of an unit
|
||||
fa_populateCargo = {
|
||||
private["_entity","_config","_magItemTypes","_magItemQtys","_i","_inventory"];
|
||||
_entity = _this select 0;
|
||||
_inventory = _this select 1;
|
||||
|
||||
clearWeaponCargoGlobal _entity;
|
||||
clearMagazineCargoGlobal _entity;
|
||||
clearBackpackCargoGlobal _entity;
|
||||
_config = ["CfgWeapons", "CfgMagazines", "CfgVehicles" ];
|
||||
{
|
||||
_magItemTypes = _x select 0;
|
||||
_magItemQtys = _x select 1;
|
||||
_i = _forEachIndex;
|
||||
{
|
||||
if (_x == "Crossbow") then { _x = "Crossbow_DZ" }; // Convert Crossbow to Crossbow_DZ
|
||||
if (_x == "BoltSteel") then { _x = "WoodenArrow" }; // Convert BoltSteel to WoodenArrow
|
||||
if (_x == "ItemBloodbag") then { _x = "bloodBagONEG" }; // Convert ItemBloodbag into universal blood type/rh bag
|
||||
// Convert to DayZ Weapons
|
||||
if (_x == "DMR") then { _x = "DMR_DZ" };
|
||||
//if (_x == "M14_EP1") then { _x = "M14_DZ" };
|
||||
if (_x == "SVD") then { _x = "SVD_DZ" };
|
||||
if (_x == "SVD_CAMO") then { _x = "SVD_CAMO_DZ" };
|
||||
if (isClass(configFile >> (_config select _i) >> _x) &&
|
||||
getNumber(configFile >> (_config select _i) >> _x >> "stopThis") != 1) then {
|
||||
if (_forEachIndex < count _magItemQtys) then {
|
||||
switch (_i) do {
|
||||
case 0: { _entity addWeaponCargoGlobal [_x,(_magItemQtys select _forEachIndex)]; };
|
||||
case 1: { _entity addMagazineCargoGlobal [_x,(_magItemQtys select _forEachIndex)]; };
|
||||
case 2: { _entity addBackpackCargoGlobal [_x,(_magItemQtys select _forEachIndex)]; };
|
||||
};
|
||||
};
|
||||
};
|
||||
} forEach _magItemTypes;
|
||||
} forEach _inventory;
|
||||
};
|
||||
|
||||
|
||||
// all damageable parts names defined in Legacy/dayz_vehicles/config.cpp, some of them commented.
|
||||
// other damageables parts, defined in other CfgVehicles, are ignored.
|
||||
dayZ_damageableParts = [ "motor", "sklo predni P", "sklo predni L", "karoserie", "palivo", "wheel_1_1_steering", "wheel_2_1_steering", "wheel_1_2_steering", "wheel_2_2_steering", "glass1", "glass2", "glass3", "glass4"
|
||||
//, "glass5", "glass6", "door_fl", "door_rl", "door_fr", "door_rr"
|
||||
];
|
||||
|
||||
// setDamagedParts: declare some damageable parts of a vehicle. Randomly set damage to 80% (very damaged) to some parts
|
||||
// compute global damage of the vehicle
|
||||
// return: global damage, "_this" is modified and should be _hitpoints array from server_monitor
|
||||
fa_setDamagedParts = {
|
||||
private ["_part_damage", "_part_name", "_damage", "_hitpoints"];
|
||||
_damage = 0;
|
||||
_hitpoints = _this;
|
||||
{
|
||||
_part_damage = 0.05; // don't put 0, otherwise server_updateObject will think it's repaired
|
||||
if (random(3)<1) then { _part_damage = 0.80; };
|
||||
_part_name = getText (configFile >> "CfgVehicles" >> (typeOf _entity) >> "HitPoints" >> _x >> "name");
|
||||
if (_part_name IN dayZ_damageableParts) then {
|
||||
_damage = _damage + _part_damage;
|
||||
_hitpoints set [count _hitpoints, [ _part_name, _part_damage ]];
|
||||
};
|
||||
} forEach (_entity call vehicle_getHitpoints);
|
||||
_damage = _damage / (1 + (count _hitpoints)); // avoid DIV0
|
||||
|
||||
_damage
|
||||
};
|
||||
|
||||
fa_tentEmpty = {
|
||||
( (count _this == 0) || {
|
||||
(count ((_this select 0) select 0) == 0) &&
|
||||
(count ((_this select 1) select 0) == 0) &&
|
||||
(count ((_this select 2) select 0) == 0)
|
||||
})
|
||||
};
|
||||
|
||||
// ignore empty tents from array of objects fetched from hive
|
||||
fa_removeExtraTents = {
|
||||
private ["_emptytenttotal", "_idx", "_intentory", "_k", "_maxEmptyTents", "_allowedEmptyTents", "_ownerID", "_stall", "_tentcur", "_tentidx", "_tentowner", "_y", "_z", "_myArray"];
|
||||
|
||||
_myArray = _this select 0;
|
||||
_maxEmptyTents = _this select 1;
|
||||
_allowedEmptyTents = _this select 2;
|
||||
|
||||
_tentowner=[];
|
||||
_tentidx=[];
|
||||
_tentcur=[];
|
||||
_emptytenttotal=0;
|
||||
|
||||
{
|
||||
if ((_x select 2) == "TentStorage") then {
|
||||
_idx=_forEachIndex;
|
||||
_ownerID = _x select 3;
|
||||
if (!(_ownerID IN _tentowner)) then {
|
||||
_tentidx set [count _tentidx, []];
|
||||
_tentcur set [count _tentcur, 0];
|
||||
_tentowner set [count _tentowner, _ownerID];
|
||||
};
|
||||
_intentory = (_x select 5);
|
||||
if (_intentory call fa_tentEmpty) then {
|
||||
{
|
||||
if (_x == _ownerID) then {
|
||||
(_tentidx select _forEachIndex) set [count (_tentidx select _forEachIndex), _idx];
|
||||
_emptytenttotal = _emptytenttotal + 1;
|
||||
};
|
||||
} forEach _tentowner;
|
||||
};
|
||||
};
|
||||
} forEach _myArray;
|
||||
diag_log (format [ "fa_removeExtraTents: Empty tents: %1, would like less than %2.",
|
||||
_emptytenttotal,
|
||||
_maxEmptyTents
|
||||
]);
|
||||
if (_emptytenttotal > _maxEmptyTents) then {
|
||||
for [{_k = _emptytenttotal / 2}, {_k >= 2}, {_k = _k / 2}] do {
|
||||
_stall = 0;
|
||||
while {_emptytenttotal > _maxEmptyTents && _stall == 0} do {
|
||||
_stall = 1;
|
||||
for [{_x = (count _tentidx) - 1}, {_x >= 0 && _emptytenttotal >= _maxEmptyTents}, {_x = _x - 1}] do {
|
||||
_y = _tentidx select _x;
|
||||
_z = _tentcur select _x;
|
||||
if (_z < (count _y) -_allowedEmptyTents + 2 - _k) then {
|
||||
_idx = _myArray select (_y select _z);
|
||||
/*diag_log (format ["fa_removeExtraTents: will remove Tent ID=%1, owner=%2",
|
||||
_idx select 1,
|
||||
_idx select 3
|
||||
]);*/
|
||||
_idx set [ 8, 1 ]; // Set damage to 100%
|
||||
_emptytenttotal = _emptytenttotal - 1;
|
||||
_tentcur set [_x, _z + 1];
|
||||
_stall=0;
|
||||
};
|
||||
};
|
||||
_z =_z + 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// check that vehicles list from the Hive has the right count of each vehicle
|
||||
// if some vehicles are missing, add them to the array
|
||||
// if a vehicle is illegal or outnumbered, delete it
|
||||
fa_checkVehicles = {
|
||||
private ["_vehcat", "_myArray", "_y", "_j","_type", "_count", "_idKey" ];
|
||||
_myArray = _this select 0;
|
||||
|
||||
// populate catalogue by browsing configFile
|
||||
_vehcat = [];
|
||||
_list = configFile >> "CfgPatches" >> "vehMaint";
|
||||
for "_x" from 0 to (count _list - 1) do {
|
||||
_class = configname (_list select _x);
|
||||
_qty = getNumber(CONFIGBASE_VEHMAINTENANCE >> _class >> "quantity");
|
||||
if (_qty > 0) then {
|
||||
_vehcat set [count _vehcat, [_class, _qty]];
|
||||
// diag_log(format["class:%1 val:%2", _class, _qty]);
|
||||
};
|
||||
};
|
||||
|
||||
// check the amount of vehicles of each kind
|
||||
{
|
||||
_type = _x select 2;
|
||||
for "_j" from 0 to (count _vehcat-1) do {
|
||||
if (_type == ((_vehcat select _j) select 0)) then {
|
||||
_count = ((_vehcat select _j) select 1);
|
||||
if (_count > 0) then {
|
||||
(_vehcat select _j) set [1, (_count-1)];
|
||||
if ((_x select 8) >= 1) then {
|
||||
#ifdef VEH_MAINTENANCE_ADD_MISSING
|
||||
(_myArray select _forEachIndex) set [8, 0.9] ; // damage = 0.9 so this veh will me respawned
|
||||
diag_log (format["fa_checkVehicles: recycling vehicle class=%1, oid=%2", _x select 2, _x select 1]);
|
||||
#endif
|
||||
};
|
||||
}
|
||||
#ifdef VEH_MAINTENANCE_IGNORE_UNKNOWN
|
||||
else {
|
||||
(_myArray select _forEachIndex) set [8,2]; // damage=2, so this veh will be deleted
|
||||
diag_log (format["fa_checkVehicles: skipping vehicle class=%1, oid=%2",
|
||||
_x select 2, _x select 1]);
|
||||
}
|
||||
#endif
|
||||
;_j = 999999; // break;
|
||||
};
|
||||
};
|
||||
} foreach _myArray;
|
||||
|
||||
#ifdef VEH_MAINTENANCE_ADD_MISSING
|
||||
// create missing vehicles of each kind.
|
||||
{
|
||||
for "_y" from 1 to (_x select 1) do {
|
||||
// create a new one at the end of _myArray list
|
||||
_type = (_x select 0);
|
||||
_idKey = format["%1%2",48,60000+floor(random 10000)];
|
||||
// "1" as Character ID since if I put "0" the vehicle is not stored in hive (since january 2013)
|
||||
_myArray set [count _myArray, ["CREATED",_idKey,_type,"1",[0,[0,0,0]],[[[],[]],[[],[]],[[],[]]],[],0,0.9]];
|
||||
diag_log (format["fa_checkVehicles: inserting in HIVE: vehicle class=%1, chosen oid=%2", _type, _idKey]);
|
||||
};
|
||||
} foreach _vehcat;
|
||||
#endif
|
||||
};
|
||||
|
||||
// move object to map boundary if it's out of map
|
||||
fa_staywithus = {
|
||||
|
||||
private["_a","_dir","_px","_py","_cx","_cy","_k", "_SWcorner", "_NEcorner"];
|
||||
|
||||
_dir = +(_this select 0); // current position of player / vehicle
|
||||
_a = +(_this select 1); // current position of player / vehicle
|
||||
|
||||
_SWcorner = getArray(CONFIGBASE_VEHMAINTENANCE >> (worldName) >> "SWcorner");
|
||||
_NEcorner = getArray(CONFIGBASE_VEHMAINTENANCE >> (worldName) >> "NEcorner");
|
||||
|
||||
_a = ASLtoATL [_a select 0, _a select 1, 0];
|
||||
if ((((_a select 2) > 9) AND {(surfaceisWater _a)}) // entity in water and sea depth above 9 meters?
|
||||
OR {(_a call fa_isoutofmap)}) then { // or entity is out of map?
|
||||
// first : put object close to the map boundary, following an axis to the center of the map.
|
||||
_px = _a select 0;
|
||||
_py = _a select 1;
|
||||
|
||||
_cx = (dayz_centerMarker select 0) - _px; if (_cx == 0) then { _cx = 0.00001; };
|
||||
_cy = (dayz_centerMarker select 1) - _py; if (_cy == 0) then { _cy = 0.00001; };
|
||||
if (_px <= (_SWcorner select 0)) then { _py = _py + (1 + (_SWcorner select 0) - _px) / _cx * _cy; _px = 1 + (_SWcorner select 0); };
|
||||
if (_py <= (_SWcorner select 1)) then { _px = _px + (1 + (_SWcorner select 1) - _py) / _cy * _cx; _py = 1 + (_SWcorner select 1); };
|
||||
if (_px >= (_NEcorner select 0)) then { _py = _py + ((_NEcorner select 0) - 1 - _px) / _cx * _cy; _px = (_NEcorner select 0) - 1; };
|
||||
if (_py >= (_NEcorner select 1)) then { _px = _px + ((_NEcorner select 1) - 1 - _py) / _cy * _cx; _py = (_NEcorner select 1) - 1; };
|
||||
// 2nd: compute the object direction, so that it heads toward the center of the map.
|
||||
_dir = atan(_cx / _cy);
|
||||
if (_cy < 0) then { _dir = _dir + 180; };
|
||||
|
||||
// 3rd: if the object is on shalow sea, make it virtually swim so that sea depth is below 9 meters.
|
||||
_a = [_px,_py,0];
|
||||
for "_k" from 0 to 1 step 0.005 do {
|
||||
_a = [_px + _cx * _k, _py + _cy * _k, 0];
|
||||
// if ((_k*200) mod 5 == 4) then { diag_log (format["fa_staywithus: a:%1 water:%2 zx:%3", _a, surfaceisWater _a, (getPosATL _o) select 2]); };
|
||||
if (surfaceisWater _a) then {
|
||||
_a = ASLtoATL [_a select 0, _a select 1, 0];
|
||||
if (((_a select 2) < 9) AND{(!(_a call fa_isoutofmap))}) then { _k = 2; }
|
||||
else { if ((_a select 2) < 30) then { _k = _k - 0.0045; };}; // slow down on the axis
|
||||
}
|
||||
else {
|
||||
if (!(_a call fa_isoutofmap)) then { _k = 2; };
|
||||
};
|
||||
};
|
||||
/*diag_log (format["FACO out-of-map new pos:%1 direction:%2 in water:%3 out-of-map:%4 ",
|
||||
(getPosATL _o) call fa_coor2str,
|
||||
round(_dir),
|
||||
surfaceisWater _a,
|
||||
(if ([_a] call fa_isoutofmap == 1) then { true } else { false })
|
||||
]);*/
|
||||
};
|
||||
|
||||
// cancel the change if it is too near original pos
|
||||
if (([(_this select 1),_a] call BIS_fnc_distance2Dsqr) <= 30) then {
|
||||
[_this select 0, +(_this select 1)]
|
||||
}
|
||||
else {
|
||||
[ _dir, [_a select 0, _a select 1, 0]]
|
||||
}
|
||||
};
|
||||
|
||||
FNC_kindOf = {
|
||||
_inherit = inheritsFrom _this;
|
||||
_list = [configName _this];
|
||||
while { (configName _inherit) != "" } do {
|
||||
_list set[count _list,configName _inherit];
|
||||
_inherit = inheritsFrom( _inherit );
|
||||
};
|
||||
_list
|
||||
};
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
private ["_SWcorner","_NEcorner","_amount","_a","_b","_c"];
|
||||
|
||||
#define CONFIGBASE_VEHMAINTENANCE configFile >> "CfgPatches" >> "vehMaint"
|
||||
|
||||
if (toLower worldName == "chernarus") then {
|
||||
_SWcorner = getArray(CONFIGBASE_VEHMAINTENANCE >> (worldName) >> "SWcorner");
|
||||
_NEcorner = getArray(CONFIGBASE_VEHMAINTENANCE >> (worldName) >> "NEcorner");
|
||||
} else {
|
||||
// Not used, plant spawner is disabled on other maps for now, may add town generator and other coordinates later
|
||||
_SWcorner = [0,1360];
|
||||
_NEcorner = [14400,13560];
|
||||
};
|
||||
_SWcorner = [0,1360];
|
||||
_NEcorner = [14400,13560];
|
||||
|
||||
_a = [(_SWcorner select 0), (_SWcorner select 1), (_NEcorner select 0) - (_SWcorner select 0), (_NEcorner select 1) - (_SWcorner select 1) ] call psrnd_init;
|
||||
_b = [ -15, -15, 30, 30 ] call psrnd_init;
|
||||
|
||||
Reference in New Issue
Block a user