diff --git a/addons/rearm/ACE_Settings.hpp b/addons/rearm/ACE_Settings.hpp index d3e4b40d03..f4d6562807 100644 --- a/addons/rearm/ACE_Settings.hpp +++ b/addons/rearm/ACE_Settings.hpp @@ -2,7 +2,7 @@ class ACE_Settings { class GVAR(level) { displayName = CSTRING(RearmSettings_level_DisplayName); description = CSTRING(RearmSettings_level_Description); - value = 1; + value = 0; typeName = "SCALAR"; values[] = {CSTRING(RearmSettings_vehicle), CSTRING(RearmSettings_magazine), CSTRING(RearmSettings_caliber)}; }; diff --git a/addons/rearm/CfgAmmo.hpp b/addons/rearm/CfgAmmo.hpp index dec33f461d..3a346f4bd3 100644 --- a/addons/rearm/CfgAmmo.hpp +++ b/addons/rearm/CfgAmmo.hpp @@ -1,5 +1,5 @@ class CfgAmmo { - + class BombCore; class BombBase : BombCore { GVAR(caliber) = 250; // Default caliber for bombs @@ -17,7 +17,7 @@ class CfgAmmo { class Missile_AA_03_F : Missile_AA_04_F { GVAR(dummy) = QGVAR(Missile_AA_03_F); }; - + class Rocket_04_HE_F : MissileBase { GVAR(caliber) = 70; GVAR(dummy) = QGVAR(Rocket_04_HE_F); @@ -60,170 +60,170 @@ class CfgAmmo { class R_Hydra_HE : RocketBase { GVAR(dummy) = QGVAR(R_Hydra_HE); }; - + class BulletBase; class B_19mm_HE : BulletBase { - GVAR(caliber) = 19; + GVAR(caliber) = 19; }; - + class B_20mm : BulletBase { - GVAR(caliber) = 20; + GVAR(caliber) = 20; }; - + class B_25mm : BulletBase { - GVAR(caliber) = 25; + GVAR(caliber) = 25; }; class B_30mm_AP : BulletBase { - GVAR(caliber) = 30; + GVAR(caliber) = 30; }; class B_30mm_HE : B_19mm_HE { - GVAR(caliber) = 30; + GVAR(caliber) = 30; }; class Gatling_30mm_HE_Plane_CAS_01_F : BulletBase { - GVAR(caliber) = 30; + GVAR(caliber) = 30; }; - + class B_35mm_AA : BulletBase { - GVAR(caliber) = 35; + GVAR(caliber) = 35; }; - + class B_30mm_APFSDS; class B_40mm_APFSDS : B_30mm_APFSDS { - GVAR(caliber) = 40; + GVAR(caliber) = 40; }; - + class B_40mm_GPR : B_30mm_HE { - GVAR(caliber) = 40; + GVAR(caliber) = 40; }; class GrenadeBase; class G_40mm_HE : GrenadeBase { - GVAR(caliber) = 40; + GVAR(caliber) = 40; }; class RDS_B_127x107_Ball : BulletBase { - GVAR(caliber) = 12.7; + GVAR(caliber) = 12.7; }; - + class ShellBase; class R_230mm_fly : ShellBase { GVAR(dummy) = QGVAR(R_230mm_fly); }; class Sh_120mm_APFSDS : Shellbase { - GVAR(caliber) = 120; + GVAR(caliber) = 120; }; class Sh_105mm_APFSDS : Sh_120mm_APFSDS { - GVAR(caliber) = 105; + GVAR(caliber) = 105; }; class Sh_125mm_APFSDS : Sh_120mm_APFSDS { - GVAR(caliber) = 125; + GVAR(caliber) = 125; }; - + class Sh_120mm_HE : ShellBase { - GVAR(caliber) = 120; + GVAR(caliber) = 120; }; class Sh_125mm_HE : Sh_120mm_HE { - GVAR(caliber) = 125; + GVAR(caliber) = 125; }; class Sh_125mm_HEAT : Sh_125mm_HE { - GVAR(caliber) = 125; + GVAR(caliber) = 125; }; class Sh_105mm_HEAT_MP : Sh_125mm_HEAT { - GVAR(caliber) = 105; + GVAR(caliber) = 105; }; - + class Sh_155mm_AMOS : ShellBase { - GVAR(caliber) = 155; + GVAR(caliber) = 155; }; class Sh_82mm_AMOS : Sh_155mm_AMOS { - GVAR(caliber) = 82; + GVAR(caliber) = 82; }; class RDS_Sh_122_HE : Sh_155mm_AMOS { - GVAR(caliber) = 122; + GVAR(caliber) = 122; }; class RDS_Sh_105_HE : Sh_155mm_AMOS { - GVAR(caliber) = 105; + GVAR(caliber) = 105; }; - + class Sh_82mm_AMOS_LG; class Sh_155mm_AMOS_LG : Sh_82mm_AMOS_LG { - GVAR(caliber) = 155; + GVAR(caliber) = 155; }; class RDS_Sh_122_LASER : Sh_155mm_AMOS_LG { - GVAR(caliber) = 122; + GVAR(caliber) = 122; }; class RDS_Sh_105_LASER : Sh_155mm_AMOS_LG { - GVAR(caliber) = 105; + GVAR(caliber) = 105; }; - + class ShotDeployBase; class Smoke_82mm_AMOS_White : ShotDeployBase { - GVAR(caliber) = 82; + GVAR(caliber) = 82; }; - + class FlareCore; class Flare_82mm_AMOS_White : FlareCore { - GVAR(caliber) = 82; + GVAR(caliber) = 82; }; - + class SmokeLauncherAmmo : BulletBase { - GVAR(caliber) = 250; + GVAR(caliber) = 250; }; - + class CMflareAmmo : BulletBase { GVAR(caliber) = 40; }; - + class SubmunitionBase; class Sh_82mm_AMOS_guided : SubmunitionBase { - GVAR(caliber) = 82; + GVAR(caliber) = 82; }; class Sh_155mm_AMOS_guided : Sh_82mm_AMOS_guided { - GVAR(caliber) = 155; + GVAR(caliber) = 155; }; class R_230mm_HE : SubmunitionBase { - GVAR(caliber) = 230; + GVAR(caliber) = 230; }; class rhs_ammo_127x108mm_x5 : SubmunitionBase { - GVAR(caliber) = 12.7; + GVAR(caliber) = 12.7; }; class Mine_155mm_AMOS_range : SubmunitionBase { - GVAR(caliber) = 155; + GVAR(caliber) = 155; }; class Cluster_155mm_AMOS : SubmunitionBase { - GVAR(caliber) = 155; + GVAR(caliber) = 155; }; class Smoke_120mm_AMOS_White : SubmunitionBase { - GVAR(caliber) = 155; + GVAR(caliber) = 155; }; class AT_Mine_155mm_AMOS_range : SubmunitionBase { - GVAR(caliber) = 155; + GVAR(caliber) = 155; }; - + class rhs_ammo_rpgShell_base : ShellBase { - GVAR(caliber) = 70; + GVAR(caliber) = 70; }; - + class Bo_Mk82 : BombCore { GVAR(dummy) = QGVAR(Bo_Mk82); }; - + class Bo_GBU12_LGB : LaserBombCore { GVAR(caliber) = 250; // Default caliber for bombs GVAR(dummy) = QGVAR(Bo_GBU12_LGB); }; - + class Bomb_04_F : LaserBombCore { GVAR(caliber) = 250; // Default caliber for bombs GVAR(dummy) = QGVAR(Bomb_04_F); }; - + class Bomb_03_F : Bomb_04_F { GVAR(dummy) = QGVAR(Bomb_03_F); }; - + // F18 Mod class js_a_fa18_wing_tank : LaserBombCore { GVAR(caliber) = 250; // Default caliber for bombs @@ -232,7 +232,7 @@ class CfgAmmo { class js_a_fa18x_GBU39_SDB : js_a_fa18x_MK82 { GVAR(caliber) = 250; // Default caliber for bombs }; - + class js_a_fa18_GBU12_LGB : LaserBombCore {}; class js_a_fa18_GBU38_JDAM : js_a_fa18_GBU12_LGB { GVAR(caliber) = 250; // Default caliber for bombs diff --git a/addons/rearm/CfgEventHandlers.hpp b/addons/rearm/CfgEventHandlers.hpp index b5d499850b..b125006442 100644 --- a/addons/rearm/CfgEventHandlers.hpp +++ b/addons/rearm/CfgEventHandlers.hpp @@ -16,4 +16,12 @@ class Extended_Respawn_EventHandlers { respawn = QUOTE(call COMPILE_FILE(XEH_respawn)); }; }; -}; \ No newline at end of file +}; + +class Extended_Killed_EventHandlers { + class CAManBase { + class ADDON { + killed = QUOTE(_this call FUNC(handleKilled)); + }; + }; +}; diff --git a/addons/rearm/CfgMagazines.hpp b/addons/rearm/CfgMagazines.hpp index 63bccd451d..a509377182 100644 --- a/addons/rearm/CfgMagazines.hpp +++ b/addons/rearm/CfgMagazines.hpp @@ -1,56 +1,56 @@ class CfgMagazines { class CA_Magazine; class 60Rnd_CMFlareMagazine : CA_Magazine { - displayName = CSTRING(60Rnd_CMFlareMagazine); + displayName = CSTRING(Mag_60Rnd_CMFlareMagazine); }; class VehicleMagazine; class SmokeLauncherMag : VehicleMagazine { - displayName = CSTRING(SmokeLauncherMag); + displayName = CSTRING(Mag_SmokeLauncherMag); }; class SmokeLauncherMag_boat : VehicleMagazine { - displayName = CSTRING(SmokeLauncherMag); + displayName = CSTRING(Mag_SmokeLauncherMag); }; - + class 1000Rnd_Gatling_30mm_Plane_CAS_01_F : VehicleMagazine { - displayName = CSTRING(1000Rnd_Gatling_30mm_Plane_CAS_01_F); + displayName = CSTRING(Mag_1000Rnd_Gatling_30mm_Plane_CAS_01_F); }; class 500Rnd_Cannon_30mm_Plane_CAS_02_F : 1000Rnd_Gatling_30mm_Plane_CAS_01_F { - displayName = CSTRING(500Rnd_Cannon_30mm_Plane_CAS_02_F); + displayName = CSTRING(Mag_500Rnd_Cannon_30mm_Plane_CAS_02_F); }; class 2Rnd_Missile_AA_04_F : VehicleMagazine { - displayName = CSTRING(2Rnd_Missile_AA_04_F); + displayName = CSTRING(Mag_2Rnd_Missile_AA_04_F); }; class 2Rnd_Missile_AA_03_F : 2Rnd_Missile_AA_04_F { - displayName = CSTRING(2Rnd_Missile_AA_03_F); + displayName = CSTRING(Mag_2Rnd_Missile_AA_03_F); }; class 6Rnd_Missile_AGM_02_F : VehicleMagazine { - displayName = CSTRING(6Rnd_Missile_AGM_02_F); + displayName = CSTRING(Mag_6Rnd_Missile_AGM_02_F); }; class 4Rnd_Missile_AGM_01_F : 6Rnd_Missile_AGM_02_F { - displayName = CSTRING(4Rnd_Missile_AGM_01_F); + displayName = CSTRING(Mag_4Rnd_Missile_AGM_01_F); }; class 7Rnd_Rocket_04_HE_F : VehicleMagazine { - displayName = CSTRING(7Rnd_Rocket_04_HE_F); + displayName = CSTRING(Mag_7Rnd_Rocket_04_HE_F); }; class 20Rnd_Rocket_03_HE_F : 7Rnd_Rocket_04_HE_F { - displayName = CSTRING(20Rnd_Rocket_03_HE_F); + displayName = CSTRING(Mag_20Rnd_Rocket_03_HE_F); }; class 7Rnd_Rocket_04_AP_F : 7Rnd_Rocket_04_HE_F { - displayName = CSTRING(7Rnd_Rocket_04_AP_F); + displayName = CSTRING(Mag_7Rnd_Rocket_04_AP_F); }; class 20Rnd_Rocket_03_AP_F : 7Rnd_Rocket_04_AP_F { - displayName = CSTRING(20Rnd_Rocket_03_AP_F); + displayName = CSTRING(Mag_20Rnd_Rocket_03_AP_F); }; class 4Rnd_Bomb_04_F : VehicleMagazine { - displayName = CSTRING(4Rnd_Bomb_04_F); + displayName = CSTRING(Mag_4Rnd_Bomb_04_F); }; class 2Rnd_Bomb_03_F : 4Rnd_Bomb_04_F { - displayName = CSTRING(2Rnd_Bomb_03_F); + displayName = CSTRING(Mag_2Rnd_Bomb_03_F); }; -}; \ No newline at end of file +}; diff --git a/addons/rearm/CfgVehicles.hpp b/addons/rearm/CfgVehicles.hpp index 775e9e8bfe..cfe0bfb289 100644 --- a/addons/rearm/CfgVehicles.hpp +++ b/addons/rearm/CfgVehicles.hpp @@ -1,13 +1,8 @@ -#define REARM_ACTION_DISTANCE 4.5 #define MACRO_REARM_ACTIONS \ class ACE_Actions { \ class ACE_MainActions { \ - displayName = ECSTRING(interaction,MainAction); \ - selection = ""; \ - distance = 10; \ - condition = "true"; \ - class GVAR(rearm) { \ - displayName = CSTRING(rearm); \ + class GVAR(Rearm) { \ + displayName = CSTRING(Rearm); \ distance = REARM_ACTION_DISTANCE; \ condition = QUOTE([ARR_2(_player,_target)] call FUNC(canRearm)); \ statement = QUOTE([ARR_2(_player,_target)] call FUNC(rearm)); \ @@ -15,23 +10,23 @@ icon = PATHTOF(ui\icon_rearm_interact.paa); \ }; \ }; \ - }; + }; #define MACRO_REARM_PICKUPAMMO \ class ACE_Actions : ACE_Actions { \ class ACE_MainActions : ACE_MainActions { \ - class GVAR(pickUpAmmo) { \ - displayName = CSTRING(pickUpAmmo); \ + class GVAR(PickUpAmmo) { \ + displayName = CSTRING(PickUpAmmo); \ distance = REARM_ACTION_DISTANCE; \ condition = QUOTE([ARR_2(_player,_target)] call FUNC(canPickUpAmmo)); \ - insertChildren = QUOTE([ARR_1(_target)] call DFUNC(addRearmActions)); \ + insertChildren = QUOTE([_target] call FUNC(addRearmActions)); \ exceptions[] = {"isNotInside"}; \ icon = PATHTOF(ui\icon_rearm_interact.paa); \ }; \ }; \ }; -#define DUMMY_PROPERTIES \ +#define MACRO_DUMMY_PROPERTIES \ displayName = QGVAR(dummy_obj); \ scope = 2; \ scopeCurator = 2; @@ -43,7 +38,7 @@ class CfgVehicles { displayName = CSTRING(RearmSettings_Module_DisplayName); icon = QUOTE(PATHTOF(ui\icon_module_rearm.paa)); category = "ACE"; - function = QUOTE(DFUNC(moduleRearmSettings)); + function = QFUNC(moduleRearmSettings); functionPriority = 1; isGlobal = 0; isTriggerActivated = 0; @@ -70,6 +65,9 @@ class CfgVehicles { }; }; }; + class ModuleDescription { + description = CSTRING(RearmSettings_Module_Description); + }; }; class LandVehicle; @@ -80,7 +78,7 @@ class CfgVehicles { class Tank : LandVehicle { MACRO_REARM_ACTIONS }; - + class StaticWeapon : LandVehicle { MACRO_REARM_ACTIONS }; @@ -99,125 +97,110 @@ class CfgVehicles { MACRO_REARM_ACTIONS }; + + // Ammo Vehicles (with full inheritance for granted ACE_Actions) class Car_F : Car {}; class Truck_F : Car_F {}; - class Truck_01_base_F: Truck_F {}; - class Truck_02_base_F : Truck_F {}; + class Truck_03_base_F : Truck_F {}; - - class B_Truck_01_transport_F : Truck_01_base_F {}; - class B_Truck_01_mover_F: B_Truck_01_transport_F {}; - - class I_Truck_02_ammo_F : Truck_02_base_F { - transportAmmo = 0; - MACRO_REARM_PICKUPAMMO - }; - - class B_Truck_01_ammo_F : B_Truck_01_mover_F { - transportAmmo = 0; - MACRO_REARM_PICKUPAMMO - }; - - class O_Truck_02_Ammo_F : Truck_02_base_F { - transportAmmo = 0; - MACRO_REARM_PICKUPAMMO - }; - class O_Truck_03_ammo_F : Truck_03_base_F { transportAmmo = 0; MACRO_REARM_PICKUPAMMO }; - // Dummy vehicles + class Truck_02_base_F : Truck_F {}; + class Truck_02_Ammo_base_F : Truck_02_base_F {}; + class I_Truck_02_ammo_F : Truck_02_Ammo_base_F { + transportAmmo = 0; + MACRO_REARM_PICKUPAMMO + }; + class O_Truck_02_Ammo_F : Truck_02_Ammo_base_F { + transportAmmo = 0; + MACRO_REARM_PICKUPAMMO + }; + + class Truck_01_base_F : Truck_F {}; + class B_Truck_01_transport_F : Truck_01_base_F {}; + class B_Truck_01_mover_F : B_Truck_01_transport_F {}; + class B_Truck_01_ammo_F : B_Truck_01_mover_F { + transportAmmo = 0; + MACRO_REARM_PICKUPAMMO + }; + + + // Dummy Vehicles class ThingX; class GVAR(Bo_GBU12_LGB) : ThingX { - DUMMY_PROPERTIES + MACRO_DUMMY_PROPERTIES model = "\A3\Weapons_F\Ammo\Bomb_01_F.p3d"; }; - class GVAR(Bo_Mk82) : ThingX { - DUMMY_PROPERTIES + MACRO_DUMMY_PROPERTIES model = "\A3\Weapons_F\Ammo\Bomb_02_F"; }; - class GVAR(Bomb_04_F) : ThingX { - DUMMY_PROPERTIES + MACRO_DUMMY_PROPERTIES model = "\A3\Weapons_F_EPC\Ammo\Bomb_04_F.p3d"; }; - class GVAR(Bomb_03_F) : ThingX { - DUMMY_PROPERTIES + MACRO_DUMMY_PROPERTIES model = "\A3\Weapons_F_EPC\Ammo\Bomb_03_F.p3d"; }; - class GVAR(Missile_AA_04_F) : ThingX { - DUMMY_PROPERTIES + MACRO_DUMMY_PROPERTIES model = "\A3\Weapons_F_EPC\Ammo\Missile_AA_04_F.p3d"; }; - class GVAR(Missile_AA_03_F) : ThingX { - DUMMY_PROPERTIES + MACRO_DUMMY_PROPERTIES model = "\A3\Weapons_F_EPC\Ammo\Missile_AA_03_F.p3d"; }; - class GVAR(Missile_AGM_02_F) : ThingX { - DUMMY_PROPERTIES + MACRO_DUMMY_PROPERTIES model = "\A3\Weapons_F_EPC\Ammo\Missile_AGM_02_F.p3d"; }; - class GVAR(Missile_AGM_01_F) : ThingX { - DUMMY_PROPERTIES + MACRO_DUMMY_PROPERTIES model = "\A3\Weapons_F_EPC\Ammo\Missile_AGM_01_F.p3d"; }; - class GVAR(R_230mm_fly) : ThingX { - DUMMY_PROPERTIES + MACRO_DUMMY_PROPERTIES model = "\A3\Weapons_F\Ammo\Missile_AT_02_F"; }; - class GVAR(R_230mm_HE) : ThingX { - DUMMY_PROPERTIES + MACRO_DUMMY_PROPERTIES model = "\A3\Weapons_F\Ammo\Missile_AT_02_F"; }; - class GVAR(M_PG_AT) : ThingX { - DUMMY_PROPERTIES + MACRO_DUMMY_PROPERTIES model = "\A3\Weapons_F\Ammo\Rocket_01_F"; }; - class GVAR(Rocket_04_HE_F) : ThingX { - DUMMY_PROPERTIES + MACRO_DUMMY_PROPERTIES model = "\A3\Weapons_F_EPC\Ammo\Rocket_04_HE_F.p3d"; }; - class GVAR(Rocket_03_HE_F) : ThingX { - DUMMY_PROPERTIES + MACRO_DUMMY_PROPERTIES model = "\A3\Weapons_F_EPC\Ammo\Rocket_03_HE_F.p3d"; }; - class GVAR(Rocket_04_AP_F) : ThingX { - DUMMY_PROPERTIES + MACRO_DUMMY_PROPERTIES model = "\A3\Weapons_F_EPC\Ammo\Rocket_04_AP_F.p3d"; }; - class GVAR(Rocket_03_AP_F) : ThingX { - DUMMY_PROPERTIES + MACRO_DUMMY_PROPERTIES model = "\A3\Weapons_F_EPC\Ammo\Rocket_03_AP_F.p3d"; }; - // Using wrong model class GVAR(R_80mm_HE) : ThingX { - DUMMY_PROPERTIES + MACRO_DUMMY_PROPERTIES model = "\A3\Weapons_F_EPC\Ammo\Rocket_03_HE_F.p3d"; }; - class GVAR(R_60mm_HE) : ThingX { - DUMMY_PROPERTIES + MACRO_DUMMY_PROPERTIES model = "\A3\Weapons_F_EPC\Ammo\Rocket_03_HE_F.p3d"; }; - class GVAR(R_Hydra_HE) : ThingX { - DUMMY_PROPERTIES + MACRO_DUMMY_PROPERTIES model = "\A3\Weapons_F_EPC\Ammo\Rocket_03_HE_F.p3d"; }; }; diff --git a/addons/rearm/XEH_postInit.sqf b/addons/rearm/XEH_postInit.sqf index 2e95457915..682ebaf094 100644 --- a/addons/rearm/XEH_postInit.sqf +++ b/addons/rearm/XEH_postInit.sqf @@ -1,27 +1,3 @@ #include "script_component.hpp" -["medical_onUnconscious", { - if (local (_this select 0)) then { - private ["_unit", "_dummy"]; - _unit = _this select 0; - if (_this select 1) then { - _dummy = _unit getVariable [QGVAR(dummy), objNull]; - if !(isNull _dummy) then { - detach _dummy; - deleteVehicle _dummy; // TODO remove when moved to CfgVehicles - }; - _unit setVariable [QGVAR(dummy), nil]; - }; - }; -}] call EFUNC(common,addEventHandler); - -["medical_onSetDead", { - if (local (_this select 0)) then { - private ["_unit"]; - _unit = _this select 0; - if (_this select 1) then { - _unit setVariable [QGVAR(selectedWeaponOnRearm), nil]; - _unit setVariable [QGVAR(carriedMagazine), nil]; - }; - }; -}] call EFUNC(common,addEventHandler); \ No newline at end of file +["medical_onUnconscious", {_this call FUNC(handleOnUnconscious)}] call EFUNC(common,addEventHandler); diff --git a/addons/rearm/XEH_preInit.sqf b/addons/rearm/XEH_preInit.sqf index 2c3bc4683a..70ec760a2e 100644 --- a/addons/rearm/XEH_preInit.sqf +++ b/addons/rearm/XEH_preInit.sqf @@ -3,16 +3,19 @@ ADDON = false; PREP(addRearmActions); -PREP(canRearm); PREP(canPickupAmmo); +PREP(canRearm); PREP(getMaxMagazines); +PREP(getNeedRearmMagazines); +PREP(handleKilled); +PREP(handleUnconscious); +PREP(moduleRearmSettings); PREP(pickUpAmmo); PREP(pickUpSuccess); PREP(rearm); PREP(rearmEntireVehicle); PREP(rearmEntireVehicleSuccess); PREP(rearmSuccess); -PREP(moduleRearmSettings); PREP(turn); ADDON = true; diff --git a/addons/rearm/config.cpp b/addons/rearm/config.cpp index 975f35b2e3..a0308e1bad 100644 --- a/addons/rearm/config.cpp +++ b/addons/rearm/config.cpp @@ -7,13 +7,14 @@ class CfgPatches { requiredVersion = REQUIRED_VERSION; requiredAddons[] = {"ace_interaction"}; author[] = {"GitHawk"}; - authorUrl = ""; + authorUrl = "https://ace3mod.com"; VERSION_CONFIG; }; }; +#include "ACE_Settings.hpp" #include "CfgEventHandlers.hpp" -#include "CfgVehicles.hpp" -#include "CfgMagazines.hpp" + #include "CfgAmmo.hpp" -#include "ACE_Settings.hpp" \ No newline at end of file +#include "CfgMagazines.hpp" +#include "CfgVehicles.hpp" diff --git a/addons/rearm/functions/fnc_addRearmActions.sqf b/addons/rearm/functions/fnc_addRearmActions.sqf index 987bc473b1..a8bd6b7382 100644 --- a/addons/rearm/functions/fnc_addRearmActions.sqf +++ b/addons/rearm/functions/fnc_addRearmActions.sqf @@ -1,7 +1,6 @@ /* * Author: GitHawk * Show the resupplyable ammunition of all surrounding vehicles. - * Called from "insertChildren" on interact_menu * * Argument: * 0: Target @@ -16,11 +15,11 @@ */ #include "script_component.hpp" -private ["_vehicleActions", "_actions", "_action", "_vehicles", "_vehicle", "_needToAdd", "_magazineHelper", "_turretPath", "_magazines", "_magazine", "_icon"]; +private ["_vehicleActions", "_actions", "_action", "_vehicles", "_vehicle", "_needToAdd", "_magazineHelper", "_turretPath", "_magazines", "_magazine", "_icon", "_cnt"]; params ["_target"]; _vehicles = nearestObjects [_target, ["AllVehicles"], 20]; -if (count _vehicles < 2) exitWith {false}; // Logistics needs at least 2 vehicles +if (count _vehicles < 2) exitWith {false}; // Rearming needs at least 2 vehicles _vehicleActions = []; { @@ -37,32 +36,32 @@ _vehicleActions = []; _magazine = _x; _cnt = { _x == _magazine } count (_vehicle magazinesTurret _turretPath); if ((_cnt < ([_vehicle, _turretPath, _magazine] call FUNC(getMaxMagazines))) && !(_magazine in _magazineHelper)) then { - _action = [_magazine, - getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"), - getText(configFile >> "CfgMagazines" >> _magazine >> "picture"), - {_this call FUNC(pickUpAmmo)}, - {true}, - {}, + _action = [_magazine, + getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"), + getText(configFile >> "CfgMagazines" >> _magazine >> "picture"), + {_this call FUNC(pickUpAmmo)}, + {true}, + {}, [_magazine, _vehicle]] call EFUNC(interact_menu,createAction); _actions pushBack [_action, [], _target]; _magazineHelper pushBack _magazine; _needToAdd = true; } else { if (((_vehicle magazineTurretAmmo [_magazine, _turretPath]) < getNumber (configFile >> "CfgMagazines" >> _magazine >> "count")) && !(_magazine in _magazineHelper)) then { - _action = [_magazine, - getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"), - getText(configFile >> "CfgMagazines" >> _magazine >> "picture"), - {_this call FUNC(pickUpAmmo)}, - {true}, - {}, + _action = [_magazine, + getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"), + getText(configFile >> "CfgMagazines" >> _magazine >> "picture"), + {_this call FUNC(pickUpAmmo)}, + {true}, + {}, [_magazine, _vehicle]] call EFUNC(interact_menu,createAction); _actions pushBack [_action, [], _target]; _magazineHelper pushBack _magazine; _needToAdd = true; }; }; - } foreach _magazines; - } foreach [[0], [-1], [0,0], [0,1], [1], [2]]; + } forEach _magazines; + } forEach REARM_TURRET_PATHS; }; if (_needToAdd) then { _icon = getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "Icon"); @@ -70,26 +69,25 @@ _vehicleActions = []; _icon = ""; }; if (GVAR(level) == 0) then { - _action = [_vehicle, - getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName"), - _icon, - {_this call FUNC(rearmEntireVehicle)}, - {true}, - {}, + _action = [_vehicle, + getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName"), + _icon, + {_this call FUNC(rearmEntireVehicle)}, + {true}, + {}, _vehicle] call EFUNC(interact_menu,createAction); _vehicleActions pushBack [_action, [], _target]; } else { - _action = [_vehicle, - getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName"), - _icon, - {}, - {true}, - {}, + _action = [_vehicle, + getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName"), + _icon, + {}, + {true}, + {}, []] call EFUNC(interact_menu,createAction); _vehicleActions pushBack [_action, _actions, _target]; }; }; -} foreach _vehicles; - +} forEach _vehicles; _vehicleActions diff --git a/addons/rearm/functions/fnc_canPickUpAmmo.sqf b/addons/rearm/functions/fnc_canPickUpAmmo.sqf index 16ff092a60..a6855de756 100644 --- a/addons/rearm/functions/fnc_canPickUpAmmo.sqf +++ b/addons/rearm/functions/fnc_canPickUpAmmo.sqf @@ -1,13 +1,13 @@ /* * Author: GitHawk - * Check if a unit can pick up ammo + * Check if a unit can pick up ammo. * * Arguments: - * 0: The Player - * 1: The Target + * 0: Unit + * 1: Target * * Return Value: - * Can rearm + * Can Pick Up Ammo * * Example: * [player, tank] call ace_rearm_fnc_canPickUpAmmo @@ -18,4 +18,4 @@ params ["_unit", "_target"]; -!(isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || { (_target distance _unit) > 7}) +!(isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {(_target distance _unit) > REARM_ACTION_DISTANCE}) diff --git a/addons/rearm/functions/fnc_canRearm.sqf b/addons/rearm/functions/fnc_canRearm.sqf index 689f01b0e9..e80fb3a940 100644 --- a/addons/rearm/functions/fnc_canRearm.sqf +++ b/addons/rearm/functions/fnc_canRearm.sqf @@ -1,13 +1,13 @@ /* - * Author: GitHawk - * Check if a unit can rearm + * Author: GitHawk, Jonpas + * Check if a unit can rearm. * * Arguments: - * 0: The unit - * 1: The target + * 0: Unit + * 1: Target * * Return Value: - * Can rearm + * Can Rearm * * Example: * [player, tank] call ace_rearm_fnc_canRearm @@ -16,64 +16,12 @@ */ #include "script_component.hpp" -private ["_magazine", "_return", "_magazines", "_path", "_cnt"]; -params ["_unit", "_vehicle"]; +private ["_magazineClass", "_magazines", "_turretPath"]; +params ["_unit", "_target"]; -#define GETRETURNVALUE \ -if ((_vehicle magazineTurretAmmo [_magazine, _path]) < getNumber (configFile >> "CfgMagazines" >> _magazine >> "count")) then { \ - _return = true; \ -} else { \ - _cnt = { _x == _magazine } count _magazines; \ - if (_cnt < ([_vehicle, _path, _magazine] call FUNC(getMaxMagazines))) then { \ - _return = true; \ - }; \ -}; +if (GVAR(level) == 0 || {isNull _unit} || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {_target distance _unit > REARM_ACTION_DISTANCE}) exitWith {false}; -if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || { (_vehicle distance _unit) > 7} || {GVAR(level) == 0}) exitWith {false}; +_magazineClass = _unit getVariable QGVAR(carriedMagazine); +if (isNil "_magazineClass") exitWith {false}; -_magazine = _unit getVariable QGVAR(carriedMagazine); -if (isNil "_magazine") exitWith {false}; - -_return = false; -_magazines = _vehicle magazinesTurret [-1]; -if (_magazine in _magazines) then { - _path = [-1]; - GETRETURNVALUE -}; -if (!_return) then { - _magazines = _vehicle magazinesTurret [0]; - if (_magazine in _magazines) then { - _path = [0]; - GETRETURNVALUE - }; -}; -if (!_return) then { - _magazines = _vehicle magazinesTurret [0,0]; - if (_magazine in _magazines) then { - _path = [0,0]; - GETRETURNVALUE - }; -}; -if (!_return) then { - _magazines = _vehicle magazinesTurret [0,1]; - if (_magazine in _magazines) then { - _path = [0,1]; - GETRETURNVALUE - }; -}; -if (!_return) then { - _magazines = _vehicle magazinesTurret [1]; - if (_magazine in _magazines) then { - _path = [1]; - GETRETURNVALUE - }; -}; -if (!_return) then { - _magazines = _vehicle magazinesTurret [2]; - if (_magazine in _magazines) then { - _path = [2]; - GETRETURNVALUE - }; -}; - -_return \ No newline at end of file +([_target, _magazines, _magazineClass] call FUNC(getNeedRearmMagazines)) select 0 diff --git a/addons/rearm/functions/fnc_getMaxMagazines.sqf b/addons/rearm/functions/fnc_getMaxMagazines.sqf index 4c5f5b2544..b9655f1c69 100644 --- a/addons/rearm/functions/fnc_getMaxMagazines.sqf +++ b/addons/rearm/functions/fnc_getMaxMagazines.sqf @@ -1,11 +1,11 @@ /* - * Author: GitHawk - * Calculates the maximum number of magazines a turret can hold according to config + * Author: GitHawk, Jonpas + * Calculates the maximum number of magazines a turret can hold according to config. * * Arguments: - * 0: The Unit - * 1: The Turretpath - * 2: The Magazine + * 0: Target + * 1: Turret Path + * 2: Magazine Classname * * Return Value: * Number of magazines on the turret path @@ -21,67 +21,36 @@ private ["_count", "_cfg"]; params ["_target", "_turretPath", "_magazine"]; if (isNull _target) exitWith {0}; -_count = 0; -// TODO replace by loop or method of interpreting _turretPath +_cfg = configFile >> "CfgVehicles" >> (typeOf _target) >> "Turrets"; -_cfg = configFile; -switch (_turretPath) do { - case [0] : { - _cfg = configFile >> "CfgVehicles" >> (typeOf _target) >> "Turrets"; - if (count _cfg > 0) then { - _cfg = _cfg select 0; - } else { - _cfg = configFile >> "CfgVehicles" >> (typeOf _target); - }; - }; - case [1] : { - _cfg = configFile >> "CfgVehicles" >> (typeOf _target) >> "Turrets"; - if (count _cfg > 0) then { - _cfg = _cfg select 1; - } else { - _cfg = configFile >> "CfgVehicles" >> (typeOf _target); - }; - }; - case [2] : { - _cfg = configFile >> "CfgVehicles" >> (typeOf _target) >> "Turrets"; - if (count _cfg > 0) then { - _cfg = _cfg select 2; - } else { - _cfg = configFile >> "CfgVehicles" >> (typeOf _target); - }; - }; - case [0,0] : { - _cfg = configFile >> "CfgVehicles" >> (typeOf _target) >> "Turrets"; - if (count _cfg > 0) then { - _cfg = (_cfg select 0) >> "Turrets"; - if (count _cfg > 0) then { - _cfg = _cfg select 0; - } else { - _cfg = configFile >> "CfgVehicles" >> (typeOf _target); - }; - } else { - _cfg = configFile >> "CfgVehicles" >> (typeOf _target); - }; - }; - case [0,1] : { - if (count _cfg > 0) then { - _cfg = (_cfg select 0) >> "Turrets"; - if (count _cfg > 0) then { - _cfg = _cfg select 1; - } else { - _cfg = configFile >> "CfgVehicles" >> (typeOf _target); - }; - } else { - _cfg = configFile >> "CfgVehicles" >> (typeOf _target); - }; - }; - default { +if (count _turretPath == 1) then { + _turretPath params ["_subPath"]; + + if (_subPath == -1) exitWith { _cfg = configFile >> "CfgVehicles" >> (typeOf _target); }; + + if (count _cfg > _subPath) then { + _cfg = _cfg select _subPath; + } else { + _cfg = nil; + }; +} else { + _turretPath params ["", "_subPath"]; + if (count _cfg > 0) then { + _cfg = (_cfg select 0) >> "Turrets"; + if (count _cfg > _subPath) then { + _cfg = _cfg select _subPath; + } else { + _cfg = nil; + }; + } else { + _cfg = nil; + }; }; if !(isClass _cfg) exitWith {0}; _count = {_x == _magazine} count getArray (_cfg >> "magazines"); -_count \ No newline at end of file +_count diff --git a/addons/rearm/functions/fnc_getNeedRearmMagazines.sqf b/addons/rearm/functions/fnc_getNeedRearmMagazines.sqf new file mode 100644 index 0000000000..f242451277 --- /dev/null +++ b/addons/rearm/functions/fnc_getNeedRearmMagazines.sqf @@ -0,0 +1,43 @@ +/* + * Author: GitHawk, Jonpas + * Get rearm return value. + * + * Arguments: + * 0: Target + * 1: Magazines + * 2: Magazine Classname + * 3: Turret Path + * + * Return Value: + * Return Value + * + * Example: + * [tank, ["mag1", "mag2"], "mag", [0]] call ace_rearm_fnc_getNeedRearmMagazines + * + * Public: No + */ +#include "script_component.hpp" + +private ["_return", "_cnt"]; +params ["_target", "_magazines", "_magazineClass"]; + +_return = [false]; +{ + _magazines = _target magazinesTurret _x; + + if (_magazineClass in _magazines) then { + _cnt = {_x == _magazineClass} count _magazines; + + if ((_target magazineTurretAmmo [_magazineClass, _x]) < getNumber (configFile >> "CfgMagazines" >> _magazineClass >> "count")) exitWith { + _return = [true, _x, _cnt]; + }; + + if (_cnt < ([_target, _x, _magazineClass] call FUNC(getMaxMagazines))) exitWith { + _return = [true, _x, _cnt]; + }; + }; + + if (_return select 0) exitWith {}; +} forEach REARM_TURRET_PATHS; + +_return diff --git a/addons/rearm/functions/fnc_handleKilled.sqf b/addons/rearm/functions/fnc_handleKilled.sqf new file mode 100644 index 0000000000..e4971c08f2 --- /dev/null +++ b/addons/rearm/functions/fnc_handleKilled.sqf @@ -0,0 +1,23 @@ +/* + * Author: GitHawk, Jonpas + * Handles medical on set dead event. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Example: + * [unit] call ace_rearm_fnc_handleKilled + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit"]; + +if (!local _unit) exitWith {}; + +_unit setVariable [QGVAR(selectedWeaponOnRearm), nil]; +_unit setVariable [QGVAR(carriedMagazine), nil]; diff --git a/addons/rearm/functions/fnc_handleUnconscious.sqf b/addons/rearm/functions/fnc_handleUnconscious.sqf new file mode 100644 index 0000000000..91287c0127 --- /dev/null +++ b/addons/rearm/functions/fnc_handleUnconscious.sqf @@ -0,0 +1,31 @@ +/* + * Author: GitHawk, Jonpas + * Handles medical on unconscious event. + * + * Arguments: + * 0: Unit + * 1: Is Unconscious + * + * Return Value: + * None + * + * Example: + * [unit] call ace_rearm_fnc_handleUnconscious + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit", "_isUnconscious"]; + +if (!local _unit || {!_isUnconscious}) exitWith {}; + +private "_dummy"; +_dummy = _unit getVariable [QGVAR(dummy), objNull]; + +if (!isNull _dummy) then { + detach _dummy; + deleteVehicle _dummy; // TODO remove when moved to CfgVehicles +}; + +_unit setVariable [QGVAR(dummy), nil]; diff --git a/addons/rearm/functions/fnc_moduleRearmSettings.sqf b/addons/rearm/functions/fnc_moduleRearmSettings.sqf index 7325a8ddaf..ec5edd1666 100644 --- a/addons/rearm/functions/fnc_moduleRearmSettings.sqf +++ b/addons/rearm/functions/fnc_moduleRearmSettings.sqf @@ -1,22 +1,26 @@ /* * Author: GitHawk - * Module for adjusting the refuel settings + * Module for adjusting the refuel settings. * * Arguments: - * 0: The module logic - * 1: units - * 2: activated + * 0: The module logic + * 1: Synchronized units + * 2: Activated * * Return Value: * None * + * Example; + * function = "ace_rearm_fnc_moduleRearmSettings" + * * Public: No */ - #include "script_component.hpp" -params ["_logic", "_units", "_activated"]; +params ["_logic", "", "_activated"]; -if !(_activated) exitWith {}; +if (!_activated) exitWith {}; [_logic, QGVAR(level), "level"] call EFUNC(common,readSettingFromModule); + +diag_log text format ["[ACE]: Rearm Module Initialized on level: %1", GVAR(level)]; diff --git a/addons/rearm/functions/fnc_pickUpAmmo.sqf b/addons/rearm/functions/fnc_pickUpAmmo.sqf index f9c0786359..4861486b2d 100644 --- a/addons/rearm/functions/fnc_pickUpAmmo.sqf +++ b/addons/rearm/functions/fnc_pickUpAmmo.sqf @@ -1,13 +1,13 @@ /* * Author: GitHawk - * Picks up a specific kind of magazine from an ammo truck + * Starts progress bar for picking up a specific kind of magazine from an ammo truck. * * Arguments: - * 0: The Ammo Truck - * 1: The Player - * 2: The Params - * 2,0: The Magazine - * 2,1: The Vehicle to be armed + * 0: Ammo Truck + * 1: Unit + * 2: Params + * 0: Magazine + * 1: Vehicle to be armed * * Return Value: * None @@ -19,8 +19,9 @@ */ #include "script_component.hpp" -private ["_ammo", "_tmpCal", "_cal"]; -params ["_target","_unit","_args"]; +private ["_ammo", "_tmpCal", "_cal", "_idx"]; + +params ["_target", "_unit", "_args"]; // _target is for future possible finite ammo _args params ["_magazine", "_vehicle"]; _ammo = getText (configFile >> "CfgMagazines" >> _magazine >> "ammo"); @@ -42,7 +43,7 @@ if (_tmpCal > 0) then { }; }; _cal = round _cal; -_idx = CALIBERS find _cal; +_idx = REARM_CALIBERS find _cal; if (_idx == -1 ) then { _idx = 2; }; @@ -51,11 +52,11 @@ _unit setVariable [QGVAR(selectedWeaponOnRearm), currentWeapon _unit]; _unit action ["SwitchWeapon", _unit, _unit, 99]; [ - (DURATION_PICKUP select _idx), + (REARM_DURATION_PICKUP select _idx), [_unit, _magazine], FUNC(pickUpSuccess), "", format [localize LSTRING(PickUpAction), getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"), getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")], {true}, ["isnotinside"] -] call EFUNC(common,progressBar); \ No newline at end of file +] call EFUNC(common,progressBar); diff --git a/addons/rearm/functions/fnc_pickUpSuccess.sqf b/addons/rearm/functions/fnc_pickUpSuccess.sqf index 4e7411f009..2a012a0bc1 100644 --- a/addons/rearm/functions/fnc_pickUpSuccess.sqf +++ b/addons/rearm/functions/fnc_pickUpSuccess.sqf @@ -1,11 +1,11 @@ /* * Author: GitHawk - * Picks up a magazine + * Picks up a magazine. * * Arguments: - * 0: The Params - * 0,0: The Unit - * 0,1: The Magazine + * 0: Params + * 0: Unit + * 1: Magazine * * Return Value: * None @@ -17,7 +17,7 @@ */ #include "script_component.hpp" -private ["_dummy"]; +private ["_dummy", "_ammo"]; params ["_args"]; _args params ["_unit", "_magazine"]; @@ -30,6 +30,7 @@ if !(isNull _dummy) then { deleteVehicle _dummy; _unit setVariable [QGVAR(dummy), objNull]; }; + _ammo = getText (configFile >> "CfgMagazines" >> _magazine >> "ammo"); _dummy = getText (configFile >> "CfgAmmo" >> _ammo >> QGVAR(dummy)); if !(_dummy == "") then { @@ -38,4 +39,4 @@ if !(_dummy == "") then { [[_dummy, [[-1,0,0],[0,0,1]]], QUOTE(DFUNC(turn)), 2] call EFUNC(common,execRemoteFnc); _dummy allowDamage false; _unit setVariable [QGVAR(dummy), _dummy]; -}; \ No newline at end of file +}; diff --git a/addons/rearm/functions/fnc_rearm.sqf b/addons/rearm/functions/fnc_rearm.sqf index d86e4df493..bb5d112a5d 100644 --- a/addons/rearm/functions/fnc_rearm.sqf +++ b/addons/rearm/functions/fnc_rearm.sqf @@ -1,9 +1,10 @@ /* * Author: GitHawk - * Rearms a vehicle + * Starts progress bar for rearming a vehicle. * * Arguments: - * 0: The vehicle + * 0: Unit + * 1: Vehicle * * Return Value: * None @@ -15,25 +16,13 @@ */ #include "script_component.hpp" -#define GETRETURNVALUE \ -_cnt = { _x == _magazine } count _magazines; \ -if ((_target magazineTurretAmmo [_magazine, _path]) < getNumber (configFile >> "CfgMagazines" >> _magazine >> "count")) then { \ - _turretPath = _path; \ - _return = true; \ -} else { \ - if (_cnt < ([_target, _path, _magazine] call FUNC(getMaxMagazines))) then { \ - _turretPath = _path; \ - _return = true; \ - }; \ -}; - -private ["_ammo", "_tmpCal", "_cal", "_idx", "_return", "_cnt", "_magazineDisplayName"]; +private ["_magazineClass", "_ammo", "_tmpCal", "_cal", "_idx", "_needRearmMags", "_magazineDisplayName"]; params ["_unit", "_vehicle"]; -_magazine = _unit getVariable QGVAR(carriedMagazine); -if (isNil "_magazine") exitWith {false}; +_magazineClass = _unit getVariable QGVAR(carriedMagazine); +if (isNil "_magazineClass") exitWith {false}; -_ammo = getText (configFile >> "CfgMagazines" >> _magazine >> "ammo"); +_ammo = getText (configFile >> "CfgMagazines" >> _magazineClass >> "ammo"); _tmpCal = getNumber (configFile >> "CfgAmmo" >> _ammo >> "ace_caliber"); _cal = 8; if (_tmpCal > 0) then { @@ -43,7 +32,7 @@ if (_tmpCal > 0) then { if (_tmpCal > 0) then { _cal = _tmpCal; } else { - diag_log format ["ACE_Rearm: Undefined Ammo [%1 : %2]", _ammo, inheritsFrom (configFile >> "CfgAmmo" >> _ammo)]; + diag_log format ["[ACE] ERROR: Undefined Ammo [%1 : %2]", _ammo, inheritsFrom (configFile >> "CfgAmmo" >> _ammo)]; if (_ammo isKindOf "BulletBase") then { _cal = 8; } else { @@ -52,70 +41,34 @@ if (_tmpCal > 0) then { }; }; _cal = round _cal; -_idx = CALIBERS find _cal; -if (_idx == -1 ) then { +_idx = REARM_CALIBERS find _cal; +if (_idx == -1) then { _idx = 2; }; -_return = false; -_turretPath = [0]; _cnt = 0; -_magazines = _target magazinesTurret [-1]; -if (_magazine in _magazines) then { - _path = [-1]; - GETRETURNVALUE -}; -if (!_return) then { - _magazines = _target magazinesTurret [0]; - if (_magazine in _magazines) then { - _path = [0]; - GETRETURNVALUE - }; -}; -if (!_return) then { - _magazines = _target magazinesTurret [0,0]; - if (_magazine in _magazines) then { - _path = [0,0]; - GETRETURNVALUE - }; -}; -if (!_return) then { - _magazines = _target magazinesTurret [0,1]; - if (_magazine in _magazines) then { - _path = [0,1]; - GETRETURNVALUE - }; -}; -if (!_return) then { - _magazines = _target magazinesTurret [1]; - if (_magazine in _magazines) then { - _path = [1]; - GETRETURNVALUE - }; -}; -if (!_return) then { - _magazines = _target magazinesTurret [2]; - if (_magazine in _magazines) then { - _path = [2]; - GETRETURNVALUE - } else { - diag_log format ["ACE_Rearm: Could not find turret for %1 in %2", _magazine, typeOf _target]; - }; +// Get magazines that can be rearmed +_needRearmMags = [_target, _magazines, _magazineClass] call FUNC(getNeedRearmMagazines); +_needRearmMags params ["_needRearm", "_turretPath", "_cnt"]; + +// Exit if no magazines need rearming +if (!_needRearm) exitWith { + diag_log format ["[ACE] ERROR: Could not find turret for %1 in %2", _magazineClass, typeOf _target]; }; -//hint format ["Magazine: %1\nAmmo: %2\nCaliber: %3\nIndex: %4\nTurretPath: %5\nDURATION_REARM: %6\nCount: %7", _magazine, _ammo, _cal, _idx, _turretPath, (DURATION_REARM select _idx), (COUNT select _idx)]; +//hint format ["Magazine: %1\nAmmo: %2\nCaliber: %3\nIndex: %4\nTurretPath: %5\nREARM_DURATION_REARM: %6\nCount: %7", _magazine, _ammo, _cal, _idx, _turretPath, (REARM_DURATION_REARM select _idx), (REARM_COUNT select _idx)]; -_magazineDisplayName = getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"); +_magazineDisplayName = getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName"); if (_magazineDisplayName == "") then { - _magazineDisplayName = _magazine; - diag_log format ["ACE_Rearm: Magazine is missing display name [%1]", _magazine]; + _magazineDisplayName = _magazineClass; + diag_log format ["[ACE] ERROR: Magazine is missing display name [%1]", _magazineClass]; }; [ - (DURATION_REARM select _idx), - [_target, _unit, _turretPath, _cnt, _magazine, (COUNT select _idx)], + (REARM_DURATION_REARM select _idx), + [_target, _unit, _turretPath, _cnt, _magazineClass, (REARM_COUNT select _idx)], FUNC(rearmSuccess), "", format [localize LSTRING(RearmAction), getText(configFile >> "CfgVehicles" >> (typeOf _target) >> "displayName"), _magazineDisplayName], {true}, ["isnotinside"] -] call EFUNC(common,progressBar); \ No newline at end of file +] call EFUNC(common,progressBar); diff --git a/addons/rearm/functions/fnc_rearmEntireVehicle.sqf b/addons/rearm/functions/fnc_rearmEntireVehicle.sqf index 59713d7263..08122d2321 100644 --- a/addons/rearm/functions/fnc_rearmEntireVehicle.sqf +++ b/addons/rearm/functions/fnc_rearmEntireVehicle.sqf @@ -1,11 +1,11 @@ /* * Author: GitHawk - * Rearms an entire vehicle + * Starts progress bar for rearming an entire vehicle. * * Arguments: - * 0: The Ammo Truck - * 1: The Player - * 2: The Vehicle to be armed + * 0: Ammo Truck + * 1: Unit + * 2: Vehicle to be armed * * Return Value: * None @@ -18,7 +18,7 @@ #include "script_component.hpp" private ["_ammo", "_tmpCal", "_cal"]; -params ["_target","_unit","_vehicle"]; +params ["_target", "_unit", "_vehicle"]; [ 10, @@ -28,4 +28,4 @@ params ["_target","_unit","_vehicle"]; format [localize LSTRING(BasicRearmAction), getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")], {true}, ["isnotinside"] -] call EFUNC(common,progressBar); \ No newline at end of file +] call EFUNC(common,progressBar); diff --git a/addons/rearm/functions/fnc_rearmEntireVehicleSuccess.sqf b/addons/rearm/functions/fnc_rearmEntireVehicleSuccess.sqf index f0d8d32cac..c4b15ed0b9 100644 --- a/addons/rearm/functions/fnc_rearmEntireVehicleSuccess.sqf +++ b/addons/rearm/functions/fnc_rearmEntireVehicleSuccess.sqf @@ -1,9 +1,9 @@ /* * Author: GitHawk - * Rearm an entire vehicle + * Rearm an entire vehicle. * * Arguments: - * 0: The Vehicle + * 0: Vehicle * * Return Value: * None @@ -15,11 +15,11 @@ */ #include "script_component.hpp" -private ["_turretPath", "_magazines", "_magazine", "_currentMagazines", "_maxMagazines", "_rounds"]; +private ["_turretPath", "_magazines", "_magazine", "_currentMagazines", "_maxMagazines", "_maxRounds", "_currentRounds"]; params ["_vehicle"]; if !(local _vehicle) exitWith { - [_this, QUOTE(DFUNC(rearmEntireVehicleSuccess)), _vehicle] call EFUNC(common,execRemoteFnc); + [_this, QFUNC(rearmEntireVehicleSuccess), _vehicle] call EFUNC(common,execRemoteFnc); }; { @@ -31,7 +31,7 @@ if !(local _vehicle) exitWith { _maxMagazines = [_vehicle, _turretPath, _magazine] call FUNC(getMaxMagazines); _maxRounds = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count"); _currentRounds = _vehicle magazineTurretAmmo [_magazine, _turretPath]; - + //diag_log format ["Target: %1\nTurretPath: %2\nNumMagazines: %3\nMaxMagazines %4\nNumRounds: %5\nMaxRounds: %6\nMagazine: %7", _vehicle, _turretPath, _currentMagazines, _maxMagazines, _currentRounds, _maxRounds, _magazine]; if (_currentMagazines < _maxMagazines) then { _vehicle setMagazineTurretAmmo [_magazine, _maxRounds, _turretPath]; @@ -46,4 +46,4 @@ if !(local _vehicle) exitWith { }; }; } foreach _magazines; -} foreach [[-1], [0], [0,0], [0,1], [1], [2]]; \ No newline at end of file +} foreach REARM_TURRET_PATHS; diff --git a/addons/rearm/functions/fnc_rearmSuccess.sqf b/addons/rearm/functions/fnc_rearmSuccess.sqf index 7e90f699b6..a662ad0958 100644 --- a/addons/rearm/functions/fnc_rearmSuccess.sqf +++ b/addons/rearm/functions/fnc_rearmSuccess.sqf @@ -1,31 +1,31 @@ /* * Author: GitHawk - * Rearms a vehicle + * Rearms a vehicle. * * Arguments: - * 0: The Params - * 0,1: The Target - * 0,2: The Caller - * 0,3: The Turretpath - * 0,4: The Number of magazines - * 0,5: The Magazine - * 0,6: The Number of rounds + * 0: Params + * 0: Target + * 1: Unit + * 2: Turret Path + * 3: Number of magazines + * 4: Magazine Classname + * 5: Number of rounds * * Return Value: * None * * Example: - * [vehicle] call ace_rearm_fnc_rearmSuccess + * [[vehicle, player, [0], 5, "calcium", 500]] call ace_rearm_fnc_rearmSuccess * * Public: No */ #include "script_component.hpp" -private ["_rounds", "_currentRounds", "_maxMagazines", "_dummy"]; +private ["_rounds", "_currentRounds", "_maxMagazines", "_dummy", "_weaponSelect"]; params ["_args"]; -_args params ["_target", "_unit", "_turretPath", "_numMagazines", "_magazine", "_numRounds"]; +_args params ["_target", "_unit", "_turretPath", "_numMagazines", "_magazineClass", "_numRounds"]; -//hint format ["Target: %1\nTurretPath: %2\nNumMagazines: %3\nMagazine: %4\nNumRounds: %5", _target, _turretPath, _numMagazines, _magazine, _numRounds]; +//hint format ["Target: %1\nTurretPath: %2\nNumMagazines: %3\nMagazine: %4\nNumRounds: %5", _target, _turretPath, _numMagazines, _magazineClass, _numRounds]; if (local _unit) then { [_unit, QGVAR(vehRearm), false] call EFUNC(common,setForceWalkStatus); @@ -44,50 +44,50 @@ if !(local _target) exitWith { [_this, QUOTE(DFUNC(rearmSuccess)), _target] call EFUNC(common,execRemoteFnc); }; -_rounds = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count"); +_rounds = getNumber (configFile >> "CfgMagazines" >> _magazineClass >> "count"); _currentRounds = 0; -_maxMagazines = [_target, _turretPath, _magazine] call FUNC(getMaxMagazines); +_maxMagazines = [_target, _turretPath, _magazineClass] call FUNC(getMaxMagazines); if (_maxMagazines == 1) then { if (GVAR(level) == 1) then { // Fill magazine completely - _target setMagazineTurretAmmo [_magazine, _rounds, _turretPath]; + _target setMagazineTurretAmmo [_magazineClass, _rounds, _turretPath]; } else { // Fill only at most _numRounds - _target setMagazineTurretAmmo [_magazine, ((_target magazineTurretAmmo [_magazine, _turretPath]) + _numRounds) min _rounds, _turretPath]; + _target setMagazineTurretAmmo [_magazineClass, ((_target magazineTurretAmmo [_magazineClass, _turretPath]) + _numRounds) min _rounds, _turretPath]; }; [[LSTRING(Hint_RearmedTriple), _numRounds, - getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"), + getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName"), getText(configFile >> "CfgVehicles" >> (typeOf _target) >> "displayName")], 3, _unit] call EFUNC(common,displayTextStructured); } else { for "_idx" from 1 to _maxMagazines do { - _currentRounds = _target magazineTurretAmmo [_magazine, _turretPath]; + _currentRounds = _target magazineTurretAmmo [_magazineClass, _turretPath]; if (_currentRounds > 0) exitWith { if (GVAR(level) == 2) then { - //hint format ["Target: %1\nTurretPath: %2\nNumMagazines: %3\nMaxMagazines %4\nMagazine: %5\nNumRounds: %6\nMagazine: %7", _target, _turretPath, _numMagazines, _maxMagazines, _currentRounds, _numRounds, _magazine]; + //hint format ["Target: %1\nTurretPath: %2\nNumMagazines: %3\nMaxMagazines %4\nMagazine: %5\nNumRounds: %6\nMagazine: %7", _target, _turretPath, _numMagazines, _maxMagazines, _currentRounds, _numRounds, _magazineClass]; // Fill only at most _numRounds if ((_currentRounds + _numRounds) > _rounds) then { - _target setMagazineTurretAmmo [_magazine, _rounds, _turretPath]; + _target setMagazineTurretAmmo [_magazineClass, _rounds, _turretPath]; if (_numMagazines < _maxMagazines) then { - _target addMagazineTurret [_magazine, _turretPath]; - _target setMagazineTurretAmmo [_magazine, _currentRounds + _numRounds - _rounds, _turretPath]; + _target addMagazineTurret [_magazineClass, _turretPath]; + _target setMagazineTurretAmmo [_magazineClass, _currentRounds + _numRounds - _rounds, _turretPath]; }; } else { - _target setMagazineTurretAmmo [_magazine, _currentRounds + _numRounds, _turretPath]; + _target setMagazineTurretAmmo [_magazineClass, _currentRounds + _numRounds, _turretPath]; }; } else { // Fill current magazine completely and fill next magazine partially - _target setMagazineTurretAmmo [_magazine, _rounds, _turretPath]; + _target setMagazineTurretAmmo [_magazineClass, _rounds, _turretPath]; if (_numMagazines < _maxMagazines) then { - _target addMagazineTurret [_magazine, _turretPath]; - _target setMagazineTurretAmmo [_magazine, _currentRounds, _turretPath]; + _target addMagazineTurret [_magazineClass, _turretPath]; + _target setMagazineTurretAmmo [_magazineClass, _currentRounds, _turretPath]; }; }; [[LSTRING(Hint_RearmedTriple), _rounds, - getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"), + getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName"), getText(configFile >> "CfgVehicles" >> (typeOf _target) >> "displayName")], 3, _unit] call EFUNC(common,displayTextStructured); }; - _target removeMagazineTurret [_magazine, _turretPath]; + _target removeMagazineTurret [_magazineClass, _turretPath]; _numMagazines = _numMagazines - 1; }; -}; \ No newline at end of file +}; diff --git a/addons/rearm/functions/fnc_turn.sqf b/addons/rearm/functions/fnc_turn.sqf index c096afd0d8..8811241216 100644 --- a/addons/rearm/functions/fnc_turn.sqf +++ b/addons/rearm/functions/fnc_turn.sqf @@ -1,16 +1,16 @@ /* * Author: GitHawk - * Turns an object + * Turns an object. * * Arguments: - * 0: The Player - * 1: The dirAndUp vector + * 0: Object + * 1: Vector dirAndUp * * Return Value: * None * * Example: - * [_dummy, [[1,0,0],[0,0,1]]] call ace_rearm_fnc_turn + * [dummy, [[1,0,0],[0,0,1]]] call ace_rearm_fnc_turn * * Public: No */ diff --git a/addons/rearm/script_component.hpp b/addons/rearm/script_component.hpp index 09f7fda69f..8a8b986869 100644 --- a/addons/rearm/script_component.hpp +++ b/addons/rearm/script_component.hpp @@ -11,7 +11,11 @@ #include "\z\ace\addons\main\script_macros.hpp" -#define CALIBERS [ 6, 7, 8, 13, 19, 20, 25, 30, 35, 40, 60, 70, 80, 82, 100, 105, 120, 122, 125, 155, 230, 250] -#define DURATION_PICKUP [ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 3, 3, 4, 5, 5, 5, 5, 13, 10] -#define DURATION_REARM [ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 7, 7, 7, 7, 7, 8, 10, 10, 10, 10, 27, 20] -#define COUNT [500, 500, 400, 100, 50, 50, 40, 25, 34, 10, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1] \ No newline at end of file + +#define REARM_ACTION_DISTANCE 7 +#define REARM_TURRET_PATHS [[-1], [0], [0,0], [0,1], [1], [2]] + +#define REARM_CALIBERS [ 6, 7, 8, 13, 19, 20, 25, 30, 35, 40, 60, 70, 80, 82, 100, 105, 120, 122, 125, 155, 230, 250] +#define REARM_DURATION_PICKUP [ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 3, 3, 4, 5, 5, 5, 5, 13, 10] +#define REARM_DURATION_REARM [ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 7, 7, 7, 7, 7, 8, 10, 10, 10, 10, 27, 20] +#define REARM_COUNT [500, 500, 400, 100, 50, 50, 40, 25, 34, 10, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1] diff --git a/addons/rearm/stringtable.xml b/addons/rearm/stringtable.xml index 24bc49a058..d226a9aaaa 100644 --- a/addons/rearm/stringtable.xml +++ b/addons/rearm/stringtable.xml @@ -1,12 +1,15 @@ - + Rearm Settings Aufmunitioniereinstellungen + + This module allows you to tweak repair system settings. + - Rearm amount + Rearm Amount Aufmunitioniermenge @@ -14,7 +17,7 @@ Wie schnell soll ein Fahrzeug aufmunitioniert werden? - Entire vehicle + Entire Vehicle Gesamtes Fahrzeug @@ -30,16 +33,16 @@ Aufmunitionieren - Rearming %1 with %2 - Munitioniere %1 auf mit %2 + Rearming %1 with %2 ... + Munitioniere %1 auf mit %2 ... - Rearming %1 - Munitioniere %1 auf + Rearming %1 ... + Munitioniere %1 auf ... - Taking %1 for %2 - Nehme %1 für %2 + Taking %1 for %2 ... + Nehme %1 für %2 ... Pick up ammo @@ -49,7 +52,7 @@ Rearmed %1 rounds of %2 on %3 %1 Schuss %2 an %3 aufmunitioniert - + Smoke Screen Smoke Screen Kouřová clona @@ -61,7 +64,7 @@ Дым. завеса Pantalla de humo - + Flares Flares Světlice @@ -73,51 +76,51 @@ ЛТЦ Bengalas - + 30mm HEI 30mm HEI - + 30mm HEI-T 30mm HEI-T - + AIM-9 Sidewinder AIM-9 Sidewinder - + Wympel R-73 Wympel R-73 - + AGM-65 Maverick AGM-65 Maverick - + Kh-25MTP Kh-25MTP - + Hydra 70 HE Hydra 70 HE - + S-8 HE S-8 HE - + Hydra 70 AP Hydra 70 AP - + S-8 AP S-8 AP - + GBU-12 GBU-12 - + FAB-250M-54 FAB-250M-54