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

Fuel part2 #2207

Merged
merged 30 commits into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
efa2997
rename spawnLight, added price to item, add callback
killerswin2 Nov 4, 2021
183e8b7
removed dev
killerswin2 Nov 4, 2021
e848631
update header
killerswin2 Nov 4, 2021
52ca8e5
changed spawned veh fuel
killerswin2 Nov 4, 2021
2804061
added nodes
killerswin2 Nov 4, 2021
899071f
final touches, changed hints, and nodes
killerswin2 Nov 4, 2021
9c8a073
changed vehicleFuelSource to array
killerswin2 Nov 5, 2021
9ae54e1
add selling fuel capped to remaining amount
killerswin2 Nov 5, 2021
9a2bcb9
removed fuel canister
killerswin2 Nov 5, 2021
999d8a7
Merge branch 'fuel' into fuelPart2
killerswin2 Nov 5, 2021
80dfb5c
changes for review
killerswin2 Nov 5, 2021
2987028
Merge branch 'unstable' into fuel
killerswin2 Nov 8, 2021
85ababb
Merge branch 'fuel' into fuelPart2
killerswin2 Nov 8, 2021
60cfe10
init work
killerswin2 Nov 22, 2021
bbf17d1
saved fuel
killerswin2 Nov 27, 2021
9ebfd9d
review changes
killerswin2 Dec 5, 2021
000b363
error checking
killerswin2 Dec 5, 2021
153b3e0
review change
killerswin2 Dec 6, 2021
d7cbe08
Merge branch 'fuel' into fuelPart2
killerswin2 Jan 8, 2022
f022940
added correct search
killerswin2 Jan 8, 2022
8f1e278
Merge branch 'unstable' into fuelPart2
killerswin2 Jan 9, 2022
cc3e720
added funnies, fixed readability
killerswin2 Jan 9, 2022
ece67e4
Merge branch 'fuelPart2' of https://github.com/killerswin2/A3-Antista…
killerswin2 Jan 9, 2022
a054a77
removed space
killerswin2 Jan 9, 2022
55ed80e
review changes
killerswin2 Jan 9, 2022
b87d527
updated save loop and loading
killerswin2 Jan 10, 2022
f44a3c0
added fuel types for supported maps
killerswin2 Jan 10, 2022
46f3831
Merge branch 'official-antistasi-community:unstable' into fuelPart2
killerswin2 Jan 10, 2022
7162c99
changes to saves
killerswin2 Jan 10, 2022
5e6874c
Merge branch 'fuelPart2' of https://github.com/killerswin2/A3-Antista…
killerswin2 Jan 10, 2022
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: 14 additions & 5 deletions A3-Antistasi/Garage/fn_addVehicle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,20 @@ if (_class in [FactionGet(occ,"surrenderCrate"), FactionGet(inv,"surrenderCrate"
true
};

//Utility refund
if (_vehicle getVariable['A3A_islight',false]) exitwith{
[25] remoteExec ["A3A_fnc_resourcesPlayer", _client];
["STR_HR_GRG_Feedback_addVehicle_LightSource_Stored"] remoteExec ["HR_GRG_fnc_Hint", _client];
deleteVehicle _vehicle;
//Utility refund and Fuel 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;
} else {
[_vehicle getVariable ['A3A_itemPrice', 0]] remoteExec ["A3A_fnc_resourcesPlayer", _client];
["STR_HR_GRG_Feedback_addVehicle_Item_Stored"] remoteExec ["HR_GRG_fnc_Hint", _client];
deleteVehicle _vehicle;
};
true
};

Expand Down
1 change: 1 addition & 0 deletions A3-Antistasi/Garage/fn_callbackHandler.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ switch _callBackName do {
_vehicle setVariable ["ownerX",getPlayerUID player,true];
};
vehiclePurchase_cost = 0;
_vehicle setFuel random [0.10, 0.175, 0.25];
};

