Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rearm - Pylon Support and Dynamically Add Supply Actions #5183

Merged
merged 8 commits into from
Jun 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/common/functions/fnc_displayTextStructured.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* 0: Text <ANY>
* 1: Size of the textbox <NUMBER> (default: 1.5)
* 2: Target Unit. Will only display if target is the player controlled object <OBJECT> (default: ACE_player)
* 3: Custom Width <NUMBER> (optional)
* 3: Custom Width <NUMBER> (default: 10)
*
* Return Value:
* None
Expand Down
2 changes: 1 addition & 1 deletion addons/common/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "\z\ace\addons\main\script_mod.hpp"

// #define DEBUG_MODE_FULL
// #define DISABLE_COMPILE_CACHE
#define DISABLE_COMPILE_CACHE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eh?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was commented out again in #5260.

// #define ENABLE_PERFORMANCE_COUNTERS

#ifdef DEBUG_ENABLED_COMMON
Expand Down
135 changes: 31 additions & 104 deletions addons/rearm/CfgVehicles.hpp
Original file line number Diff line number Diff line change
@@ -1,64 +1,16 @@

#define MACRO_REARM_ACTIONS \
class ACE_Actions { \
class ACE_MainActions { \
class GVAR(Rearm) { \
displayName = CSTRING(Rearm); \
distance = REARM_ACTION_DISTANCE; \
condition = QUOTE(_this call FUNC(canRearm)); \
statement = QUOTE(_this call FUNC(rearm)); \
exceptions[] = {"isNotInside"}; \
icon = QPATHTOF(ui\icon_rearm_interact.paa); \
}; \
}; \
};

