Moved relevant functions from common to medical.

Removed unnecessary event function.
This commit is contained in:
Thomas Kooi 2015-01-24 17:18:38 +01:00
parent e06c5010bb
commit 8d34f98909
31 changed files with 141 additions and 259 deletions

View File

@ -142,21 +142,6 @@ GVAR(OldPlayerTurret) = [ACE_player] call FUNC(getTurretIndex);
}, 0, []] call cba_fnc_addPerFrameHandler;
[QGVAR(reviveCounter_f), 0, false, QGVAR(ADDON)] call FUNC(defineVariable);
[QGVAR(inReviveState), false, true, QGVAR(ADDON)] call FUNC(defineVariable);
["ACE_isDead",false,true,QUOTE(ADDON)] call FUNC(defineVariable);
[QGVAR(isDeadPlayer), false, true, QUOTE(ADDON)] call FUNC(defineVariable);
[QGVAR(StateArrested),false,true,QUOTE(ADDON)] call FUNC(defineVariable);
["ACE_isUnconscious",false,true,QUOTE(ADDON)] call FUNC(defineVariable);
[QGVAR(ENABLE_REVIVE_SETDEAD_F),0,false,QUOTE(ADDON)] call FUNC(defineVariable);
[QGVAR(carriedBy),objNull,false,QUOTE(ADDON)] call FUNC(defineVariable);
if (isNil QGVAR(ENABLE_REVIVE_F)) then {
GVAR(ENABLE_REVIVE_F) = 0;
};
[
{((_this select 0) getvariable [QGVAR(inReviveState), false])}
] call EFUNC(common,registerUnconsciousCondition);
[QGVAR(carriedObj),objNull,false,QUOTE(ADDON)] call FUNC(defineVariable);

View File

@ -78,7 +78,6 @@ PREP(isAutoWind);
PREP(isEngineer);
PREP(isEOD);
PREP(isInBuilding);
PREP(isMedic);
PREP(isPlayer);
PREP(isTurnedOut);
PREP(letterToCode);
@ -213,11 +212,10 @@ PREP(getCanInteract);
PREP(canInteract);
PREP(resetAllDefaults_f);
PREP(broadcastSound3D_f);
PREP(setDead);
PREP(isAwake);
PREP(setProne);
PREP(raiseScriptedEvent_f);
PREP(setDisableUserInputStatus);
PREP(dropWeapon_f);
@ -225,7 +223,6 @@ PREP(inWater_f);
PREP(setVolume_f);
PREP(closeAllDialogs_f);
PREP(disableAI_f);
PREP(moduleBasicRevive);
PREP(switchToGroupSide_f);
PREP(getFirstObjectIntersection);
PREP(getFirstTerrainIntersection);
@ -241,22 +238,18 @@ PREP(getCarriedObj);
PREP(getCarriedBy);
PREP(beingCarried);
PREP(setCarriedBy);
PREP(setUnconsciousState);
PREP(isUnconscious);
PREP(getUnconsciousCondition);
PREP(registerUnconsciousCondition);
PREP(setCaptiveSwitch);
PREP(moveToTempGroup);
PREP(canGoUnconsciousState);
PREP(setWeaponsCorrectUnconscious);
PREP(limitMovementSpeed);
PREP(setArrestState);
PREP(isArrested);
PREP(loadPerson_F);
PREP(loadPersonLocal_F);
PREP(makeCopyOfBody_F);
PREP(unloadPerson_F);
PREP(cleanUpCopyOfBody_F);
ADDON = true;

View File