default {false};
Expand Down
10 changes: 7 additions & 3 deletions A3-Antistasi/Stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3787,9 +3787,13 @@
<Original>Loot crate stored</Original>
<English>Loot crate stored</English>
</Key>
<Key ID="STR_HR_GRG_Feedback_addVehicle_LightSource_Stored">
<Original>Light stored</Original>
<English>Light stored</English>
<Key ID="STR_HR_GRG_Feedback_addVehicle_Item_Stored">
<Original>Item stored</Original>
<English>Item stored</English>
</Key>
<Key ID="STR_HR_GRG_Feedback_addVehicle_Fuel_sold">
<Original>Fuel sold</Original>
<English>Fuel sold</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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +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;
["vehicleFuelTank", ["B_Slingload_01_Fuel_F", 1000]] call _fnc_saveToTemplate;
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,11 @@ A3A_logistics_attachmentOffset = [

//small sized crates //location //rotation //size //description
["Box_NATO_Equip_F" call A3A_fnc_classNameToModel, [0,0,0.37], [1,0,0], 1], //Equipment box
["\A3\weapons_F\AmmoBoxes\WpnsBox_F", [0,0,0.17], [0,1,0], 1] //surrender crates
["\A3\weapons_F\AmmoBoxes\WpnsBox_F", [0,0,0.17], [0,1,0], 1], //surrender crates

//fuel containers
["FlexibleTank_01_forest_F"call A3A_fnc_classNameToModel, [0,0,0.37], [1,0,0], 1],
["B_Slingload_01_Fuel_F"call A3A_fnc_classNameToModel, [0,-0.25,1.35], [0,1,0], 7]
];

