diff --git a/addons/microdagr/README.md b/addons/microdagr/readme.md similarity index 100% rename from addons/microdagr/README.md rename to addons/microdagr/readme.md diff --git a/addons/refuel/$PBOPREFIX$ b/addons/refuel/$PBOPREFIX$ new file mode 100644 index 0000000000..2a68bfaf74 --- /dev/null +++ b/addons/refuel/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\refuel \ No newline at end of file diff --git a/addons/refuel/ACE_Settings.hpp b/addons/refuel/ACE_Settings.hpp new file mode 100644 index 0000000000..0ae0accaad --- /dev/null +++ b/addons/refuel/ACE_Settings.hpp @@ -0,0 +1,8 @@ +class ACE_Settings { + class GVAR(rate) { + displayName = CSTRING(RefuelSettings_speed_DisplayName); + description = CSTRING(RefuelSettings_speed_Description); + value = 1; + typeName = "SCALAR"; + }; +}; diff --git a/addons/refuel/CfgEventHandlers.hpp b/addons/refuel/CfgEventHandlers.hpp new file mode 100644 index 0000000000..f1a9f1a3c8 --- /dev/null +++ b/addons/refuel/CfgEventHandlers.hpp @@ -0,0 +1,27 @@ +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; + +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; + +class Extended_Respawn_EventHandlers { + class CAManBase { + class ADDON { + respawn = QUOTE(call COMPILE_FILE(XEH_respawn)); + }; + }; +}; + +class Extended_Killed_EventHandlers { + class CAManBase { + class ADDON { + killed = QUOTE(_this call FUNC(handleKilled)); + }; + }; +}; \ No newline at end of file diff --git a/addons/refuel/CfgVehicles.hpp b/addons/refuel/CfgVehicles.hpp new file mode 100644 index 0000000000..7294ed0695 --- /dev/null +++ b/addons/refuel/CfgVehicles.hpp @@ -0,0 +1,633 @@ +#define MACRO_REFUEL_ACTIONS \ + class ACE_Actions: ACE_Actions { \ + class ACE_MainActions: ACE_MainActions { \ + class GVAR(Refuel) { \ + displayName = CSTRING(Refuel); \ + distance = REFUEL_ACTION_DISTANCE; \ + condition = "true"; \ + statement = ""; \ + showDisabled = 0; \ + priority = 2; \ + icon = PATHTOF(ui\icon_refuel_interact.paa); \ + class GVAR(TakeNozzle) { \ + displayName = CSTRING(TakeNozzle); \ + condition = QUOTE([ARR_2(_player,_target)] call FUNC(canTakeNozzle)); \ + statement = QUOTE([ARR_3(_player,_target,objNull)] call FUNC(TakeNozzle)); \ + exceptions[] = {"isNotInside"}; \ + icon = PATHTOF(ui\icon_refuel_interact.paa); \ + }; \ + class GVAR(CheckFuelCounter) { \ + displayName = CSTRING(CheckFuelCounter); \ + condition = "true"; \ + statement = QUOTE([ARR_2(_player,_target)] call FUNC(readFuelCounter)); \ + exceptions[] = {"isNotInside"}; \ + icon = PATHTOF(ui\icon_refuel_interact.paa); \ + }; \ + class GVAR(CheckFuel) { \ + displayName = CSTRING(CheckFuel); \ + condition = QUOTE([ARR_2(_player,_target)] call FUNC(canCheckFuel)); \ + statement = QUOTE([ARR_2(_player,_target)] call FUNC(checkFuel)); \ + exceptions[] = {"isNotInside"}; \ + icon = PATHTOF(ui\icon_refuel_interact.paa); \ + }; \ + class GVAR(Connect) { \ + displayName = CSTRING(Connect); \ + condition = QUOTE([ARR_2(_player,_target)] call FUNC(canConnectNozzle)); \ + statement = QUOTE([ARR_2(_player,_target)] call DFUNC(connectNozzle)); \ + exceptions[] = {"isNotInside"}; \ + icon = PATHTOF(ui\icon_refuel_interact.paa); \ + }; \ + class GVAR(Return) { \ + displayName = CSTRING(Return); \ + condition = QUOTE([ARR_2(_player,_target)] call FUNC(canReturnNozzle)); \ + statement = QUOTE([ARR_2(_player,_target)] call DFUNC(returnNozzle)); \ + exceptions[] = {"isNotInside"}; \ + icon = PATHTOF(ui\icon_refuel_interact.paa); \ + }; \ + }; \ + }; \ + }; + +#define MACRO_CONNECT_ACTIONS \ + class ACE_Actions { \ + class ACE_MainActions { \ + class GVAR(Refuel) { \ + displayName = CSTRING(Refuel); \ + distance = REFUEL_ACTION_DISTANCE; \ + condition = "true"; \ + statement = ""; \ + showDisabled = 0; \ + priority = 2; \ + icon = PATHTOF(ui\icon_refuel_interact.paa); \ + class GVAR(Connect) { \ + displayName = CSTRING(Connect); \ + condition = QUOTE([ARR_2(_player,_target)] call FUNC(canConnectNozzle)); \ + statement = QUOTE([ARR_2(_player,_target)] call DFUNC(connectNozzle)); \ + exceptions[] = {"isNotInside"}; \ + icon = PATHTOF(ui\icon_refuel_interact.paa); \ + }; \ + }; \ + }; \ + }; + +#define MACRO_NOZZLE_ACTIONS \ + class ACE_Actions { \ + class ACE_MainActions { \ + displayName = CSTRING(Refuel); \ + distance = REFUEL_ACTION_DISTANCE; \ + condition = "true"; \ + statement = ""; \ + showDisabled = 0; \ + priority = 2; \ + icon = PATHTOF(ui\icon_refuel_interact.paa); \ + class GVAR(PickUpNozzle) { \ + displayName = CSTRING(TakeNozzle); \ + condition = QUOTE([ARR_2(_player,_target)] call FUNC(canTakeNozzle)); \ + statement = QUOTE([ARR_3(_player,objNull,_target)] call FUNC(TakeNozzle)); \ + exceptions[] = {"isNotInside"}; \ + icon = PATHTOF(ui\icon_refuel_interact.paa); \ + }; \ + class GVAR(TurnOn) { \ + displayName = CSTRING(TurnOn); \ + condition = QUOTE([ARR_2(_player,_target)] call FUNC(canTurnOn)); \ + statement = QUOTE([ARR_2(_player,_target)] call DFUNC(turnOn)); \ + exceptions[] = {"isNotInside"}; \ + icon = PATHTOF(ui\icon_refuel_interact.paa); \ + }; \ + class GVAR(TurnOff) { \ + displayName = CSTRING(TurnOff); \ + condition = QUOTE([ARR_2(_player,_target)] call FUNC(canTurnOff)); \ + statement = QUOTE([ARR_2(_player,_target)] call DFUNC(turnOff)); \ + exceptions[] = {"isNotInside"}; \ + icon = PATHTOF(ui\icon_refuel_interact.paa); \ + }; \ + class GVAR(Disconnect) { \ + displayName = CSTRING(Disconnect); \ + condition = QUOTE([ARR_2(_player,_target)] call FUNC(canDisconnect)); \ + statement = QUOTE([ARR_2(_player,_target)] call DFUNC(disconnect)); \ + exceptions[] = {"isNotInside"}; \ + icon = PATHTOF(ui\icon_refuel_interact.paa); \ + }; \ + }; \ + }; + +class CfgVehicles { + class ACE_Module; + class ACE_moduleRefuelSettings : ACE_Module { + scope = 2; + displayName = CSTRING(RefuelSettings_Module_DisplayName); + icon = QUOTE(PATHTOF(ui\icon_module_refuel.paa)); + category = "ACE_Logistics"; + function = QFUNC(moduleRefuelSettings); + functionPriority = 1; + isGlobal = 0; + isTriggerActivated = 0; + author = ECSTRING(common,ACETeam); + class Arguments { + class rate { + displayName = CSTRING(RefuelSettings_speed_DisplayName); + description = CSTRING(RefuelSettings_speed_Description); + typeName = "NUMBER"; + defaultValue = 10; + }; + }; + }; + + class ThingX; + class ACE_refuel_fuelNozzle : ThingX { + XEH_ENABLED; + MACRO_NOZZLE_ACTIONS + displayName = QGVAR(fuelNozzle); + scope = 2; + scopeCurator = 2; + model = "\A3\Structures_F_Heli\VR\Helpers\Sign_sphere10cm_F.p3d"; + }; + + class All; + + class Static : All {}; + + class Building : Static {}; + + class NonStrategic : Building {}; + + class House_Base : NonStrategic {}; + + class House : House_Base {}; + + class House_F : House {}; + + class House_Small_F : House_F { + class ACE_Actions { + class ACE_MainActions { + displayName = ECSTRING(interaction,MainAction); + selection = ""; + distance = 10; + condition = "true"; + }; + }; + }; + + class AllVehicles : All { + GVAR(flowRate) = 1; + }; + class Land : AllVehicles {}; + class LandVehicle : Land {}; + class Car : LandVehicle { + MACRO_CONNECT_ACTIONS + }; + + class Tank : LandVehicle { + MACRO_CONNECT_ACTIONS + GVAR(flowRate) = 4; + }; + + class StaticWeapon : LandVehicle { + MACRO_CONNECT_ACTIONS + }; + + class Air : AllVehicles { + GVAR(flowRate) = 8; + }; + + class Helicopter : Air { + MACRO_CONNECT_ACTIONS + GVAR(fuelCapacity) = 1500; + }; + + class Helicopter_Base_F : Helicopter {}; + + class Helicopter_Base_H : Helicopter_Base_F { + GVAR(fuelCapacity) = 3000; + }; + + class Plane : Air { + MACRO_CONNECT_ACTIONS + GVAR(fuelCapacity) = 2000; + GVAR(flowRate) = 16; + }; + + class Plane_Base_F : Plane {}; + + class Ship : AllVehicles {}; + + class Ship_F : Ship { + MACRO_CONNECT_ACTIONS + GVAR(fuelCapacity) = 2000; + GVAR(flowRate) = 4; + }; + + class Boat_Civil_01_base_F : Ship_F { + GVAR(fuelCapacity) = 200; + }; + + class Boat_F : Ship_F { + GVAR(flowRate) = 1; + }; + + class Boat_Armed_01_base_F : Boat_F { + GVAR(fuelCapacity) = 300; + }; + class Rubber_duck_base_F : Boat_F { + GVAR(fuelCapacity) = 30; + }; + class SDV_01_base_F : Boat_F { + // SDV is using electrical propulsion + GVAR(fuelCapacity) = 0; + }; + + class Car_F : Car { + // Assuming large vehicle tank + GVAR(fuelCapacity) = 60; + }; + + class Kart_01_Base_F : Car_F { + GVAR(fuelCapacity) = 8; + }; + + class Offroad_01_base_F: Car_F {}; + + class Wheeled_APC_F: Car_F { + // Assuming average APC tank + GVAR(fuelCapacity) = 300; + }; + + class Hatchback_01_base_F: Car_F { + // Assume normal vehicle tank + GVAR(fuelCapacity) = 50; + }; + + class Quadbike_01_base_F : Car_F { + // Assuming usual Yamaha quad + GVAR(fuelCapacity) = 10; + }; + + class MRAP_01_base_F: Car_F { + // M-ATV + // No data, assuming similar to Fennek + GVAR(fuelCapacity) = 230; + }; + + class MRAP_02_base_F: Car_F { + // Punisher + // No data, assuming similar to Fennek + GVAR(fuelCapacity) = 230; + }; + + class MRAP_03_base_F: Car_F { + // Fennek + GVAR(fuelCapacity) = 230; + }; + + class APC_Wheeled_01_base_F: Wheeled_APC_F { + // Patria = LAV + GVAR(fuelCapacity) = 269; + }; + + class Truck_F : Car_F { + GVAR(fuelCapacity) = 400; + GVAR(flowRate) = 2; + }; + + class Truck_01_base_F: Truck_F { + // HEMTT + GVAR(fuelCapacity) = 583; + }; + + class B_Truck_01_transport_F : Truck_01_base_F {}; + + class B_Truck_01_mover_F: B_Truck_01_transport_F {}; + + class Truck_02_base_F: Truck_F { + // KamAZ + // Assuming similar to Ural + GVAR(fuelCapacity) = 400; + }; + + class Truck_03_base_F: Truck_F { + // Tempest + // Assuming heavier than KamAZ + GVAR(fuelCapacity) = 600; + }; + + class Van_01_base_F : Truck_F { + // Small Truck + // Assuming 80L as in Ford Transit + GVAR(fuelCapacity) = 80; + }; + + class Van_01_fuel_base_F: Van_01_base_F { + transportFuel = 0; //1k + MACRO_REFUEL_ACTIONS + GVAR(hooks[]) = {{0.38,-3.17,-.7},{-0.41,-3.17,-.7}}; + GVAR(fuelCargo) = 2000; + }; + + class Tank_F: Tank { + GVAR(fuelCapacity) = 1200; + }; + + class APC_Tracked_01_base_F: Tank_F { + // Namer + // Assuming Merkava fuel + GVAR(fuelCapacity) = 1400; + }; + + class B_APC_Tracked_01_base_F: APC_Tracked_01_base_F {}; + + class B_APC_Tracked_01_CRV_F: B_APC_Tracked_01_base_F { + transportFuel = 0; //3k + MACRO_REFUEL_ACTIONS + GVAR(hooks[]) = {{-1.08,-4.81,-.8}}; + GVAR(fuelCargo) = 1000; + }; + + class APC_Tracked_02_base_F : Tank_F { + // BM-2T + // Assuming 1 L/km + GVAR(fuelCapacity) = 1000; + }; + + class APC_Tracked_03_base_F: Tank_F { + // FV 510 + // Assuming 1 L/km + GVAR(fuelCapacity) = 660; + }; + + class MBT_01_base_F: Tank_F { + // Merkava IV + GVAR(fuelCapacity) = 1400; + }; + + class MBT_02_base_F: Tank_F { + // T100 Black Eagle + // Assuming T80 + GVAR(fuelCapacity) = 1100; + }; + + class MBT_03_base_F: Tank_F { + // Leopard + GVAR(fuelCapacity) = 1160; + }; + + class MBT_01_arty_base_F : MBT_01_base_F { + // Assuming similar 2S3 + GVAR(fuelCapacity) = 830; + }; + + class MBT_02_arty_base_F : MBT_02_base_F { + // Assuming similar 2S3 + GVAR(fuelCapacity) = 830; + }; + + class Heli_Attack_01_base_F : Helicopter_Base_F { + // Commanche + }; + + class Heli_Attack_02_base_F : Helicopter_Base_F { + // Mi-48 Kajman + }; + + class Heli_Light_01_base_F : Helicopter_Base_H { + // MH-6 + GVAR(fuelCapacity) = 242; + }; + + class Heli_Light_02_base_F : Helicopter_Base_H { + // Ka-60 Kasatka + GVAR(fuelCapacity) = 1450; + }; + + class Heli_light_03_base_F : Helicopter_Base_F { + // AW159 + GVAR(fuelCapacity) = 1004; + }; + + class Heli_Transport_01_base_F : Helicopter_Base_H { + // Ghost Hawk + // Assuming similar UH60 + GVAR(fuelCapacity) = 1360; + }; + + class Heli_Transport_02_base_F : Helicopter_Base_H { + // AW101 + GVAR(fuelCapacity) = 3222; + }; + + class Heli_Transport_03_base_F : Helicopter_Base_H { + // Chinook 47I + GVAR(fuelCapacity) = 3914; + }; + + class Heli_Transport_04_base_F : Helicopter_Base_H { + // Mi-290 Taru + GVAR(fuelCapacity) = 3914; + }; + + class Plane_CAS_01_base_F : Plane_Base_F { + // Assuming similar to A10 + GVAR(fuelCapacity) = 6223; + }; + + class Plane_CAS_02_base_F : Plane_Base_F { + // Yak-130 + GVAR(fuelCapacity) = 2099; + }; + + class UAV_01_base_F : Helicopter_Base_F { + // Darter is electrical + GVAR(fuelCapacity) = 0; + }; + + class UAV : Plane {}; + + class UAV_02_base_F : UAV { + // Assuming similar YAHBON-R2 + GVAR(fuelCapacity) = 270; + }; + + class UGV_01_base_F : Car_F { + // Stomper + GVAR(fuelCapacity) = 100; + }; + + class Plane_Fighter_03_base_F : Plane_Base_F { + // L-159 ALCA + GVAR(fuelCapacity) = 1914; + }; + + // Vanilla fuel vehicles + class Truck_02_fuel_base_F : Truck_02_base_F { + transportFuel = 0; //3k + MACRO_REFUEL_ACTIONS + GVAR(hooks[]) = {{0.99,-3.47,-0.67},{-1.04,-3.47,-0.67}}; + GVAR(fuelCargo) = 10000; + }; + + class B_Truck_01_fuel_F : B_Truck_01_mover_F { + transportFuel = 0; //3k + MACRO_REFUEL_ACTIONS + GVAR(hooks[]) = {{.28,-4.99,-.3},{-.25,-4.99,-.3}}; + GVAR(fuelCargo) = 10000; + }; + + class O_Truck_03_fuel_F : Truck_03_base_F { + transportFuel = 0; //3k + MACRO_REFUEL_ACTIONS + GVAR(hooks[]) = {{1.3,-1.59,-.62},{-1.16,-1.59,-.62}}; + GVAR(fuelCargo) = 10000; + }; + + class ReammoBox_F; + class Slingload_01_Base_F : ReammoBox_F { + class ACE_Actions { + class ACE_MainActions { + displayName = ECSTRING(interaction,MainAction); + selection = ""; + distance = 10; + condition = "true"; + }; + }; + }; + + class B_Slingload_01_Fuel_F : Slingload_01_Base_F { + XEH_ENABLED; + transportFuel = 0; //3k + MACRO_REFUEL_ACTIONS + GVAR(hooks[]) = {{0.55,3.02,-0.5},{-0.52,3.02,-0.5}}; + GVAR(fuelCargo) = 10000; + }; + + class O_Heli_Transport_04_fuel_F : Heli_Transport_04_base_F { + XEH_ENABLED; + transportFuel = 0; //3k + MACRO_REFUEL_ACTIONS + GVAR(hooks[]) = {{-1.52,1.14,-1.18}}; + GVAR(fuelCargo) = 10000; + }; + + class Pod_Heli_Transport_04_base_F : StaticWeapon {}; + class Land_Pod_Heli_Transport_04_fuel_F : Pod_Heli_Transport_04_base_F { + XEH_ENABLED; + transportFuel = 0; //3k + MACRO_REFUEL_ACTIONS + GVAR(hooks[]) = {{-1.49,1.41,-.3}}; + GVAR(fuelCargo) = 10000; + }; + + // Vanilla buildings + class Land_Fuelstation_Feed_F : House_Small_F { + XEH_ENABLED; + transportFuel = 0; //50k + MACRO_REFUEL_ACTIONS + GVAR(hooks[]) = {{0,0,-0.5}}; + GVAR(fuelCargo) = REFUEL_INFINITE_FUEL; + }; + + class Land_fs_feed_F : House_Small_F { + XEH_ENABLED; + transportFuel = 0; //50k + MACRO_REFUEL_ACTIONS + GVAR(hooks[]) = {{-0.4,0.022,-.23}}; + GVAR(fuelCargo) = REFUEL_INFINITE_FUEL; + }; + + /* // Barrels found in config \ + BarrelHelper : Misc_thing 100 + BarrelBase : BarrelHelper 100 + Barrels : BarrelBase 400 + Barrel1 : BarrelBase 100 + Barrel2 : BarrelBase 100 + Barrel3 : BarrelBase 100 + Barrel4 : BarrelBase 100 + Barrel5 : BarrelBase 100 + Barrel6 : BarrelBase 100 + Wooden_barrel : BarrelBase 100 + Wooden_barrels : Wooden_barrel 400 + */ + + // Trucks + // Src: HEMTT http://www.inetres.com/gp/military/cv/eng/M977.html 583L > 483km + // Src: https://en.wikipedia.org/wiki/Heavy_Expanded_Mobility_Tactical_Truck 587L > 483km + // Src: https://en.wikipedia.org/wiki/Kamaz_Typhoon ? > 1200km + // Src: https://en.wikipedia.org/wiki/Humvee 95L + // Src: https://en.wikipedia.org/wiki/RG-33 80 gal = 302 + // Src: MTVR http://oshkoshdefense.com/wp-content/uploads/2013/08/MTVR_StndCargo_SS_6-13-11.pdf 295L + // Src: M1078 http://tarakia.weebly.com/ta-vehicles.html 219L + // Src: https://en.wikipedia.org/wiki/Ural-4320 360L + // Src: http://www.automobile-catalog.com/car/2012/1024400/gaz_233011_tigr.html 138L + // Src: https://en.wikipedia.org/wiki/UAZ-469 78L + // Src: https://en.wikipedia.org/wiki/GAZ-66 210L + + // Tracked IFV + // Src: https://en.wikipedia.org/wiki/Marder_%28IFV%29 652L > 520km + // Src: https://en.wikipedia.org/wiki/Tanque_Argentino_Mediano ~250L > 500km (200L additional tank for 400km range boost) + // Src: https://en.wikipedia.org/wiki/ACEC_Cobra 309L > 600km + // Src: https://en.wikipedia.org/wiki/Egyptian_Infantry_Fighting_Vehicle 454L > 482km + // Src: https://en.wikipedia.org/wiki/Lazika 400L > 400-450km + // Src: https://en.wikipedia.org/wiki/Type_73_Armored_Personnel_Carrier 450L > 300km + // Src: https://en.wikipedia.org/wiki/BMP-1 462L > 500-600km + // Src: http://www.inetres.com/gp/military/cv/inf/BMP-1.html 460L > 600km + // Src: http://www.inetres.com/gp/military/cv/inf/BMP-2.html 460L > 600km + // Src: http://www.inetres.com/gp/military/cv/inf/M2.html 662L > 483-402km + // Src: https://en.wikipedia.org/wiki/2T_Stalker ? > 1000km + // Src: https://en.wikipedia.org/wiki/Namer ? > 500km + // Src: https://en.wikipedia.org/wiki/Warrior_tracked_armoured_vehicle ? > 660km + // Src: http://www.globalsecurity.org/military/systems/ground/m113-specs.htm 360L + // Src: http://afvdb.50megs.com/usa/m2bradley.html 746L + // Src: https://en.wikipedia.org/wiki/BMD-1 300L + // Trend: 1-2 L/km + + // Wheeled IFV/APC + // Src: https://en.wikipedia.org/wiki/BTR-60 290L > 500km + // Src: http://www.inetres.com/gp/military/cv/inf/BTR-70.html 350L > 600km + // Src: http://www.inetres.com/gp/military/cv/inf/BTR-80.html 300L > 600km + // Src: https://en.wikipedia.org/wiki/Mowag_Piranha 4x4 200L > 700km + // Src: https://en.wikipedia.org/wiki/Mowag_Piranha 6x6 200L > 500km + // Src: https://en.wikipedia.org/wiki/ERC_90_Sagaie 242L > 700km + // Src: https://en.wikipedia.org/wiki/V%C3%A9hicule_de_l%27Avant_Blind%C3%A9 310L > 1200km + // Src: https://en.wikipedia.org/wiki/Panhard_M3 165L > 600km + // Src: https://fr.wikipedia.org/wiki/V%C3%A9hicule_blind%C3%A9_de_combat_d%27infanterie 400L > 750km + // Src: https://de.wikipedia.org/wiki/Sp%C3%A4hwagen_Fennek 230L > 460-1000km + // Src: http://www.inetres.com/gp/military/cv/inf/LAV.html 269L > 660km + // Src: http://www.inetres.com/gp/military/cv/inf/M1126.html 200L > 531km + // Src: https://en.wikipedia.org/wiki/Patria_AMV ? > 600-850km + // Src: https://en.wikipedia.org/wiki/Otokar_Arma ? > 700km + // Trend: 0.3-0.6 L/km + + // MBT + // Src: http://www.inetres.com/gp/military/cv/tank/Leopard2.html 1200L > 550km + // Src: http://www.inetres.com/gp/military/cv/tank/M1.html 1909L > 479km + // Src: https://en.wikipedia.org/wiki/T-80 1100L > 335km + // Src: https://en.wikipedia.org/wiki/T-72 1200L > 490km + // Trend: 2-4 L/km + + // Artillery + // Src: http://www.inetres.com/gp/military/cv/arty/M109.html 511L > 349km + // Src: https://en.wikipedia.org/wiki/2S3_Akatsiya 830L > 500km + + // Other + // https://en.wikipedia.org/wiki/ZSU-23-4 515L + + // Helicopter + // Src: http://www.bga-aeroweb.com/Defense/UH-1Y-Venom.html 1172kg / 0.81 kg/L = 1447L + // Src: http://www.bga-aeroweb.com/Defense/AH-1Z-Viper.html 1296kg / 0.81 kg/L = 1600L + // Src: http://www.army-technology.com/projects/black_hawk/ 1360L + // Src: http://www.bga-aeroweb.com/Defense/CH-47-Chinook.html 3914L + // Src: http://helicopters.axlegeeks.com/l/61/Boeing-AH-64-Apache 375 gal = 1420L + // Src: https://en.wikipedia.org/wiki/Mil_Mi-8 3700l + // Src: Google Ka-52 1870L + // Src: http://www.airforce-technology.com/projects/hind/ 1500kg / 0.81 L/kg = 1851L + // Src: https://en.wikipedia.org/wiki/MD_Helicopters_MH-6_Little_Bird 242L + // Src: http://www.globalsecurity.org/military/world/europe/aw159-specs.htm 1004L + // Src: https://en.wikipedia.org/wiki/AgustaWestland_AW101 3 * 1074L = 3222L + // Src: http://www.aviastar.org/helicopters_eng/ka-62.php 1450L + + // Planes + // Src: http://www.theaviationzone.com/factsheets/c130j.asp 20820kg / 0.81 kg/L = 25704L + // Src: http://www.avialogs.com/viewer/avialogs-documentviewer.php?id=3298 p29 1644 gal = 6223L + // Src: http://www.airforce-technology.com/projects/su25/ 3600L + // Src: http://www.thaitechnics.com/aircraft/L159.html 1551kg / 0.81 kg/L = 1914L + // Src: https://en.wikipedia.org/wiki/Yakovlev_Yak-130 1700kg / 0.81 kg/L = 2099L + // Src: http://www.adcom-systems.com/ENG/UAV/YAHBON-R2/Overview.html 270L +}; diff --git a/addons/refuel/README.md b/addons/refuel/README.md new file mode 100644 index 0000000000..6e3d226693 --- /dev/null +++ b/addons/refuel/README.md @@ -0,0 +1,11 @@ +ace_refuel +=============== + +The Refuel module introduces ability to refuel vehicles on different realistic levels. + +## Maintainers + +The people responsible for merging changes to this component or answering potential questions. + +- [GitHawk] (https://github.com/GitHawk) +- [Jonpas] (https://github.com/jonpas) diff --git a/addons/refuel/XEH_postInit.sqf b/addons/refuel/XEH_postInit.sqf new file mode 100644 index 0000000000..682ebaf094 --- /dev/null +++ b/addons/refuel/XEH_postInit.sqf @@ -0,0 +1,3 @@ +#include "script_component.hpp" + +["medical_onUnconscious", {_this call FUNC(handleOnUnconscious)}] call EFUNC(common,addEventHandler); diff --git a/addons/refuel/XEH_preInit.sqf b/addons/refuel/XEH_preInit.sqf new file mode 100644 index 0000000000..691df0478d --- /dev/null +++ b/addons/refuel/XEH_preInit.sqf @@ -0,0 +1,32 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP(canCheckFuel); +PREP(canConnectNozzle); +PREP(canDisconnect); +PREP(canReturnNozzle); +PREP(canTakeNozzle); +PREP(canTurnOff); +PREP(canTurnOn); +PREP(checkFuel); +PREP(connectNozzle); +PREP(connectNozzleAction); +PREP(disconnect); +PREP(dropNozzle); +PREP(getFuel); +PREP(handleKilled); +PREP(handleUnconscious); +PREP(makeJerryCan); +PREP(moduleRefuelSettings); +PREP(readFuelCounter); +PREP(refuel); +PREP(reset); +PREP(resetLocal); +PREP(returnNozzle); +PREP(setFuel); +PREP(takeNozzle); +PREP(turnOff); +PREP(turnOn); + +ADDON = true; diff --git a/addons/refuel/XEH_respawn.sqf b/addons/refuel/XEH_respawn.sqf new file mode 100644 index 0000000000..39225f2521 --- /dev/null +++ b/addons/refuel/XEH_respawn.sqf @@ -0,0 +1,11 @@ +#include "script_component.hpp" + +private ["_unit"]; + +_unit = _this select 0; + +if !(local _unit) exitWith {}; + +[_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); +_unit setVariable [QGVAR(selectedWeaponOnRefuel), nil]; +_unit setVariable [QGVAR(isRefueling), false]; diff --git a/addons/refuel/config.cpp b/addons/refuel/config.cpp new file mode 100644 index 0000000000..6140cefe8c --- /dev/null +++ b/addons/refuel/config.cpp @@ -0,0 +1,17 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {}; + weapons[] = {"ACE_refuel_fuelNozzle"}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_interaction"}; + author[] = {"GitHawk"}; + authorUrl = ""; + VERSION_CONFIG; + }; +}; + +#include "ACE_Settings.hpp" +#include "CfgEventHandlers.hpp" +#include "CfgVehicles.hpp" diff --git a/addons/refuel/functions/fnc_canCheckFuel.sqf b/addons/refuel/functions/fnc_canCheckFuel.sqf new file mode 100644 index 0000000000..a1584ea333 --- /dev/null +++ b/addons/refuel/functions/fnc_canCheckFuel.sqf @@ -0,0 +1,26 @@ +/* + * Author: Jonpas, GitHawk + * Checks if unit can check fuel. + * + * Arguments: + * 0: Unit + * 1: Fuel Truck/Station + * + * Return Value: + * Can Check Fuel + * + * Example: + * [player, truck] call ace_refuel_fnc_canCheckFuel + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit", "_target"]; + +!(isNull _unit || + {!(_unit isKindOf "CAManBase")} || + {!local _unit} || + {!alive _target} || + {(_target distance _unit) > REFUEL_ACTION_DISTANCE} || + {(_target call FUNC(getFuel) == REFUEL_INFINITE_FUEL)}) diff --git a/addons/refuel/functions/fnc_canConnectNozzle.sqf b/addons/refuel/functions/fnc_canConnectNozzle.sqf new file mode 100644 index 0000000000..812234818e --- /dev/null +++ b/addons/refuel/functions/fnc_canConnectNozzle.sqf @@ -0,0 +1,26 @@ +/* + * Author: GitHawk + * Check if a unit can connect a fuel nozzle + * + * Arguments: + * 0: Unit + * 1: Target + * + * Return Value: + * Can Connect Nozzle + * + * Example: + * [player, tank] call ace_refuel_fnc_canConnectNozzle + * + * Public: No + */ +#include "script_component.hpp" + +private ["_nozzle"]; +params ["_unit", "_target"]; + +_nozzle = _unit getVariable [QGVAR(nozzle), objNull]; + +!(isNull _nozzle || + {(_target distance _unit) > REFUEL_ACTION_DISTANCE} || + {!isNull (_target getVariable [QGVAR(nozzle), objNull])}) // TODO verify cant connect multiple fuel lines diff --git a/addons/refuel/functions/fnc_canDisconnect.sqf b/addons/refuel/functions/fnc_canDisconnect.sqf new file mode 100644 index 0000000000..50d22702a0 --- /dev/null +++ b/addons/refuel/functions/fnc_canDisconnect.sqf @@ -0,0 +1,29 @@ +/* + * Author: GitHawk + * Check if a unit can disconnect a fuel nozzle + * + * Arguments: + * 0: Unit + * 1: Nozzle + * + * Return Value: + * Can disconnect + * + * Example: + * [player, nozzle] call ace_refuel_fnc_canDisconnect + * + * Public: No + */ +#include "script_component.hpp" + +private ["_sink"]; +params ["_unit", "_nozzle"]; + +if (isNull _unit || + {isNull _nozzle} || + {!(_unit isKindOf "CAManBase")} || + {!local _unit} || + {(_nozzle distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false}; + +_sink = _nozzle getVariable [QGVAR(sink), objNull]; +!((isNull _sink) || {_nozzle getVariable [QGVAR(isRefueling), false]}) diff --git a/addons/refuel/functions/fnc_canReturnNozzle.sqf b/addons/refuel/functions/fnc_canReturnNozzle.sqf new file mode 100644 index 0000000000..139c921d34 --- /dev/null +++ b/addons/refuel/functions/fnc_canReturnNozzle.sqf @@ -0,0 +1,24 @@ +/* + * Author: GitHawk + * Check if a unit can return a fuel nozzle + * + * Arguments: + * 0: Unit + * 1: Fuel truck + * + * Return Value: + * Can Return Nozzle + * + * Example: + * [player, fuelTruck] call ace_refuel_fnc_canReturnNozzle + * + * Public: No + */ +#include "script_component.hpp" + +private ["_nozzle"]; +params ["_unit", "_target"]; + +_nozzle = _unit getVariable QGVAR(nozzle); + +(_this call FUNC(canConnectNozzle)) && {_target == (_nozzle getVariable [QGVAR(source), objNull])} diff --git a/addons/refuel/functions/fnc_canTakeNozzle.sqf b/addons/refuel/functions/fnc_canTakeNozzle.sqf new file mode 100644 index 0000000000..85f5b815a5 --- /dev/null +++ b/addons/refuel/functions/fnc_canTakeNozzle.sqf @@ -0,0 +1,27 @@ +/* + * Author: GitHawk + * Check if a unit can take a fuel nozzle + * + * Arguments: + * 0: Unit + * 1: Fuel Station or Nozzle + * + * Return Value: + * Can connect + * + * Example: + * [player, nozzle] call ace_refuel_fnc_canTakeNozzle + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit", "_target"]; + +if (isNull _unit || + {!(_unit isKindOf "CAManBase")} || + {!local _unit} || + {!alive _target} || + {(_target distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false}; + +!(_target getVariable [QGVAR(isConnected), false]) && {!(_unit getVariable [QGVAR(isRefueling), false])} diff --git a/addons/refuel/functions/fnc_canTurnOff.sqf b/addons/refuel/functions/fnc_canTurnOff.sqf new file mode 100644 index 0000000000..7d2d3652e0 --- /dev/null +++ b/addons/refuel/functions/fnc_canTurnOff.sqf @@ -0,0 +1,27 @@ +/* + * Author: GitHawk + * Check if a unit can turn off a fuel nozzle + * + * Arguments: + * 0: Unit + * 1: Nozzle + * + * Return Value: + * Can turn off + * + * Example: + * [player, nozzle] call ace_refuel_fnc_canTurnOff + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit", "_nozzle"]; + +if (isNull _unit || + {isNull _nozzle} || + {!(_unit isKindOf "CAManBase")} || + {!local _unit} || + {(_nozzle distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false}; + +(_nozzle getVariable [QGVAR(isRefueling), false]) diff --git a/addons/refuel/functions/fnc_canTurnOn.sqf b/addons/refuel/functions/fnc_canTurnOn.sqf new file mode 100644 index 0000000000..3053e699a2 --- /dev/null +++ b/addons/refuel/functions/fnc_canTurnOn.sqf @@ -0,0 +1,30 @@ +/* + * Author: GitHawk + * Check if a unit can turn on a fuel nozzle + * + * Arguments: + * 0: Unit + * 1: Nozzle + * + * Return Value: + * Can turn on + * + * Example: + * [player, nozzle] call ace_refuel_fnc_canTurnOn + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit", "_nozzle"]; + +if (isNull _unit || + {isNull _nozzle} || + {!(_unit isKindOf "CAManBase")} || + {!local _unit} || + {(_nozzle distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false}; + +!(_nozzle getVariable [QGVAR(isRefueling), false]) && + {[_nozzle getVariable QGVAR(source)] call FUNC(getFuel) != 0} && + {!isNull (_nozzle getVariable [QGVAR(sink), objNull])} && + {(fuel (_nozzle getVariable QGVAR(sink))) < 1} diff --git a/addons/refuel/functions/fnc_checkFuel.sqf b/addons/refuel/functions/fnc_checkFuel.sqf new file mode 100644 index 0000000000..b50e9a8171 --- /dev/null +++ b/addons/refuel/functions/fnc_checkFuel.sqf @@ -0,0 +1,40 @@ +/* + * Author: GitHawk + * Get the remaining fuel amount + * + * Arguments: + * 0: Unit + * 1: Fuel Truck + * + * Return Value: + * None + * + * Example: + * [player, fuelTruck] call ace_refuel_fnc_checkFuel + * + * Public: No + */ +#include "script_component.hpp" +private ["_fuel"]; +params ["_unit", "_target"]; + +_fuel = [_target] call FUNC(getFuel); + +[ + 5, + [_unit, _target, _fuel], + { + params ["_args"]; + _args params ["_unit", "_target", "_fuel"]; + if (_fuel > 0 ) then { + ["displayTextStructured", [_unit], [[LSTRING(Hint_RemainingFuel), _fuel], 2, _unit]] call EFUNC(common,targetEvent); + } else { + ["displayTextStructured", [_unit], [LSTRING(Hint_Empty), 2, _unit]] call EFUNC(common,targetEvent); + }; + true + }, + {true}, + localize LSTRING(CheckFuelAction), + {true}, + ["isnotinside"] +] call EFUNC(common,progressBar); diff --git a/addons/refuel/functions/fnc_connectNozzle.sqf b/addons/refuel/functions/fnc_connectNozzle.sqf new file mode 100644 index 0000000000..f5d8d35759 --- /dev/null +++ b/addons/refuel/functions/fnc_connectNozzle.sqf @@ -0,0 +1,65 @@ +/* + * Author: GitHawk et.al. + * Connect a fuel nozzle. + * With code from ace_attach + * + * Arguments: + * 0: Unit + * 1: Target + * + * Return Value: + * None + * + * Example: + * [player, tank] call ace_refuel_fnc_connectNozzle + * + * Public: No + */ +#include "script_component.hpp" + +#define PLACE_WAITING -1 +#define PLACE_CANCEL 0 +#define PLACE_APPROVE 1 + +private ["_nozzle", "_actionID"]; +params ["_unit", "_target"]; + +_nozzle = _unit getVariable [QGVAR(nozzle), objNull]; +if (isNull _nozzle) exitWith {}; + +GVAR(placeAction) = PLACE_WAITING; + +[{[localize LSTRING(Connect_Action), ""] call EFUNC(interaction,showMouseHint)}, []] call EFUNC(common,execNextFrame); +_unit setVariable [QGVAR(placeActionEH), [_unit, "DefaultAction", {true}, {GVAR(placeAction) = PLACE_APPROVE;}] call EFUNC(common,AddActionEventHandler)]; + +_actionID = _unit addAction [format ["%1", localize LSTRING(Cancel)], {GVAR(placeAction) = PLACE_CANCEL;}]; + +[{ + private["_virtualPos", "_virtualPosASL", "_lineInterection"]; + params ["_args","_pfID"]; + _args params ["_unit", "_target", "_nozzle", "_actionID"]; + + _virtualPosASL = (eyePos _unit) vectorAdd (positionCameraToWorld [0,0,0.6]) vectorDiff (positionCameraToWorld [0,0,0]); + if (cameraView == "EXTERNAL") then { + _virtualPosASL = _virtualPosASL vectorAdd ((positionCameraToWorld [0.3,0,0]) vectorDiff (positionCameraToWorld [0,0,0])); + }; + _virtualPos = _virtualPosASL call EFUNC(common,ASLToPosition); + _lineInterection = lineIntersects [eyePos ace_player, _virtualPosASL, ace_player]; + + //Don't allow placing in a bad position: + if (_lineInterection && {GVAR(placeAction) == PLACE_APPROVE}) then {GVAR(placeAction) = PLACE_WAITING;}; + + if ((GVAR(placeAction) != PLACE_WAITING) || + {_unit != ace_player} || + {!([_unit, _target, []] call EFUNC(common,canInteractWith))}) then { + + [_pfID] call CBA_fnc_removePerFrameHandler; + [] call EFUNC(interaction,hideMouseHint); + [_unit, "DefaultAction", (_unit getVariable [QGVAR(placeActionEH), -1])] call EFUNC(common,removeActionEventHandler); + _unit removeAction _actionID; + + if (GVAR(placeAction) == PLACE_APPROVE) then { + [_unit, _target, _virtualPos, _nozzle] call FUNC(ConnectNozzleAction); + }; + }; // TODO add model like in attach/functions/fnc_attach +}, 0, [_unit, _target, _nozzle, _actionID] ] call cba_fnc_addPerFrameHandler; diff --git a/addons/refuel/functions/fnc_connectNozzleAction.sqf b/addons/refuel/functions/fnc_connectNozzleAction.sqf new file mode 100644 index 0000000000..42190aacc6 --- /dev/null +++ b/addons/refuel/functions/fnc_connectNozzleAction.sqf @@ -0,0 +1,106 @@ +/* + * Author: GitHawk et.al. + * Calculates a connection for refueling. + * With code from ace_attach + * + * Arguments: + * 0: Unit + * 1: Target + * 2: Visual Position + * 3: Nozzle + * + * Return Value: + * None + * + * Example: + * [player, tank, [0,0,0], nozzle] call ace_refuel_fnc_connectNozzleAction + * + * Public: No + */ +#include "script_component.hpp" +private ["_startingOffset", "_startDistanceFromCenter", "_closeInUnitVector", "_closeInMax", "_closeInMin", "_closeInDistance", "_endPosTestOffset", "_endPosTest", "_doesIntersect", "_startingPosShifted", "_endASL", "_rate", "_maxFuel"]; + +params ["_unit", "_target", "_startingPosition", "_nozzle"]; +_startingOffset = _target worldToModel _startingPosition; + +_startDistanceFromCenter = vectorMagnitude _startingOffset; +_closeInUnitVector = vectorNormalized (_startingOffset vectorFromTo [0,0,0]); + +_closeInMax = _startDistanceFromCenter; +_closeInMin = 0; + +while {(_closeInMax - _closeInMin) > 0.01} do { + _closeInDistance = (_closeInMax + _closeInMin) / 2; + _endPosTestOffset = _startingOffset vectorAdd (_closeInUnitVector vectorMultiply _closeInDistance); + _endPosTestOffset set [2, (_startingOffset select 2)]; + _endPosTest = _target modelToWorldVisual _endPosTestOffset; + + _doesIntersect = false; + { + if (_doesIntersect) exitWith {}; + _startingPosShifted = _startingPosition vectorAdd _x; + _startASL = if (surfaceIsWater _startingPosShifted) then {_startingPosShifted} else {ATLtoASL _startingPosShifted}; + { + _endPosShifted = _endPosTest vectorAdd _x; + _endASL = if (surfaceIsWater _startingPosShifted) then {_endPosShifted} else {ATLtoASL _endPosShifted}; + + //Uncomment to see the lazor show, and see how the scanning works: + // drawLine3D [_startingPosShifted, _endPosShifted, [1,0,0,1]]; + if (_target in lineIntersectsWith [_startASL, _endASL, _unit]) exitWith {_doesIntersect = true}; + } forEach [[0,0,0.045], [0,0,-0.045], [0,0.045,0], [0,-0.045,0], [0.045,0,0], [-0.045,0,0]]; + } forEach [[0,0,0], [0,0,0.05], [0,0,-0.05]]; + + if (_doesIntersect) then { + _closeInMax = _closeInDistance; + } else { + _closeInMin = _closeInDistance; + }; +}; + +_closeInDistance = (_closeInMax + _closeInMin) / 2; + +//Checks (too close to center or can't attach) +if (((_startDistanceFromCenter - _closeInDistance) < 0.1) || {!([_target, _unit, _itemClassname] call FUNC(canAttach))}) exitWith { + TRACE_2("no valid spot found",_closeInDistance,_startDistanceFromCenter); + [localize LSTRING(Failed)] call EFUNC(common,displayTextStructured); +}; + +//Move it out slightly, for visibility sake (better to look a little funny than be embedded//sunk in the hull and be useless) +_closeInDistance = (_closeInDistance - 0.0085); + +_endPosTestOffset = _startingOffset vectorAdd (_closeInUnitVector vectorMultiply _closeInDistance); +_endPosTestOffset set [2, (_startingOffset select 2)]; + +[ + 2, + [_unit, _nozzle, _target, _endPosTestOffset], + { + private "_actionID"; + params ["_args"]; + _args params ["_unit", "_nozzle", "_target", "_endPosTestOffset"]; + _unit setVariable [QGVAR(nozzle), nil]; + _unit setVariable [QGVAR(isRefueling), false]; + [_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); + REFUEL_UNHOLSTER_WEAPON + _actionID = _unit getVariable [QGVAR(ReleaseActionID), -1]; + if (_actionID != -1) then { + _unit removeAction _actionID; + _unit setVariable [QGVAR(ReleaseActionID), nil]; + }; + + detach _nozzle; + _nozzle attachTo [_target, _endPosTestOffset]; + _nozzle setVariable [QGVAR(sink), _target, true]; + _nozzle setVariable [QGVAR(isConnected), true, true]; + _target setVariable [QGVAR(nozzle), _nozzle, true]; + + _source = _nozzle getVariable QGVAR(source); + _source setVariable [QGVAR(fuelCounter), [_source] call FUNC(getFuel), true]; + + [_unit, _target, _nozzle, _endPosTestOffset] call FUNC(refuel); + }, + "", + localize LSTRING(ConnectAction), + {true}, + ["isnotinside"] +] call EFUNC(common,progressBar); diff --git a/addons/refuel/functions/fnc_disconnect.sqf b/addons/refuel/functions/fnc_disconnect.sqf new file mode 100644 index 0000000000..e007ddf05f --- /dev/null +++ b/addons/refuel/functions/fnc_disconnect.sqf @@ -0,0 +1,30 @@ +/* + * Author: GitHawk + * Disconnect a fuel nozzle. + * + * Arguments: + * 0: Unit + * 1: Nozzle + * + * Return Value: + * None + * + * Example: + * [player, nozzle] call ace_refuel_fnc_disconnect + * + * Public: No + */ +#include "script_component.hpp" + +private ["_sink"]; +params ["_unit", "_nozzle"]; + +_sink = _nozzle getVariable [QGVAR(sink), objNull]; +if (isNull _sink) exitWith {}; + +_sink setVariable [QGVAR(nozzle), objNull, true]; +_nozzle setVariable [QGVAR(sink), objNull, true]; +_nozzle setVariable [QGVAR(isConnected), false, true]; +[objNull, _nozzle, true] call FUNC(dropNozzle); + +[_unit, objNull, _nozzle] call FUNC(takeNozzle); diff --git a/addons/refuel/functions/fnc_dropNozzle.sqf b/addons/refuel/functions/fnc_dropNozzle.sqf new file mode 100644 index 0000000000..c44c20c059 --- /dev/null +++ b/addons/refuel/functions/fnc_dropNozzle.sqf @@ -0,0 +1,32 @@ +/* + * Author: GitHawk + * Detaches the fuel nozzle, drops it and removes player variables. + * + * Arguments: + * 0: Unit (optional) + * 1: Nozzle + * 2: Disconnect Only + * + * Return Value: + * None + * + * Example: + * [player, nozzle, false] call ace_refuel_fnc_dropNozzle + * [objNull, nozzle, false] call ace_refuel_fnc_dropNozzle + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit", "_nozzle", ["_disconnectOnly", false]]; + +detach _nozzle; +_nozzle setVariable [QGVAR(isRefueling), false, true]; + +if (_disconnectOnly) exitWith {}; +_nozzle setVelocity [0, 0, 0]; +_nozzle setPosATL [(getPosATL _nozzle) select 0, (getPosATL _nozzle) select 1, 0.05]; + +if (isNull _unit) exitWith {}; +_unit setVariable [QGVAR(isRefueling), false, true]; +_unit setVariable [QGVAR(nozzle), objNull, true]; diff --git a/addons/refuel/functions/fnc_getFuel.sqf b/addons/refuel/functions/fnc_getFuel.sqf new file mode 100644 index 0000000000..9bbb4987be --- /dev/null +++ b/addons/refuel/functions/fnc_getFuel.sqf @@ -0,0 +1,28 @@ +/* + * Author: GitHawk, Jonpas + * Get the remaining fuel amount. + * + * Arguments: + * 0: Target + * + * Return Value: + * Fuel left (in liters) + * + * Example: + * [fuelTruck] call ace_refuel_fnc_getFuel + * + * Public: No + */ +#include "script_component.hpp" + +private ["_fuel"]; +params ["_target"]; + +_fuel = _target getVariable QGVAR(currentFuelCargo); + +if (isNil "_fuel") then { + _fuel = getNumber (configFile >> "CfgVehicles" >> typeOf _target >> QGVAR(fuelCargo)); + _target setVariable [QGVAR(currentFuelCargo), _fuel, true]; +}; + +_fuel diff --git a/addons/refuel/functions/fnc_handleKilled.sqf b/addons/refuel/functions/fnc_handleKilled.sqf new file mode 100644 index 0000000000..897337c062 --- /dev/null +++ b/addons/refuel/functions/fnc_handleKilled.sqf @@ -0,0 +1,26 @@ +/* + * Author: GitHawk, Jonpas + * Handles medical on set dead event. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Example: + * [player] call ace_refuel_fnc_handleKilled + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit"]; + +if (!local _unit) exitWith {}; + +_unit setVariable [QGVAR(selectedWeaponOnRefuel), nil]; +_nozzle = _unit getVariable [QGVAR(nozzle), objNull]; +if !(isNull _nozzle) then { + [_unit, _nozzle] call FUNC(dropNozzle); +}; diff --git a/addons/refuel/functions/fnc_handleUnconscious.sqf b/addons/refuel/functions/fnc_handleUnconscious.sqf new file mode 100644 index 0000000000..6a6e561230 --- /dev/null +++ b/addons/refuel/functions/fnc_handleUnconscious.sqf @@ -0,0 +1,29 @@ +/* + * Author: GitHawk, Jonpas + * Handles medical on unconscious event. + * + * Arguments: + * 0: Unit + * 1: Is Unconscious + * + * Return Value: + * None + * + * Example: + * [player, true] call ace_refuel_fnc_handleUnconscious + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit", "_isUnconscious"]; + +if (!local _unit || {!_isUnconscious}) exitWith {}; + +private "_nozzle"; + +[_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); +_nozzle = _unit getVariable [QGVAR(nozzle), objNull]; +if !(isNull _nozzle) then { + [_unit, _nozzle] call FUNC(dropNozzle); +}; diff --git a/addons/refuel/functions/fnc_makeJerryCan.sqf b/addons/refuel/functions/fnc_makeJerryCan.sqf new file mode 100644 index 0000000000..3df209196d --- /dev/null +++ b/addons/refuel/functions/fnc_makeJerryCan.sqf @@ -0,0 +1,89 @@ +/* + * Author: GitHawk + * Makes an object into a jerry can. + * + * Arguments: + * 0: Target + * 1: Fuel amount (in liters) + * + * Return Value: + * None + * + * Example: + * [can] call ace_refuel_fnc_makeJerryCan + * + * Public: No + */ +#include "script_component.hpp" + +private ["_actions", "_action"]; +params ["_target", ["_fuelAmount", 20]]; + +if (isNull _target || + {_target isKindOf "AllVehicles"}) exitWith {}; + +[_target, _fuelAmount] call FUNC(setFuel); +_target setVariable [QGVAR(source), _target, true]; + +_actions = []; +// Add pickup +_action = [QGVAR(PickUpNozzle), + localize LSTRING(TakeNozzle), + QUOTE(PATHTOF(ui\icon_refuel_interact.paa)), + {[_player, objNull, _target] call FUNC(TakeNozzle)}, + {[_player, _target] call FUNC(canTakeNozzle)}, + {}, + [], + [0, 0, 0], + REFUEL_ACTION_DISTANCE] call EFUNC(interact_menu,createAction); +_actions pushBack [_action, [], _target]; + +// Add turnOn +_action = [QGVAR(TurnOn), + localize LSTRING(TurnOn), + QUOTE(PATHTOF(ui\icon_refuel_interact.paa)), + {[_player, _target] call FUNC(turnOn)}, + {[_player, _target] call FUNC(canTurnOn)}, + {}, + [], + [0, 0, 0], + REFUEL_ACTION_DISTANCE] call EFUNC(interact_menu,createAction); +_actions pushBack [_action, [], _target]; + +// Add turnOff +_action = [QGVAR(TurnOff), + localize LSTRING(TurnOff), + QUOTE(PATHTOF(ui\icon_refuel_interact.paa)), + {[_player, _target] call FUNC(turnOff)}, + {[_player, _target] call FUNC(canTurnOff)}, + {}, + [], + [0, 0, 0], + REFUEL_ACTION_DISTANCE] call EFUNC(interact_menu,createAction); +_actions pushBack [_action, [], _target]; + +// Add disconnect +_action = [QGVAR(Disconnect), + localize LSTRING(Disconnect), + QUOTE(PATHTOF(ui\icon_refuel_interact.paa)), + {[_player, _target] call FUNC(disconnect)}, + {[_player, _target] call FUNC(canDisconnect)}, + {}, + [], + [0, 0, 0], + REFUEL_ACTION_DISTANCE] call EFUNC(interact_menu,createAction); +_actions pushBack [_action, [], _target]; + +// Main Action +_action = [QGVAR(Refuel), + localize LSTRING(Refuel), + QUOTE(PATHTOF(ui\icon_refuel_interact.paa)), + {}, + {true}, + {}, + [], + [0, 0, 0], + REFUEL_ACTION_DISTANCE] call EFUNC(interact_menu,createAction); + +[_target, 0] call EFUNC(interact_menu,addMainAction); +[_target, 0, ["ACE_MainActions"], [_action, _actions, _target]] call EFUNC(interact_menu,addActionToObject); diff --git a/addons/refuel/functions/fnc_moduleRefuelSettings.sqf b/addons/refuel/functions/fnc_moduleRefuelSettings.sqf new file mode 100644 index 0000000000..6cdc78b9f7 --- /dev/null +++ b/addons/refuel/functions/fnc_moduleRefuelSettings.sqf @@ -0,0 +1,24 @@ +/* + * Author: GitHawk + * Module for adjusting the refuel settings. + * + * Arguments: + * 0: The module logic + * 1: units + * 2: activated + * + * Return Value: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_logic", "_units", "_activated"]; + +if !(_activated) exitWith {}; + +[_logic, QGVAR(rate), "rate"] call EFUNC(common,readSettingFromModule); + +diag_log text format ["[ACE]: Refuel Module Initialized with flow rate: %1", GVAR(rate)]; diff --git a/addons/refuel/functions/fnc_readFuelCounter.sqf b/addons/refuel/functions/fnc_readFuelCounter.sqf new file mode 100644 index 0000000000..af95c044e3 --- /dev/null +++ b/addons/refuel/functions/fnc_readFuelCounter.sqf @@ -0,0 +1,37 @@ +/* + * Author: GitHawk + * Reads the fuel counter. + * + * Arguments: + * 0: Unit + * 1: Fuel Truck + * + * Return Value: + * None + * + * Example: + * [player, fuelTruck] call ace_refuel_fnc_readFuelCounter + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit", "_target"]; + +[ + 2, + [_unit, _target], + { + private ["_currentFuel", "_fuelCounter"]; + params ["_args"]; + _args params ["_unit", "_target"]; + + _currentFuel = [_target] call FUNC(getFuel); + _fuelCounter = 0.01 * round (100 * ((_target getVariable [QGVAR(fuelCounter), _currentFuel]) - _currentFuel)); + [[LSTRING(Hint_FuelCounter), _fuelCounter], 1.5, _unit] call EFUNC(common,displayTextStructured); + }, + "", + localize LSTRING(CheckFuelCounterAction), + {true}, + ["isnotinside"] +] call EFUNC(common,progressBar); diff --git a/addons/refuel/functions/fnc_refuel.sqf b/addons/refuel/functions/fnc_refuel.sqf new file mode 100644 index 0000000000..ed6eb257cf --- /dev/null +++ b/addons/refuel/functions/fnc_refuel.sqf @@ -0,0 +1,99 @@ +/* + * Author: GitHawk + * Refuels the vehicle. + * + * Arguments: + * 0: Unit + * 1: Target + * 2: Nozzle + * 3: Connection Point + * + * Return Value: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +#define PFH_STEPSIZE 0.1 + +private ["_rate", "_maxFuel"]; +params ["_unit", "_target", "_nozzle", "_connectToPoint"]; + +_rate = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(flowRate)) * GVAR(rate) * PFH_STEPSIZE; +_maxFuel = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(fuelCapacity)); + +[{ + private ["_source", "_tooFar", "_fuelInSource", "_fuelInSink", "_finished", "_fueling"]; + params ["_args", "_pfID"]; + _args params ["_source", "_sink", "_unit", "_nozzle", "_rate", "_startFuel", "_maxFuel", "_connectFromPoint", "_connectToPoint"]; + + _fueling = _nozzle getVariable [QGVAR(isRefueling), false]; + if (!alive _source || {!alive _sink}) exitWith { + [objNull, _nozzle] call FUNC(dropNozzle); + _nozzle setVariable [QGVAR(isConnected), false, true]; + _nozzle setVariable [QGVAR(sink), objNull, true]; + _sink setVariable [QGVAR(nozzle), objNull, true]; + [_pfID] call cba_fnc_removePerFrameHandler; + }; + _tooFar = ((_sink modelToWorld _connectToPoint) distance (_source modelToWorld _connectFromPoint)) > (REFUEL_HOSE_LENGTH - 2); + if (_tooFar) exitWith { + [LSTRING(Hint_TooFar), 2, _unit] call EFUNC(common,displayTextStructured); + + [objNull, _nozzle] call FUNC(dropNozzle); + _nozzle setVariable [QGVAR(isConnected), false, true]; + _nozzle setVariable [QGVAR(sink), objNull, true]; + _sink setVariable [QGVAR(nozzle), objNull, true]; + [_pfID] call cba_fnc_removePerFrameHandler; + }; + + _finished = false; + if (_fueling) then { + _fuelInSource = [_source] call FUNC(getFuel); + if (_fuelInSource == 0) exitWith { + [LSTRING(Hint_SourceEmpty), 2, _unit] call EFUNC(common,displayTextStructured); + _nozzle setVariable [QGVAR(isRefueling), false, true]; + }; + if !(_fuelInSource == REFUEL_INFINITE_FUEL) then { + _fuelInSource = _fuelInSource - _rate; + }; + if (_fuelInSource < 0 && {_fuelInSource > -1}) then { + _fuelInSource = 0; + _finished = true; + [LSTRING(Hint_SourceEmpty), 2, _unit] call EFUNC(common,displayTextStructured); + }; + + _fuelInSink = (_unit getVariable [QGVAR(tempFuel), _startFuel]) + ( _rate / _maxFuel); + if (_fuelInSink > 1) then { + _fuelInSink = 1; + _finished = true; + [LSTRING(Hint_Completed), 2, _unit] call EFUNC(common,displayTextStructured); + }; + _unit setVariable [QGVAR(tempFuel), _fuelInSink]; + + if !(local _sink) then { + [[_sink, _fuelInSink], "{(_this select 0) setFuel (_this select 1)}", _sink] call EFUNC(common,execRemoteFnc); + } else { + _sink setFuel _fuelInSink; + }; + [_source, _fuelInSource] call FUNC(setFuel); + } else { + _unit setVariable [QGVAR(tempFuel), fuel _sink]; + }; + + if (_finished) exitWith { + _nozzle setVariable [QGVAR(isRefueling), false, true]; + }; +}, +PFH_STEPSIZE, +[_nozzle getVariable QGVAR(source), + _target, + _unit, + _nozzle, + _rate, + fuel _target, + _maxFuel, + _nozzle getVariable [QGVAR(attachPos), [0,0,0]], + _connectToPoint] +] call cba_fnc_addPerFrameHandler; diff --git a/addons/refuel/functions/fnc_reset.sqf b/addons/refuel/functions/fnc_reset.sqf new file mode 100644 index 0000000000..f235180b0e --- /dev/null +++ b/addons/refuel/functions/fnc_reset.sqf @@ -0,0 +1,50 @@ +/* + * Author: GitHawk + * Resets a fuel vehicle in case is got bugged + * + * Arguments: + * 0: Fuel truck + * + * Return Value: + * None + * + * Example: + * [truck] call ace_refuel_fnc_reset + * + * Public: No + */ +#include "script_component.hpp" + +private ["_nozzle", "_nozzleTarget", "_rope"]; +params ["_target"]; + +if (local _target) then { + _target setHitPointDamage ["HitEngine", _target getVariable [QGVAR(engineHit), 0]]; +} else { + [[_target, ["HitEngine", _target getVariable [QGVAR(engineHit), 0]]], "{(_this select 0) setHitPointDamage (_this select 1)}", _target] call EFUNC(common,execRemoteFnc); +}; +_target setVariable [QGVAR(engineHit), nil, true]; +_target setVariable [QGVAR(isConnected), false, true]; + +_nozzle = _target getVariable [QGVAR(ownedNozzle), nil]; +if !(isNil "_nozzle") then { + _nozzleTarget = _nozzle getVariable [QGVAR(sink), nil]; + if !(isNil "_nozzleTarget") then { + _nozzleTarget setVariable [QGVAR(nozzle), nil, true]; + }; + + _rope = _nozzle getVariable [QGVAR(rope), nil]; + if !(isNil "_rope") then { + ropeDestroy _rope; + }; + + { + if (local _x) then { + [_x, _nozzle] call FUNC(resetLocal); + } else { + [[_x, _nozzle], "{_this call FUNC(resetLocal)}", _x] call EFUNC(common,execRemoteFnc); + }; + } count allPlayers; + deleteVehicle _nozzle; +}; +_target setVariable [QGVAR(ownedNozzle), nil, true]; diff --git a/addons/refuel/functions/fnc_resetLocal.sqf b/addons/refuel/functions/fnc_resetLocal.sqf new file mode 100644 index 0000000000..a8b0c184cc --- /dev/null +++ b/addons/refuel/functions/fnc_resetLocal.sqf @@ -0,0 +1,37 @@ +/* + * Author: GitHawk + * Resets a player + * + * Arguments: + * 0: Fuel nozzle + * + * Return Value: + * None + * + * Example: + * [nozzle] call ace_refuel_fnc_resetLocal + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit", "_nozzle"]; + + +if (isNull _unit || + {isNull _nozzle} || + {!(_unit isKindOf "CAManBase")} || + {!local _unit}) exitWith {}; +private ["_attachedNozzle", "_actionID"]; +_attachedNozzle = _unit getVariable [QGVAR(nozzle), nil]; +if (isNil "_attachedNozzle") exitWith {}; + +if (_nozzle != _attachedNozzle) exitWith {}; + +_actionID = _unit getVariable [QGVAR(ReleaseActionID), -1]; +if (_actionID != -1) then { + _unit removeAction _actionID; + _unit setVariable [QGVAR(isRefueling), false, true]; + _unit setVariable [QGVAR(ReleaseActionID), nil]; + _unit setVariable [QGVAR(nozzle), nil]; +}; diff --git a/addons/refuel/functions/fnc_returnNozzle.sqf b/addons/refuel/functions/fnc_returnNozzle.sqf new file mode 100644 index 0000000000..d3fca33021 --- /dev/null +++ b/addons/refuel/functions/fnc_returnNozzle.sqf @@ -0,0 +1,63 @@ +/* + * Author: GitHawk, Jonpas + * Returns the nozzle back to source vehicle. + * + * Arguments: + * 0: Unit + * 1: Fuel Truck + * + * Return Value: + * Returned Nozzle + * + * Example: + * [player, fuelTruck] call ace_refuel_fnc_returnNozzle + * + * Public: No + */ +#include "script_component.hpp" + +private ["_nozzle", "_dummy", "_actionID"]; +params ["_unit", "_target"]; + +_nozzle = _unit getVariable [QGVAR(nozzle), objNull]; +_source = _nozzle getVariable QGVAR(source); + +if (isNull _nozzle || {_source != _target}) exitWith {false}; + +[ + 2, + [_unit, _nozzle, _target], + { + private "_actionID"; + params ["_args"]; + _args params ["_unit", "_nozzle", "_target"]; + _unit setVariable [QGVAR(nozzle), nil]; + detach _nozzle; + [_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); + REFUEL_UNHOLSTER_WEAPON + _unit setVariable [QGVAR(isRefueling), false]; + _actionID = _unit getVariable [QGVAR(ReleaseActionID), -1]; + if (_actionID != -1) then { + _unit removeAction _actionID; + _unit setVariable [QGVAR(ReleaseActionID), nil]; + }; + + _target setVariable [QGVAR(isConnected), false, true]; + _target setVariable [QGVAR(ownedNozzle), nil, true]; + ropeDestroy (_nozzle getVariable QGVAR(rope)); + deleteVehicle _nozzle; + + if !(local _target) then { + [[_target, ["HitEngine", _target getVariable [QGVAR(engineHit), 0]]], "{(_this select 0) setHitPointDamage (_this select 1)}", _sink] call EFUNC(common,execRemoteFnc); + } else { + _target setHitPointDamage ["HitEngine", _target getVariable [QGVAR(engineHit), 0]]; + }; + _target setVariable [QGVAR(engineHit), nil, true]; + }, + "", + localize LSTRING(ReturnAction), + {true}, + ["isnotinside"] +] call EFUNC(common,progressBar); + +true diff --git a/addons/refuel/functions/fnc_setFuel.sqf b/addons/refuel/functions/fnc_setFuel.sqf new file mode 100644 index 0000000000..a182d463ae --- /dev/null +++ b/addons/refuel/functions/fnc_setFuel.sqf @@ -0,0 +1,24 @@ +/* + * Author: GitHawk + * Set the remaining fuel amount. + * + * Arguments: + * 0: Fuel Truck + * 1: Amount (in liters) + * + * Return Value: + * None + * + * Example: + * [fuelTruck, 42] call ace_refuel_fnc_setFuel + * + * Public: No + */ +#include "script_component.hpp" +private ["_maxFuel"]; +params ["_target", "_fuel"]; + +if (isNull _target || + {isNil "_fuel"}) exitWith {}; + +_target setVariable [QGVAR(currentFuelCargo), _fuel, true]; diff --git a/addons/refuel/functions/fnc_takeNozzle.sqf b/addons/refuel/functions/fnc_takeNozzle.sqf new file mode 100644 index 0000000000..f6d953cecc --- /dev/null +++ b/addons/refuel/functions/fnc_takeNozzle.sqf @@ -0,0 +1,141 @@ +/* + * Author: GitHawk + * Take a fuel nozzle either from a fuel truck/station or from the ground. + * + * Arguments: + * 0: Unit + * 1: Fuel Truck + * 2: Nozzle (optional) + * + * Return Value: + * None + * + * Example: + * [player, fuelTruck] call ace_refuel_fnc_takeNozzle + * [player, objNull, nozzle] call ace_refuel_fnc_takeNozzle + * + * Public: No + */ +#include "script_component.hpp" + +private ["_endPosOffset"], +params ["_unit", "_target", ["_nozzle", objNull]]; + +[_unit, QGVAR(vehAttach), true] call EFUNC(common,setForceWalkStatus); + +REFUEL_HOLSTER_WEAPON + +_endPosOffset = [0, 0, 0]; +if (isNull _nozzle) then { // func is called on fuel truck + _target setVariable [QGVAR(engineHit), _target getHitPointDamage "HitEngine", true]; + if !(local _target) then { + [[_target, ["HitEngine", 1]], "{(_this select 0) setHitPointDamage (_this select 1)}", _sink] call EFUNC(common,execRemoteFnc); + } else { + _target setHitPointDamage ["HitEngine", 1]; + }; + + _target setVariable [QGVAR(isConnected), true, true]; + _endPosOffset = getArray (configFile >> "CfgVehicles" >> typeOf _target >> "ace_refuel_hooks"); + if (count _endPosOffset == 2) then { + if (_unit distance (_target modelToWorld (_endPosOffset select 0)) < _unit distance (_target modelToWorld (_endPosOffset select 1))) then { + _endPosOffset = _endPosOffset select 0; + } else { + _endPosOffset = _endPosOffset select 1; + }; + } else { + _endPosOffset = _endPosOffset select 0; + }; + [ + 2, + [_unit, _target, _endPosOffset], + { + private ["_newNozzle", "_rope", "_actionID"]; + params ["_args"]; + _args params ["_unit", "_target", "_endPosOffset"]; + + _newNozzle = "ACE_refuel_fuelNozzle" createVehicle position _unit; + _newNozzle attachTo [_unit, [-0.02,-0.05,0], "righthandmiddle1"]; // TODO replace with right coordinates for real model + _unit setVariable [QGVAR(nozzle), _newNozzle]; + + _rope = ropeCreate [_target, _endPosOffset, _newNozzle, [0, 0, 0], REFUEL_HOSE_LENGTH]; + _newNozzle setVariable [QGVAR(attachPos), _endPosOffset, true]; + _newNozzle setVariable [QGVAR(source), _target, true]; + _newNozzle setVariable [QGVAR(rope), _rope, true]; + _target setVariable [QGVAR(ownedNozzle), _newNozzle, true]; + + _unit setVariable [QGVAR(isRefueling), true]; + _actionID = _unit getVariable [QGVAR(ReleaseActionID), -1]; + if (_actionID != -1) then { + _unit removeAction _actionID; + }; + _actionID = _unit addAction [ + format ["%1", localize ELSTRING(dragging,Drop)], + '_unit = _this select 0; _nozzle = _unit getVariable QGVAR(nozzle); [_unit, _nozzle] call FUNC(dropNozzle); [_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); REFUEL_UNHOLSTER_WEAPON', + nil, + 20, + false, + true, + "", + '!isNull (_target getVariable [QGVAR(nozzle), objNull])' + ]; + _unit setVariable [QGVAR(ReleaseActionID), _actionID]; + }, + "", + localize LSTRING(TakeNozzleAction), + {true}, + ["isnotinside"] + ] call EFUNC(common,progressBar); +} else { // func is called in muzzle either connected or on ground + [ + 2, + [_unit, _nozzle], + { + private ["_actionID"]; + params ["_args"]; + _args params ["_unit", "_nozzle"]; + _nozzle attachTo [_unit, [-0.02,-0.05,0], "righthandmiddle1"]; // TODO replace with right coordinates for real model + _unit setVariable [QGVAR(nozzle), _nozzle]; + + _unit setVariable [QGVAR(isRefueling), true]; + _actionID = _unit getVariable [QGVAR(ReleaseActionID), -1]; + if (_actionID != -1) then { + _unit removeAction _actionID; + }; + _actionID = _unit addAction [ + format ["%1", localize ELSTRING(dragging,Drop)], + '_unit = _this select 0; _nozzle = _unit getVariable QGVAR(nozzle); [_unit, _nozzle] call FUNC(dropNozzle); [_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); REFUEL_UNHOLSTER_WEAPON', + nil, + 20, + false, + true, + "", + '!isNull (_target getVariable [QGVAR(nozzle), objNull])' + ]; + _unit setVariable [QGVAR(ReleaseActionID), _actionID]; + }, + "", + localize LSTRING(TakeNozzleAction), + {true}, + ["isnotinside"] + ] call EFUNC(common,progressBar); + + _target = _nozzle getVariable QGVAR(source); + _endPosOffset = _nozzle getVariable QGVAR(attachPos); +}; +[{ + private ["_nozzle"]; + params ["_args", "_pfID"]; + _args params ["_unit", "_source", "_endPosOffset"]; + + if (_unit distance (_source modelToWorld _endPosOffset) > (REFUEL_HOSE_LENGTH - 2)) exitWith { + _nozzle = _unit getVariable [QGVAR(nozzle), objNull]; + if !(isNull _nozzle) then { + [_unit, _nozzle] call FUNC(dropNozzle); + REFUEL_UNHOLSTER_WEAPON + + [_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); + [LSTRING(Hint_TooFar), 2, _unit] call EFUNC(common,displayTextStructured); + }; + [_pfID] call cba_fnc_removePerFrameHandler; + }; +}, 0, [_unit, _target, _endPosOffset]] call cba_fnc_addPerFrameHandler; diff --git a/addons/refuel/functions/fnc_turnOff.sqf b/addons/refuel/functions/fnc_turnOff.sqf new file mode 100644 index 0000000000..115c1eabe2 --- /dev/null +++ b/addons/refuel/functions/fnc_turnOff.sqf @@ -0,0 +1,34 @@ +/* + * Author: GitHawk + * Turn off a fuel nozzle. + * + * Arguments: + * 0: Unit + * 1: Nozzle + * + * Return Value: + * None + * + * Example: + * [nozzle] call ace_refuel_fnc_turnOff + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit", "_nozzle"]; + +[ + 2, + [_unit, _nozzle], + { + params ["_args"]; + _args params ["_unit", "_nozzle"]; + _nozzle setVariable [QGVAR(isRefueling), false, true]; + [LSTRING(Hint_Stopped), 1.5, _unit] call EFUNC(common,displayTextStructured); + }, + "", + localize LSTRING(TurnOffAction), + {true}, + ["isnotinside"] +] call EFUNC(common,progressBar); diff --git a/addons/refuel/functions/fnc_turnOn.sqf b/addons/refuel/functions/fnc_turnOn.sqf new file mode 100644 index 0000000000..017a8ee021 --- /dev/null +++ b/addons/refuel/functions/fnc_turnOn.sqf @@ -0,0 +1,35 @@ +/* + * Author: GitHawk + * Turn on a fuel nozzle. + * + * Arguments: + * 0: Unit + * 1: Nozzle + * + * Return Value: + * None + * + * Example: + * [player, nozzle] call ace_refuel_fnc_turnOn + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit", "_nozzle"]; + +[ + 2, + [_unit, _nozzle], + { + private "_source"; + params ["_args"]; + _args params ["_unit", "_nozzle"]; + _nozzle setVariable [QGVAR(isRefueling), true, true]; + [LSTRING(Hint_Started), 1.5, _unit] call EFUNC(common,displayTextStructured); + }, + "", + localize LSTRING(TurnOnAction), + {true}, + ["isnotinside"] +] call EFUNC(common,progressBar); diff --git a/addons/refuel/functions/script_component.hpp b/addons/refuel/functions/script_component.hpp new file mode 100644 index 0000000000..167c1e614a --- /dev/null +++ b/addons/refuel/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\refuel\script_component.hpp" diff --git a/addons/refuel/script_component.hpp b/addons/refuel/script_component.hpp new file mode 100644 index 0000000000..28e6fb7931 --- /dev/null +++ b/addons/refuel/script_component.hpp @@ -0,0 +1,25 @@ +#define COMPONENT refuel +#include "\z\ace\addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_REFUEL + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_ENABLED_REFUEL + #define DEBUG_SETTINGS DEBUG_ENABLED_REFUEL +#endif + +#include "\z\ace\addons\main\script_macros.hpp" + +#define REFUEL_INFINITE_FUEL -1 +#define REFUEL_ACTION_DISTANCE 37 +#define REFUEL_HOSE_LENGTH 12 + +#define REFUEL_HOLSTER_WEAPON \ + _unit setVariable [QGVAR(selectedWeaponOnRefuel), currentWeapon _unit]; \ + _unit action ["SwitchWeapon", _unit, _unit, 99]; + +#define REFUEL_UNHOLSTER_WEAPON \ + _weaponSelect = _unit getVariable QGVAR(selectedWeaponOnRefuel); \ + _unit selectWeapon _weaponSelect; \ + _unit setVariable [QGVAR(selectedWeaponOnRefuel), nil]; diff --git a/addons/refuel/stringtable.xml b/addons/refuel/stringtable.xml new file mode 100644 index 0000000000..c530501346 --- /dev/null +++ b/addons/refuel/stringtable.xml @@ -0,0 +1,129 @@ + + + + + Refuel Settings + Betankungseinst. + + + Flow Rate + Fließrate + + + How fast should a vehicle be refueled? + Wie schnell soll ein Fahrzeug aufgetankt sein? + + + Refuel + Betankung + + + Take fuel nozzle + Zapfpistole nehmen + + + Taking fuel nozzle ... + Nehme Zapfpistole ... + + + Connect fuel nozzle + Zapfpistole anschließen + + + Connecting fuel nozzle ... + Zapfpistole anschließen ... + + + Disconnect fuel nozzle + Zapfpistole entfernen + + + Connect + Anschließen + + + Check remaining fuel + Verbleibenden Kraftstoff überprüfen + + + Checking remaining fuel ... + Überprüfe verbleibenden Kraftstoff ... + + + There are %1 liters left. + Es sind noch %1 Liter übrig. + + + There is no fuel left. + Es ist kein Kraftstoff übrig. + + + Cancel + Abbrechen + + + Failed + Gescheitert + + + Stop fueling + Betankung stoppen + + + Stopping fueling ... + Stoppe Betankung ... + + + Start fueling + Betankung beginnen + + + Starting fueling ... + Beginne Betankung ... + + + %1 Liters fueled + %1 Liters getankt + + + The fuel source is empty. + Die Treibstoffquelle ist leer. + + + Maximum fuel hose length reached. + Maximale Schlauchlänge erreicht. + + + Fueling completed + Betankung abgeschlossen + + + Fueling stopped + Betankung angehalten + + + Fueling started + Betankung begonnen + + + Return fuel nozzle + Zapfpistole zurückstecken + + + Returning fuel nozzle ... + Stecke Zapfpistole zurück ... + + + Check fuel counter + Tankuhr ansehen + + + >Checking fuel counter ... + Betrachte Tankuhr ... + + + %1 liters have been fueled. + %1 Liter wurden getankt. + + + diff --git a/addons/refuel/ui/icon_module_refuel.paa b/addons/refuel/ui/icon_module_refuel.paa new file mode 100644 index 0000000000..84704c13d7 Binary files /dev/null and b/addons/refuel/ui/icon_module_refuel.paa differ diff --git a/addons/refuel/ui/icon_refuel_interact.paa b/addons/refuel/ui/icon_refuel_interact.paa new file mode 100644 index 0000000000..2cc1a9320d Binary files /dev/null and b/addons/refuel/ui/icon_refuel_interact.paa differ diff --git a/addons/vehiclelock/README.md b/addons/vehiclelock/readme.md similarity index 76% rename from addons/vehiclelock/README.md rename to addons/vehiclelock/readme.md index c31402c6e3..64ae01a99c 100644 --- a/addons/vehiclelock/README.md +++ b/addons/vehiclelock/readme.md @@ -5,10 +5,11 @@ Adds keys as an item, to lock and unlock vehicles. Primary target would be role play or TVT, but has uses in all game types, even co-ops (e.g.: DAC AI will steal unlocked vehicles) Two key modes (can be used together): -- Simple Side based keys (e.g. "ACE_key_west" works on any [WEST] vehicle like the M-ATV//hunter) -- Custom keys (one key will only open a specific vehicle and nothing else) +* Simple Side based keys (e.g. "ACE_key_west" works on any [WEST] vehicle like the M-ATV//hunter) +* Custom keys (one key will only open a specific vehicle and nothing else) #### Items Added: + `ACE_key_lockpick` `ACE_key_master` `ACE_key_west` @@ -19,21 +20,19 @@ Two key modes (can be used together): #### Magazine added: `ACE_key_customKeyMagazine` (should never be manualy added, needs to be "programed" to work on a vehicle, see `ACE_VehicleLock_fnc_addKeyForVehicle`) - ## For Mission Makers: #### Modules: -- Vehicle Lock Setup - Settings for locking inventory of locked vehicles, default lockpick time, and initial vehicle lock state. -- Vehicle Key Assign - Sync with vehicles and players. Will handout custom keys to players for every synced vehicle. Will NOT work for JIP units. +* Vehicle Lock Setup - Settings for locking inventory of locked vehicles, default lockpick time, and initial vehicle lock state. +* Vehicle Key Assign - Sync with vehicles and players. Will handout custom keys to players for every synced vehicle. Will NOT work for JIP units. #### Vehicle setVariables: -- `ACE_VehicleLock_lockSide` - SIDE: overrides a vehicle's side, allows indfor to use little-bird's with indp keys -- `ACE_vehicleLock_lockpickStrength` - NUMBER: secons, determines how long lockpicking with take, overrides ACE_VehicleLock_DefaultLockpickStrength +* `ACE_VehicleLock_lockSide` - SIDE: overrides a vehicle's side, allows indfor to use little-bird's with indp keys +* `ACE_vehicleLock_lockpickStrength` - NUMBER: secons, determines how long lockpicking with take, overrides ACE_VehicleLock_DefaultLockpickStrength #### Public Functions: `[bob, car1, true] call ACE_VehicleLock_fnc_addKeyForVehicle;` - will add a `ACE_key_customKeyMagazine` to bob and program it to work on car1 - ## Maintainers The people responsible for merging changes to this component or answering potential questions. diff --git a/extras/assets/icons/Icon_Module_png/Icons_Modules_Refuel.png b/extras/assets/icons/Icon_Module_png/Icons_Modules_Refuel.png new file mode 100644 index 0000000000..da50b92caf Binary files /dev/null and b/extras/assets/icons/Icon_Module_png/Icons_Modules_Refuel.png differ diff --git a/optionals/compat_bwa3/CfgVehicles.hpp b/optionals/compat_bwa3/CfgVehicles.hpp new file mode 100644 index 0000000000..bdcebdab9d --- /dev/null +++ b/optionals/compat_bwa3/CfgVehicles.hpp @@ -0,0 +1,11 @@ +class CfgVehicles { + class Tank_F; + class BWA3_Puma_base: Tank_F { + // Assuming 1 L/km + EGVAR(refuel,fuelCapacity) = 700; + }; + + class BWA3_Leopard_base: Tank_F { + EGVAR(refuel,fuelCapacity) = 1160; + }; +}; diff --git a/optionals/compat_rhs_afrf3/CfgVehicles.hpp b/optionals/compat_rhs_afrf3/CfgVehicles.hpp index e9c71f4da7..963913d74d 100644 --- a/optionals/compat_rhs_afrf3/CfgVehicles.hpp +++ b/optionals/compat_rhs_afrf3/CfgVehicles.hpp @@ -28,6 +28,7 @@ class cfgVehicles { class CommanderOptics; }; class rhs_bmd_base: Tank_F { + EGVAR(refuel,fuelCapacity) = 300; class Turrets: Turrets { class CommanderOptics: NewTurret { ace_fcs_Enabled = 0; @@ -41,6 +42,7 @@ class cfgVehicles { }; }; class rhs_bmp1tank_base: Tank_F { + EGVAR(refuel,fuelCapacity) = 460; class Turrets: Turrets { class MainTurret: MainTurret { ace_fcs_Enabled = 0; @@ -57,13 +59,14 @@ class cfgVehicles { class MainTurret: MainTurret { class Turrets: Turrets { class CommanderOptics : CommanderOptics { - ace_fcs_Enabled = 0; + ace_fcs_Enabled = 0; }; }; }; }; }; class rhs_bmp3tank_base: Tank_F { + EGVAR(refuel,fuelCapacity) = 460; class Turrets: Turrets { class MainTurret: MainTurret { ace_fcs_Enabled = 0; @@ -79,6 +82,7 @@ class cfgVehicles { }; }; class rhs_btr_base: Wheeled_APC_F { + EGVAR(refuel,fuelCapacity) = 300; class Turrets: Turrets { class MainTurret: MainTurret { ace_fcs_Enabled = 0; @@ -89,6 +93,7 @@ class cfgVehicles { }; }; class rhs_a3spruttank_base: Tank_F { + EGVAR(refuel,fuelCapacity) = 400; class Turrets: Turrets { class MainTurret: MainTurret { ace_fcs_Enabled = 0; @@ -105,6 +110,7 @@ class cfgVehicles { }; }; class rhs_a3t72tank_base: Tank_F { + EGVAR(refuel,fuelCapacity) = 1200; class Turrets: Turrets { class MainTurret: MainTurret { ace_fcs_Enabled = 0; @@ -133,6 +139,7 @@ class cfgVehicles { }; }; class rhs_tank_base: Tank_F { + EGVAR(refuel,fuelCapacity) = 1200; class Turrets: Turrets { class MainTurret: MainTurret { ace_fcs_Enabled = 0; @@ -153,4 +160,71 @@ class cfgVehicles { { ace_gforcecoef = 0.55; }; -}; \ No newline at end of file + + class O_Plane_CAS_02_F; + class RHS_su25_base : O_Plane_CAS_02_F { + EGVAR(refuel,fuelCapacity) = 3600; + }; + + class Heli_Light_02_base_F; + class RHS_Mi8_base : Heli_Light_02_base_F { + EGVAR(refuel,fuelCapacity) = 3700; + }; + + class Heli_Attack_02_base_F; + class RHS_Ka52_base : Heli_Attack_02_base_F { + EGVAR(refuel,fuelCapacity) = 1870; + }; + + class RHS_Mi24_base : Heli_Attack_02_base_F { + EGVAR(refuel,fuelCapacity) = 1851; + }; + + class rhs_t80b : rhs_tank_base { + EGVAR(refuel,fuelCapacity) = 1100; + }; + + class Truck_F; + class RHS_Ural_BaseTurret : Truck_F { + EGVAR(refuel,fuelCapacity) = 360; + }; + + class rhs_truck : Truck_F { + EGVAR(refuel,fuelCapacity) = 210; + }; + + class MRAP_02_base_F; + class rhs_tigr_base : MRAP_02_base_F { + EGVAR(refuel,fuelCapacity) = 138; + }; + + class Offroad_01_base_f; + class RHS_UAZ_Base : Offroad_01_base_f { + EGVAR(refuel,fuelCapacity) = 78; + }; + + class APC_Tracked_02_base_F; + class rhs_zsutank_base : APC_Tracked_02_base_F { + EGVAR(refuel,fuelCapacity) = 515; + }; + + class rhs_btr60_base : rhs_btr_base { + EGVAR(refuel,fuelCapacity) = 290; + }; + class rhs_btr70_vmf : rhs_btr_base { + EGVAR(refuel,fuelCapacity) = 350; + }; + + class rhs_btr70_msv : rhs_btr70_vmf {}; + class rhs_btr80_msv : rhs_btr70_msv { + EGVAR(refuel,fuelCapacity) = 300; + }; + + class rhs_2s3tank_base : Tank_F { + EGVAR(refuel,fuelCapacity) = 830; + }; + + class OTR21_Base : Truck_F { + EGVAR(refuel,fuelCapacity) = 500; + }; +}; diff --git a/optionals/compat_rhs_afrf3/config.cpp b/optionals/compat_rhs_afrf3/config.cpp index 123f80b566..aa9d6bed95 100644 --- a/optionals/compat_rhs_afrf3/config.cpp +++ b/optionals/compat_rhs_afrf3/config.cpp @@ -6,7 +6,7 @@ class CfgPatches { weapons[] = {}; requiredVersion = REQUIRED_VERSION; requiredAddons[] = {"rhs_c_weapons", "rhs_c_troops"}; - author[]={"Ruthberg"}; + author[]={"Ruthberg", "GitHawk"}; VERSION_CONFIG; }; }; @@ -14,4 +14,4 @@ class CfgPatches { #include "CfgAmmo.hpp" #include "CfgMagazines.hpp" #include "CfgWeapons.hpp" -#include "CfgVehicles.hpp" \ No newline at end of file +#include "CfgVehicles.hpp" diff --git a/optionals/compat_rhs_usf3/CfgVehicles.hpp b/optionals/compat_rhs_usf3/CfgVehicles.hpp index 2be7a8076e..3c56b91aa9 100644 --- a/optionals/compat_rhs_usf3/CfgVehicles.hpp +++ b/optionals/compat_rhs_usf3/CfgVehicles.hpp @@ -15,6 +15,7 @@ class cfgVehicles { class MBT_01_base_F: Tank_F {}; class rhsusf_m1a1tank_base: MBT_01_base_F { + EGVAR(refuel,fuelCapacity) = 1909; class Turrets: Turrets { class MainTurret: MainTurret { ace_fcs_Enabled = 0; @@ -29,4 +30,67 @@ class cfgVehicles { }; }; }; -}; \ No newline at end of file + + class Heli_light_03_base_F; + class RHS_UH1_Base : Heli_light_03_base_F { + EGVAR(refuel,fuelCapacity) = 1447; + }; + + class Heli_Transport_01_base_F; + class RHS_UH60_Base : Heli_Transport_01_base_F { + EGVAR(refuel,fuelCapacity) = 1360; + }; + + class Heli_Transport_02_base_F; + class RHS_CH_47F_base : Heli_Transport_02_base_F { + EGVAR(refuel,fuelCapacity) = 3914; + }; + + class Heli_Attack_01_base_F; + class RHS_AH1Z_base : Heli_Attack_01_base_F { + EGVAR(refuel,fuelCapacity) = 1600; + }; + + class RHS_AH64_base : Heli_Attack_01_base_F { + EGVAR(refuel,fuelCapacity) = 1420; + }; + + class MBT_01_arty_base_F; + class rhsusf_m109tank_base : MBT_01_arty_base_F { + EGVAR(refuel,fuelCapacity) = 511; + }; + + class MRAP_01_base_F; + class rhsusf_hmmwe_base : MRAP_01_base_F { + EGVAR(refuel,fuelCapacity) = 95; + }; + + class rhsusf_rg33_base : MRAP_01_base_F { + EGVAR(refuel,fuelCapacity) = 302; + }; + + class Truck_01_base_F; + class rhsusf_fmtv_base : Truck_01_base_F { + EGVAR(refuel,fuelCapacity) = 219; + }; + + class APC_Tracked_02_base_F; + class rhsusf_m113_tank_base : APC_Tracked_02_base_F { + EGVAR(refuel,fuelCapacity) = 360; + }; + + class APC_Tracked_03_base_F; + class RHS_M2A2_Base : APC_Tracked_03_base_F { + EGVAR(refuel,fuelCapacity) = 746; + }; + + class Plane_CAS_01_base_F; + class RHS_A10 : Plane_CAS_01_base_F { + EGVAR(refuel,fuelCapacity) = 6223; + }; + + class Plane_Base_F; + class RHS_C130J_Base : Plane_Base_F { + EGVAR(refuel,fuelCapacity) = 25704; + }; +}; diff --git a/optionals/compat_rhs_usf3/config.cpp b/optionals/compat_rhs_usf3/config.cpp index 3e9aee6ec7..59517ed64f 100644 --- a/optionals/compat_rhs_usf3/config.cpp +++ b/optionals/compat_rhs_usf3/config.cpp @@ -6,7 +6,7 @@ class CfgPatches { weapons[] = {}; requiredVersion = REQUIRED_VERSION; requiredAddons[] = {"rhsusf_c_weapons", "rhsusf_c_troops"}; - author[]={"Ruthberg"}; + author[]={"Ruthberg", "GitHawk"}; VERSION_CONFIG; }; }; @@ -14,4 +14,4 @@ class CfgPatches { #include "CfgAmmo.hpp" #include "CfgMagazines.hpp" #include "CfgWeapons.hpp" -#include "CfgVehicles.hpp" \ No newline at end of file +#include "CfgVehicles.hpp"