From 072f2cc3a74520fb5cb017663177f1bf5c2e5fdc Mon Sep 17 00:00:00 2001 From: ViperMaul Date: Thu, 11 Jun 2015 15:56:11 -0700 Subject: [PATCH 1/5] fix animation and consistently unload units from vehicle #1575 and #1577 --- addons/common/XEH_postInit.sqf | 2 ++ .../functions/fnc_unloadPersonLocal.sqf | 21 +++++++++++++++---- .../functions/fnc_actionUnloadUnit.sqf | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index eb015a6264..158346a247 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -20,6 +20,8 @@ ["fixFloating", DFUNC(fixFloating)] call FUNC(addEventhandler); ["fixPosition", DFUNC(fixPosition)] call FUNC(addEventhandler); +["unloadPersonEvent", DFUNC(unloadPersonLocal)] call FUNC(addEventhandler); + ["lockVehicle", { _this setVariable [QGVAR(lockStatus), locked _this]; _this lock 2; diff --git a/addons/common/functions/fnc_unloadPersonLocal.sqf b/addons/common/functions/fnc_unloadPersonLocal.sqf index a927858f9a..ec6229dab8 100644 --- a/addons/common/functions/fnc_unloadPersonLocal.sqf +++ b/addons/common/functions/fnc_unloadPersonLocal.sqf @@ -18,6 +18,7 @@ private ["_vehicle", "_loaded", "_emptyPos"]; PARAMS_1(_unit); _vehicle = vehicle _unit; +TRACE_1("Unloading Unit Variable", _unit); if (_vehicle == _unit) exitwith {false;}; if !(speed _vehicle <1 && (((getpos _vehicle) select 2) < 2)) exitwith {false;}; @@ -27,9 +28,10 @@ if (count _emptyPos == 0) exitwith {false}; _unit setPos _emptyPos; unassignVehicle _unit; -if (!alive _unit) then { - _unit action ["Eject", vehicle _unit]; -}; +[_unit] orderGetIn false; +TRACE_1("Ejecting", alive _unit); +_unit action ["Eject", vehicle _unit]; + [_unit, false, GROUP_SWITCH_ID, side group _unit] call FUNC(switchToGroupSide); @@ -38,7 +40,18 @@ _loaded = _loaded - [_unit]; _vehicle setvariable [QGVAR(loaded_persons),_loaded,true]; if (!([_unit] call FUNC(isAwake))) then { - [_unit,([_unit] call FUNC(getDeathAnim)), 1, true] call FUNC(doAnimation); + TRACE_1("Check if isAwake", [_unit] call FUNC(isAwake)); + if (driver _unit == _unit) then { + _anim = [_unit] call EFUNC(common,getDeathAnim); + [_unit, _anim, 1, true] call EFUNC(common,doAnimation); + [{ + _unit = _this select 0; + _anim = _this select 1; + if ((_unit getVariable "ACE_isUnconscious") and (animationState _unit != _anim)) then { + [_unit, _anim, 2, true] call EFUNC(common,doAnimation); + }; + }, [_unit, _anim], 0.5, 0] call EFUNC(common,waitAndExecute); + }; }; true; diff --git a/addons/medical/functions/fnc_actionUnloadUnit.sqf b/addons/medical/functions/fnc_actionUnloadUnit.sqf index 96c7251d6b..c5057d52a6 100644 --- a/addons/medical/functions/fnc_actionUnloadUnit.sqf +++ b/addons/medical/functions/fnc_actionUnloadUnit.sqf @@ -24,4 +24,4 @@ _drag = if (count _this > 2) then {_this select 2} else {false}; if (vehicle _target == _target) exitwith {}; if (([_target] call EFUNC(common,isAwake))) exitwith {}; -[_target] call EFUNC(common,unloadPerson) \ No newline at end of file +["unloadPersonEvent",[_target]] call EFUNC(common,globalEvent) \ No newline at end of file From 1c0811aa31707e0928d4521f9ad861d9570e5fdc Mon Sep 17 00:00:00 2001 From: ViperMaul Date: Fri, 12 Jun 2015 16:56:13 -0700 Subject: [PATCH 2/5] Change from globalEvent to targetEvent #1575 and #1577 --- .../functions/fnc_unloadPersonLocal.sqf | 46 ++++++++++--------- .../functions/fnc_actionUnloadUnit.sqf | 2 +- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/addons/common/functions/fnc_unloadPersonLocal.sqf b/addons/common/functions/fnc_unloadPersonLocal.sqf index ec6229dab8..5ebe35a439 100644 --- a/addons/common/functions/fnc_unloadPersonLocal.sqf +++ b/addons/common/functions/fnc_unloadPersonLocal.sqf @@ -15,22 +15,39 @@ #define GROUP_SWITCH_ID QUOTE(FUNC(loadPerson)) -private ["_vehicle", "_loaded", "_emptyPos"]; -PARAMS_1(_unit); -_vehicle = vehicle _unit; -TRACE_1("Unloading Unit Variable", _unit); +private ["_loaded", "_emptyPos"]; +PARAMS_2(_unit,_vehicle); -if (_vehicle == _unit) exitwith {false;}; +if (driver _vehicle == _unit) exitwith {false;}; +TRACE_1("Vehicle Check", driver _vehicle == _unit); if !(speed _vehicle <1 && (((getpos _vehicle) select 2) < 2)) exitwith {false;}; _emptyPos = ((getPos _vehicle) findEmptyPosition [0, 10, typeof _unit]); if (count _emptyPos == 0) exitwith {false}; -_unit setPos _emptyPos; unassignVehicle _unit; [_unit] orderGetIn false; TRACE_1("Ejecting", alive _unit); _unit action ["Eject", vehicle _unit]; +[ { + private "_anim"; + PARAMS_2(_unit,_emptyPos); + _unit setPos _emptyPos; + if (!([_unit] call FUNC(isAwake))) then { + TRACE_1("Check if isAwake", [_unit] call FUNC(isAwake)); + if (driver _unit == _unit) then { + _anim = [_unit] call EFUNC(common,getDeathAnim); + [_unit, _anim, 1, true] call EFUNC(common,doAnimation); + [{ + _unit = _this select 0; + _anim = _this select 1; + if ((_unit getVariable "ACE_isUnconscious") and (animationState _unit != _anim)) then { + [_unit, _anim, 2, true] call EFUNC(common,doAnimation); + }; + }, [_unit, _anim], 0.5, 0] call EFUNC(common,waitAndExecute); + }; + }; +},[_unit,_emptyPos], 0.5, 0] call EFUNC(common,waitAndExecute); [_unit, false, GROUP_SWITCH_ID, side group _unit] call FUNC(switchToGroupSide); @@ -39,19 +56,4 @@ _loaded = _vehicle getvariable [QGVAR(loaded_persons),[]]; _loaded = _loaded - [_unit]; _vehicle setvariable [QGVAR(loaded_persons),_loaded,true]; -if (!([_unit] call FUNC(isAwake))) then { - TRACE_1("Check if isAwake", [_unit] call FUNC(isAwake)); - if (driver _unit == _unit) then { - _anim = [_unit] call EFUNC(common,getDeathAnim); - [_unit, _anim, 1, true] call EFUNC(common,doAnimation); - [{ - _unit = _this select 0; - _anim = _this select 1; - if ((_unit getVariable "ACE_isUnconscious") and (animationState _unit != _anim)) then { - [_unit, _anim, 2, true] call EFUNC(common,doAnimation); - }; - }, [_unit, _anim], 0.5, 0] call EFUNC(common,waitAndExecute); - }; -}; - -true; +true \ No newline at end of file diff --git a/addons/medical/functions/fnc_actionUnloadUnit.sqf b/addons/medical/functions/fnc_actionUnloadUnit.sqf index c5057d52a6..a73f32265a 100644 --- a/addons/medical/functions/fnc_actionUnloadUnit.sqf +++ b/addons/medical/functions/fnc_actionUnloadUnit.sqf @@ -24,4 +24,4 @@ _drag = if (count _this > 2) then {_this select 2} else {false}; if (vehicle _target == _target) exitwith {}; if (([_target] call EFUNC(common,isAwake))) exitwith {}; -["unloadPersonEvent",[_target]] call EFUNC(common,globalEvent) \ No newline at end of file +["unloadPersonEvent", _target, [_target, vehicle _target]] call EFUNC(common,targetEvent) \ No newline at end of file From cbb620ba98d3cff1d66a631654292fdf2a2a8fab Mon Sep 17 00:00:00 2001 From: ViperMaul Date: Sat, 13 Jun 2015 07:24:50 -0700 Subject: [PATCH 3/5] Change setPos to setPosASL to support roof tops and multi-level objects and faster code. #1575 and #1577 --- addons/common/functions/fnc_unloadPersonLocal.sqf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/common/functions/fnc_unloadPersonLocal.sqf b/addons/common/functions/fnc_unloadPersonLocal.sqf index 5ebe35a439..a710fc1831 100644 --- a/addons/common/functions/fnc_unloadPersonLocal.sqf +++ b/addons/common/functions/fnc_unloadPersonLocal.sqf @@ -20,9 +20,9 @@ PARAMS_2(_unit,_vehicle); if (driver _vehicle == _unit) exitwith {false;}; TRACE_1("Vehicle Check", driver _vehicle == _unit); -if !(speed _vehicle <1 && (((getpos _vehicle) select 2) < 2)) exitwith {false;}; +if !(speed _vehicle <1 && (((getPosASL _vehicle) select 2) < 2)) exitwith {false;}; -_emptyPos = ((getPos _vehicle) findEmptyPosition [0, 10, typeof _unit]); +_emptyPos = ((getPosASL _vehicle) findEmptyPosition [0, 10, typeof _unit]); if (count _emptyPos == 0) exitwith {false}; unassignVehicle _unit; @@ -32,7 +32,7 @@ _unit action ["Eject", vehicle _unit]; [ { private "_anim"; PARAMS_2(_unit,_emptyPos); - _unit setPos _emptyPos; + _unit setPosASL _emptyPos; if (!([_unit] call FUNC(isAwake))) then { TRACE_1("Check if isAwake", [_unit] call FUNC(isAwake)); if (driver _unit == _unit) then { From 911a18d169ed9480a94cd0d9664200d10f8e01fb Mon Sep 17 00:00:00 2001 From: ViperMaul Date: Sat, 13 Jun 2015 12:37:10 -0700 Subject: [PATCH 4/5] Expand maxDistance for findEmptyPosition from 10 to 13 to support the GhostHawk Convert ASLtoPosition #1575 and #1577 --- addons/common/functions/fnc_unloadPersonLocal.sqf | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/addons/common/functions/fnc_unloadPersonLocal.sqf b/addons/common/functions/fnc_unloadPersonLocal.sqf index a710fc1831..87c86b0ad0 100644 --- a/addons/common/functions/fnc_unloadPersonLocal.sqf +++ b/addons/common/functions/fnc_unloadPersonLocal.sqf @@ -10,7 +10,7 @@ * * Public: No */ -//#define DEBUG_MODE_FULL +#define DEBUG_MODE_FULL #include "script_component.hpp" #define GROUP_SWITCH_ID QUOTE(FUNC(loadPerson)) @@ -18,12 +18,13 @@ private ["_loaded", "_emptyPos"]; PARAMS_2(_unit,_vehicle); -if (driver _vehicle == _unit) exitwith {false;}; +if (driver _vehicle == _unit) exitwith {TRACE_1("Exiting on Failed Driver Check", driver _vehicle == _unit); false;}; TRACE_1("Vehicle Check", driver _vehicle == _unit); -if !(speed _vehicle <1 && (((getPosASL _vehicle) select 2) < 2)) exitwith {false;}; +if !(speed _vehicle <1 && (((getPos _vehicle) select 2) < 2)) exitwith {TRACE_1("Exiting on Failed speed check", getPosASL _vehicle == _unit); false;}; +TRACE_1("getPosASL Vehicle Check", getPos _vehicle); -_emptyPos = ((getPosASL _vehicle) findEmptyPosition [0, 10, typeof _unit]); -if (count _emptyPos == 0) exitwith {false}; +_emptyPos = ((getPosASL _vehicle) call EFUNC(common,ASLtoPosition) findEmptyPosition [0, 13, typeof _unit]); +if (count _emptyPos == 0) exitwith {false}; //consider displaying text saying there are no safe places to exit the vehicle unassignVehicle _unit; [_unit] orderGetIn false; @@ -32,7 +33,7 @@ _unit action ["Eject", vehicle _unit]; [ { private "_anim"; PARAMS_2(_unit,_emptyPos); - _unit setPosASL _emptyPos; + _unit setPosASL (_emptyPos call EFUNC(common,PositiontoASL)); if (!([_unit] call FUNC(isAwake))) then { TRACE_1("Check if isAwake", [_unit] call FUNC(isAwake)); if (driver _unit == _unit) then { From 132ec343b075b3dbe6e25642be2c0767e3878785 Mon Sep 17 00:00:00 2001 From: ViperMaul Date: Sat, 13 Jun 2015 12:39:29 -0700 Subject: [PATCH 5/5] Suppress debug --- addons/common/functions/fnc_unloadPersonLocal.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/common/functions/fnc_unloadPersonLocal.sqf b/addons/common/functions/fnc_unloadPersonLocal.sqf index 87c86b0ad0..23d33e4bfe 100644 --- a/addons/common/functions/fnc_unloadPersonLocal.sqf +++ b/addons/common/functions/fnc_unloadPersonLocal.sqf @@ -10,7 +10,7 @@ * * Public: No */ -#define DEBUG_MODE_FULL +//#define DEBUG_MODE_FULL #include "script_component.hpp" #define GROUP_SWITCH_ID QUOTE(FUNC(loadPerson))