Epoch/Sources/epoch_code/compile/vehicles/EPOCH_client_VehicleMaintananceCheck.sqf

81 lines
2.7 KiB
Plaintext
Raw Normal View History

2017-07-31 16:28:18 +00:00
/*
Author: He-Man - Ignatz-Gaming
Contributors:
Description:
Check for repairable / replaceable and removeable Vehicle-parts
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/release/Sources/epoch_code/compile/vehicles/EPOCH_client_VehicleMaintananceCheck.sqf
*/
2017-09-25 17:04:24 +00:00
private ["_veh","_VehicleRepairs","_EnableRemoveParts","_repairs","_removes","_replaces","_wheels","_wheelcounter","_HitPointName","_Hit","_wheel","_repairarrays"];
2017-07-31 16:28:18 +00:00
_veh = _this;
_VehicleRepairs = ["CfgEpochClient", "VehicleRepairs", []] call EPOCH_fnc_returnConfigEntryV2;
_EnableRemoveParts = ["CfgEpochClient", "EnableRemoveParts", true] call EPOCH_fnc_returnConfigEntryV2;
2017-07-31 16:28:18 +00:00
_repairs = [];
_removes = [];
_replaces = [];
_wheels = getnumber (configfile >> "cfgvehicles" >> (typeof _veh) >> "numberPhysicalWheels");
if (_veh iskindof "ebike_epoch") then {
_wheels = 2;
};
_wheelcounter = 0;
{
2018-04-12 22:15:07 +00:00
_HitPointName = tolower _x;
2017-07-31 16:28:18 +00:00
_Hit = (getAllHitPointsDamage _veh) select 2 select _foreachindex;
{
_x params ["_searchedhit","_limit1","_limit2"];
2018-04-12 22:15:07 +00:00
_searchedhit = tolower _searchedhit;
2017-07-31 16:28:18 +00:00
if (_searchedhit isequalto _HitPointName) then {
_wheel = ["wheel",tolower _searchedhit] call bis_fnc_instring;
if (_wheel) then {
_wheelcounter = _wheelcounter + 1;
};
if (_wheel && _wheelcounter > _wheels) exitwith {};
if (_Hit >= _limit2) exitwith {
_replaces pushback _searchedhit;
};
if (_Hit >= _limit1) exitwith {
_repairs pushback _searchedhit;
};
if (!((_veh getvariable ["vehicle_slot","-1"]) isequalto "-1") && _EnableRemoveParts) then {
2017-07-31 16:28:18 +00:00
if (_searchedhit in ["HitLFWheel","HitLF2Wheel","HitLMWheel","HitLBWheel","HitRFWheel","HitRF2Wheel","HitRMWheel","HitRBWheel","HitEngine"]) then {
_removes pushback _searchedhit;
};
};
}
else {
if (_searchedhit isequalto "glass") then {
if ("glass" in _repairs) exitwith {};
_glass = ["glass",tolower _HitPointName] call bis_fnc_instring;
if (_glass) then {
if (_Hit >= _limit1) exitwith {
_repairs pushback _searchedhit;
};
};
};
};
} foreach _VehicleRepairs;
} foreach ((getAllHitPointsDamage _veh) select 0);
2017-09-25 17:04:24 +00:00
_repairarrays = [];
2017-07-31 16:28:18 +00:00
{
2017-09-25 17:04:24 +00:00
if (!(_x in _repairs || _x in _replaces || (["glass",tolower _x] call Bis_fnc_instring)) || _x isequalto "") then {
_repairarrays pushback [_foreachindex, 0];
2017-07-31 16:28:18 +00:00
};
} foreach ((getAllHitPointsDamage _veh) select 0);
2017-09-25 17:04:24 +00:00
if !(_repairarrays isequalto []) then {
2017-07-31 16:28:18 +00:00
if (local _veh) then {
[_veh, _repairarrays] call EPOCH_client_repairVehicle;
} else {
[_veh,_repairarrays,player,Epoch_personalToken] remoteExec ["EPOCH_server_repairVehicle",2];
};
};
2017-09-25 17:04:24 +00:00
EPOCH_VehicleRepairs = [_repairs,_removes,_replaces];