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

Add chatter keybind #755

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions addons/editor/initKeybinds.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@
};
}, {}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound

[ELSTRING(main,DisplayName), QGVAR(ModuleChatter), ELSTRING(modules,ModuleChatter), {
if (isRemoteControlling player) exitWith {
[remoteControlled player] call EFUNC(modules,moduleChatterUnit);
};

if (isNull curatorCamera) exitWith {};

[effectiveCommander (SELECTED_OBJECTS param [0, objNull])] call EFUNC(modules,moduleChatterUnit);
}, {}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound

[ELSTRING(main,DisplayName), QGVAR(reloadDisplay), [LSTRING(ReloadDisplay), LSTRING(ReloadDisplay_Description)], {
if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then {
[] call EFUNC(common,reloadDisplay);
Expand Down
1 change: 1 addition & 0 deletions addons/modules/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ PREP(moduleBindVariable);
PREP(moduleCAS);
PREP(moduleChangeHeight);
PREP(moduleChatter);
PREP(moduleChatterUnit);
PREP(moduleConvoyParameters);
PREP(moduleCreateIED);
PREP(moduleCreateIntel);
Expand Down
69 changes: 11 additions & 58 deletions addons/modules/functions/fnc_moduleChatter.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,65 +20,18 @@ params ["_logic"];
private _unit = effectiveCommander attachedTo _logic;
deleteVehicle _logic;

if (isNull _unit) then {
[LSTRING(ModuleChatter), [
["EDIT", LSTRING(ModuleChatter_Message)],
["SIDES", ELSTRING(common,Side), west]
], {
params ["_dialogValues"];
_dialogValues params ["_message", "_side"];
if (!isNull _unit) exitWith {[_unit] call FUNC(moduleChatterUnit);};

if (_message == "") exitWith {};
[LSTRING(ModuleChatter), [
["EDIT", LSTRING(ModuleChatter_Message), "", true],
["SIDES", ELSTRING(common,Side), west]
], {
params ["_dialogValues"];
_dialogValues params ["_message", "_side"];

// Send message from HQ is using side
[QEGVAR(common,sideChat), [[_side, "HQ"], _message]] call CBA_fnc_globalEvent;
}] call EFUNC(dialog,create);
} else {
if !(_unit isKindOf "CAManBase") exitWith {
[LSTRING(OnlyInfantry)] call EFUNC(common,showMessage);
};
if (_message == "") exitWith {};

if !(alive _unit) exitWith {
[LSTRING(OnlyAlive)] call EFUNC(common,showMessage);
};
// Send message from HQ is using side
[QEGVAR(common,sideChat), [[_side, "HQ"], _message]] call CBA_fnc_globalEvent;
}] call EFUNC(dialog,create);

if (isPlayer _unit) exitWith {
["str_a3_cfgvehicles_moduleremotecontrol_f_errorPlayer"] call EFUNC(common,showMessage);
};

[format ["%1 (%2)", localize LSTRING(ModuleChatter), name _unit], [
["EDIT", LSTRING(ModuleChatter_Message)],
["COMBO", LSTRING(ModuleChatter_Channel), [[], [
["STR_channel_global", "", "", [0.85, 0.85, 0.85, 1]],
["STR_channel_side", "", "", [0.27, 0.83, 0.99, 1]],
["STR_channel_command", "", "", [1, 1, 0.27, 1]],
["STR_channel_group", "", "", [0.71, 0.97, 0.38, 1]],
["STR_channel_vehicle", "", "", [1, 0.82, 0, 1]]
], 1]]
], {
params ["_dialogValues", "_unit"];
_dialogValues params ["_message", "_channel"];

if (_message == "") exitWith {};

// Get chat type from channel number
private _chatType = [
QEGVAR(common,globalChat),
QEGVAR(common,sideChat),
QEGVAR(common,commandChat),
QEGVAR(common,groupChat),
QEGVAR(common,vehicleChat)
] select _channel;

// Edit message to indicate AI communication
_message = format ["%1 [AI]: %2", name _unit, _message];

// Ensure vehicle of unit if vehicle chat
if (_channel == 4) then {
_unit = vehicle _unit;
};

// Send message over given chat channel
[_chatType, [_unit, _message]] call CBA_fnc_globalEvent;
}, {}, _unit] call EFUNC(dialog,create);
};
68 changes: 68 additions & 0 deletions addons/modules/functions/fnc_moduleChatterUnit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include "script_component.hpp"
/*
* Author: mharis001, Ampersand
* Opens chatter dialog for given AI.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [_unit] call zen_modules_fnc_moduleChatterUnit
*
* Public: No
*/

params ["_unit"];

if (isNull _unit) exitWith {};

if !(_unit isKindOf "CAManBase") exitWith {
[LSTRING(OnlyInfantry)] call EFUNC(common,showMessage);
};

if !(alive _unit) exitWith {
[LSTRING(OnlyAlive)] call EFUNC(common,showMessage);
};

if (isPlayer _unit) exitWith {
["str_a3_cfgvehicles_moduleremotecontrol_f_errorPlayer"] call EFUNC(common,showMessage);
};

[format ["%1 (%2)", localize LSTRING(ModuleChatter), name _unit], [
["EDIT", LSTRING(ModuleChatter_Message), "", true],
["COMBO", LSTRING(ModuleChatter_Channel), [[], [
["STR_channel_global", "", "", [0.85, 0.85, 0.85, 1]],
["STR_channel_side", "", "", [0.27, 0.83, 0.99, 1]],
["STR_channel_command", "", "", [1, 1, 0.27, 1]],
["STR_channel_group", "", "", [0.71, 0.97, 0.38, 1]],
["STR_channel_vehicle", "", "", [1, 0.82, 0, 1]]
], 0, true]]
], {
params ["_dialogValues", "_unit"];
_dialogValues params ["_message", "_channel"];

if (_message == "") exitWith {};

// Get chat type from channel number
private _chatType = [
QEGVAR(common,globalChat),
QEGVAR(common,sideChat),
QEGVAR(common,commandChat),
QEGVAR(common,groupChat),
QEGVAR(common,vehicleChat)
] select _channel;

// Edit message to indicate AI communication
_message = format ["%1 [AI]: %2", name _unit, _message];

// Ensure vehicle of unit if vehicle chat
if (_channel == 4) then {
_unit = vehicle _unit;
};

// Send message over given chat channel
[_chatType, [_unit, _message]] call CBA_fnc_globalEvent;
}, {}, _unit] call EFUNC(dialog,create);
Loading