mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Common - Add setDead
API (#10045)
* Added `setDead` API * Update XEH_PREP.hpp * Update fnc_setDead.sqf * Update addons/common/functions/fnc_disableUserInput.sqf Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> * Update fnc_setDead.sqf * Added warning for non-local units --------- Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
This commit is contained in:
parent
5a1e3bc585
commit
9f2ee9fb6f
@ -161,6 +161,7 @@ PREP(sendRequest);
|
|||||||
PREP(serverLog);
|
PREP(serverLog);
|
||||||
PREP(setAimCoef);
|
PREP(setAimCoef);
|
||||||
PREP(setApproximateVariablePublic);
|
PREP(setApproximateVariablePublic);
|
||||||
|
PREP(setDead);
|
||||||
PREP(setDefinedVariable);
|
PREP(setDefinedVariable);
|
||||||
PREP(setDisableUserInputStatus);
|
PREP(setDisableUserInputStatus);
|
||||||
PREP(setHearingCapability);
|
PREP(setHearingCapability);
|
||||||
|
@ -143,11 +143,7 @@ if (_state) then {
|
|||||||
_ctrl ctrlSetEventHandler ["ButtonClick", toString {
|
_ctrl ctrlSetEventHandler ["ButtonClick", toString {
|
||||||
closeDialog 0;
|
closeDialog 0;
|
||||||
|
|
||||||
if (["ace_medical"] call FUNC(isModLoaded)) then {
|
[player, "respawn_button"] call FUNC(setDead);
|
||||||
[player, "respawn_button"] call EFUNC(medical_status,setDead);
|
|
||||||
} else {
|
|
||||||
player setDamage 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
[false] call FUNC(disableUserInput);
|
[false] call FUNC(disableUserInput);
|
||||||
}];
|
}];
|
||||||
|
44
addons/common/functions/fnc_setDead.sqf
Normal file
44
addons/common/functions/fnc_setDead.sqf
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#include "..\script_component.hpp"
|
||||||
|
/*
|
||||||
|
* Author: johnb43
|
||||||
|
* Kills a unit without changing visual appearance.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Unit <ARRAY>
|
||||||
|
* 1: Reason for death (only used if ace_medical is loaded) <STRING> (default: "")
|
||||||
|
* 2: Killer (vehicle that killed unit) <ARRAY> (default: objNull)
|
||||||
|
* 3: Instigator (unit who pulled trigger) <ARRAY> (default: objNull)
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* [cursorObject, "", player, player] call ace_common_fnc_setDead;
|
||||||
|
*
|
||||||
|
* Public: Yes
|
||||||
|
*/
|
||||||
|
|
||||||
|
params [["_unit", objNull, [objNull]], ["_reason", "", [""]], ["_source", objNull, [objNull]], ["_instigator", objNull, [objNull]]];
|
||||||
|
|
||||||
|
if (!local _unit) exitWith {
|
||||||
|
WARNING_1("setDead executed on non-local unit - %1",_this);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (["ace_medical"] call EFUNC(common,isModLoaded)) then {
|
||||||
|
[_unit, _reason, _source, _instigator] call EFUNC(medical_status,setDead);
|
||||||
|
} else {
|
||||||
|
// From 'ace_medical_status_fnc_setDead': Kill the unit without changing visual appearance
|
||||||
|
|
||||||
|
// (#8803) Reenable damage if disabled to prevent having live units in dead state
|
||||||
|
// Keep this after death event for compatibility with third party hooks
|
||||||
|
if (!isDamageAllowed _unit) then {
|
||||||
|
WARNING_1("setDead executed on unit with damage blocked - %1",_this);
|
||||||
|
_unit allowDamage true;
|
||||||
|
};
|
||||||
|
|
||||||
|
private _currentDamage = _unit getHitPointDamage "HitHead";
|
||||||
|
|
||||||
|
_unit setHitPointDamage ["HitHead", 1, true, _source, _instigator];
|
||||||
|
|
||||||
|
_unit setHitPointDamage ["HitHead", _currentDamage, true, _source, _instigator];
|
||||||
|
};
|
@ -21,11 +21,7 @@ params ["_player", "_thirst", "_hunger"];
|
|||||||
|
|
||||||
// Kill unit with max thirst or hunger
|
// Kill unit with max thirst or hunger
|
||||||
if ((_thirst > 99.9 || {_hunger > 99.9}) && {random 1 < 0.5}) exitWith {
|
if ((_thirst > 99.9 || {_hunger > 99.9}) && {random 1 < 0.5}) exitWith {
|
||||||
if (["ace_medical"] call EFUNC(common,isModLoaded)) then {
|
[_player, "Hunger/Thirst empty"] call EFUNC(common,setDead);
|
||||||
[_player, "Hunger/Thirst empty"] call EFUNC(medical_status,setDead);
|
|
||||||
} else {
|
|
||||||
_player setDamage 1;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Exit if unit is not awake, below are animation based consequences
|
// Exit if unit is not awake, below are animation based consequences
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
* 0: The unit <OBJECT>
|
* 0: The unit <OBJECT>
|
||||||
* 1: Reason for death <STRING>
|
* 1: Reason for death <STRING>
|
||||||
* 2: Killer <OBJECT>
|
* 2: Killer <OBJECT>
|
||||||
|
* 3: Instigator <OBJECT>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* None
|
* None
|
||||||
@ -14,9 +15,8 @@
|
|||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
|
||||||
params ["_unit", ["_reason", "#setDead"], ["_instigator", objNull]];
|
params ["_unit", ["_reason", "#setDead"], ["_source", objNull], ["_instigator", objNull]];
|
||||||
TRACE_3("setDead",_unit,_reason,_instigator);
|
TRACE_4("setDead",_unit,_reason,_source,_instigator);
|
||||||
|
|
||||||
|
|
||||||
// No heart rate or blood pressure to measure when dead
|
// No heart rate or blood pressure to measure when dead
|
||||||
_unit setVariable [VAR_HEART_RATE, 0, true];
|
_unit setVariable [VAR_HEART_RATE, 0, true];
|
||||||
@ -38,7 +38,7 @@ if (_unitState isNotEqualTo "Dead") then {
|
|||||||
|
|
||||||
// (#8803) Reenable damage if disabled to prevent having live units in dead state
|
// (#8803) Reenable damage if disabled to prevent having live units in dead state
|
||||||
// Keep this after death event for compatibility with third party hooks
|
// Keep this after death event for compatibility with third party hooks
|
||||||
if !(isDamageAllowed _unit) then {
|
if (!isDamageAllowed _unit) then {
|
||||||
WARNING_1("setDead executed on unit with damage blocked - %1",_this);
|
WARNING_1("setDead executed on unit with damage blocked - %1",_this);
|
||||||
_unit allowDamage true;
|
_unit allowDamage true;
|
||||||
};
|
};
|
||||||
@ -46,6 +46,6 @@ if !(isDamageAllowed _unit) then {
|
|||||||
// Kill the unit without changing visual apperance
|
// Kill the unit without changing visual apperance
|
||||||
private _prevDamage = _unit getHitPointDamage "HitHead";
|
private _prevDamage = _unit getHitPointDamage "HitHead";
|
||||||
|
|
||||||
_unit setHitPointDamage ["HitHead", 1, true, _instigator];
|
_unit setHitPointDamage ["HitHead", 1, true, _source, _instigator];
|
||||||
|
|
||||||
_unit setHitPointDamage ["HitHead", _prevDamage];
|
_unit setHitPointDamage ["HitHead", _prevDamage, true, _source, _instigator];
|
||||||
|
Loading…
Reference in New Issue
Block a user