Commit 41d43d41 authored by Ryan Grupp's avatar Ryan Grupp
Browse files

ID Support, In selection functions, start of power modulation and garbage...

ID Support, In selection functions, start of power modulation and garbage collection, updated click handler, progress bar rework
parent fcf375ee
tsm_spectrum_device_fnc_signalAdd = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_signalAdd.sqf';
tsm_spectrum_device_fnc_signalRemove = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_signalRemove.sqf';
tsm_spectrum_device_fnc_handleSignals = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_handleSignals.sqf';
tsm_spectrum_device_fnc_updateScannerRanges = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_updateScannerRanges.sqf';
tsm_spectrum_device_fnc_setSelectionRange = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_setSelectionRange.sqf';
tsm_spectrum_device_fnc_setScanRange = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_setScanRange.sqf';
tsm_spectrum_device_fnc_filterSignals = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_filterSignals.sqf';
tsm_spectrum_device_fnc_keyDown = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_keyDown.sqf';
tsm_spectrum_device_fnc_doProgressBar = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_doProgressBar.sqf';
tsm_spectrum_device_fnc_noise = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_noise.sqf';
tsm_spectrum_device_fnc_noiseStop = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_noiseStop.sqf';
tsm_spectrum_device_fnc_signalAdd = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_signalAdd.sqf';
tsm_spectrum_device_fnc_signalRemove = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_signalRemove.sqf';
tsm_spectrum_device_fnc_handleSignals = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_handleSignals.sqf';
tsm_spectrum_device_fnc_updateScannerRanges = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_updateScannerRanges.sqf';
tsm_spectrum_device_fnc_setSelectionRange = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_setSelectionRange.sqf';
tsm_spectrum_device_fnc_setScanRange = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_setScanRange.sqf';
tsm_spectrum_device_fnc_filterSignals = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_filterSignals.sqf';
tsm_spectrum_device_fnc_keyDown = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_keyDown.sqf';
tsm_spectrum_device_fnc_progressBar = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_progressBar.sqf';
tsm_spectrum_device_fnc_progressBarStop = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_progressBarStop.sqf';
tsm_spectrum_device_fnc_noise = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_noise.sqf';
tsm_spectrum_device_fnc_noiseStop = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_noiseStop.sqf';
tsm_spectrum_device_fnc_getSignalsInSelection = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_getSignalsInSelection.sqf';
tsm_spectrum_device_fnc_getSignalInSelectionClosest = compile preprocessFileLineNumbers 'tsm\spectrum_device\functions\fnc_getSignalInSelectionClosest.sqf';
call compile preprocessFileLineNumbers 'tsm\spectrum_device\load_config.sqf';
......
......@@ -7,7 +7,7 @@ if (tsm_spectrum_device_angleRestriction >= 360) exitWith {_signals};
private _signalsFiltered = [];
{
_x params ['_source', '_freq'];
_x params ['_source', ''];
private _loc = if (_source isEqualType objNull) then {getPosAtl _source} else {_source};
if ([getPosATL player, getDir player, tsm_spectrum_device_angleRestriction, _loc] call BIS_fnc_inAngleSector) then {
_signalsFiltered pushback _x;
......
private _signals = call tsm_spectrum_device_fnc_getSignalsInSelection;
if (count _signals isEqualTo 0) exitWith {nil};
if (count _signals isEqualTo 1) exitWith {_signals#0};
private _selMin = missionNamespace getVariable ["#EM_SelMin", 0];
private _selMax = missionNamespace getVariable ["#EM_SelMax", 0];
private _selCenter = ((_selMax - _selMin) / 2) + _selMin;
private _signalsSorted = [
_signals,
[_selCenter],
{
private _freq = _x#2;
private _diff = _freq - _selCenter;
(abs _diff)
},
'ASCEND'
] call BIS_fnc_sortBy;
(_signalsSorted#0)
\ No newline at end of file
private _selMin = missionNamespace getVariable ["#EM_SelMin", 0];
private _selMax = missionNamespace getVariable ["#EM_SelMax", 0];
private _signals = missionNamespace getVariable ['tsm_spectrum_device_signals', []];
private _signalsInSelection = [];
{
_x params ['_source', '', '_freq'];
private _loc = if (_source isEqualType objNull) then {getPosAtl _source} else {_source};
if ([getPosATL player, getDir player, tsm_spectrum_device_angleRestriction, _loc] call BIS_fnc_inAngleSector) then {
if (_freq >= _selMin && { _freq <= _selMax }) then {
_signalsInSelection pushBack _x;
};
};
false
} count _signals;
_signalsInSelection
\ No newline at end of file
......@@ -7,7 +7,7 @@ _signals = [_signals] call tsm_spectrum_device_fnc_filterSignals;
private _signalValues = [];
{
_x params ['_source', '_freq'];
_x params ['_source', '_id', '_freq', '_powerHook'];
private _sourceDistance = player distance _source;
private _signalStrength = linearConversion [0, tsm_spectrum_device_maxDistance, _sourceDistance, 100, 0, true];
......
......@@ -2,6 +2,4 @@ params ['_display', '_button', '', '', '_shift', '_ctrl', '_alt'];
if (!(currentWeapon player isEqualTo "hgun_esd_01_F") || { _button != 0 }) exitWith {};
[5, {
hint 'Wow, you did a scan!';
}] call tsm_spectrum_device_fnc_doProgressBar;
\ No newline at end of file
["tsm_spectrum_device_leftClick", _this] call CBA_fnc_localEvent;
\ No newline at end of file
params ['_duration', '_success'];
params [
['_duration', 5, [0]],
['_success', {}, [{}]],
['_disallowSelectChange', true, [true]]
];
if !(isNil "tsm_spectrum_device_pfhProgress") exitWith {};
private _selectRange = if (_disallowSelectChange) then {
[missionNamespace getVariable ["#EM_SelMin", 0], missionNamespace getVariable ["#EM_SelMax", 0]]
} else {false};
tsm_spectrum_device_pfhProgress = [{
params ['_args', '_pfh'];
_args params ['_start', '_duration', '_success'];
_args params ['_start', '_duration', '_success', '_selectRange'];
private _elapsedTime = (CBA_missionTime - _start) min _duration;
private _status = linearConversion [0, _duration, _elapsedTime, 0, 1, true];
missionNamespace setVariable ["#EM_Progress", _status];
if !(currentWeapon player isEqualTo "hgun_esd_01_F") exitWith {
missionNamespace setVariable ["#EM_Progress", 0];
[_pfh] call CBA_fnc_removePerFrameHandler;
tsm_spectrum_device_pfhProgress = nil;
[_pfh] call tsm_spectrum_device_fnc_progressBarStop;
};
if (_selectRange isEqualType []) then {
private _selMin = missionNamespace getVariable ["#EM_SelMin", 0];
private _selMax = missionNamespace getVariable ["#EM_SelMax", 0];
if !((_selectRange#0) isEqualTo _selMin && { (_selectRange#1) isEqualTo _selMax }) exitWith {
[_pfh] call tsm_spectrum_device_fnc_progressBarStop;
};
};
if (_elapsedTime isEqualTo _duration) exitWith {
missionNamespace setVariable ["#EM_Progress", 0];
[_pfh] call CBA_fnc_removePerFrameHandler;
tsm_spectrum_device_pfhProgress = nil;
call _success;
[_pfh, _success] call tsm_spectrum_device_fnc_progressBarStop;
};
}, 0, [CBA_missionTime, _duration, _success]] call CBA_fnc_addPerFrameHandler;
\ No newline at end of file
}, 0, [CBA_missionTime, _duration, _success, _selectRange]] call CBA_fnc_addPerFrameHandler;
\ No newline at end of file
params [
['_pfh', -1, [0]],
['_code', {}, [{}]]
];
missionNamespace setVariable ["#EM_Progress", 0];
[_pfh] call CBA_fnc_removePerFrameHandler;
tsm_spectrum_device_pfhProgress = nil;
if !(_code isEqualTo {}) then {
call _code;
};
\ No newline at end of file
params [
['_source', [0,0,0], [objNull, []]],
['_frequency', -1]
['_id', '', ['']],
['_frequency', -1],
['_powerHook', tsm_spectrum_device_hookAllPowerVarsByDefault, [true]]
];
if !(isServer) exitWith {};
private _signals = missionNamespace getVariable ['tsm_spectrum_device_signals', []];
_signals pushback [_source, _frequency];
_signals pushback [_source, _id, _frequency, _powerHook];
missionNamespace setVariable ['tsm_spectrum_device_signals', _signals, true];
\ No newline at end of file
params [
['_source', [0,0,0], [objNull, []]]
['_id', '', ['']]
];
if !(isServer) exitWith {};
private _signals = missionNamespace getVariable ['tsm_spectrum_device_signals', []];
private _index = _signals findIf {_x#0 isEqualTo _source};
private _index = _signals findIf {_x#1 isEqualTo _source};
if (_index > -1) then {
_signals deleteAt _index;
......
tsm_spectrum_device_scanRange = ['spectrum_device', 'scanRange', []] call tsm_core_fnc_getConfigValue;
tsm_spectrum_device_scanRange = ['spectrum_device', 'scanRange', []] call tsm_core_fnc_getConfigValue;
tsm_spectrum_device_requireAntenna = ['spectrum_device', 'requireAntenna', 1] call tsm_core_fnc_getConfigValue;
tsm_spectrum_device_requireAntenna = ['spectrum_device', 'requireAntenna', 1] call tsm_core_fnc_getConfigValue;
tsm_spectrum_device_selectionRange = ['spectrum_device', 'selectionRange', 0.1] call tsm_core_fnc_getConfigValue;
tsm_spectrum_device_selectionRange = ['spectrum_device', 'selectionRange', 0.1] call tsm_core_fnc_getConfigValue;
tsm_spectrum_device_angleRestriction = ['spectrum_device', 'angleRestriction', 90] call tsm_core_fnc_getConfigValue;
tsm_spectrum_device_angleRestriction = ['spectrum_device', 'angleRestriction', 90] call tsm_core_fnc_getConfigValue;
tsm_spectrum_device_angleDegradation = ['spectrum_device', 'angleDegradation', 0.5] call tsm_core_fnc_getConfigValue;
tsm_spectrum_device_angleDegradation = ['spectrum_device', 'angleDegradation', 0.5] call tsm_core_fnc_getConfigValue;
tsm_spectrum_device_updateFrequency = ['spectrum_device', 'updateFrequency', 1] call tsm_core_fnc_getConfigValue;
tsm_spectrum_device_updateFrequency = ['spectrum_device', 'updateFrequency', 1] call tsm_core_fnc_getConfigValue;
tsm_spectrum_device_maxDistance = ['spectrum_device', 'maxDistance', 1] call tsm_core_fnc_getConfigValue;
\ No newline at end of file
tsm_spectrum_device_maxDistance = ['spectrum_device', 'maxDistance', 1] call tsm_core_fnc_getConfigValue;
tsm_spectrum_device_hookAllPowerVarsByDefault = ['spectrum_device', 'hookAllPowerVarsByDefault', 0] call tsm_core_fnc_getConfigValue;
tsm_spectrum_device_garbageCollectTimer = ['spectrum_device', 'garbageCollectTimer', 60] call tsm_core_fnc_getConfigValue;
tsm_spectrum_device_hookAllPowerVarsByDefault = if (tsm_spectrum_device_hookAllPowerVarsByDefault > 0) then {true} else {false};
......@@ -72,5 +72,13 @@ class TSM_Config
/* Number of meters in which a signal can be detected */
maxDistance = 10000;
/* Forces the system to hook all power vars by default, which makes the system slightly easier to use, but at a performance cost */
hookAllPowerVarsByDefault = 0;
/* How often in seconds the server should attempt to clean up dead signals */
garbageCollectTimer = 60;
};
};
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment