diff --git a/addons/editor/initKeybinds.sqf b/addons/editor/initKeybinds.sqf index 4b211ee57..1c3c167c5 100644 --- a/addons/editor/initKeybinds.sqf +++ b/addons/editor/initKeybinds.sqf @@ -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); diff --git a/addons/modules/XEH_PREP.hpp b/addons/modules/XEH_PREP.hpp index 30cc02679..b54a1ed06 100644 --- a/addons/modules/XEH_PREP.hpp +++ b/addons/modules/XEH_PREP.hpp @@ -36,6 +36,7 @@ PREP(moduleBindVariable); PREP(moduleCAS); PREP(moduleChangeHeight); PREP(moduleChatter); +PREP(moduleChatterUnit); PREP(moduleConvoyParameters); PREP(moduleCreateIED); PREP(moduleCreateIntel); diff --git a/addons/modules/functions/fnc_moduleChatter.sqf b/addons/modules/functions/fnc_moduleChatter.sqf index 1cb6e4bc9..88455b476 100644 --- a/addons/modules/functions/fnc_moduleChatter.sqf +++ b/addons/modules/functions/fnc_moduleChatter.sqf @@ -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); -}; diff --git a/addons/modules/functions/fnc_moduleChatterUnit.sqf b/addons/modules/functions/fnc_moduleChatterUnit.sqf new file mode 100644 index 000000000..0001501e1 --- /dev/null +++ b/addons/modules/functions/fnc_moduleChatterUnit.sqf @@ -0,0 +1,68 @@ +#include "script_component.hpp" +/* + * Author: mharis001, Ampersand + * Opens chatter dialog for given AI. + * + * Arguments: + * 0: Unit + * + * 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);