trade: calc damage %, return new cost

This commit is contained in:
Raymix 2017-08-03 19:32:55 +01:00
parent ce70600c86
commit 3abac17557
2 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,35 @@
/*
Author: Raimonds Virtoss - EpochMod.com
Contributors:
Description: Takes in total cost of vehicle and returns new price with damage % taken into account
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/gui/scripts/favBar/epoch_favBar_refresh.sqf
Usage: [_vehOBJ,_costINT] call EPOCH_calcDamageCost;
*/
private ["_dmg","_hitPoints"];
params [["_obj",objNull, [objNull]],["_cost",0, [0]]];
if (_obj isEqualTo objNull) exitWith {-1};
_hitPoints = getAllHitPointsDamage _obj;
_totalHPoints = count (_hitPoints select 1);
_totalDamagedPoints = 0;
{
_dmg = _hitPoints select 2 select _forEachIndex;
if (_dmg > 0) then {
_totalDamagedPoints = _totalDamagedPoints +1;
};
} forEach (_hitPoints select 1);
_math = round (_totalDamagedPoints / _totalHPoints * 100);
_newCost = _cost - _math;
_newCost

View File

@ -72,6 +72,7 @@ class CfgClientFunctions
class tradeFilter {};
class takeCrypto {};
class startBankTransfer {};
class calcDamageCost {};
};
class interface_event_handlers
{