Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update fn_vehiclePrice to not fail on absent vehicles. #3228

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions A3A/addons/core/functions/REINF/fn_vehiclePrice.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Tiny-DM marked this conversation as resolved.
Show resolved Hide resolved
Tiny-DM marked this conversation as resolved.
Show resolved Hide resolved
_costs = 5 * round ((_costs - (_costs * 0.1 * _discount))/5); //Applies the discount, rounds to the nearest 5€
};
};

_costs