Skip to content

Commit

Permalink
⛽ Fuel Support Rework (#2251)
Browse files Browse the repository at this point in the history
* first commit

* Changes fuel balancing

* sell vehicle indent fix

* Land_vn_usaf_fueltank_75_01 added

* frost money changes

* temp commit for help

* yessssssssssssssssssssssssss, Fixed array not being array

Co-authored-by: HakonRydland <HakonRydland@users.noreply.github.com>

* _insufficientFunds variable name

Co-authored-by: HakonRydland <HakonRydland@users.noreply.github.com>
  • Loading branch information
killerswin2 and HakonRydland committed Feb 15, 2022
1 parent 73e2cd6 commit 8e485c2
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 27 deletions.
20 changes: 11 additions & 9 deletions A3A/addons/Garage/Public/fn_addVehicle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,18 @@ if (_class in [FactionGet(occ,"surrenderCrate"), FactionGet(inv,"surrenderCrate"
true
};


//Utility refund and Fuel refund
//Utility refund
if (_vehicle getVariable ['A3A_canGarage', false]) exitwith{
if (_class in [FactionGet(reb,"vehicleFuelDrum"), FactionGet(reb,"vehicleFuelTank")]) then {
[floor (
[_vehicle] call A3A_fnc_remainingFuel *
(_vehicle getVariable ['A3A_itemPrice', 0])
)] remoteExec ["A3A_fnc_resourcesPlayer", _client];
["STR_HR_GRG_Feedback_addVehicle_Fuel_sold"] remoteExec ["HR_GRG_fnc_Hint", _client];
deleteVehicle _vehicle;
if (_class in [FactionGet(reb,"vehicleFuelDrum") # 0, FactionGet(reb,"vehicleFuelTank") # 0]) then {
if (_player isEqualTo theBoss) then {
[floor (
([_vehicle] call A3A_fnc_remainingFuel) * (_vehicle getVariable ['A3A_itemPrice', 0])
)] remoteExec ["A3A_fnc_resourcesPlayer", _client];
["STR_HR_GRG_Feedback_addVehicle_Fuel_sold"] remoteExec ["HR_GRG_fnc_Hint", _client];
deleteVehicle _vehicle;
} else {
["STR_HR_GRG_Feedback_addVehicle_Fuel_commander_only"] remoteExec ["HR_GRG_fnc_Hint", _client];
};
} else {
[_vehicle getVariable ['A3A_itemPrice', 0]] remoteExec ["A3A_fnc_resourcesPlayer", _client];
["STR_HR_GRG_Feedback_addVehicle_Item_Stored"] remoteExec ["HR_GRG_fnc_Hint", _client];
Expand Down
4 changes: 4 additions & 0 deletions A3A/addons/Garage/Stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@
<Original>Fuel sold</Original>
<English>Fuel sold</English>
</Key>
<Key ID="STR_HR_GRG_Feedback_addVehicle_Fuel_commander_only">
<Original>Fuel sources can only be garaged by commander</Original>
<English>Fuel sources can only be garaged by commander</English>
</Key>
<Key ID="STR_HR_GRG_Feedback_addVehicle_Distance">
<Original>You can't garage vehicles that are more than 25m away from you</Original>
<English>You can't garage vehicles that are more than 25m away from you</English>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
["flyGear", ["U_I_pilotCoveralls"]] call _fnc_saveToTemplate;

["vehicleLightSource", "Land_LampShabby_F"] call _fnc_saveToTemplate;
["vehicleFuelDrum", ["FlexibleTank_01_forest_F", 80]] call _fnc_saveToTemplate;
["vehicleFuelDrum", ["FlexibleTank_01_forest_F", 160]] call _fnc_saveToTemplate;
["vehicleFuelTank", ["B_Slingload_01_Fuel_F", 1000]] call _fnc_saveToTemplate;
28 changes: 18 additions & 10 deletions A3A/addons/core/functions/UtilityItems/fn_buyItem.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Author: [Killerswin2, Håkon]
trys to purchase a item and places it near the player. Damage for the object is disabled.
Arguments:
0. <object> Unit that will be buying a light
1. <array> Item classname
1. <string> Item classname
2. <number> price of item
3. <array> callback functions, [[name, isGlobal - > true if need exec]]
Expand Down Expand Up @@ -37,18 +37,26 @@ if (_price == 0) exitwith {};
private _lastTimePurchase = _unit getVariable["A3A_spawnItem_cooldown",time];
if (_lastTimePurchase > time) exitwith {["Item Purchase", format ["You already bought one, wait %1 seconds before you can buy another.", ceil (_lastTimePurchase - time)]] call A3A_fnc_customHint;};

//find out if we have money
private _money = player getVariable ["moneyX", 0];

if (_money < _price) exitwith {["Item Purchase", "You can't afford this Item."] call A3A_fnc_customHint};
_unit setVariable["A3A_spawnItem_cooldown", time + 15];

//take money away
[-_price] call A3A_fnc_resourcesPlayer;
//try to take money away 😞
private _insufficientFunds = isNil {
if (_unit == theBoss && (server getVariable ["resourcesFIA", 0]) >= _price) then {
[0,(-_price)] remoteExec ["A3A_fnc_resourcesFIA",2];
true;
} else {
if ((_unit getVariable ["moneyX", 0]) >= _price) then {
[-_price] call A3A_fnc_resourcesPlayer;
true;
};
};
};
if (_insufficientFunds) exitwith {["Item Purchase", "You can't afford this Item."] call A3A_fnc_customHint};

//had money for item
_unit setVariable ["A3A_spawnItem_cooldown", time + 15];

//spawn the Item
_position = (getPos _unit vectorAdd [3,0,0]) findEmptyPosition [1,10,_spawnItem];
private _position = (getPos _unit vectorAdd [3,0,0]) findEmptyPosition [1,10,_spawnItem];
if (_position isEqualTo []) then {_position = getPos _unit};
private _item = _spawnItem createVehicle _position;
_item allowDamage false;
Expand All @@ -64,6 +72,6 @@ _item setVariable ["A3A_itemPrice", _price, true];
private _jipKey = "A3A_utilityItems_item_" + ((str _item splitString ":") joinString "");
[_item, _jipKey] remoteExecCall [_func_name, 0, _jipKey];
} else {
[_item] spawn (missionNamespace getVariable _func_name);
[_item] call (missionNamespace getVariable _func_name);
};
} foreach (_callbacks);
6 changes: 3 additions & 3 deletions A3A/addons/core/functions/init/fn_initClient.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -401,16 +401,16 @@ if (A3A_hasACE) then { [vehicleBox, VehicleBox] call ace_common_fnc_claim;}; //D
}},nil,0,false,true,"","(isPlayer _this) and (_this == _this getVariable ['owner',objNull]) and (side (group _this) == teamPlayer)", 4];
#endif
vehicleBox addAction ["Move this asset", A3A_fnc_moveHQObject,nil,0,false,true,"","(_this == theBoss)", 4];
vehicleBox addAction ["Buy Light for 25€", {[player, 'vehicleLightSource', 25, [['A3A_fnc_initMovableObject', 0]]] call A3A_fnc_buyItem},nil,0,false,true,"","true",4];
vehicleBox addAction ["Buy Light for 25€", {[player, FactionGet(reb,"vehicleLightSource"), 25, [['A3A_fnc_initMovableObject', false]]] call A3A_fnc_buyItem},nil,0,false,true,"","true",4];
private _fuelDrum = FactionGet(reb,"vehicleFuelDrum");
private _fuelTank = FactionGet(reb,"vehicleFuelTank");
if (isClass (configFile/"CfgVehicles"/_fuelDrum # 0)) then {
private _dispName = getText (configFile/"CfgVehicles"/_fuelDrum # 0/"displayName");
vehicleBox addAction [format["Buy %1 for %2€",_dispName, _fuelDrum # 1], {[player, _this # 3 # 0, _this # 3 # 1, [['A3A_fnc_initMovableObject', true], ['A3A_fnc_logistics_addLoadAction', false]]] call A3A_fnc_buyItem},_fuelDrum,0,false,true,"","true",4];
vehicleBox addAction [format["Buy %1 for %2€",_dispName, _fuelDrum # 1], {[player, _this # 3 # 0, _this # 3 # 1, [['A3A_fnc_initMovableObject', true], ['A3A_fnc_logistics_addLoadAction', false]]] call A3A_fnc_buyItem},_fuelDrum,0,false,true,"","_this == theBoss",4];
};
if (isClass (configFile/"CfgVehicles"/_fuelTank # 0)) then {
private _dispName = getText (configFile/"CfgVehicles"/_fuelTank # 0/"displayName");
vehicleBox addAction [format["Buy %1 for %2€",_dispName, _fuelTank # 1], {[player, _this # 3 # 0, _this # 3 # 1, [['A3A_fnc_logistics_addLoadAction', false]]] call A3A_fnc_buyItem},_fuelTank,0,false,true,"","true",4];
vehicleBox addAction [format["Buy %1 for %2€",_dispName, _fuelTank # 1], {[player, _this # 3 # 0, _this # 3 # 1, [['A3A_fnc_initMovableObject', true], ['A3A_fnc_logistics_addLoadAction', false]]] call A3A_fnc_buyItem},_fuelTank,0,false,true,"","_this == theBoss",4];
};
call A3A_fnc_dropObject;

Expand Down
7 changes: 4 additions & 3 deletions A3A/addons/core/functions/init/fn_initZones.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,11 @@ A3A_fuelStations apply {
_mrkFinalFuel = createMarker [format ["Ant%1", mapGridPosition _x], position _x];
_mrkFinalFuel setMarkerShape "ICON";
_mrkFinalFuel setMarkerType "loc_Fuelstation";
_mrkFinalFuel setMarkerColor "ColorPink";
_mrkFinalFuel setMarkerText "fuel station";
_mrkFinalFuel setMarkerColor "ColorGrey";
_mrkFinalFuel setMarkerText "Fuel station";
_mrkFinalFuel setMarkerAlpha 0.75;
if(A3A_hasACE) then {
[_x, 10000] call ace_refuel_fnc_setFuel; // only call on fuels that are not blacklisted and first zone init.
[_x, 250] call ace_refuel_fnc_setFuel; // only call on fuels that are not blacklisted and first zone init.
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class cam_lao_nam {
{},{"airport_5","outpost_33","outpost_34","resource_4","seaport_3","outpost_15","outpost_22","outpost_8","outpost_4","resource_9","outpost_21","resource_14","outpost_3","outpost_2","factory_3","outpost_1","outpost_7","seaport_2","outpost_32","airport_1","outpost_23","outpost_10","outpost_5","outpost_16","outpost_6","outpost_11","resource_6","resource_20","outpost_9","outpost_38"},{},{"control_1","control_2","control_3","control_4","control_5","control_6","control_7","control_8","control_9","control_10","control_11","control_12","control_13","control_14","control_15","control_16","control_17","control_18","control_19","control_20","control_21","control_22","control_23","control_24","control_25","control_26","control_27","control_28","control_29"}
};
fuelStationTypes[] = {
"Land_vn_fuelstation_01_pump_f","Land_vn_fuelstation_02_pump_f","Land_vn_fuelstation_feed_f"
"Land_vn_fuelstation_01_pump_f","Land_vn_fuelstation_02_pump_f","Land_vn_fuelstation_feed_f","Land_vn_usaf_fueltank_75_01"
};
climate = "tropical";
};

0 comments on commit 8e485c2

Please sign in to comment.