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

Prototyp OPT Revive system #214

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
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
44 changes: 44 additions & 0 deletions addons/main/REVIVE/fn_checkisUnconscious.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Author: [GNC]Lord-MDB
* Kontrolliert ob Spieler bewustlos ist.
*
* Arguments:
* 0: <OBJECT> target add action is attached to
* 1: <OBJECT> unit that called the add action
*
* Return Value:
* 0: <BOOL> 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
1 change: 1 addition & 0 deletions addons/main/REVIVE/fn_clientInit.sqf
Original file line number Diff line number Diff line change
@@ -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)}];
47 changes: 16 additions & 31 deletions addons/main/REVIVE/fn_clientInitEH.sqf
Original file line number Diff line number Diff line change
@@ -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;
}];

18 changes: 17 additions & 1 deletion addons/main/REVIVE/fn_clientInitcbaclassevents.sqf
Original file line number Diff line number Diff line change
@@ -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 <OBJECT>
@@ -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;

8 changes: 5 additions & 3 deletions addons/main/REVIVE/fn_dialog.sqf
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions addons/main/REVIVE/fn_handleaction.sqf
Original file line number Diff line number Diff line change
@@ -33,6 +33,11 @@ switch (_action) do
[] call FUNC(release);
};

case "action_revive":
{
[_target] call FUNC(revive);
};

default
{

39 changes: 39 additions & 0 deletions addons/main/REVIVE/fn_initCBASettings.sqf
Original file line number Diff line number Diff line change
@@ -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;
51 changes: 51 additions & 0 deletions addons/main/REVIVE/fn_revive.sqf
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions addons/main/modules.hpp
Original file line number Diff line number Diff line change
@@ -66,6 +66,8 @@ class CfgCLibModules
FNC(release);
FNC(weaponreequip);
FNC(clientInitcbaclassevents);
FNC(revive);
FNC(checkisUnconscious);
};

MODULE(GELDZEIT)
2 changes: 1 addition & 1 deletion addons/main/script_version.hpp
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
#define MAJOR 1
#define MINOR 9
#define PATCHLVL 2
#define BUILD 639
#define BUILD 672


#ifdef VERSION