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 - Limited Supply (Fix Merge Conflcits) #5182

Merged
merged 20 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
12 changes: 7 additions & 5 deletions addons/common/functions/fnc_displayTextStructured.sqf
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
/*
* Author: commy2, Glowbal
* Author: commy2, Glowbal, GitHawk
* Display a structured text.
*
* Arguments:
* 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)
Copy link
Member

Choose a reason for hiding this comment

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

(default: 10)

*
* Return Value:
* None
*
* Example:
*
* [["Test: %1", 123], 1.5] call ace_common_fnc_displayTextStructured
* ["wow", 1, ace_player, 3] call ace_common_fnc_displayTextStructured
*
* Public: Yes
*/
#include "script_component.hpp"

params [["_text", ""], ["_size", 1.5, [0]], ["_target", ACE_player, [objNull]]];
params [["_text", ""], ["_size", 1.5, [0]], ["_target", ACE_player, [objNull]], ["_width", 10, [0]]];

if (_target != ACE_player) exitWith {};

Expand Down Expand Up @@ -55,9 +57,9 @@ private _wPos = profilenamespace getVariable ["IGUI_GRID_ACE_displayText_W", (10
private _hPos = profilenamespace getVariable ["IGUI_GRID_ACE_displayText_H", (2 *((((safezoneW / safezoneH) min 1.2) / 1.2) / 25))];
*/

private _xPos = ((safezoneX + safezoneW) - (10 *(((safezoneW / safezoneH) min 1.2) / 40)) - 2.9 *(((safezoneW / safezoneH) min 1.2) / 40));
private _xPos = ((safezoneX + safezoneW) - (_width *(((safezoneW / safezoneH) min 1.2) / 40)) - 2.9 *(((safezoneW / safezoneH) min 1.2) / 40));
private _yPos = safeZoneY + 0.175 * safezoneH;
private _wPos = (10 *(((safezoneW / safezoneH) min 1.2) / 40));
private _wPos = (_width *(((safezoneW / safezoneH) min 1.2) / 40));
private _hPos = (2 *((((safezoneW / safezoneH) min 1.2) / 1.2) / 25));

// Zeus Interface Open and Display would be under the "CREATE" list
Expand Down
7 changes: 7 additions & 0 deletions addons/rearm/ACE_Settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,11 @@ class ACE_Settings {
typeName = "SCALAR";
values[] = {CSTRING(RearmSettings_vehicle), CSTRING(RearmSettings_magazine), CSTRING(RearmSettings_caliber)};
};
class GVAR(supply) {
displayName = CSTRING(RearmSettings_supply_DisplayName);
description = CSTRING(RearmSettings_supply_Description);
value = 0;
typeName = "SCALAR";
values[] = {CSTRING(RearmSettings_unlimited), CSTRING(RearmSettings_limited), CSTRING(RearmSettings_magazineSupply)};
};
};
52 changes: 51 additions & 1 deletion addons/rearm/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
displayName = CSTRING(Rearm); \
distance = REARM_ACTION_DISTANCE; \
condition = QUOTE(_this call FUNC(canRearm)); \
statement = QUOTE(_player call FUNC(rearm)); \
statement = QUOTE(_this call FUNC(rearm)); \
exceptions[] = {"isNotInside"}; \
icon = QPATHTOF(ui\icon_rearm_interact.paa); \
}; \
Expand All @@ -16,6 +16,26 @@
#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; \
Expand All @@ -37,6 +57,9 @@
}; \
};

#define MACRO_REARM_DEFAULT_SUPPLY \
GVAR(defaultSupply) = 1200;

class CBA_Extended_EventHandlers;

