diff --git a/A3A/addons/core/functions/REINF/fn_vehiclePrice.sqf b/A3A/addons/core/functions/REINF/fn_vehiclePrice.sqf index b1b6469a72..fe524f1ffb 100644 --- a/A3A/addons/core/functions/REINF/fn_vehiclePrice.sqf +++ b/A3A/addons/core/functions/REINF/fn_vehiclePrice.sqf @@ -3,29 +3,35 @@ FIX_LINE_NUMBERS() params ["_typeX"]; -private _costs = server getVariable _typeX; +private _costs = 0; + +if (isNil "_typeX") then +{ + Error_1("Vehicle does not exist."); + _costs = 0; +} +else +{ + _costs = server getVariable _typeX; +}; if (isNil "_costs") then - { - Error_1("Invalid vehicle price :%1.", _typeX); +{ + Error_1("Invalid vehicle price :%1.", _typeX); _costs = 0; - } +} else +{ + if (count seaports > 3) then + { + private _numFriendlySeaports = ({sidesX getVariable [_x,sideUnknown] == teamPlayer} count seaports) min 6; + _costs = round (_costs - (_costs * 0.05 * _numFriendlySeaports)); + } + else { - if (count seaports > 3) then { - private _numFriendlySeaports = ({sidesX getVariable [_x,sideUnknown] == teamPlayer} count seaports) min 6; - _costs = round (_costs - (_costs * 0.05 * _numFriendlySeaports)); - } else { - _discount = switch (true) do { - case (tierWar in [1,2]): { 0 }; - case (tierWar in [3,4]): { 0 }; - case (tierWar in [5,6]): { 1 }; - case (tierWar in [7,8]): { 2 }; - case (tierWar in [9,10]): { 3 }; - default { 0 }; - }; - _costs = round (_costs - (_costs * 0.1 * _discount)); - }; + _discount = 0 max ((tierWar - 4) * 0.5); //4 is the last war tier before discounts, the 0.5 makes the discount go from 0-3 instead of 0-6. + _costs = 5 * round ((_costs - (_costs * 0.1 * _discount))/5); //Applies the discount, rounds to the nearest 5€ }; +}; _costs