#define MACRO_REARM_TRUCK_ACTIONS \
class ACE_Actions: ACE_Actions { \
class ACE_MainActions: ACE_MainActions { \
class GVAR(ReadSupplyCounter) { \
displayName = CSTRING(ReadSupplyCounter); \
distance = REARM_ACTION_DISTANCE; \
condition = QUOTE(_this call FUNC(canReadSupplyCounter)); \
statement = QUOTE(_this call FUNC(readSupplyCounter)); \
exceptions[] = {"isNotInside"}; \
showDisabled = 0; \
priority = 2; \
icon = PATHTOF(ui\icon_rearm_interact.paa); \
}; \
class GVAR(Rearm) { \
displayName = CSTRING(Rearm); \
distance = REARM_ACTION_DISTANCE; \
condition = QUOTE(_this call FUNC(canRearmVehicle)); \
insertChildren = QUOTE(_target call FUNC(addRearmActions)); \
exceptions[] = {"isNotInside"}; \
showDisabled = 0; \
priority = 2; \
icon = PATHTOF(ui\icon_rearm_interact.paa); \
}; \
class GVAR(TakeAmmo) { \
displayName = CSTRING(TakeAmmo); \
distance = REARM_ACTION_DISTANCE; \
condition = QUOTE(_this call FUNC(canTakeAmmo)); \
insertChildren = QUOTE(_target call FUNC(addRearmActions)); \
exceptions[] = {"isNotInside"}; \
showDisabled = 0; \
priority = 2; \
icon = QPATHTOF(ui\icon_rearm_interact.paa); \
}; \
class GVAR(StoreAmmo) { \
displayName = CSTRING(StoreAmmo); \
distance = REARM_ACTION_DISTANCE; \
condition = QUOTE(_this call FUNC(canStoreAmmo)); \
statement = QUOTE(_this call FUNC(storeAmmo)); \
exceptions[] = {"isNotInside"}; \
icon = QPATHTOF(ui\icon_rearm_interact.paa); \
}; \
class ACE_Actions { \
class ACE_MainActions { \
class GVAR(Rearm) { \
displayName = CSTRING(Rearm); \
distance = REARM_ACTION_DISTANCE; \
condition = QUOTE(_this call FUNC(canRearm)); \
statement = QUOTE(_this call FUNC(rearm)); \
exceptions[] = {"isNotInside"}; \
icon = QPATHTOF(ui\icon_rearm_interact.paa); \
}; \
};

#define MACRO_REARM_DEFAULT_SUPPLY \
GVAR(defaultSupply) = 1200;
}; \
};

class CBA_Extended_EventHandlers;

Expand Down Expand Up @@ -148,96 +100,71 @@ class CfgVehicles {
MACRO_REARM_ACTIONS
};


// Ammo Vehicles (with full inheritance for granted ACE_Actions)
class Car_F: Car {};
class Truck_F: Car_F {};
class Tank_F: Tank {};

class Truck_03_base_F: Truck_F {};
class Truck_03_base_F;
class O_Truck_03_ammo_F: Truck_03_base_F {
transportAmmo = 0;
MACRO_REARM_DEFAULT_SUPPLY
MACRO_REARM_TRUCK_ACTIONS
GVAR(defaultSupply) = 1200;
};

class Truck_02_base_F: Truck_F {};
class Truck_02_Ammo_base_F: Truck_02_base_F {};
class Truck_02_Ammo_base_F;
class I_Truck_02_ammo_F: Truck_02_Ammo_base_F {
transportAmmo = 0;
MACRO_REARM_DEFAULT_SUPPLY
MACRO_REARM_TRUCK_ACTIONS
GVAR(defaultSupply) = 1200;
};
class O_Truck_02_Ammo_F: Truck_02_Ammo_base_F {
transportAmmo = 0;
MACRO_REARM_DEFAULT_SUPPLY
MACRO_REARM_TRUCK_ACTIONS
GVAR(defaultSupply) = 1200;
};

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_mover_F;
class B_Truck_01_ammo_F: B_Truck_01_mover_F {
transportAmmo = 0;
MACRO_REARM_DEFAULT_SUPPLY
MACRO_REARM_TRUCK_ACTIONS
GVAR(defaultSupply) = 1200;
};

class APC_Tracked_01_base_F: Tank_F {};
class B_APC_Tracked_01_base_F: APC_Tracked_01_base_F {};
class B_APC_Tracked_01_base_F;
class B_APC_Tracked_01_CRV_F: B_APC_Tracked_01_base_F {
transportAmmo = 0;
MACRO_REARM_TRUCK_ACTIONS
GVAR(defaultSupply) = 1200;
};

class Helicopter_Base_F: Helicopter {};
class Helicopter_Base_H: Helicopter_Base_F {};
class Heli_Transport_04_base_F: Helicopter_Base_H {};
class Heli_Transport_04_base_F;
class O_Heli_Transport_04_ammo_F: Heli_Transport_04_base_F {
transportAmmo = 0;
MACRO_REARM_DEFAULT_SUPPLY
MACRO_REARM_TRUCK_ACTIONS
};

class ThingX;
class ReammoBox_F: ThingX {
class ACE_Actions {
class ACE_MainActions {};
};
GVAR(defaultSupply) = 1200;
};
class Slingload_base_F: ReammoBox_F {};
class Slingload_01_Base_F: Slingload_base_F {};

class Pod_Heli_Transport_04_base_F: Slingload_base_F {};
class Pod_Heli_Transport_04_base_F;
class Land_Pod_Heli_Transport_04_ammo_F: Pod_Heli_Transport_04_base_F {
transportAmmo = 0;
MACRO_REARM_DEFAULT_SUPPLY
MACRO_REARM_TRUCK_ACTIONS
GVAR(defaultSupply) = 1200;
};

class Slingload_01_Base_F;
class B_Slingload_01_Ammo_F: Slingload_01_Base_F {
transportAmmo = 0;
MACRO_REARM_DEFAULT_SUPPLY
MACRO_REARM_TRUCK_ACTIONS
GVAR(defaultSupply) = 1200;
};

class ReammoBox_F;
class NATO_Box_Base: ReammoBox_F{};
class Box_NATO_AmmoVeh_F: NATO_Box_Base {
transportAmmo = 0;
MACRO_REARM_TRUCK_ACTIONS
GVAR(defaultSupply) = 1200;
};
class EAST_Box_Base: ReammoBox_F{};
class Box_East_AmmoVeh_F: EAST_Box_Base {
transportAmmo = 0;
MACRO_REARM_TRUCK_ACTIONS
GVAR(defaultSupply) = 1200;
};
class IND_Box_Base: ReammoBox_F{};
class Box_IND_AmmoVeh_F: IND_Box_Base {
transportAmmo = 0;
MACRO_REARM_TRUCK_ACTIONS
GVAR(defaultSupply) = 1200;
};

// Dummy Vehicles
class ThingX;
class GVAR(defaultCarriedObject): ThingX {
class EventHandlers {
class CBA_Extended_EventHandlers: CBA_Extended_EventHandlers {};
Expand Down
5 changes: 2 additions & 3 deletions addons/rearm/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ PREP(addRearmActions);
PREP(addVehicleMagazinesToSupply);
PREP(canReadSupplyCounter);
PREP(canRearm);
PREP(canRearmVehicle);
PREP(canStoreAmmo);
PREP(canTakeAmmo);
PREP(createDummy);
PREP(disable);
PREP(dropAmmo);
PREP(getCaliber);
PREP(getConfigMagazines);
PREP(getHardpointMagazines);
PREP(getMaxMagazines);
PREP(getNeedRearmMagazines);
PREP(getSupplyCount);
Expand All @@ -20,7 +19,7 @@ PREP(grabAmmo);
PREP(handleKilled);
PREP(handleUnconscious);
PREP(hasEnoughSupply);
PREP(magazineInSupply);
PREP(initSupplyVehicle);
PREP(makeDummy);
PREP(moduleRearmSettings);
PREP(pickUpAmmo);
Expand Down
8 changes: 8 additions & 0 deletions addons/rearm/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#include "script_component.hpp"

GVAR(hardpointGroupsCache) = [] call CBA_fnc_createNamespace;
GVAR(configTypesAdded) = [];
["ace_settingsInitialized", {
TRACE_2("settingsInit",GVAR(level),GVAR(supply));
["LandVehicle", "Init", {_this call FUNC(initSupplyVehicle)}, true, ["StaticWeapon"], true] call CBA_fnc_addClassEventHandler;
["ReammoBox_F", "Init", {_this call FUNC(initSupplyVehicle)}, true, [], true] call CBA_fnc_addClassEventHandler;
}] call CBA_fnc_addEventHandler;

["ace_unconscious", LINKFUNC(handleUnconscious)] call CBA_fnc_addEventHandler;
["vehicle", {
params ["_unit"];
Expand Down
33 changes: 18 additions & 15 deletions addons/rearm/functions/fnc_addMagazineToSupply.sqf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Author: GitHawk
* Adds magazines to the supply.
* Adds magazines to the supply. [Global Effects]
*
* Arguments:
* 0: Ammo Truck <OBJECT>
* 1: Magazine Classname <STRING>
* 2: Only partial <BOOL>(optional)
* 2: Only partial <BOOL> (default: false)
*
* Return Value:
* None
Expand All @@ -17,27 +17,30 @@
*/
#include "script_component.hpp"

params [
["_truck", objNull, [objNull]],
["_magazineClass", "", [""]],
["_partial", false, [false]]
];
if !(EGVAR(common,settingsInitFinished)) exitWith { // only run this after the settings are initialized
EGVAR(common,runAtSettingsInitialized) pushBack [FUNC(addMagazineToSupply), _this];
};

params [["_truck", objNull, [objNull]], ["_magazineClass", "", [""]], ["_partial", false, [false]]];
TRACE_3("addMagazineToSupply",_truck,_magazineClass,_partial);

if (isNull _truck ||
{_magazineClass isEqualTo ""} ||
{GVAR(supply) == 0}) exitWith {};
if (GVAR(supply) == 0) exitWith {WARNING("supply setting is set to unlimited");};

if (isNull _truck || {_magazineClass isEqualTo ""}) exitWith {};

([_magazineClass] call FUNC(getCaliber)) params ["_cal", "_idx"];

// With limited supply, we add the caliber to the supply count
if (GVAR(supply) == 1) then {
private _supply = [_truck] call FUNC(getSupplyCount);
if (!_partial || {GVAR(level) == 1}) then {
[_truck, _supply + _cal] call FUNC(setSupplyCount);
private _amountToAdd = if (!_partial || {GVAR(level) == 1}) then {
_cal
} else {
private _magazinePart = ((REARM_COUNT select _idx) / (getNumber (configFile >> "CfgMagazines" >> _magazineClass >> "count"))) min 1;
[_truck, (_supply + (_cal * _magazinePart))] call FUNC(setSupplyCount);
_cal * _magazinePart
};
TRACE_1("Adding",_amountToAdd);
[_truck, (_supply + _amountToAdd)] call FUNC(setSupplyCount);
};

// With magazine specific supply, we add or update the magazineSupply array
Expand All @@ -56,7 +59,7 @@ if (GVAR(supply) == 2) then {
_roundsPerTransaction = _roundsPerTransaction min (REARM_COUNT select _idx);
};
if (_magazineIdx == -1) then {
if (count _magazineSupply == 0) then {
if (_magazineSupply isEqualTo []) then {
_magazineSupply = [[_magazineClass, _roundsPerTransaction]];
} else {
_magazineSupply append [[_magazineClass, _roundsPerTransaction]];
Expand Down
Loading