diff --git a/addons/main/REVIVE/fn_checkisUnconscious.sqf b/addons/main/REVIVE/fn_checkisUnconscious.sqf new file mode 100644 index 00000000..ce659791 --- /dev/null +++ b/addons/main/REVIVE/fn_checkisUnconscious.sqf @@ -0,0 +1,44 @@ +/** +* Author: [GNC]Lord-MDB +* Kontrolliert ob Spieler bewustlos ist. +* +* Arguments: +* 0: target add action is attached to +* 1: unit that called the add action +* +* Return Value: +* 0: true - Spieler ist bewustlos +* +* Example: +* [cursorObject, player] call fn_checkisUnconscious.sqf; +* +*/ +#include "macros.hpp" + +params ["_target", "_caller"]; + +private _return = false; + +private _isPlayerUnconscious = _caller getVariable "OPT_isUnconscious"; + +if (!alive _caller || {_isPlayerUnconscious == 1} || {GVAR(OPT_isDragging)} || {isNil "_target"} || {!alive _target} || {(_target distance _caller) > 5}) exitWith +{ + _return; +}; + +// Target of the action +private _isTargetUnconscious = false; +private _isDragged = _target getVariable "OPT_isDragged"; +private _isPlayerUnconscioustarget = _target getVariable "OPT_isUnconscious"; + +if (_isPlayerUnconscioustarget == 1) then +{ + _isTargetUnconscious = true; +}; + +if (_isTargetUnconscious && (_isDragged == 0)) then +{ + _return = true; +}; + +_return diff --git a/addons/main/REVIVE/fn_clientInit.sqf b/addons/main/REVIVE/fn_clientInit.sqf index 42818ecc..1a3a732a 100644 --- a/addons/main/REVIVE/fn_clientInit.sqf +++ b/addons/main/REVIVE/fn_clientInit.sqf @@ -56,6 +56,7 @@ DFUNC(SelfCare) = player setVariable ["OPT_isStabilized", 0, true]; GVAR(OPT_isDragging) = false; player setVariable ["OPT_isDragged", 0, true]; + player setVariable ["OPT_damage_var",0]; //Chat abschaltung bei Bewustlosigkeit (findDisplay 46) displayAddEventHandler ["KeyDown", {_this call FUNC(keyUnbind)}]; diff --git a/addons/main/REVIVE/fn_clientInitEH.sqf b/addons/main/REVIVE/fn_clientInitEH.sqf index 2ecb3f47..1f98b240 100644 --- a/addons/main/REVIVE/fn_clientInitEH.sqf +++ b/addons/main/REVIVE/fn_clientInitEH.sqf @@ -54,15 +54,15 @@ DFUNC(HandleDamage) = GVAR(Damage_instigator_age) = serverTime; }; - // Einmalige Auslösung bei schwerer Verletzung lebenswichtiger Körperteile - if (_unit isEqualTo player && isNil QGVAR(unconsciousHandler) && _damage >= MAX_DAMAGE && !(_selection in ["arms", "hands", "legs"])) then + // Einmalige Auslösung bei schwerer Verletzung lebenswichtiger Körperteile + if (_unit isEqualTo player && isNil QGVAR(unconsciousHandler) && _damage >= GVAR(levelreviveaktiv) && !(_selection in ["arms", "hands", "legs"])) then { // Spieler bewusstlos machen und weiteren Schaden ausblenden - player setDamage 0.5; player allowDamage false; + player setDamage GVAR(levelreviveaktiv); + player setUnconscious true; GVAR(unconsciousHandler) = true; -// ["DEBUG", "KillHandler", [GVAR(Damage_unit), _selection, _damage, GVAR(Damage_source), GVAR(Damage_projectile), _hitIndex, GVAR(Damage_instigator), _hitPoint]] remoteExec [QEFUNC(LOGGING,writelog), 2]; // für Dragging und Chat _unit setVariable ["OPT_isUnconscious", 1, true]; @@ -75,6 +75,9 @@ DFUNC(HandleDamage) = // Einheit aus Fahrzeug entfernen if (vehicle _unit != _unit) then {moveOut _unit}; + //Spieler verwundet darstellen + player playAction "Unconscious"; + // Verzögert, damit möglichst alle Variablen gefüllt sind (der EH feuert zig mal, teilweise mit unvollständigen Angaben) [{ // alte Variablen von vorherigen Verletzungen leeren @@ -135,13 +138,13 @@ DFUNC(HandleDamage) = // Respawn-Dialog anzeigen [] call FUNC(dialog); }, 2, ""] call CFUNC(wait); - 0; // keine weitere Damage zurückgeben, da wir eh schon bewusstlos sind + 0; } else { - // Maximal MAX_DAMAGE zurückgeben, damit man nie sofort stirbt (Extremitätsverletzungen werden ignoriert) + // Maximal levelreviveaktiv zurückgeben, damit man nie sofort stirbt (Extremitätsverletzungen werden ignoriert) if (_selection in ["arms", "hands", "legs"]) then {0} - else {_damage min MAX_DAMAGE}; + else {_damage min GVAR(levelreviveaktiv)}; }; }; @@ -151,14 +154,16 @@ DFUNC(HandleDamage) = _data params ["_newPlayer", "_oldPlayer"]; // Respawn will change the player Object. We need to reassign the Eventhandler. - _oldPlayer removeEventHandler ["HandleDamage", GVAR(PLAYER_HANDLE_DAMAGE_EH_ID)]; - GVAR(PLAYER_HANDLE_DAMAGE_EH_ID) = _newPlayer addEventHandler ["HandleDamage", FUNC(HandleDamage)]; + _oldPlayer removeEventHandler ["HandleDamage",player getVariable ["opt_revive_ehHandleDamage",-1]]; + player setVariable ["opt_revive_ehHandleDamage", player addEventHandler ["HandleDamage",OPT_REVIVE_fnc_HandleDamage]]; _newPlayer setVariable ["OPT_isUnconscious", 0, true]; _newPlayer setVariable ["OPT_isStabilized", 0, true]; _newPlayer setVariable ["OPT_isDragged", 0, true]; _newPlayer allowDamage true; _newPlayer setVariable ["tf_unable_to_use_radio", false]; + _newPlayer setUnconscious false; + _newPlayer playAction "PlayerStand"; GVAR(OPT_isDragging) = false; GVAR(unconsciousHandler) = nil; @@ -207,29 +212,8 @@ DFUNC(HandleDamage) = }, 1, ""] call CFUNC(wait); }] call CFUNC(addEventhandler); -// Avoid Handcuffing -// by TeTeT for OPT -// (ist nur noch zur Sicherheit drin) -inGameUISetEventHandler ["Action", ' - params ["_target"]; - private _actionID = _target getVariable [ "#rev_actionID_secure", -1 ]; - if (_actionID isNotEqualTo -1) then { - [ _target, _actionID ] call bis_fnc_holdActionRemove; - true; - }; -']; - -// The initial EHs are not needed and resulting in strange problems adding a new EH, so we remove any. -// still very bad practise that screams for sideeffects. -// Just look away. -for "_i" from 0 to 6 do { - player removeEventHandler ["HandleDamage", _i]; -}; -// ok now you may have a peek again - - // Initial assignment, Respawn Handler does not trigger on first-spawn. -GVAR(PLAYER_HANDLE_DAMAGE_EH_ID) = player addEventHandler ["HandleDamage", FUNC(HandleDamage)]; +player setVariable ["opt_revive_ehHandleDamage", player addEventHandler ["HandleDamage",OPT_REVIVE_fnc_HandleDamage]]; // Variablen-Reset GVAR(Damage_unit) = objNull; @@ -257,3 +241,4 @@ GVAR(missionEH_draw3D) = addMissionEventHandler ["Draw3D", drawIcon3D ["\a3\ui_f\data\map\MapControl\hospital_ca.paa", [0.6, 0.15, 0, 0.8], _x, 0.5, 0.5, 0, format ["%1 (%2m)", name _x, round (player distance _x)], 0, 0.02]; } forEach _nearbyUnits; }]; + diff --git a/addons/main/REVIVE/fn_clientInitcbaclassevents.sqf b/addons/main/REVIVE/fn_clientInitcbaclassevents.sqf index 6822cdac..9eb83f6c 100644 --- a/addons/main/REVIVE/fn_clientInitcbaclassevents.sqf +++ b/addons/main/REVIVE/fn_clientInitcbaclassevents.sqf @@ -47,6 +47,21 @@ } ] call ace_interact_menu_fnc_createAction; + private _action_revive = + [ + "OPT_REVIVE_REVIVE", + MLOC(MEDIC_REVIVE), + "\a3\ui_f\data\map\MapControl\hospital_ca.paa", + { + params ["_target", "_player", "_params"]; + [_target, _player, "action_revive"] call FUNC(handleAction); + }, + { + params ["_target", "_player", "_params"]; + [_target, _player] call FUNC(checkisUnconscious); + } + ] call ace_interact_menu_fnc_createAction; + /* * Argument: * 0: Object the action should be assigned to @@ -61,5 +76,6 @@ ["ACE_MainActions"], _x ] call ace_interact_menu_fnc_addActionToObject; - } forEach [ _action_drag]; + } forEach [ _action_drag,_action_revive]; }, nil, nil, true] call CBA_fnc_addClassEventHandler; + diff --git a/addons/main/REVIVE/fn_dialog.sqf b/addons/main/REVIVE/fn_dialog.sqf index e229cbd6..ebabb9dd 100644 --- a/addons/main/REVIVE/fn_dialog.sqf +++ b/addons/main/REVIVE/fn_dialog.sqf @@ -71,9 +71,6 @@ _Respawn_button ctrlAddEventHandler ["ButtonClick", EGVAR(LOGGING,LAST_POSITION) = nil; EGVAR(LOGGING,LAST_DISTANCE) = 0; - // Eventhandler löschen - player removeEventHandler ["HandleDamage", GVAR(PLAYER_HANDLE_DAMAGE_EH_ID)]; - GVAR(RespawnPressed) = true; ["Health", "Respawn", [getPlayerUID player, name player, side player, "RespawnClick"]] remoteExecCall [QEFUNC(LOGGING,writelog), 2, false]; player allowDamage true; @@ -168,9 +165,14 @@ GVAR(startzeit) = time; player setVariable ["OPT_isUnconscious", 0, true]; player setVariable ["tf_unable_to_use_radio", false]; + //Spieler umdrehen + player playMove "amovppnemstpsraswrfldnon"; + player playMove ""; + // Schaden freigeben player allowDamage true; GVAR(unconsciousHandler) = nil; + player setUnconscious false; // Nicht nach dem Respawnen ausführen if (isNil QGVAR(RespawnPressed)) then diff --git a/addons/main/REVIVE/fn_handleaction.sqf b/addons/main/REVIVE/fn_handleaction.sqf index 2ec1d8eb..c5960df4 100644 --- a/addons/main/REVIVE/fn_handleaction.sqf +++ b/addons/main/REVIVE/fn_handleaction.sqf @@ -33,6 +33,11 @@ switch (_action) do [] call FUNC(release); }; + case "action_revive": + { + [_target] call FUNC(revive); + }; + default { diff --git a/addons/main/REVIVE/fn_initCBASettings.sqf b/addons/main/REVIVE/fn_initCBASettings.sqf index a4e2acfc..7bd7fbab 100644 --- a/addons/main/REVIVE/fn_initCBASettings.sqf +++ b/addons/main/REVIVE/fn_initCBASettings.sqf @@ -109,3 +109,42 @@ 1, // "_isGlobal" flag. Set this to true to always have this setting synchronized between all clients in multiplayer {} // function that will be executed once on mission start and every time the setting is changed. ] call CBA_Settings_fnc_init; + +[ + QGVAR(levelreviveaktiv), // Internal setting name, should always contain a tag! This will be the global variable which takes the value of the setting. + "SLIDER", // setting type + [ + "Grenzwert für Revive Auslösung", // Pretty name shown inside the ingame settings menu. Can be stringtable entry. + "Wert ab dem der Revive ausgelöst wird" + endl // Mouse-Over description of the above + ], + "OPT San-System", // Pretty name of the category where the setting can be found. Can be stringtable entry. + [0, 1.0, 0.75, 2], // [min, max, default, decimal] + 1, // "_isGlobal" flag. Set this to true to always have this setting synchronized between all clients in multiplayer + {} // function that will be executed once on mission start and every time the setting is changed. +] call CBA_Settings_fnc_init; + +[ + QGVAR(Heilzeitsani), // Internal setting name, should always contain a tag! This will be the global variable which takes the value of the setting. + "SLIDER", // setting type + [ + "Dauer für die Revivezeit des Sanis", // Pretty name shown inside the ingame settings menu. Can be stringtable entry. + "Zeit in Sek" + endl // Mouse-Over description of the above + ], + "OPT San-System", // Pretty name of the category where the setting can be found. Can be stringtable entry. + [1, 30, 20, 0], // [min, max, default, decimal] + 1, // "_isGlobal" flag. Set this to true to always have this setting synchronized between all clients in multiplayer + {} // function that will be executed once on mission start and every time the setting is changed. +] call CBA_Settings_fnc_init; + +[ + QGVAR(Heilzeitfaktor), // Internal setting name, should always contain a tag! This will be the global variable which takes the value of the setting. + "SLIDER", // setting type + [ + "Verlängerung bei nicht Sani Einheiten", // Pretty name shown inside the ingame settings menu. Can be stringtable entry. + "Prozentwert um die sich die Sani Heilzeit vergrößert" + endl // Mouse-Over description of the above + ], + "OPT San-System", // Pretty name of the category where the setting can be found. Can be stringtable entry. + [1, 100, 50, 0], // [min, max, default, decimal] + 1, // "_isGlobal" flag. Set this to true to always have this setting synchronized between all clients in multiplayer + {} // function that will be executed once on mission start and every time the setting is changed. +] call CBA_Settings_fnc_init; diff --git a/addons/main/REVIVE/fn_revive.sqf b/addons/main/REVIVE/fn_revive.sqf new file mode 100644 index 00000000..11e09779 --- /dev/null +++ b/addons/main/REVIVE/fn_revive.sqf @@ -0,0 +1,51 @@ +/** +* Author: James +* release unit that player carries +* +* Arguments: +* None +* +* Return Value: +* None +* +* Example: +* [_target] call fn_revive; +* +*/ +#include "macros.hpp" + +params ["_target"]; + +GVAR(verletzter) = _target; +GVAR(Heilzeit) = 0; + +GVAR(Heilzeit) = GVAR(Heilzeitsani); + +//längere Heilzeit bei nicht Sanitätern +if (!(typeOf player in GVAR(SaniKlassen))) then +{ + GVAR(Heilzeit) = GVAR(Heilzeitsani)+(GVAR(Heilzeitsani)*GVAR(Heilzeitfaktor)/100); +}; + +//Revive Funktion +player playAction "medicStart"; + +[ + GVAR(Heilzeit), + [], + { + player playAction "medicStop"; + player action ["WeaponInHand", player]; + + //Var zurück setzen + GVAR(verletzter) setVariable ["OPT_isUnconscious", 0, true]; + GVAR(verletzter) setDamage 0.0; + }, + { + player playAction "medicStop"; + player action ["WeaponInHand", player]; + }, + MLOC(MEDIC_REVIVE) +] call ace_common_fnc_progressBar; + +true diff --git a/addons/main/modules.hpp b/addons/main/modules.hpp index de2deeeb..15ddfdc7 100644 --- a/addons/main/modules.hpp +++ b/addons/main/modules.hpp @@ -66,6 +66,8 @@ class CfgCLibModules FNC(release); FNC(weaponreequip); FNC(clientInitcbaclassevents); + FNC(revive); + FNC(checkisUnconscious); }; MODULE(GELDZEIT) diff --git a/addons/main/script_version.hpp b/addons/main/script_version.hpp index fdee5fd6..4409426a 100755 --- a/addons/main/script_version.hpp +++ b/addons/main/script_version.hpp @@ -2,7 +2,7 @@ #define MAJOR 1 #define MINOR 9 #define PATCHLVL 2 -#define BUILD 639 +#define BUILD 672 #ifdef VERSION