@ -5,7 +5,7 @@ class CfgPatches {
units[] = {"ACE_Box_Misc"};
weapons[] = {"ACE_ItemCore","ACE_FakePrimaryWeapon"};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_main", "ace_gui"};
requiredAddons[] = {"ace_main"};
author[] = {"KoffeinFlummi"};
authorUrl = "https://github.com/KoffeinFlummi/";
VERSION_CONFIG;

View File

@ -37,4 +37,3 @@ GVAR(OBJECT_VARIABLES_STORAGE) pushback [_name,_value,_defaultGlobal,_catagory,_
missionNamespace setvariable [QGVAR(OBJECT_VARIABLES_STORAGE_) + _name, [_name,_value,_defaultGlobal,_catagory,_code, _persistent]];
[[_name,_value,_defaultGlobal,_catagory,_code, _persistent],"variableDefined"] call FUNC(raiseScriptedEvent_f);

View File

@ -1,18 +0,0 @@
/*
* Author: KoffeinFlummi
*
* Checks if a unit is a medic.
*
* Arguments:
* 0: unit to be checked (object)
*
* Return Value:
* Bool: is unit medic?
*/
#include "script_component.hpp"
private ["_unit"];
_unit = _this select 0;
_unit getVariable ["ACE_isMedic", (getNumber(configFile >> "CfgVehicles" >> typeOf _unit >> "attendant") == 1)]

View File

@ -1,64 +0,0 @@
/**
* fn_raiseScriptedEvent_f.sqf
* @Descr: Execute a custom defined eventhandler.
* @Author: Glowbal
*
* @Arguments: [arguments ANY, handle STRING (The name of the eventhandler)]
* @Return: ARRAY Array containing the results of the called eventhandlers.
* @PublicAPI: true
*/
#include "script_component.hpp"
private ["_arguments","_handle","_ehCfg","_eventHandlerCollection","_eventHandlerName","_cfg","_code","_classType", "_return"];
_arguments = _this select 0;
_handle = _this select 1;
// TODO figure out how we want to handle custom eventhandlers
_eventHandlerName = (QGVAR(f_custom_eventhandlers_) + _handle);
_eventHandlerCollection = missionNamespace getvariable _eventHandlerName;
if (isnil "_eventHandlerCollection") then {
_eventHandlerCollection = [];
[format["caching Custom Eventhandler: %1",_handle]] call FUNC(debug);
_cfg = (ConfigFile >> "ACE_Eventhandlers" >> "CustomEventHandlers" >> _handle);
if (isClass _cfg) then {
_numberOfEH = count _cfg;
for "_EHiterator" from 0 to (_numberOfEH -1) /* step +1 */ do {
//for [{_EHiterator=0}, {(_EHiterator< _numberOfEH)}, {_EHiterator=_EHiterator+1}] do {
_ehCfg = _cfg select _EHiterator;
if (isClass _ehCfg) then {
_classType = (ConfigName _ehCfg);
_code = (compile getText(_ehCfg >> "onCall"));
_eventHandlerCollection pushback [_classType, _code];
true;
};
};
};
_cfg = (MissionConfigFile >> "ACE_Eventhandlers" >> "CustomEventHandlers" >> _handle);
if (isClass _cfg) then {
_numberOfEH = count _cfg;
for "_EHiterator" from 0 to (_numberOfEH -1) /* step +1 */ do {
//for [{_EHiterator=0}, {(_EHiterator< _numberOfEH)}, {_EHiterator=_EHiterator+1}] do {
_ehCfg = _cfg select _EHiterator;
if (isClass _ehCfg) then {
_classType = (ConfigName _ehCfg);
_code = (compile getText(_ehCfg >> "onCall"));
_eventHandlerCollection pushback [_classType, _code];
true;
};
};
};
missionNamespace setvariable [_eventHandlerName, _eventHandlerCollection];
[format["Custom Eventhandler: %1 cache: %2",_handle, _eventHandlerCollection]] call FUNC(debug);
};
_return = [];
{
_return pushback (_arguments call (_x select 1));
}foreach _eventHandlerCollection;
_return

View File

@ -19,7 +19,9 @@ _unit setvariable ["ACE_isUnconscious", nil, true];
if (isPlayer _unit) then {
[true] call FUNC(setVolume_f);
[false] call FUNC(disableKeyInput_f);
[false] call EFUNC(GUI,effectBlackOut);
if (["ace_medical"] call FUNC(isModLoader_f)) then {
[false] call EFUNC(medical,effectBlackOut);
};
if !(isnil QGVAR(DISABLE_USER_INPUT_COLLECTION_F)) then {
// clear all disable user input
@ -35,4 +37,3 @@ if (isPlayer _unit) then {
};
}foreach ([_unit] call FUNC(getAllDefinedSetVariables));
[[_unit],"resetToDefaults"] call FUNC(raiseScriptedEvent_f);

View File

@ -42,4 +42,3 @@ if (_setArrest) then {
};
};
[[_unit, _setArrest],"setArrestState"] call FUNC(raiseScriptedEvent_f);

View File

@ -1,88 +0,0 @@
/**
* fn_setDead.sqf
* @Descr: Kills a unit
* @Author: Glowbal
*
* @Arguments: [unit OBJECT]
* @Return: void
* @PublicAPI: true
*/
#include "script_component.hpp"
#define TIME_BETWEEN_REVIVE_RUNS 0.5
private ["_unit"];
_unit = _this select 0;
_force = false;
if (count _this >= 2) then {
_force = _this select 1;
};
if (!alive _unit) exitwith{};
if (!local _unit) exitwith {
[[_unit, _force], QUOTE(FUNC(setDead)), _unit, false] call BIS_fnc_MP;
};
if (isnil QGVAR(ENABLE_REVIVE_F)) then {
GVAR(ENABLE_REVIVE_F) = 0;
};
if (((GVAR(ENABLE_REVIVE_F) == 1 && isPlayer _unit) || (GVAR(ENABLE_REVIVE_F) == 2)) && !_force && (alive (vehicle _unit))) exitwith {
// enter revive state
_unit setvariable [QGVAR(inReviveState), true, true];
// Remain unconscious while in revive state
[_unit] call FUNC(setUnconsciousState);
// setting the revive default values
if (isnil QGVAR(REVIVE_TIMER_F)) then {
GVAR(REVIVE_TIMER_F) = 10;
};
if (isnil QGVAR(REVIVE_NUMBER_MAX_F)) then {
GVAR(REVIVE_NUMBER_MAX_F) = -1;
};
[{
private ["_unit","_playerDead","_counter"];
_unit = (_this select 0) select 0;
_playerDead = (_this select 0) select 1;
// Check if a unit woke up or was already killed
if (!([_unit] call FUNC(isUnconscious)) || !alive _unit) exitwith {
[(_this select 1)] call cba_fnc_removePerFrameHandler;
// Cleaning up the variables, as we no longer need them.
_unit setvariable [QGVAR(reviveCounter_f), nil];
_unit setvariable [QGVAR(inReviveState), nil, true];
};
_counter = _unit getvariable [QGVAR(reviveCounter_f), 0];
if (_counter >= GVAR(REVIVE_TIMER_F)) exitwith{
if (isPlayer _unit) then {
titleText ["You died..","PLAIN DOWN"];
};
[_unit,"ACE_isDead", true, true] call FUNC(setDefinedVariable);
if (_playerDead) then {
[_unit,QGVAR(isDeadPlayer),true,true] call FUNC(setDefinedVariable);
};
_unit setdamage 1; // killing a unit will automatically clean up all variables.
[[_unit, true],"killed"] call FUNC(raiseScriptedEvent_f);
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
_unit setvariable [QGVAR(reviveCounter_f),_counter + TIME_BETWEEN_REVIVE_RUNS];
}, TIME_BETWEEN_REVIVE_RUNS, [_unit, isPlayer _unit] ] call CBA_fnc_addPerFrameHandler;
};
[_unit,"ACE_isDead",true,true] call FUNC(setDefinedVariable);
if (isPLayer _unit) then {
[_unit,QGVAR(isDeadPlayer),true,true] call FUNC(setDefinedVariable);
};
_unit setdamage 1;
[[_unit, false],"killed"] call FUNC(raiseScriptedEvent_f);

View File

@ -44,5 +44,3 @@ if (_setVolume) then {
player setVariable ["acre_sys_core_isDisabled", true, true];
};
[[_setVolume],"setVolume"] call FUNC(raiseScriptedEvent_f);

View File

@ -62,5 +62,3 @@ if (_switch) then {
reverse _previousGroupsList; // we have to reverse again, to ensure the list is in the right order.
_unit setvariable [QGVAR(previousGroupSwitchTo_F), _previousGroupsList, true];
};
[[_unit, _switch, _id, _side],"switchToGroupSide"] call FUNC(raiseScriptedEvent_f);

View File

@ -38,8 +38,9 @@ GVAR(injuredUnitCollection) = [];
[
{(([_this select 0,QGVAR(bloodVolume)] call EFUNC(common,getDefinedVariable)) < 65)},
{(([_this select 0,QGVAR(amountOfPain)] call EFUNC(common,getDefinedVariable)) > 48)},
{(((_this select 0) call FUNC(getBloodLoss)) > 0.25)}
] call EFUNC(common,registerUnconsciousCondition);
{(((_this select 0) call FUNC(getBloodLoss)) > 0.25)},
{((_this select 0) getvariable ["ACE_inReviveState", false])}
] call FUNC(registerUnconsciousCondition);
call FUNC(handleDisplayEffects);
@ -49,6 +50,9 @@ call FUNC(handleDisplayEffects);
["onUnconscious", FUNC(onUnconscious)] call ace_common_fnc_addEventHandler;
["carryObjectDropped", FUNC(onCarryObjectDropped)] call ace_common_fnc_addEventHandler;
if (isNil QGVAR(ENABLE_REVIVE_F)) then {
GVAR(ENABLE_REVIVE_F) = 0;
};
// Keybindings
@ -88,7 +92,6 @@ GVAR(keyPressed) = false;
"keyUp"] call cba_fnc_registerKeybind;
// Adding the treatment options for all available medical equipment.
// Advanced Treatment options

View File

@ -131,11 +131,23 @@ PREP(updateIcons);
PREP(updateUIInfo);
PREP(useEquipment);
PREP(cacheHandledamageCall);
PREP(checkDamage);
PREP(setUnconsciousState);
PREP(isUnconscious);
PREP(getUnconsciousCondition);
PREP(registerUnconsciousCondition);
PREP(cleanUpCopyOfBody_F);
PREP(makeCopyOfBody_F);
PREP(canGoUnconsciousState);
PREP(setDead);
PREP(moduleBasicRevive);
PREP(setWeaponsCorrectUnconscious);
PREP(setCaptiveSwitch);
// initalize all module parameters.
GVAR(setting_allowInstantDead) = true;
GVAR(setting_AdvancedLevel) = 0;

View File

@ -28,3 +28,4 @@ class CfgAddons {
#include "CfgVehicles.hpp"
#include "ui\define.hpp"
#include "ui\menu.hpp"
#include "ui\RscTitles.hpp"

View File

@ -42,7 +42,7 @@ if (!alive _unit) exitwith {
[_caller, false] call FUNC(treatmentMutex);
[{
_this call FUNC(actionCarryUnit);
}, [_caller, ([_unit,_caller] call EFUNC(common,makeCopyOfBody_F)), _killOnDrop], 0.2, 0.2] call EFUNC(common,waitAndExecute);
}, [_caller, ([_unit,_caller] call EFUNC(medical,makeCopyOfBody_F)), _killOnDrop], 0.2, 0.2] call EFUNC(common,waitAndExecute);
};
if !([_caller,_unit] call EFUNC(common,carryObj)) exitwith {

View File

@ -40,7 +40,7 @@ if (!alive _unit) exitwith {
[_caller, false] call FUNC(treatmentMutex);
[{
_this call FUNC(actionDragUnit);
}, [_caller, ([_unit,_caller] call EFUNC(common,makeCopyOfBody_F)), _killOnDrop], 0.2, 0.2] call EFUNC(common,waitAndExecute);
}, [_caller, ([_unit,_caller] call EFUNC(medical,makeCopyOfBody_F)), _killOnDrop], 0.2, 0.2] call EFUNC(common,waitAndExecute);
};
if (primaryWeapon _caller == "") then {

View File

@ -14,4 +14,4 @@
private ["_unit"];
_unit = _this select 0;
(!(isNull _unit) && {(_unit isKindOf "CaManBase") && ([_unit] call FUNC(isAwake))})
(!(isNull _unit) && {(_unit isKindOf "CaManBase") && ([_unit] call EFUNC(common,isAwake))})

View File

@ -14,4 +14,4 @@ private ["_unit","_caller"];
_caller = _this select 0;
_target = _this select 1;
([_caller, "ACE_itemBodyBag"] call EFUNC(common,hasItem) && {(!(alive _target) || (_target getvariable [QEGVAR(common,isDead),false]) || (_target getvariable [QEGVAR(common,inReviveState), false]))} && {(_target distance _caller) < 7.5} && (vehicle _target == _unit)); // return
([_caller, "ACE_itemBodyBag"] call EFUNC(common,hasItem) && {(!(alive _target) || (_target getvariable [QEGVAR(common,isDead),false]) || (_target getvariable ["ACE_inReviveState", false]))} && {(_target distance _caller) < 7.5} && (vehicle _target == _unit)); // return

View File

@ -15,7 +15,7 @@ _unit = _this select 0;
_copy = _unit getvariable QGVAR(copyOfBody_f);
if (isnil "_copy") exitwith {false};
[format["Cleaning up a copy of Body: %1 %2", _unit, _copy]] call FUNC(debug);
[format["Cleaning up a copy of Body: %1 %2", _unit, _copy]] call EFUNC(common,debug);
// lets clean it up
_unit setvariable [QGVAR(originalCopy_f), nil, true];
_unit setvariable [QGVAR(copyOfBody_f), nil, true];

View File

@ -52,12 +52,12 @@ waituntil{!isnil "ACE_gui" && !isnil "ACE_common"};
if (GVAR(setting_AdvancedLevel) > 0) then {
[
{(([_this select 0,QGVAR(heartRate)] call EFUNC(common,getDefinedVariable)) < 20)}
] call EFUNC(common,registerUnconsciousCondition);
] call FUNC(registerUnconsciousCondition);
if (GVAR(setting_allowAirwayInjuries)) then {
[
{(([_this select 0,QGVAR(airway)] call EFUNC(common,getDefinedVariable)) > 2)}
] call EFUNC(common,registerUnconsciousCondition);
] call FUNC(registerUnconsciousCondition);
};
};

