From 3702d0b6718df4bd442b7cfb1da52b8897743790 Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Thu, 14 May 2015 23:04:58 +0100 Subject: [PATCH] Implemented knockout module --- addons/zeus/CfgVehicles.hpp | 39 +++++++++++------ addons/zeus/XEH_preInit.sqf | 1 + addons/zeus/config.cpp | 4 +- addons/zeus/functions/fnc_moduleKnockout.sqf | 44 ++++++++++++++++++++ 4 files changed, 75 insertions(+), 13 deletions(-) create mode 100644 addons/zeus/functions/fnc_moduleKnockout.sqf diff --git a/addons/zeus/CfgVehicles.hpp b/addons/zeus/CfgVehicles.hpp index cb7346e18d..e9958edb3d 100644 --- a/addons/zeus/CfgVehicles.hpp +++ b/addons/zeus/CfgVehicles.hpp @@ -3,6 +3,18 @@ class CfgVehicles { class ModuleEmpty_F; class ACE_Module; + class ModuleCurator_F: Module_F { + function = QUOTE(DFUNC(bi_moduleCurator)); + }; + class ModuleMine_F: ModuleEmpty_F { + function = QUOTE(DFUNC(bi_moduleMine)); + }; + class ModuleOrdnance_F: Module_F { + function = QUOTE(DFUNC(bi_moduleProjectile)); + }; + class ModuleRemoteControl_F: Module_F { + function = QUOTE(DFUNC(bi_moduleRemoteControl)); + }; class GVAR(moduleZeusSettings): ACE_Module { scope = 2; displayName = "$STR_ACE_Zeus_Module_DisplayName"; @@ -64,17 +76,20 @@ class CfgVehicles { sync[] = {}; }; }; - - class ModuleCurator_F: Module_F { - function = QUOTE(DFUNC(bi_moduleCurator)); - }; - class ModuleMine_F: ModuleEmpty_F { - function = QUOTE(DFUNC(bi_moduleMine)); - }; - class ModuleOrdnance_F: Module_F { - function = QUOTE(DFUNC(bi_moduleProjectile)); - }; - class ModuleRemoteControl_F: Module_F { - function = QUOTE(DFUNC(bi_moduleRemoteControl)); + class GVAR(moduleKnockout): Module_F { + scopeCurator = 2; + displayName = "Knockout/Wakeup Unit"; + //icon = QUOTE(PATHTOF(iconGoesHere)); + category = "ACE_zeus"; + function = QUOTE(DFUNC(moduleKnockout)); + functionPriority = 1; + isGlobal = 1; + isTriggerActivated = 0; + curatorCanAttach = 1; + author = "SilentSpike"; + class ModuleDescription { + description = "Knocks out or wakes up the specified unit."; + sync[] = {}; + }; }; }; diff --git a/addons/zeus/XEH_preInit.sqf b/addons/zeus/XEH_preInit.sqf index e7bb1b96a5..1c8a2c4e62 100644 --- a/addons/zeus/XEH_preInit.sqf +++ b/addons/zeus/XEH_preInit.sqf @@ -6,6 +6,7 @@ PREP(bi_moduleCurator); PREP(bi_moduleMine); PREP(bi_moduleProjectile); PREP(bi_moduleRemoteControl); +PREP(moduleKnockout); PREP(moduleZeusSettings); ADDON = true; diff --git a/addons/zeus/config.cpp b/addons/zeus/config.cpp index 5ea4212dbb..3f15dbcd88 100644 --- a/addons/zeus/config.cpp +++ b/addons/zeus/config.cpp @@ -2,7 +2,9 @@ class CfgPatches { class ADDON { - units[] = {}; + units[] = { + QGVAR(moduleKnockout) + }; weapons[] = {}; requiredVersion = REQUIRED_VERSION; requiredAddons[] = {"ace_common"}; diff --git a/addons/zeus/functions/fnc_moduleKnockout.sqf b/addons/zeus/functions/fnc_moduleKnockout.sqf new file mode 100644 index 0000000000..353cebf8b9 --- /dev/null +++ b/addons/zeus/functions/fnc_moduleKnockout.sqf @@ -0,0 +1,44 @@ +/* + * Author: SilentSpike + * Flips the unconscious state of the unit the module is attached to. + * + * Arguments: + * 0: The module logic + * 1: units + * 2: activated + * + * ReturnValue: + * nil + * + * Public: no + */ + +#include "script_component.hpp" + +private ["_logic","_unit","_conscious","_previous"]; + +_logic = _this select 0; +_unit = attachedTo _logic; + +if (isNil QEFUNC(medical,setUnconscious)) exitWith { + ["Requires ACE_Medical to work."] call DEFUNC(common,displayTextStructured); + deleteVehicle _logic; +}; +if (isNull _unit) exitWith { + ["Module must be placed on a unit."] call DEFUNC(common,displayTextStructured); + deleteVehicle _logic; +}; + +_conscious = _unit getVariable ["ACE_isUnconscious", false]; + +//Hacky method, will be replaced once #1205 is complete +_previous = _unit getvariable [QEGVAR(medical,enableUnconsciousnessAI), EGVAR(medical,enableUnconsciousnessAI)]; +if (_previous < 2) then {_unit setvariable [QEGVAR(medical,enableUnconsciousnessAI), 2];}; + +[_unit, !_conscious] call DEFUNC(medical,setUnconscious); + +if (_previous < 2) then { + _unit setvariable [QEGVAR(medical,enableUnconsciousnessAI), _previous]; +}; + +deleteVehicle _logic; \ No newline at end of file