Converted to use CBA PFH's and MACROs.

This commit is contained in:
Garth L-H de Wet 2015-02-02 23:58:24 +02:00
parent 966cb6ffdf
commit aca1c0c6cf
5 changed files with 51 additions and 56 deletions

View File

@ -4,27 +4,23 @@ if (!hasInterface) exitWith {};
["ACE3", localize "STR_ACE_Parachute_showAltimeter", ["ACE3", localize "STR_ACE_Parachute_showAltimeter",
{ {
if (!('ACE_Altimeter' in assignedItems ace_player)) exitWith {false}; if (!('ACE_Altimeter' in assignedItems ace_player)) exitWith {false};
if (isNull (missionNamespace getVariable ['ACE_Parachute_AltimeterFnc', scriptNull])) then { if (!(missionNamespace getVariable [QGVAR(AltimeterActive), false])) then {
[ace_player] call ACE_Parachute_fnc_showAltimeter [ace_player] call FUNC(showAltimeter);
} else { } else {
call ACE_Parachute_fnc_hideAltimeter call FUNC(hideAltimeter);
}; };
true true
}, [24, false, false, false], false, "keydown"] call CALLSTACK(cba_fnc_registerKeybind); }, [24, false, false, false], false, "keydown"] call CALLSTACK(cba_fnc_registerKeybind);
[] spawn { GVAR(PFH) = false;
ACE_Parachuting_PFH = false;
while {true} do { [{
sleep 1; if (!GVAR(PFH) && {(vehicle ACE_player) isKindOf "ParachuteBase"}) then {
// I believe this doesn't work for Zeus. GVAR(PFH) = true;
// vehicle _player [FUNC(onEachFrame), 0.1, []] call CALLSTACK(cba_fnc_addPerFrameHandler);
if (!ACE_Parachuting_PFH && {(vehicle ACE_player) isKindOf "ParachuteBase"}) then {
ACE_Parachuting_PFH = true;
["ACE_ParachuteFix", "OnEachFrame", {call ACE_Parachute_fnc_onEachFrame;}] call BIS_fnc_addStackedEventHandler;
};
}; };
}; }, 1, []] call CALLSTACK(cba_fnc_addPerFrameHandler);
// don't show speed and height when in expert mode // don't show speed and height when in expert mode
["Parachute", {if (!cadetMode) then {_dlg = _this select 0; {(_dlg displayCtrl _x) ctrlShow false} forEach [121, 122, 1004, 1005, 1006, 1014];};}] call ACE_Core_fnc_addInfoDisplayEventHandler; //@todo addEventHandler infoDisplayChanged with select 1 == "Parachute" ["Parachute", {if (!cadetMode) then {_dlg = _this select 0; {(_dlg displayCtrl _x) ctrlShow false} forEach [121, 122, 1004, 1005, 1006, 1014];};}] call EFUNC(common,addInfoDisplayEventHandler); //@todo addEventHandler infoDisplayChanged with select 1 == "Parachute"
["Soldier", {if (!cadetMode) then {_dlg = _this select 0; {_ctrl = (_dlg displayCtrl _x); _ctrl ctrlSetPosition [0,0,0,0]; _ctrl ctrlCommit 0;} forEach [380, 382]};}] call ACE_Core_fnc_addInfoDisplayEventHandler; //@todo addEventHandler infoDisplayChanged with select 1 == "Soldier" ["Soldier", {if (!cadetMode) then {_dlg = _this select 0; {_ctrl = (_dlg displayCtrl _x); _ctrl ctrlSetPosition [0,0,0,0]; _ctrl ctrlCommit 0;} forEach [380, 382]};}] call EFUNC(common,addInfoDisplayEventHandler); //@todo addEventHandler infoDisplayChanged with select 1 == "Soldier"

View File

@ -18,10 +18,11 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_unit"]; private ["_unit"];
_unit = _this select 0; _unit = _this select 0;
["ACE_ParachuteFix", "OnEachFrame"] call BIS_fnc_removeStackedEventHandler; GVAR(PFH) = false;
ACE_Parachuting_PFH = false; [_unit, "AmovPercMevaSrasWrflDf_AmovPknlMstpSrasWrflDnon", 2] call EFUNC(common,doAnimation);
[_unit, "AmovPercMevaSrasWrflDf_AmovPknlMstpSrasWrflDnon", 2] call ACE_Core_fnc_doAnimation; [{
[_unit] spawn { if (diag_tickTime >= ((_this select 0) select 0) + 1) then {
sleep 1; ((_this select 0) select 1) playActionNow "Crouch";
(_this select 0) playActionNow "Crouch"; [(_this select 1)] call CALLSTACK(cba_fnc_removePerFrameHandler);
}; };
}, 1, [diag_tickTime,_unit]] call CALLSTACK(cba_fnc_addPerFrameHandler);

View File

@ -15,5 +15,5 @@
call ACE_Parachute_fnc_hideAltimeter call ACE_Parachute_fnc_hideAltimeter
*/ */
#include "script_component.hpp" #include "script_component.hpp"
terminate ACE_Parachute_AltimeterFnc; GVAR(AltimeterActive) = false;
(["ACE_Altimeter"] call BIS_fnc_rscLayer) cutText ["","PLAIN",0,true]; (["ACE_Altimeter"] call BIS_fnc_rscLayer) cutText ["","PLAIN",0,true];

View File

