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

Medical - Add AI Unconsciousness exception (when using zeus module) #8903

Merged
merged 17 commits into from
May 8, 2022
Merged
Show file tree
Hide file tree
Changes from 11 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
3 changes: 2 additions & 1 deletion AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ VyMajoris(W-Cephei)<vycanismajoriscsa@gmail.com>
Walthzer <walthzer.69@gmail.com>
Winter <simon@agius-muscat.net>
wizpig64
YetheSamartaka
xrufix
Zakant <Zakant@gmx.de>
zGuba
zGuba
2 changes: 1 addition & 1 deletion addons/medical_statemachine/Statemachine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ACE_Medical_StateMachine {
onStateEntered = QFUNC(enteredStateUnconscious);
class DeathAI {
targetState = "Dead";
condition = QUOTE(!GVAR(AIUnconsciousness) && {!isPlayer _this});
condition = QUOTE(!(_this call FUNC(AIUnconsciousException) || GVAR(AIUnconsciousness)) && {!isPlayer _this});
YetheSamartaka marked this conversation as resolved.
Show resolved Hide resolved
};
class WakeUp {
targetState = "Injured";
Expand Down
1 change: 1 addition & 0 deletions addons/medical_statemachine/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ PREP(leftStateCardiacArrest);
PREP(localityChangedEH);
PREP(resetStateDefault);
PREP(transitionSecondChance);
PREP(AIUnconsciousException);
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "script_component.hpp"
/*
* Author: YetheSamartaka
* Checks for AI Unconsciousness Exception variable
*
* Arguments:
* 0: The Unit <OBJECT>
*
* Return Value:
* Has Unconsciousness Exception variable <BOOL>
*
* Example:
* [_unit] call ace_medical_statemachine_fnc_AIUnconsciousException
*
* Public: No
*/

params ["_unit"];

// If the unit died the loop is finished
if (!alive _unit || {!local _unit}) exitWith {};

if (_unit getVariable ["ACE_AI_Unconsciousness_ExceptionVar", false]) exitWith { true };

false
9 changes: 9 additions & 0 deletions addons/medical_statemachine/initSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
true
] call CBA_fnc_addSetting;

[
QGVAR(AIUnconsciousness_Exception),
"CHECKBOX",
[LSTRING(AIUnconsciousness_Exception_DisplayName), LSTRING(AIUnconsciousness_Exception_Description)],
[ELSTRING(medical,Category), LSTRING(SubCategory)],
true,
true
] call CBA_fnc_addSetting;

[
QGVAR(cardiacArrestTime),
"TIME",
Expand Down
8 changes: 8 additions & 0 deletions addons/medical_statemachine/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,13 @@
<Chinesesimp>控制单位是否会在心脏骤停时间耗完之前因失血过多而死亡。</Chinesesimp>
<Korean>지정한 심정지 시간이 다 되기전에 출혈로 인해 사망할 수 있는지를 결정합니다.</Korean>
</Key>
<Key ID="STR_ACE_Medical_Statemachine_AIUnconsciousness_Exception_DisplayName">
<English>AI Unconsciousness exception</English>
<Czech>Výjimka pro AI bezvědomí</Czech>
</Key>
<Key ID="STR_ACE_Medical_Statemachine_AIUnconsciousness_Exception_Description">
<English>If enabled, it allows you to put AI into unconsciousness via Zeus Module even though the AI unconsciousness is disabled.</English>
<Czech>Pokud povoleno, povolí vám uvrhnout AI do bezvědomí pomocí Zeus modulu i přes to, že bezvědomí pro AI je zakázáno.</Czech>
</Key>
</Package>
</Project>
6 changes: 6 additions & 0 deletions addons/zeus/functions/fnc_moduleUnconscious.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ if (isNil QEFUNC(medical,setUnconscious)) then {
[LSTRING(OnlyAlive)] call FUNC(showMessage);
} else {
private _unconscious = GETVAR(_unit,ACE_isUnconscious,false);
if (ace_medical_statemachine_AIUnconsciousness_Exception) then {
_unit setVariable ["ACE_AI_Unconsciousness_ExceptionVar", true, true];
if (_unconscious) then {
_unit setVariable ["ACE_AI_Unconsciousness_ExceptionVar", false, true];
};
};
// Function handles locality for me
[_unit, !_unconscious, 10e10] call EFUNC(medical,setUnconscious);
};
Expand Down