View File

@ -23,10 +23,10 @@ _caller = _this select 1;
_newUnit = _group createUnit [typeof _oldBody, _position, [], 0, "NONE"];
_allVariables = [_oldBody] call FUNC(getAllDefinedSetVariables);
_allVariables = [_oldBody] call EFUNC(common,getAllDefinedSetVariables);
// [NAME (STRING), TYPENAME (STRING), VALUE (ANY), DEFAULT GLOBAL (BOOLEAN)]
{
[_newUnit,_x select 0, _x select 2] call FUNC(setDefinedVariable);
[_newUnit,_x select 0, _x select 2] call EFUNC(common,setDefinedVariable);
}foreach _allVariables;
_newUnit setVariable [QGVAR(name),_name,true];

View File

@ -1,6 +1,6 @@
/**
* fn_setDead.sqf
* @Descr: Set a unit dead from within CMS.
* @Descr: Kills a unit
* @Author: Glowbal
*
* @Arguments: [unit OBJECT]
@ -10,15 +10,76 @@
#include "script_component.hpp"
#define TIME_BETWEEN_REVIVE_RUNS 0.5
private ["_unit"];
_unit = _this select 0;
_force = false;
if (count _this >= 2) then {
_force = _this select 1;
};
if (!alive _unit) exitwith{};
if (!local _unit) exitwith {};
if (!local _unit) exitwith {
[[_unit, _force], QUOTE(FUNC(setDead)), _unit, false] call BIS_fnc_MP;
};
[_unit, QGVAR(amountOfPain),0,true] call EFUNC(common,setDefinedVariable);
[_unit, QGVAR(heartRate),0,true] call EFUNC(common,setDefinedVariable);
[_unit, QGVAR(bloodPressure), [0,0],true] call EFUNC(common,setDefinedVariable);
[_unit, QGVAR(airway), 3, true] call EFUNC(common,setDefinedVariable);
if (isnil QGVAR(ENABLE_REVIVE_F)) then {
GVAR(ENABLE_REVIVE_F) = 0;
};
[_unit] call EFUNC(common,setDead); // calling framework function
if (((GVAR(ENABLE_REVIVE_F) == 1 && isPlayer _unit) || (GVAR(ENABLE_REVIVE_F) == 2)) && !_force && (alive (vehicle _unit))) exitwith {
// enter revive state
_unit setvariable ["ACE_inReviveState", true, true];
// Remain unconscious while in revive state
[_unit] call FUNC(setUnconsciousState);
// setting the revive default values
if (isnil QGVAR(REVIVE_TIMER_F)) then {
GVAR(REVIVE_TIMER_F) = 10;
};
if (isnil QGVAR(REVIVE_NUMBER_MAX_F)) then {
GVAR(REVIVE_NUMBER_MAX_F) = -1;
};
[{
private ["_unit","_playerDead","_counter"];
_unit = (_this select 0) select 0;
_playerDead = (_this select 0) select 1;
// Check if a unit woke up or was already killed
if (!([_unit] call FUNC(isUnconscious)) || !alive _unit) exitwith {
[(_this select 1)] call cba_fnc_removePerFrameHandler;
// Cleaning up the variables, as we no longer need them.
_unit setvariable ["ACE_reviveCounterValue", nil];
_unit setvariable ["ACE_inReviveState", nil, true];
};
_counter = _unit getvariable ["ACE_reviveCounterValue", 0];
if (_counter >= GVAR(REVIVE_TIMER_F)) exitwith{
if (isPlayer _unit) then {
titleText ["You died..","PLAIN DOWN"];
};
[_unit,"ACE_isDead", true, true] call EFUNC(common,setDefinedVariable);
if (_playerDead) then {
[_unit,QGVAR(isDeadPlayer),true,true] call EFUNC(common,setDefinedVariable);
};
_unit setdamage 1; // killing a unit will automatically clean up all variables.
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
_unit setvariable ["ACE_reviveCounterValue",_counter + TIME_BETWEEN_REVIVE_RUNS];
}, TIME_BETWEEN_REVIVE_RUNS, [_unit, isPlayer _unit] ] call CBA_fnc_addPerFrameHandler;
};
[_unit,"ACE_isDead",true,true] call EFUNC(common,setDefinedVariable);
if (isPLayer _unit) then {
[_unit,QGVAR(isDeadPlayer),true,true] call EFUNC(common,setDefinedVariable);
};
_unit setdamage 1;

View File

@ -14,17 +14,17 @@ private ["_unit", "_animState", "_dAnim"];
_unit = _this select 0;
if !([_unit] call FUNC(canGoUnconsciousState)) exitwith{
[format["Exit setUnconscious: %1", _this]] call FUNC(debug);
[format["Exit setUnconscious: %1", _this]] call EFUNC(common,debug);
};
// We only want this function to work on local machines
if (!local _unit) exitwith {
[[_unit], QUOTE(FUNC(setUnconsciousState)), _unit, false] call EFUNC(common,execRemoteFnc);
[format["Exit setUnconscious: %1", _this]] call FUNC(debug);
[format["Exit setUnconscious: %1", _this]] call EFUNC(common,debug);
};
// get rid of the object we are carrying, before we go unconscious.
[_unit, ObjNull, [0,0,0]] call FUNC(carryObj);
[_unit, ObjNull, [0,0,0]] call EFUNC(common,carryObj);
// Set the unit in the unconscious state.
_unit setvariable ["ACE_isUnconscious",true,true];
@ -41,23 +41,23 @@ _originalPos = unitPos _unit;
// Handle the on screen effects
if (isPlayer _unit) then {
[] call FUNC(closeAllDialogs_f);
[true] call EFUNC(GUI,effectBlackOut);
["unconscious", true] call FUNC(setDisableUserInputStatus);
[false] call FUNC(setVolume_f);
[] call EFUNC(common,closeAllDialogs_f);
[true] call FUNC(effectBlackOut);
["unconscious", true] call EFUNC(common,setDisableUserInputStatus);
[false] call EFUNC(common,setVolume_f);
} else {
_unit setUnitPos "DOWN";
[_unit, true] call FUNC(disableAI_F);
[_unit, true] call EFUNC(common,disableAI_F);
};
// So the AI does not get stuck, we are moving the unit to a temp group on its own.
[_unit, true, "ACE_isUnconscious", side group _unit] call FUNC(switchToGroupSide_f);
[_unit, true, "ACE_isUnconscious", side group _unit] call EFUNC(common,switchToGroupSide_f);
_captiveSwitch = [_unit, true] call FUNC(setCaptiveSwitch);
[_unit, [_unit] call FUNC(getDeathAnim), 1, true] call FUNC(doAnimation);
_captiveSwitch = [_unit, true] call EFUNC(common,setCaptiveSwitch);
[_unit, [_unit] call EFUNC(common,getDeathAnim), 1, true] call EFUNC(common,doAnimation);
[format["Unit moving into unconscious: %1", _this]] call FUNC(debug);
[format["Unit moving into unconscious: %1", _this]] call EFUNC(common,debug);
_startingTime = time;
@ -75,28 +75,26 @@ _minWaitingTime = (round(random(10)+5));
// Since the unit is no longer alive, get rid of this PFH.
if (!alive _unit) exitwith {
[format["%1 Unit no longer alive, exiting"], _unit] call FUNC(debug);
[format["%1 Unit no longer alive, exiting"], _unit] call EFUNC(common,debug);
// EXIT PFH
[(_this select 1)] call cba_fnc_removePerFrameHandler;
[[_unit, false],"setUnconsciousState"] call FUNC(raiseScriptedEvent_f);
};
// In case the unit is no longer in an unconscious state, we are going to check if we can already reset the animation
if !([_unit] call FUNC(isUnconscious)) exitwith {
[format["%1 Unit no longer unconscious, handling exit and animation"], _unit] call FUNC(debug);
[format["%1 Unit no longer unconscious, handling exit and animation"], _unit] call EFUNC(common,debug);
// Wait until the unit isn't being carried anymore, so we won't end up with wierd animations
if !([_unit] call FUNC(beingCarried)) then {
if !([_unit] call EFUNC(common,beingCarried)) then {
if (vehicle _unit == _unit) then {
[_unit,"amovppnemstpsnonwnondnon", 1] call FUNC(doAnimation);
[_unit,"amovppnemstpsnonwnondnon", 1] call EFUNC(common,doAnimation);
} else {
// Switch to the units original animation, assuming
// TODO: what if the unit switched vehicle?
[_unit, _oldAnimation, 1] call FUNC(doAnimation);
[_unit, _oldAnimation, 1] call EFUNC(common,doAnimation);
};
// EXIT PFH
[(_this select 1)] call cba_fnc_removePerFrameHandler;
[[_unit, false],"setUnconsciousState"] call FUNC(raiseScriptedEvent_f);
};
};
// Ensure we are waiting at least a minimum period before checking if we can wake up the unit again, allows for temp knock outs
@ -104,7 +102,7 @@ _minWaitingTime = (round(random(10)+5));
// Wait until the unit is no longer unconscious
if (!([_unit] call FUNC(getUnconsciousCondition))) then {
[format["%1 No unconscious condition valid anymore, moving uit out of unconsciousState"], _unit] call FUNC(debug);
[format["%1 No unconscious condition valid anymore, moving uit out of unconsciousState"], _unit] call EFUNC(common,debug);
// Reset the unit back to the previous captive state.
if (_captiveSwitch) then {
[_unit, false] call FUNC(setCaptiveSwitch);
@ -112,31 +110,30 @@ _minWaitingTime = (round(random(10)+5));
_unit setUnconscious false;
// Swhich the unit back to its original group
[_unit, false, "ACE_isUnconscious", side group _unit] call FUNC(switchToGroupSide_f);
[_unit, false, "ACE_isUnconscious", side group _unit] call EFUNC(common,switchToGroupSide_f);
// Reset any visual and audio effects for players, or enable everything again for AI.
if (isPlayer _unit) then {
[false] call EFUNC(GUI,effectBlackOut);
[true] call FUNC(setVolume_f);
["unconscious", false] call FUNC(setDisableUserInputStatus);
[false] call FUNC(effectBlackOut);
[true] call EFUNC(common,setVolume_f);
["unconscious", false] call EFUNC(common,setDisableUserInputStatus);
} else {
[_unit, false] call FUNC(disableAI_F);
[_unit, false] call EFUNC(common,disableAI_F);
_unit setUnitPos _originalPos; // This is not position but stance (DOWN, MIDDLE, UP)
};
// Move unit out of unconscious state
_unit setvariable ["ACE_isUnconscious", false, true];
[format["%1 Unit no longer unconsicous"], _unit] call FUNC(debug);
[format["%1 Unit no longer unconsicous"], _unit] call EFUNC(common,debug);
};
};
// A check to ensure that the animation is being played properly.
// TODO: Might no longer be necessary: Have to test this in MP.
if (vehicle _unit == _unit && {animationState _unit != "deadState" && animationState _unit != "unconscious"} && {(isNull ([_unit] call FUNC(getCarriedBy)))} && (time - _startingTime >= 0.5)) then {
[_unit,([_unit] call FUNC(getDeathAnim)), 1, true] call FUNC(doAnimation); // Reset animations if unit starts doing wierd things.
[format["%1 Had to reset an animation for unconscious"], _unit] call FUNC(debug);
if (vehicle _unit == _unit && {animationState _unit != "deadState" && animationState _unit != "unconscious"} && {(isNull ([_unit] call EFUNC(common,getCarriedBy)))} && (time - _startingTime >= 0.5)) then {
[_unit,([_unit] call FUNC(getDeathAnim)), 1, true] call EFUNC(common,doAnimation); // Reset animations if unit starts doing wierd things.
[format["%1 Had to reset an animation for unconscious"], _unit] call EFUNC(common,debug);
};
}, 0.1, [_unit,_animState, _captiveSwitch, _originalPos, _startingTime, _minWaitingTime] ] call CBA_fnc_addPerFrameHandler;
[[_unit, true],"setUnconsciousState"] call FUNC(raiseScriptedEvent_f);

View File

@ -51,5 +51,10 @@
[QGVAR(bodyPartStatusPrevious),[0,0,0,0,0,0],false, QUOTE(ADDON)] call EFUNC(common,defineVariable);
[QGVAR(addedToUnitLoop),false,false, QUOTE(ADDON)] call EFUNC(common,defineVariable);
["ACE_reviveCounterValue", 0, false, QGVAR(ADDON)] call FUNC(defineVariable);
["ACE_inReviveState", false, true, QGVAR(ADDON)] call FUNC(defineVariable);
["ACE_isDead",false,true,QUOTE(ADDON)] call FUNC(defineVariable);
["ACE_isUnconscious",false,true,QUOTE(ADDON)] call FUNC(defineVariable);
["ACE_isDeadPlayer", false, true, QUOTE(ADDON)] call FUNC(defineVariable);
GVAR(VarDefinesCompleted) = true;