@ -18,15 +18,18 @@
#include "script_component.hpp" #include "script_component.hpp"
private "_player"; private "_player";
_player = ACE_player; _player = ACE_player;
if (isNull _player) exitWith {["ACE_ParachuteFix", "OnEachFrame"] call BIS_fnc_removeStackedEventHandler;ACE_Parachuting_PFH = false;}; if (!GVAR(PFH)) exitWith {[(_this select 1)] call CALLSTACK(cba_fnc_removePerFrameHandler);};
if (isNull _player) exitWith {[(_this select 1)] call CALLSTACK(cba_fnc_removePerFrameHandler);GVAR(PFH) = false;};
if !((vehicle _player) isKindOf "ParachuteBase") exitWith {}; if !((vehicle _player) isKindOf "ParachuteBase") exitWith {};
if (isTouchingGround _player) exitWith {}; if (isTouchingGround _player) exitWith {[(_this select 1)] call CALLSTACK(cba_fnc_removePerFrameHandler);GVAR(PFH) = false;};
private ["_pos", "_intersects"]; private ["_pos"];
_pos = getPosASL (Vehicle _player); _pos = getPosASL (vehicle _player);
if ((lineIntersects [_pos, _pos vectorAdd [0,0,-0.5], vehicle _player, _player]) || {((ASLtoATL _pos) select 2) < 0.75}) then { if ((lineIntersects [_pos, _pos vectorAdd [0,0,-0.5], vehicle _player, _player]) || {((ASLtoATL _pos) select 2) < 0.75}) then {
[(_this select 1)] call CALLSTACK(cba_fnc_removePerFrameHandler);
GVAR(PFH) = false;
// I believe this will not work for Zeus units. // I believe this will not work for Zeus units.
deleteVehicle (vehicle _player); deleteVehicle (vehicle _player);
[_player] call ACE_Parachute_fnc_doLanding; [_player] call FUNC(doLanding);
}; };

View File

@ -21,33 +21,28 @@ _unit = _this select 0;
(["ACE_Altimeter"] call BIS_fnc_rscLayer) cutRsc ["ACE_Altimeter", "PLAIN",0,true]; (["ACE_Altimeter"] call BIS_fnc_rscLayer) cutRsc ["ACE_Altimeter", "PLAIN",0,true];
if (isNull (uiNamespace getVariable ["ACE_Altimeter", displayNull])) exitWith {}; if (isNull (uiNamespace getVariable ["ACE_Altimeter", displayNull])) exitWith {};
ACE_Parachute_AltimeterFnc = [uiNamespace getVariable ["ACE_Altimeter", displayNull], _unit] spawn { GVAR(AltimeterActive) = true;
private ["_height", "_hour", "_minute", "_descentRate"]; [{
_unit = _this select 1; if (!GVAR(AltimeterActive)) exitWith {[_this select 1] call CALLSTACK(cba_fnc_removePerFrameEventHandler);};
_height = floor ((getPosASL _unit) select 2); disableSerialization;
_oldHeight = _height; EXPLODE_4_PVT(_this select 0,_display,_unit,_oldHeight,_prevTime);
_descentRate = 0; if !("ACE_Altimeter" in assignedItems _unit) exitWith {[_this select 1] call CALLSTACK(cba_fnc_removePerFrameEventHandler);call FUNC(hideAltimeter);};
private ["_height", "_hour", "_minute", "_descentRate","_HeightText", "_DecendRate", "_TimeText", "_curTime"];
_HeightText = _display displayCtrl 1100;
_DecendRate = _display displayCtrl 1000;
_TimeText = _display displayCtrl 1001;
_hour = floor daytime; _hour = floor daytime;
_minute = floor ((daytime - _hour) * 60); _minute = floor ((daytime - _hour) * 60);
disableSerialization;
private ["_HeightText", "_DecendRate", "_TimeText", "_prevTime", "_curTime"];
_HeightText = (_this select 0) displayCtrl 1100;
_DecendRate = (_this select 0) displayCtrl 1000;
_TimeText = (_this select 0) displayCtrl 1001;
_curTime = time;
_prevTime = _curTime;
while {true} do {
_TimeText ctrlSetText (format ["%1:%2",[_hour, 2] call ACE_Core_fnc_numberToDigitsString,[_minute, 2] call ACE_Core_fnc_numberToDigitsString]);
_HeightText ctrlSetText (format ["%1", floor(_height)]);
_DecendRate ctrlSetText (format ["%1", _descentRate max 0]);
sleep 0.2;
_height = (getPosASL _unit) select 2;
_curTime = time;
_descentRate = floor ((_oldHeight - _height) / (_curTime - _prevTime));
_oldHeight = _height;
_prevTime = _curTime;
// close altimeter, @todo _unit can change due to team switch, zeus! _height = (getPosASL _unit) select 2;
if !("ACE_Altimeter" in assignedItems _unit) exitWith {call ACE_Parachute_fnc_hideAltimeter}; _curTime = time;
}; _descentRate = floor ((_oldHeight - _height) / (_curTime - _prevTime));
};
_TimeText ctrlSetText (format ["%1:%2",[_hour, 2] call EFUNC(common,numberToDigitsString),[_minute, 2] call EFUNC(common,numberToDigitsString)]);
_HeightText ctrlSetText (format ["%1", floor(_height)]);
_DecendRate ctrlSetText (format ["%1", _descentRate max 0]);
(_this select 0) set [2, _height];
(_this select 0) set [3, _curTime];
}, 0.2, [uiNamespace getVariable ["ACE_Altimeter", displayNull], _unit,floor ((getPosASL _unit) select 2), time]] call CALLSTACK(cba_fnc_addPerFrameEventHandler);