//all vehicles with jnl loading nodes where the nodes are not located in the open, this can be because its inside the vehicle or it has a cover over the loading plane.
Expand Down
3 changes: 2 additions & 1 deletion A3-Antistasi/functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,8 +753,9 @@ class A3A
class carryItem {};
class initMovableObject {};
class rotateItem {};
class spawnLight {};
class buyItem {};
class attachedObjects {};
class dropObject {};
class remainingFuel {}
};
};
2 changes: 2 additions & 0 deletions A3-Antistasi/functions/CREATE/fn_createCIV.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ while {(spawner getVariable _spawnKey != 2) and (_countParked < _numParked)} do
*/
_veh = _typeVehX createVehicle _pos;
_veh setDir _dirveh;
_veh setFuel random [0.10, 0.30, 0.50];
clearMagazineCargoGlobal _veh;
clearWeaponCargoGlobal _veh;
clearItemCargoGlobal _veh;
Expand Down Expand Up @@ -158,6 +159,7 @@ if ([_markerX,false] call A3A_fnc_fogCheck > 0.2) then
_typeVehX = selectRandomWeighted civVehiclesWeighted;
_veh = _typeVehX createVehicle (getPos _p1);
_veh setDir _dirveh;
_veh setFuel random [0.10, 0.30, 0.50];
clearMagazineCargoGlobal _veh;
clearWeaponCargoGlobal _veh;
clearItemCargoGlobal _veh;
Expand Down
1 change: 1 addition & 0 deletions A3-Antistasi/functions/Save/fn_loadServer.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if (isServer) then {
["membersX"] call A3A_fnc_getStatVariable;
["vehInGarage"] call A3A_fnc_getStatVariable;
["HR_Garage"] call A3A_fnc_getStatVariable;
["A3A_fuelAmountleftArray"] call A3A_fnc_getStatVariable;
["destroyedBuildings"] call A3A_fnc_getStatVariable;
["idlebases"] call A3A_fnc_getStatVariable;
["idleassets"] call A3A_fnc_getStatVariable;
Expand Down
30 changes: 29 additions & 1 deletion A3-Antistasi/functions/Save/fn_loadStat.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
Arguments:
0. <String> variable name or identifier for subroutine to run
1. <any> data that will be set
Return Value:
nil

Scope: Server
Environment: unscheduled
Public: yes
Dependencies:

Example:
[_varName,_varValue] call A3A_fnc_loadStat;
*/


//===========================================================================
//ADD VARIABLES TO THIS ARRAY THAT NEED SPECIAL SCRIPTING TO LOAD
/*specialVarLoads =
Expand Down Expand Up @@ -26,7 +43,7 @@ private _specialVarLoads = [
"garrison","tasks","smallCAmrk","membersX","vehInGarage","destroyedBuildings","idlebases",
"idleassets","chopForest","weather","killZones","jna_dataList","controlsSDK","mrkCSAT","nextTick",
"bombRuns","wurzelGarrison","aggressionOccupants", "aggressionInvaders",
"countCA", "attackCountdownInvaders", "testingTimerIsActive", "version", "HR_Garage"
"countCA", "attackCountdownInvaders", "testingTimerIsActive", "version", "HR_Garage","A3A_fuelAmountleftArray"
];

private _varName = _this select 0;
Expand Down Expand Up @@ -334,6 +351,17 @@ if (_varName in _specialVarLoads) then {
};
} forEach _varvalue;
};

if(_varname == 'A3A_fuelAmountleftArray') then {
A3A_fuelAmountleftArray = _varValue;
for "_i" from 0 to (count A3A_fuelAmountleftArray - 1) do {
if(A3A_hasACE) then {
[A3A_fuelStations # _i, A3A_fuelAmountleftArray # _i] call ace_refuel_fnc_setFuel;
} else {
(A3A_fuelStations # _i) setFuelCargo (A3A_fuelAmountleftArray # _i);
};
};
killerswin2 marked this conversation as resolved.
Show resolved Hide resolved
};
if(_varname == 'testingTimerIsActive') then
{
if(_varValue) then
Expand Down
11 changes: 11 additions & 0 deletions A3-Antistasi/functions/Save/fn_saveLoop.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,17 @@ _dataX = [];
_controlsX = controlsX select {(sidesX getVariable [_x,sideUnknown] == teamPlayer) and (controlsX find _x < defaultControlIndex)};
["controlsSDK",_controlsX] call A3A_fnc_setStatVariable;

_fuelAmountleftArray = [];
{
if (A3A_hasACE) then {
_fuelAmountleftArray pushback ([_x] call ace_refuel_fnc_getFuel);
} else {
_fuelAmountleftArray pushback (getFuelCargo _x);
};

} forEach A3A_fuelStations;
["A3A_fuelAmountleftArray",_fuelAmountleftArray] call A3A_fnc_setStatVariable;

//Saving the state of the testing timer
["testingTimerIsActive", testingTimerIsActive] call A3A_fnc_setStatVariable;

Expand Down
69 changes: 69 additions & 0 deletions A3-Antistasi/functions/UtilityItems/fn_buyItem.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
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
2. <number> price of item
3. <array> callback functions, [[name, isGlobal - > true if need exec]]

Return Value:
<nil>

Scope: Clients
Environment: Unscheduled
Public: yes
Dependencies:

Example:
[player, _fuelDrum # 0, _fuelDrum # 1, [['A3A_fnc_initMovableObject', true], ['A3A_fnc_logistics_addLoadAction', false]]] call A3A_fnc_buyItem
*/
#include "..\..\Includes\common.inc"
params [
["_unit", objNull, [objNull]],
["_spawnItem", "", [""]],
["_price", 0, [0]],
["_callbacks", [], [[]]]
];

// error checking, _unit, _spawnItem, and _callbacks
if (!canSuspend) exitwith{};
if (!hasInterface) exitwith{};
if (isNull _unit) exitwith {};
if (!isClass (configFile/"CfgVehicles"/_spawnItem)) exitwith {};
if (_price == 0) exitwith {};

//check to make sure that the player is not spamming
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;


//spawn the Item
_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;

//object globals
_item setVariable ["A3A_canGarage", true, true];
_item setVariable ["A3A_itemPrice", _price, true];

// callbacks
{
private _func_name = (_x #0);
if (_x #1) then {
private _jipKey = "A3A_utilityItems_item_" + ((str _item splitString ":") joinString "");
[_item, _jipKey] remoteExecCall [_func_name, 0, _jipKey];
} else {
[_item] spawn (missionNamespace getVariable _func_name);
};
} foreach (_callbacks);
31 changes: 31 additions & 0 deletions A3-Antistasi/functions/UtilityItems/fn_remainingFuel.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Author: [Killerswin2]
find the remaining fuel cargo and returns a precentage
Arguments:
0. <object> Object to find the remaining fuel cargo


Return Value:
<number> percentile remaining fuel 0 -> 1

Scope: Clients
Environment: Unscheduled
Public: yes
Dependencies:

Example:
[_veh] call A3A_fnc_remainingFuel
*/

params [["_vehicle", objNull, [objNull]]];

private _vehType = if (_vehicle isEqualType objNull) then {typeOf _vehicle} else {_vehicle};
killerswin2 marked this conversation as resolved.
Show resolved Hide resolved
private _vehCfg = configFile/"CfgVehicles"/_vehType;
killerswin2 marked this conversation as resolved.
Show resolved Hide resolved

if(A3A_hasACE) then {
private _ace_refuel_cargo = getNumber (_vehCfg >> "ace_refuel_fuelCargo");
killerswin2 marked this conversation as resolved.
Show resolved Hide resolved
if(_ace_refuel_cargo == 0) exitwith {};
killerswin2 marked this conversation as resolved.
Show resolved Hide resolved
(_vehicle getVariable ["ace_refuel_currentFuelCargo"] / _ace_refuel_cargo);
} else {
getFuelCargo _vehicle;
};
45 changes: 0 additions & 45 deletions A3-Antistasi/functions/UtilityItems/fn_spawnLight.sqf

This file was deleted.

12 changes: 11 additions & 1 deletion A3-Antistasi/functions/init/fn_initClient.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,17 @@ vehicleBox addAction ["Vehicle Arsenal", JN_fnc_arsenal_handleAction, [], 0, tru
if (A3A_hasACE) then { [vehicleBox, VehicleBox] call ace_common_fnc_claim;}; //Disables ALL Ace Interactions
vehicleBox addAction ["Buy Vehicle", {if ([player,300] call A3A_fnc_enemyNearCheck) then {["Purchase Vehicle", "You cannot buy vehicles while there are enemies near you."] call A3A_fnc_customHint;} else {nul = createDialog "vehicle_option"}},nil,0,false,true,"","(isPlayer _this) and (_this == _this getVariable ['owner',objNull]) and (side (group _this) == teamPlayer)", 4];
vehicleBox addAction ["Move this asset", A3A_fnc_moveHQObject,nil,0,false,true,"","(_this == theBoss)", 4];
vehicleBox addAction ["Buy Light for 25€", {player call A3A_fnc_spawnLight},nil,0,false,true,"","true",4];
vehicleBox addAction ["Buy Light for 25€", {[player, 'vehicleLightSource', 25, [['A3A_fnc_initMovableObject', 0]]] 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];
};
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];
};
call A3A_fnc_dropObject;

if (LootToCrateEnabled) then {
Expand Down
16 changes: 16 additions & 0 deletions A3-Antistasi/functions/init/fn_initZones.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,21 @@ blackListDest = (markersX - controlsX - ["Synd_HQ"] - citiesX) select {
if (_idx == -1) then {true} else {false};
};

private _fuelStationTypes = ["Land_Fuelstation_Feed_F", "Land_fs_feed_F", "Land_FuelStation_01_pump_F", "Land_FuelStation_01_pump_malevil_F", "Land_FuelStation_03_pump_F", "Land_FuelStation_02_pump_F"];
HakonRydland marked this conversation as resolved.
Show resolved Hide resolved
killerswin2 marked this conversation as resolved.
Show resolved Hide resolved
A3A_fuelStations = nearestObjects [[worldSize/2, worldSize/2], _fuelStationTypes, worldSize];
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";
if(A3A_hasACE) then {
[_x, 10000] call ace_refuel_fnc_setFuel; // only call on fuels that are not blacklisted and first zone init.
};
};



publicVariable "blackListDest";
publicVariable "markersX";
publicVariable "citiesX";
Expand All @@ -302,6 +317,7 @@ publicVariable "seaSpawn";
publicVariable "seaAttackSpawn";
publicVariable "defaultControlIndex";
publicVariable "detectionAreas";
publicvariable "A3A_fuelStations";

if (isMultiplayer) then {
[petros, "hint","Zones Init Completed"] remoteExec ["A3A_fnc_commsMP", -2]
Expand Down