ACE3/addons/huntir/functions/fnc_huntir.sqf

99 lines
3.7 KiB
Plaintext
Raw Normal View History

2015-06-06 12:13:34 +00:00
/*
* Author: Norrin, Rocko, Ruthberg
*
* HuntIR monitor system
*
* Arguments:
2015-08-13 22:02:19 +00:00
* None
2015-06-06 12:13:34 +00:00
*
* Return Value:
2015-08-13 22:02:19 +00:00
* None
2015-06-06 12:13:34 +00:00
*
* Public: No
*/
#include "script_component.hpp"
#define __TYPE_WRITER_DELAY 0.05
if ((ACE_player call CBA_fnc_getUnitAnim) select 0 == "stand") then {
ACE_player playMove "AmovPercMstpSrasWrflDnon_diary";
};
2015-06-07 11:55:35 +00:00
HUNTIR_BACKGROUND_LAYER_ID cutText ["", "BLACK", 0];
2015-06-06 12:13:34 +00:00
createDialog "ace_huntir_cam_dialog_off";
[{
if (!dialog) exitWith {
2015-06-07 11:55:35 +00:00
HUNTIR_BACKGROUND_LAYER_ID cutText ["", "PLAIN", 0];
2015-06-06 12:13:34 +00:00
};
closeDialog 0;
createDialog "ace_huntir_cam_dialog_inactive";
uiNameSpace setVariable ["ace_huntir_monitor", findDisplay 18881];
[{
GVAR(startTime) = ACE_time;
GVAR(done) = false;
GVAR(connectionDelay) = 5;
GVAR(state) = "searching";
GVAR(message) = [];
2015-08-13 22:02:19 +00:00
GVAR(messageSearching) = toArray "Searching.....";
2015-06-06 12:13:34 +00:00
GVAR(messageConnecting) = toArray "Connecting.....";
[{
//Close monitor if we no longer have item:
if ((!([ACE_player, "ACE_HuntIR_monitor"] call EFUNC(common,hasItem))) && {!isNull (uiNameSpace getVariable ["ace_huntir_monitor", displayNull])}) then {
closeDialog 0;
};
2015-08-13 22:02:19 +00:00
2015-06-06 12:13:34 +00:00
private ["_elapsedTime", "_nearestHuntIRs"];
_elapsedTime = ACE_time - GVAR(startTime);
2015-06-07 12:47:56 +00:00
_nearestHuntIRs = ACE_player nearEntities ["ACE_HuntIR", HUNTIR_MAX_TRANSMISSION_RANGE];
2015-08-13 22:02:19 +00:00
2015-06-06 12:13:34 +00:00
if ((!dialog) || GVAR(done)) exitWith {
2015-11-30 15:45:20 +00:00
[_this select 1] call CBA_fnc_removePerFrameHandler;
2015-08-13 22:02:19 +00:00
2015-06-06 12:13:34 +00:00
if (dialog && GVAR(state) == "connected") then {
[_nearestHuntIRs select 0] call FUNC(cam);
} else {
2015-06-07 11:55:35 +00:00
HUNTIR_BACKGROUND_LAYER_ID cutText ["", "PLAIN"];
2015-06-06 12:13:34 +00:00
};
};
switch (GVAR(state)) do {
case "searching": {
if (count GVAR(message) < count GVAR(messageSearching)) then {
GVAR(message) pushBack (GVAR(messageSearching) select (count GVAR(message)));
ctrlSetText [1, toString GVAR(message)];
} else {
GVAR(message) = [];
if (_elapsedTime > 10) then {
GVAR(state) = "noGDS";
};
if (_elapsedTime > 5 && {{_x getHitPointDamage "HitCamera" < 0.25} count _nearestHuntIRs > 0}) then {
2015-06-06 12:13:34 +00:00
GVAR(state) = "connecting";
};
};
};
case "connecting": {
if (count GVAR(message) < count GVAR(messageConnecting)) then {
GVAR(message) pushBack (GVAR(messageConnecting) select (count GVAR(message)));
ctrlSetText [1, toString GVAR(message)];
} else {
GVAR(message) = [];
GVAR(connectionDelay) = GVAR(connectionDelay) - 1;
if (GVAR(connectionDelay) <= 0) then {
GVAR(done) = true;
GVAR(state) = "connected";
};
};
};
case "noGDS": {
ctrlSetText [1, "No GDS System detected"];
[{
GVAR(done) = true;
closedialog 0;
2015-06-07 11:55:35 +00:00
HUNTIR_BACKGROUND_LAYER_ID cutText ["", "PLAIN"];
2015-06-06 12:13:34 +00:00
}, [], 3, 0] call EFUNC(common,waitAndExecute);
};
};
}, __TYPE_WRITER_DELAY, []] call CBA_fnc_addPerFrameHandler;
}, [], 0.5, 0] call EFUNC(common,waitAndExecute);
}, [], 1, 0] call EFUNC(common,waitAndExecute);