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

Racks - Add Use to Intercom-Radios and Increase access on MRAPs #1271

Merged
merged 11 commits into from
Sep 25, 2023
4 changes: 2 additions & 2 deletions addons/sys_rack/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ class CfgVehicles {
displayName = CSTRING(dashUpper); // Name is displayed in the interaction menu.
shortName = CSTRING(dashUpperShort);
componentName = "ACRE_VRC110";
allowedPositions[] = {"driver", {"cargo", 0}}; // Who has access "inside" - anyone inside, "external" - provides access upto 10m away, "driver", "gunner", "copilot", "commander"
allowedPositions[] = {"driver", {"cargo", 0}, "commander"}; // Who has access "inside" - anyone inside, "external" - provides access upto 10m away, "driver", "gunner", "copilot", "commander"
isRadioRemovable = 1;
intercom[] = {"intercom_1"};
};
class Rack_2 {
displayName = CSTRING(dashLower); // If you have multiple racks a text label helps identify the particular rack.
shortName = CSTRING(dashLowerShort);
componentName = "ACRE_VRC103";
allowedPositions[] = {"driver", {"cargo", 0}};
allowedPositions[] = {"driver", {"cargo", 0}, "commander"};
mountedRadio = "ACRE_PRC117F";
intercom[] = {"intercom_1"};
};
Expand Down
1 change: 1 addition & 0 deletions addons/sys_rack/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ PREP(configureRackIntercom);
PREP(initializeRack);
PREP(getRackBaseClassname);
PREP(getRackFromRadio);
PREP(getRackLetterFromRadio);
PREP(getMountableRadios);
PREP(getMountedRadio);
PREP(getWiredIntercoms);
Expand Down
30 changes: 30 additions & 0 deletions addons/sys_rack/fnc_getRackLetterFromRadio.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "script_component.hpp"
/*
* Author: ACRE2Team, mrschick
* Returns the rack letter if a radio is currently mounted.
*
* Arguments:
* 0: Radio ID <STRING>
*
* Return Value:
* Letter on Work knob corresponding to the rack, or "" if radio is not in a rack <STRING>
*
* Example:
* ["ACRE_PRC152_ID_1"] call acre_sys_rack_fnc_getRackLetterFromRadio
*
* Public: No
*/

params ["_radioId"];

private _return = "";

private _wiredRacks = [vehicle acre_player, acre_player, EGVAR(sys_intercom,activeIntercom), "wiredRacks"] call EFUNC(sys_intercom,getStationConfiguration);
{
private _rackId = _x select 0;
if (([_rackId] call FUNC(getMountedRadio)) == _radioId) exitWith {
_return = [RACK_LETTERS] select _forEachIndex;
};
} forEach _wiredRacks;

_return
39 changes: 25 additions & 14 deletions addons/sys_rack/fnc_rackChildrenActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,31 @@ if (_mountedRadio == "") then { // Empty
] call ace_interact_menu_fnc_createAction;
_actions pushBack [_action, [], _target];
};
};

// Start using (only if not yet accessible and not connected to intercom)
if (!(_mountedRadio in ACRE_ACCESSIBLE_RACK_RADIOS) && {!([_mountedRadio, acre_player] call FUNC(isRadioHearable))}) then {
private _action = [
QGVAR(useMountedRadio),
localize LSTRING(useRadio),
"",
{_this call FUNC(startUsingMountedRadio)},
{true},
{},
_mountedRadio
] call ace_interact_menu_fnc_createAction;
_actions pushBack [_action, [], _target];
} else {
// Start using (only if not yet accessible and not connected to intercom)
if (!([_mountedRadio, acre_player] call FUNC(isRadioHearable))) then {
private _action = [
QGVAR(useMountedRadio),
localize LSTRING(useRadio),
"",
{_this call FUNC(startUsingMountedRadio)},
{true},
{},
_mountedRadio
] call ace_interact_menu_fnc_createAction;
_actions pushBack [_action, [], _target];
} else {
// Open FFCS (only if not accessible but wired to intercom)
// mimics standalone radio interaction to radios wired to intercom for easier UX
private _action = [
QGVAR(useMountedRadio),
format [localize LSTRING(useIntercomRadio), ([_mountedRadio] call FUNC(getRackLetterFromRadio))],
"",
{[] call EFUNC(sys_intercom,openGui)},
{true}
] call ace_interact_menu_fnc_createAction;
_actions pushBack [_action, [], _target];
};
};
};

Expand Down
2 changes: 2 additions & 0 deletions addons/sys_rack/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#define MAX_EXTERNAL_RACK_DISTANCE 10

#define RACK_LETTERS "A", "B", "C", "D", "E", "F"

#include "script_acre_rack_defines.hpp"

#include "\idi\acre\addons\sys_components\script_acre_component_defines.hpp"
Expand Down
5 changes: 5 additions & 0 deletions addons/sys_rack/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@
<Russian>Использовать</Russian>
<Turkish>Kullan</Turkish>
</Key>
<Key ID="STR_ACRE_sys_rack_useIntercomRadio">
<English>Use via Intercom (Work: %1)</English>
<German>Durch Intercom verwenden (Work: %1)</German>
<Italian>Usa tramite l'intercom (Work: %1)</Italian>
</Key>
<Key ID="STR_ACRE_sys_rack_unableUnmount">
<English>Unable to unmount radio as you have no inventory space.</English>
<German>Funkgerät kann nicht deinstalliert werden. Nicht genug Platz im Inventar.</German>
Expand Down