From 5f4349eae5b432f6a24de87f7a4cada3187a6b69 Mon Sep 17 00:00:00 2001 From: jaj22 Date: Mon, 27 May 2024 19:58:35 +0100 Subject: [PATCH] Switch respawn & self-revive keys to custom keybinds (#3233) * Switch Antistasi medical respawn & self-revive keys to custom keybind system * Show actual bound keys in the unconscious HUD --- A3A/addons/core/Stringtable.xml | 16 +++++- .../core/functions/Revive/fn_respawn.sqf | 3 +- .../core/functions/Revive/fn_selfRevive.sqf | 3 + .../core/functions/Revive/fn_unconscious.sqf | 55 +++++++++---------- .../core/keybinds/CfgDefaultKeysPresets.hpp | 2 + A3A/addons/core/keybinds/CfgUserActions.hpp | 10 ++++ A3A/addons/core/keybinds/UserActionGroups.hpp | 2 + .../keybinds/UserActionsConflictGroups.hpp | 2 + 8 files changed, 62 insertions(+), 31 deletions(-) diff --git a/A3A/addons/core/Stringtable.xml b/A3A/addons/core/Stringtable.xml index b8a007849d..d8d9931bbd 100644 --- a/A3A/addons/core/Stringtable.xml +++ b/A3A/addons/core/Stringtable.xml @@ -7728,14 +7728,14 @@ %1正在赶来救助你的路上 - Press R to respawn. + Press %1 to respawn. Appuyez sur R pour réapparaître. R 키를 눌러 리스폰합니다. Нажмите R, чтобы возродиться. 按R键重生 - Press H to shake off the injury. + Press %1 to shake off the injury. Appuyez sur H pour vous débarrasser de la blessure. H 키를 눌러 부상을 떨쳐냅니다. Нажмите H, чтобы избавиться от повреждения. @@ -8616,6 +8616,18 @@ 안티스타시의 전투 메뉴를 엽니다. Открывает меню битвы Antistasi. + + Respawn + + + Respawn when unconscious in the Antistasi medical system. + + + Self revive + + + Self revive when unconscious in the Antistasi medical system. + Dismiss Previous Hint Chiudi Suggerimento Precedente diff --git a/A3A/addons/core/functions/Revive/fn_respawn.sqf b/A3A/addons/core/functions/Revive/fn_respawn.sqf index 539d4f1256..bbd987d5ae 100644 --- a/A3A/addons/core/functions/Revive/fn_respawn.sqf +++ b/A3A/addons/core/functions/Revive/fn_respawn.sqf @@ -5,7 +5,8 @@ if (_unit getVariable "respawning") exitWith {}; if (_unit != _unit getVariable ["owner",_unit]) exitWith {}; if (!isPlayer _unit) exitWith {}; -if (!isNil "respawnMenu") then {(findDisplay 46) displayRemoveEventHandler ["KeyDown", respawnMenu]}; +removeAllUserActionEventHandlers ["A3A_core_respawn", "Activate"]; +removeAllUserActionEventHandlers ["A3A_core_selfRevive", "Activate"]; _unit setVariable ["respawning",true]; private _layer = ["A3A_infoCenter"] call BIS_fnc_rscLayer; ["Respawning",0,0,3,0,0,_layer] spawn bis_fnc_dynamicText; diff --git a/A3A/addons/core/functions/Revive/fn_selfRevive.sqf b/A3A/addons/core/functions/Revive/fn_selfRevive.sqf index 1e7767216c..df386b8b10 100644 --- a/A3A/addons/core/functions/Revive/fn_selfRevive.sqf +++ b/A3A/addons/core/functions/Revive/fn_selfRevive.sqf @@ -22,6 +22,9 @@ if (time < player getVariable ["A3A_selfReviveTimeout", -1]) exitWith { }; // ok so now we actually do it... +removeAllUserActionEventHandlers ["A3A_core_respawn", "Activate"]; +removeAllUserActionEventHandlers ["A3A_core_selfRevive", "Activate"]; + player setVariable ["incapacitated", false, true]; player setDamage 0.5; player removeItem selectRandom _hasFAKs; diff --git a/A3A/addons/core/functions/Revive/fn_unconscious.sqf b/A3A/addons/core/functions/Revive/fn_unconscious.sqf index a5a70dab51..bbbfbb15a7 100644 --- a/A3A/addons/core/functions/Revive/fn_unconscious.sqf +++ b/A3A/addons/core/functions/Revive/fn_unconscious.sqf @@ -17,19 +17,7 @@ if (isPlayer _unit) then _unit spawn { sleep 5; _this allowDamage true }; closeDialog 0; openMap false; - if (!isNil "respawnMenu") then {(findDisplay 46) displayRemoveEventHandler ["KeyDown", respawnMenu]}; - respawnMenu = (findDisplay 46) displayAddEventHandler ["KeyDown", - { - if !(player getVariable ["incapacitated",false]) exitWith {false}; - if (_this select 1 == 19) then { - [player] spawn A3A_fnc_respawn; - }; - if (_this select 1 == 35) then { - if (A3A_selfReviveMethods) then { [] spawn A3A_fnc_selfRevive }; - //if (A3A_selfReviveMethods == 2) then { [] spawn A3A_fnc_transferToAI }; // different keys later? - }; - false; - }]; + if (_injurer != Invaders) then {_unit setCaptive true}; { if ((!isPlayer _x) and (vehicle _x != _x) and (_x distance _unit < 50)) then {unassignVehicle _x; [_x] orderGetIn false} @@ -60,22 +48,31 @@ else _unit setFatigue 1; sleep 2; if (_isPlayer) then - { +{ + addUserActionEventHandler ["A3A_core_respawn", "Activate", { + if !(player getVariable ["incapacitated",false]) exitWith {}; + [player] spawn A3A_fnc_respawn; + }]; + addUserActionEventHandler ["A3A_core_selfRevive", "Activate", { + if !(player getVariable ["incapacitated",false]) exitWith {}; + if (A3A_selfReviveMethods) then { [] spawn A3A_fnc_selfRevive }; + }]; + if (A3A_hasTFAR || A3A_hasTFARBeta) then - { + { _saveVolumeVoice = player getVariable ["tf_voiceVolume", 1.0]; player setVariable ["tf_unable_to_use_radio", true, true]; player setVariable ["tf_voiceVolume", 0]; _saveVolume = player getVariable ["tf_globalVolume", 1.0]; player setVariable ["tf_globalVolume", 0.7, true]; - }; + }; group _unit setCombatMode "YELLOW"; if (isMultiplayer) then - { + { [_unit,"heal1"] remoteExec ["A3A_fnc_flagaction",0,_unit]; //[_unit,"carry"] remoteExec ["A3A_fnc_flagaction",0,_unit]; - }; }; +}; private _nextRequest = 0; @@ -95,9 +92,9 @@ while {(time < _bleedOut) and (_unit getVariable ["incapacitated",false]) and (a if (_helper distance _unit < 3) exitWith { format [localize "STR_A3A_fn_revive_unconscious_helping", name _helper] }; format [localize "STR_A3A_fn_revive_unconscious_onTheWay", name _helper]; }; - private _respawnText = "
" + localize "STR_A3A_fn_revive_unconscious_respawn"; + private _respawnText = format ["
" + localize "STR_A3A_fn_revive_unconscious_respawn", actionKeysNames "A3A_core_respawn"]; private _reviveText = call { - if (A3A_selfReviveMethods) exitWith { "
" + localize "STR_A3A_fn_revive_unconscious_selfRevive" }; + if (A3A_selfReviveMethods) exitWith { format ["
" + localize "STR_A3A_fn_revive_unconscious_selfRevive", actionKeysNames "A3A_core_selfRevive"] }; //if (A3A_selfReviveMethods == 2) exitWith { "
Hit H to take over nearest AI ally" }; "" }; @@ -112,24 +109,26 @@ while {(time < _bleedOut) and (_unit getVariable ["incapacitated",false]) and (a }; if (_isPlayer) then - { - (findDisplay 46) displayRemoveEventHandler ["KeyDown", respawnMenu]; +{ + removeAllUserActionEventHandlers ["A3A_core_respawn", "Activate"]; + removeAllUserActionEventHandlers ["A3A_core_selfRevive", "Activate"]; + if (A3A_hasTFAR || A3A_hasTFARBeta) then - { + { player setVariable ["tf_unable_to_use_radio", false, true]; player setVariable ["tf_globalVolume", _saveVolume]; player setVariable ["tf_voiceVolume", _saveVolumeVoice, true]; - }; + }; if (isMultiplayer) then {[_unit,"remove"] remoteExec ["A3A_fnc_flagaction",0,_unit]}; - } +} else - { +{ _unit stop false; if (_inPlayerGroup or _playersX) then - { + { [_unit,"remove"] remoteExec ["A3A_fnc_flagaction",0,_unit]; - }; }; +}; if (_isPlayer and (_unit getVariable ["respawn",false])) exitWith {}; diff --git a/A3A/addons/core/keybinds/CfgDefaultKeysPresets.hpp b/A3A/addons/core/keybinds/CfgDefaultKeysPresets.hpp index 6d3f70ec35..647df59fbc 100644 --- a/A3A/addons/core/keybinds/CfgDefaultKeysPresets.hpp +++ b/A3A/addons/core/keybinds/CfgDefaultKeysPresets.hpp @@ -4,6 +4,8 @@ class CfgDefaultKeysPresets { class Mappings { GVAR(battleMenu)[] = {DIK_Y}; GVAR(artyMenu)[] = {0x2A130015}; //combo Left shift + Y (no double tap) + GVAR(respawn)[] = {DIK_R}; + GVAR(selfRevive)[] = {DIK_H}; GVAR(infoBar)[] = {0x381300C7}; //combo Left alt + Home (no double tap) GVAR(earPlugs)[] = {DIK_END}; GVAR(customHintDismiss)[] = {}; diff --git a/A3A/addons/core/keybinds/CfgUserActions.hpp b/A3A/addons/core/keybinds/CfgUserActions.hpp index f2d9967c3e..61158dc308 100644 --- a/A3A/addons/core/keybinds/CfgUserActions.hpp +++ b/A3A/addons/core/keybinds/CfgUserActions.hpp @@ -13,6 +13,16 @@ class CfgUserActions { onActivate = ACTION(artyMenu); }; + class GVAR(respawn) { + displayName = $STR_A3A_keybinds_CfgUserAct_respawn_DN; + tooltip = $STR_A3A_keybinds_CfgUserAct_respawn_tip; + }; + + class GVAR(selfRevive) { + displayName = $STR_A3A_keybinds_CfgUserAct_selfRevive_DN; + tooltip = $STR_A3A_keybinds_CfgUserAct_selfRevive_tip; + }; + class GVAR(infoBar) { displayName = $STR_A3A_keybinds_CfgUserAct_infoBar_DN; tooltip = $STR_A3A_keybinds_CfgUserAct_infoBar_tip; diff --git a/A3A/addons/core/keybinds/UserActionGroups.hpp b/A3A/addons/core/keybinds/UserActionGroups.hpp index 187d3fcbfd..b72a141ce0 100644 --- a/A3A/addons/core/keybinds/UserActionGroups.hpp +++ b/A3A/addons/core/keybinds/UserActionGroups.hpp @@ -5,6 +5,8 @@ class UserActionGroups { group[] = { QGVAR(battleMenu), QGVAR(artyMenu), + QGVAR(respawn), + QGVAR(selfRevive), QGVAR(infoBar), QGVAR(earPlugs), QGVAR(customHintDismiss) diff --git a/A3A/addons/core/keybinds/UserActionsConflictGroups.hpp b/A3A/addons/core/keybinds/UserActionsConflictGroups.hpp index 4eeb8e35e6..c419c16540 100644 --- a/A3A/addons/core/keybinds/UserActionsConflictGroups.hpp +++ b/A3A/addons/core/keybinds/UserActionsConflictGroups.hpp @@ -3,6 +3,8 @@ class UserActionsConflictsGroups { PREFIX[] = { QGVAR(battleMenu), QGVAR(artyMenu), + QGVAR(respawn), + QGVAR(selfRevive), QGVAR(infoBar), QGVAR(earPlugs), QGVAR(customHintDismiss)