class CfgVehicles {
Expand Down Expand Up @@ -72,6 +95,26 @@ class CfgVehicles {
};
};
};
class supply {
displayName = CSTRING(RearmSettings_supply_DisplayName);
description = CSTRING(RearmSettings_supply_Description);
typeName = "NUMBER";
class values {
class unlimited {
name = CSTRING(RearmSettings_unlimited);
value = 0;
default = 1;
};
class magazine {
name = CSTRING(RearmSettings_limited);
value = 1;
};
class caliber {
name = CSTRING(RearmSettings_magazineSupply);
value = 2;
};
};
};
};
class ModuleDescription {
description = CSTRING(RearmSettings_Module_Description);
Expand Down Expand Up @@ -114,17 +157,20 @@ class CfgVehicles {
class Truck_03_base_F: Truck_F {};
class O_Truck_03_ammo_F: Truck_03_base_F {
transportAmmo = 0;
MACRO_REARM_DEFAULT_SUPPLY
MACRO_REARM_TRUCK_ACTIONS
};

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_DEFAULT_SUPPLY
MACRO_REARM_TRUCK_ACTIONS
};
class O_Truck_02_Ammo_F: Truck_02_Ammo_base_F {
transportAmmo = 0;
MACRO_REARM_DEFAULT_SUPPLY
MACRO_REARM_TRUCK_ACTIONS
};

Expand All @@ -133,6 +179,7 @@ class CfgVehicles {
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_DEFAULT_SUPPLY
MACRO_REARM_TRUCK_ACTIONS
};

Expand All @@ -148,6 +195,7 @@ class CfgVehicles {
class Heli_Transport_04_base_F: Helicopter_Base_H {};
class O_Heli_Transport_04_ammo_F: Heli_Transport_04_base_F {
transportAmmo = 0;
MACRO_REARM_DEFAULT_SUPPLY
MACRO_REARM_TRUCK_ACTIONS
};

Expand All @@ -163,11 +211,13 @@ class CfgVehicles {
class Pod_Heli_Transport_04_base_F: Slingload_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
};

class B_Slingload_01_Ammo_F: Slingload_01_Base_F {
transportAmmo = 0;
MACRO_REARM_DEFAULT_SUPPLY
MACRO_REARM_TRUCK_ACTIONS
};

Expand Down
12 changes: 12 additions & 0 deletions addons/rearm/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@

PREP(addMagazineToSupply);
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(getMaxMagazines);
PREP(getNeedRearmMagazines);
PREP(getSupplyCount);
PREP(getVehicleMagazines);
PREP(grabAmmo);
PREP(handleKilled);
PREP(handleUnconscious);
PREP(hasEnoughSupply);
PREP(magazineInSupply);
PREP(makeDummy);
PREP(moduleRearmSettings);
PREP(pickUpAmmo);
PREP(readSupplyCounter);
PREP(rearm);
PREP(rearmEntireVehicle);
PREP(rearmEntireVehicleSuccess);
PREP(rearmEntireVehicleSuccessLocal);
PREP(rearmSuccess);
PREP(rearmSuccessLocal);
PREP(removeMagazineFromSupply);
PREP(setSupplyCount);
PREP(storeAmmo);
PREP(takeAmmo);
PREP(takeSuccess);
8 changes: 4 additions & 4 deletions addons/rearm/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "script_component.hpp"

["ace_unconscious", {_this call FUNC(handleUnconscious)}] call CBA_fnc_addEventHandler;
["ace_unconscious", LINKFUNC(handleUnconscious)] call CBA_fnc_addEventHandler;
["vehicle", {
params ["_unit"];
[_unit] call FUNC(dropAmmo);
Expand All @@ -10,9 +10,9 @@ if (isServer) then {
addMissionEventHandler ["HandleDisconnect", {params ["_unit"]; [_unit] call FUNC(dropAmmo)}];
};

[QGVAR(makeDummyEH), FUNC(makeDummy)] call CBA_fnc_addEventHandler;
[QGVAR(rearmEntireVehicleSuccessLocalEH), FUNC(rearmEntireVehicleSuccessLocal)] call CBA_fnc_addEventHandler;
[QGVAR(rearmSuccessLocalEH), FUNC(rearmSuccessLocal)] call CBA_fnc_addEventHandler;
[QGVAR(makeDummyEH), LINKFUNC(makeDummy)] call CBA_fnc_addEventHandler;
[QGVAR(rearmEntireVehicleSuccessLocalEH), LINKFUNC(rearmEntireVehicleSuccessLocal)] call CBA_fnc_addEventHandler;
[QGVAR(rearmSuccessLocalEH), LINKFUNC(rearmSuccessLocal)] call CBA_fnc_addEventHandler;


#ifdef DEBUG_MODE_FULL
Expand Down
2 changes: 1 addition & 1 deletion addons/rearm/XEH_respawn.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ if !(isNull _dummy) then {
detach _dummy;
deleteVehicle _dummy;
};
_unit setVariable [QGVAR(dummy), nil];
_unit setVariable [QGVAR(dummy), nil];
69 changes: 69 additions & 0 deletions addons/rearm/functions/fnc_addMagazineToSupply.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Author: GitHawk
* Adds magazines to the supply.
*
* Arguments:
* 0: Ammo Truck <OBJECT>
* 1: Magazine Classname <STRING>
* 2: Only partial <BOOL>(optional)
Copy link
Member

Choose a reason for hiding this comment

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

<BOOL> (default: false)

*
* Return Value:
* None
*
* Example:
* [ammo_truck, "32Rnd_155mm_Mo_shells"] call ace_rearm_fnc_addMagazineToSupply
*
* Public: Yes
*/
#include "script_component.hpp"

params [
["_truck", objNull, [objNull]],
["_magazineClass", "", [""]],
["_partial", false, [false]]
];

if (isNull _truck ||
{_magazineClass isEqualTo ""} ||
{GVAR(supply) == 0}) 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);
} else {
private _magazinePart = ((REARM_COUNT select _idx) / (getNumber (configFile >> "CfgMagazines" >> _magazineClass >> "count"))) min 1;
[_truck, (_supply + (_cal * _magazinePart))] call FUNC(setSupplyCount);
};
};

// With magazine specific supply, we add or update the magazineSupply array
if (GVAR(supply) == 2) then {
private _magazineSupply = _truck getVariable [QGVAR(magazineSupply), []];
private _magazineIdx = -1;
{
_x params ["_magazine", "_rounds"];
if ((_magazine isEqualTo _magazineClass)) exitWith {
_magazineIdx = _forEachIndex;
};
} forEach _magazineSupply;

private _roundsPerTransaction = getNumber (configFile >> "CfgMagazines" >> _magazineClass >> "count");
if (_partial) then {
_roundsPerTransaction = _roundsPerTransaction min (REARM_COUNT select _idx);
};
if (_magazineIdx == -1) then {
if (count _magazineSupply == 0) then {
_magazineSupply = [[_magazineClass, _roundsPerTransaction]];
} else {
_magazineSupply append [[_magazineClass, _roundsPerTransaction]];
}
} else {
(_magazineSupply select _magazineIdx) params ["", "_rounds"];
_magazineSupply set [_magazineIdx, [_magazineClass, (_rounds + _roundsPerTransaction)]];
};
_truck setVariable [QGVAR(magazineSupply), _magazineSupply, true];
};
Loading