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 1 commit
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
Prev Previous commit
Next Next commit
Revive funktion
GNCLORD-MDB committed Jul 2, 2022
commit dceb1b66b55ac21423c040f7590a71d03022e6f9
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
45 changes: 6 additions & 39 deletions addons/main/REVIVE/fn_clientInitcbaclassevents.sqf
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@
private _action_drag =
[
"OPT_REVIVE_DRAG",
MLOC(MEDIC_REVIVE),
MLOC(DRAG),
"z\ace\addons\dragging\UI\icons\person_drag.paa",
{
params ["_target", "_player", "_params"];
@@ -47,52 +47,18 @@
}
] call ace_interact_menu_fnc_createAction;

/*
* Argument:
* 0: Object the action should be assigned to <OBJECT>
* 1: Type of action, 0 for actions, 1 for self-actions <NUMBER>
* 2: Parent path of the new action <ARRAY> (Example: `["ACE_SelfActions", "ACE_Equipment"]`)
* 3: Action <ARRAY>
*/
{
[
_unit,
0,
["ACE_MainActions"],
_x
] call ace_interact_menu_fnc_addActionToObject;
} forEach [ _action_drag];
}, nil, nil, true] call CBA_fnc_addClassEventHandler;

["CAManBase", "init",
{
params ["_unit"];

/*
* Argument:
* 0: Action name <STRING>
* 1: Name of the action shown in the menu <STRING>
* 2: Icon <STRING>
* 3: Statement <CODE>
* 4: Condition <CODE>
* 5: Insert children code <CODE> (Optional)
* 6: Action parameters <ANY> (Optional)
* 7: Position (Position array, Position code or Selection Name) <ARRAY>, <CODE> or <STRING> (Optional)
* 8: Distance <NUMBER> (Optional)
* 9: Other parameters [showDisabled,enableInside,canCollapse,runOnHover,doNotCheckLOS] <ARRAY> (Optional)
* 10: Modifier function <CODE> (Optional)
*/
private _action_revive =
[
"OPT_REVIVE_REVIVE",
MLOC(DRAG),
MLOC(MEDIC_REVIVE),
"\a3\ui_f\data\map\MapControl\hospital_ca.paa",
{
params ["_target", "_player", "_params"];
[_target, _player, "action_revive"] call FUNC(handleAction);
},
{
(cursorTarget getVariable ["OPT_isUnconscious", 1])
params ["_target", "_player", "_params"];
[_target, _player] call FUNC(checkisUnconscious);
}
] call ace_interact_menu_fnc_createAction;

@@ -110,5 +76,6 @@
["ACE_MainActions"],
_x
] call ace_interact_menu_fnc_addActionToObject;
} forEach [ _action_revive];
} forEach [ _action_drag,_action_revive];
}, nil, nil, true] call CBA_fnc_addClassEventHandler;

2 changes: 1 addition & 1 deletion addons/main/REVIVE/fn_handleaction.sqf
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ switch (_action) do

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

default
13 changes: 13 additions & 0 deletions addons/main/REVIVE/fn_initCBASettings.sqf
Original file line number Diff line number Diff line change
@@ -122,3 +122,16 @@
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(Helizeitsani), // 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;
44 changes: 22 additions & 22 deletions addons/main/REVIVE/fn_revive.sqf
Original file line number Diff line number Diff line change
@@ -9,34 +9,34 @@
* None
*
* Example:
* [] call fn_revive;
* [_target] call fn_revive;
*
*/
#include "macros.hpp"

//Revive Funktion
DFUNC(revive) =
{
GVAR(verletzter) = cursorTarget;
params ["_target"];

GVAR(verletzter) = _target;

player switchmove "AinvPknlMstpSnonWrflDnon_medic";
//Revive Funktion
player switchmove "AinvPknlMstpSnonWrflDnon_medic";

[
GVAR(Helizeitsani),
[],
{
player switchmove "";
player action ["WeaponInHand", player];
[
GVAR(Helizeitsani),
[],
{
player switchmove "";
player action ["WeaponInHand", player];

//Var zurück setzen
GVAR(verletzter) setVariable ["OPT_isUnconscious", 0, true];
},
{
player switchmove "";
player action ["WeaponInHand", player];
},
MLOC(MEDIC_REVIVE)
] call ace_common_fnc_progressBar;
};
//Var zurück setzen
GVAR(verletzter) setVariable ["OPT_isUnconscious", 0, true];
GVAR(verletzter) setDamage 0.0;
},
{
player switchmove "";
player action ["WeaponInHand", player];
},
MLOC(MEDIC_REVIVE)
] call ace_common_fnc_progressBar;

true
1 change: 1 addition & 0 deletions addons/main/modules.hpp
Original file line number Diff line number Diff line change
@@ -67,6 +67,7 @@ class CfgCLibModules
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 648


#ifdef VERSION