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

Fix multiple rebel squad/vehicle price bugs #2151

Merged
Merged
Show file tree
Hide file tree
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
19 changes: 8 additions & 11 deletions A3-Antistasi/REINF/dismissSquad.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private _assignedVehicles = [];
{
_hr = _hr + 1;
_resourcesFIA = _resourcesFIA + (server getVariable [_x getVariable "unitType",0]);
if (!isNull (assignedVehicle _x)) then
if (!isNull (assignedVehicle _x) and {isNull attachedTo (assignedVehicle _x)}) then
HakonRydland marked this conversation as resolved.
Show resolved Hide resolved
{
_assignedVehicles pushBackUnique (assignedVehicle _x);
};
Expand All @@ -65,17 +65,14 @@ private _assignedVehicles = [];

{
private _veh = _x;
if ((typeOf _veh) in vehFIA) then
if !(typeOf _veh in vehFIA) then { continue };
_resourcesFIA = _resourcesFIA + ([typeOf _veh] call A3A_fnc_vehiclePrice);
{
_resourcesFIA = _resourcesFIA + ([(typeOf _veh)] call A3A_fnc_vehiclePrice);
if (count attachedObjects _veh > 0) then
{
_subVeh = (attachedObjects _veh) select 0;
_resourcesFIA = _resourcesFIA + ([(typeOf _subVeh)] call A3A_fnc_vehiclePrice);
deleteVehicle _subVeh;
};
deleteVehicle _veh;
};
if !(typeOf _x in vehFIA) then { continue };
_resourcesFIA = _resourcesFIA + ([typeOf _x] call A3A_fnc_vehiclePrice);
deleteVehicle _x;
} forEach attachedObjects _veh;
deleteVehicle _veh;
} forEach _assignedVehicles;

_nul = [_hr,_resourcesFIA] remoteExec ["A3A_fnc_resourcesFIA",2];
8 changes: 4 additions & 4 deletions A3-Antistasi/functions/REINF/fn_addFIAsquadHC.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ if (_typeGroup isEqualType []) then {

} else {
_costs = _costs + (2*(server getVariable staticCrewTeamPlayer)) + ([_typeGroup] call A3A_fnc_vehiclePrice);
if (_typeGroup == staticAAteamPlayer) then { _costs = _costs + ([vehSDKTruck] call A3A_fnc_vehiclePrice) };
_formatX = [staticCrewTeamPlayer,staticCrewTeamPlayer];
_costHR = 2;

if ((_typeGroup == SDKMortar) or (_typeGroup == SDKMGStatic)) exitWith { _isInfantry = true };
_costs = _costs + ([vehSDKTruck] call A3A_fnc_vehiclePrice)
};

if ((_withBackpck != "") and A3A_hasIFA) exitWith {["Recruit Squad", "Your current modset doesn't support packing/unpacking static weapons."] call A3A_fnc_customHint;};
Expand Down Expand Up @@ -110,8 +110,8 @@ private _vehiclePlacementMethod = if (getMarkerPos respawnTeamPlayer distance pl
if (!_isInfantry) exitWith { [_vehType, "HCSquadVehicle", [_formatX, _idFormat, _special], _mounts] call _vehiclePlacementMethod };

private _vehCost = [_vehType] call A3A_fnc_vehiclePrice;
if ((_costs + _vehCost) > server getVariable "resourcesFIA") exitWith {
["Recruit Squad", format ["You do not have enough money for this request (%1 € required).",_vehCost]] call A3A_fnc_customHint;
if (_isInfantry and (_costs + _vehCost) > server getVariable "resourcesFIA") exitWith {
["Recruit Squad", format ["No money left to buy a transport vehicle (%1 € required), creating barefoot squad.",_vehCost]] call A3A_fnc_customHint;
[_formatX, _idFormat, _special, objNull] spawn A3A_fnc_spawnHCGroup;
};

Expand All @@ -122,7 +122,7 @@ private _display = findDisplay 100;

if (str (_display) != "no display") then {
private _ChildControl = _display displayCtrl 104;
_ChildControl ctrlSetTooltip format ["Buy a vehicle for this squad for %1 €.",_costs];
_ChildControl ctrlSetTooltip format ["Buy a vehicle for this squad for %1 €.", _vehCost];
_ChildControl = _display displayCtrl 105;
_ChildControl ctrlSetTooltip "Barefoot Infantry";
};
Expand Down
10 changes: 8 additions & 2 deletions A3-Antistasi/functions/REINF/fn_spawnHCGroup.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ params [
, ["_vehicle", objNull, [objNull]]
];

//calculate cost
//calculate base cost
private _cost = if (isNull _vehicle) then { 0 } else { [typeOf _vehicle] call A3A_fnc_vehiclePrice };
private _costHR = 0;
{
_cost = _cost + (server getVariable _x); _costHR = _costHR +1
} forEach _unitTypes;
[- _costHR, - _cost] remoteExec ["A3A_fnc_resourcesFIA", 2];

//spawn group
private _pos = [(getMarkerPos respawnTeamPlayer), 30, random 360] call BIS_Fnc_relPos;
Expand Down Expand Up @@ -82,6 +81,7 @@ switch _special do {
call _initInfVeh;
_group setVariable ["staticAutoT",false,true];
[_group, _staticType] spawn A3A_fnc_MortyAI;
_cost = _cost + ([_staticType] call A3A_fnc_vehiclePrice);
};

//vehicle squad
Expand All @@ -90,6 +90,8 @@ switch _special do {
(_units # (_countUnits -1)) assignAsDriver _vehicle;
(_units # _countUnits) assignAsGunner _static;
call _initVeh;
_cost = _cost + ([staticAAteamPlayer] call A3A_fnc_vehiclePrice);

};
case "VehicleSquad": {
(_units # (_countUnits -1)) assignAsDriver _vehicle;
Expand All @@ -103,13 +105,17 @@ switch _special do {
case "MG": {
(_units # (_countUnits - 1)) addBackpackGlobal supportStaticsSDKB2;
(_units # _countUnits) addBackpackGlobal MGStaticSDKB;
_cost = _cost + ([SDKMGStatic] call A3A_fnc_vehiclePrice);
};
case "Mortar": {
(_units # (_countUnits - 1)) addBackpackGlobal supportStaticsSDKB3;
(_units # _countUnits) addBackpackGlobal MortStaticSDKB;
_cost = _cost + ([SDKMortar] call A3A_fnc_vehiclePrice);
};
};

[- _costHR, - _cost] remoteExec ["A3A_fnc_resourcesFIA", 2];

if !(_bypassAI) then {_group spawn A3A_fnc_attackDrillAI};

_group
2 changes: 2 additions & 0 deletions A3-Antistasi/functions/init/fn_initVarServer.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ private _vehUnlimited = vehNATONormal + vehCSATNormal + [vehNATORBoat,vehNATOPat
DECLARE_SERVER_VAR(vehUnlimited, _vehUnlimited);

private _vehFIA = [vehSDKBike,vehSDKAT,vehSDKLightArmed,SDKMGStatic,vehSDKLightUnarmed,vehSDKTruck,vehSDKBoat,SDKMortar,staticATteamPlayer,staticAAteamPlayer,vehSDKRepair];
if (vehSDKAA != "not_supported") then { _vehFIA pushBack vehSDKAA };
DECLARE_SERVER_VAR(vehFIA, _vehFIA);

private _vehCargoTrucks = (vehTrucks + vehNATOCargoTrucks) select { [_x] call A3A_fnc_logistics_getVehCapacity > 1 };
Expand Down Expand Up @@ -758,6 +759,7 @@ server setVariable [vehSDKTruck,300,true]; //300
{server setVariable [_x,700,true]} forEach [vehSDKLightArmed,vehSDKAT];
{server setVariable [_x,400,true]} forEach [SDKMGStatic,vehSDKBoat,vehSDKRepair]; //400
{server setVariable [_x,800,true]} forEach [SDKMortar,staticATteamPlayer,staticAAteamPlayer]; //800
server setVariable [vehSDKAA,1100,true]; // should be vehSDKTruck + staticAAteamPlayer otherwise things will break

///////////////////////
// GARRISONS ///
Expand Down