Commit 39b92313 authored by Ryan Grupp's avatar Ryan Grupp
Browse files

New hotness

parent c3ba4aba
......@@ -11,6 +11,7 @@ tsm_modules = [
'car_radio',
'components',
'lz_select',
'spectrum_device',
'static_radio'
];
......
tsm_ambient_sounds_sounds = ['ambient_sounds', 'sounds', []] call tsm_core_Fnc_getConfigValue;
tsm_ambient_sounds_sounds = ['ambient_sounds', 'sounds', []] call tsm_core_fnc_getConfigValue;
tsm_ambient_sounds_mode = ['ambient_sounds', 'mode', 0] call tsm_core_Fnc_getConfigValue;
tsm_ambient_sounds_mode = ['ambient_sounds', 'mode', 0] call tsm_core_fnc_getConfigValue;
tsm_ambient_sounds_initialDelay = ['ambient_sounds', 'initialDelay', 30] call tsm_core_Fnc_getConfigValue;
tsm_ambient_sounds_initialDelay = ['ambient_sounds', 'initialDelay', 30] call tsm_core_fnc_getConfigValue;
tsm_ambient_sounds_gapTime = ['ambient_sounds', 'gapTime', [60,120]] call tsm_core_Fnc_getConfigValue;
tsm_ambient_sounds_gapTime = ['ambient_sounds', 'gapTime', [60,120]] call tsm_core_fnc_getConfigValue;
if (count tsm_ambient_sounds_gapTime isEqualTo 1) then {
tsm_ambient_sounds_gapTime = tsm_ambient_sounds_gapTime select 0;
......
if (hasInterface) then {
tsm_spectrum_device_pfh = [tsm_spectrum_device_fnc_handleSignals, tsm_spectrum_device_updateFrequency] call CBA_fnc_addPerFrameHandler;
[{
!isNull (finddisplay 46)
},{
tsm_spectrum_device_keyHandler = (findDisplay 46) displayAddEventHandler ["MouseButtonDown", tsm_spectrum_device_fnc_keyDown];
}] call CBA_fnc_waitUntilAndExecute;
};
\ No newline at end of file
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';
call compile preprocessFileLineNumbers 'tsm\spectrum_device\load_config.sqf';
if (hasInterface) then
{
tsm_spectrum_device_currentHandgun = "";
tsm_spectrum_device_currentAntenna = "";
missionNamespace setVariable ["#EM_FMin", 0];
missionNamespace setVariable ["#EM_FMax", 0];
missionNamespace setVariable ["#EM_SMin", 0];
missionNamespace setVariable ["#EM_SMax", 100];
missionNamespace setVariable ["#EM_SelMin", 0];
missionNamespace setVariable ["#EM_SelMax", 0];
missionNamespace setVariable ["#EM_Progress", 0];
missionNamespace setVariable ["#EM_Transmit", false];
missionNamespace setVariable ["#EM_Values", []];
["loadout", tsm_spectrum_device_fnc_updateScannerRanges] call CBA_fnc_addPlayerEventHandler;
};
\ No newline at end of file
params ['_duration', '_success'];
if !(isNil "tsm_spectrum_device_pfhProgress") exitWith {};
tsm_spectrum_device_pfhProgress = [{
params ['_args', '_pfh'];
_args params ['_start', '_duration', '_success'];
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;
};
if (_elapsedTime isEqualTo _duration) exitWith {
missionNamespace setVariable ["#EM_Progress", 0];
[_pfh] call CBA_fnc_removePerFrameHandler;
tsm_spectrum_device_pfhProgress = nil;
call _success;
};
}, 0, [CBA_missionTime, _duration, _success]] call CBA_fnc_addPerFrameHandler;
\ No newline at end of file
params ['_signals'];
if (tsm_spectrum_device_angleRestriction >= 360) exitWith {_signals};
private _signalsFiltered = [];
{
_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 {
_signalsFiltered pushback _x;
};
false
} count _signals;
_signalsFiltered
\ No newline at end of file
if !(isNil "tsm_spectrum_device_pfhNoise") exitWith {};
private _signals = missionNamespace getVariable ['tsm_spectrum_device_signals', []];
_signals = [_signals] call tsm_spectrum_device_fnc_filterSignals;
private _signalValues = [];
{
_x params ['_source', '_freq'];
private _sourceDistance = player distance _source;
private _signalStrength = linearConversion [0, tsm_spectrum_device_maxDistance, _sourceDistance, 100, 0, true];
private _relDir = player getRelDir _source;
_relDir = if(_relDir >= 180) then {360 - _relDir} else {_relDir};
private _strengthModifier = linearConversion [tsm_spectrum_device_angleRestriction/2, 0, _relDir, tsm_spectrum_device_angleDegradation, 1, true];
_signalStrength = _signalStrength * _strengthModifier;
_signalValues = _signalValues + [_freq, _signalStrength];
false
} count _signals;
missionNamespace setVariable ["#EM_Values", _signalValues];
\ No newline at end of file
params ['_display', '_button', '', '', '_shift', '_ctrl', '_alt'];
if (!(currentWeapon player isEqualTo "hgun_esd_01_F") || { _button != 0 }) exitWith {};
q = _this;
[5, {
hint 'Wow, you did a scan!';
}] call tsm_spectrum_device_fnc_doProgressBar;
\ No newline at end of file
if !(isNil "tsm_spectrum_device_pfhNoise") exitWith {};
tsm_spectrum_device_pfhNoise = [{
private _signals = [];
private _freqScale = [missionNamespace getVariable ["#EM_FMin", 0], missionNamespace getVariable ["#EM_FMax", 1]];
private _freqStep = ((_freqScale#1) - (_freqScale#0))/60;
for "_i" from 0 to 59 do
{
private _freq = (_freqScale#0) + (_i * _freqStep);
private _signalStrength = random 100;
_signals = _signals + [_freq, _signalStrength];
};
missionNamespace setVariable ["#EM_Values", _signals];
}, 0.1] call CBA_fnc_addPerFrameHandler;
\ No newline at end of file
if (isNil "tsm_spectrum_device_pfhNoise") exitWith {};
[tsm_spectrum_device_pfhNoise] call CBA_fnc_removePerFrameHandler;
tsm_spectrum_device_pfhNoise = nil;
\ No newline at end of file
private _range = switch (tsm_spectrum_device_currentAntenna) do
{
case "muzzle_antenna_01_f": { [78, 89] };
case "muzzle_antenna_02_f": { [390, 500] };
case "muzzle_antenna_03_f": { [433, 434] };
default { [0, 0] };
};
if (count tsm_spectrum_device_scanRange isEqualTo 2) then
{
_range = +tsm_spectrum_device_scanRange;
};
missionNamespace setVariable ["#EM_FMin", _range select 0];
missionNamespace setVariable ["#EM_FMax", _range select 1];
_range
\ No newline at end of file
params ['_min', '_max'];
private _diff = _max - _min;
private _size = _diff * tsm_spectrum_device_selectionRange;
missionNamespace setVariable ["#EM_SelMin", _min];
missionNamespace setVariable ["#EM_SelMax", _min+_size];
\ No newline at end of file
params [
['_source', [0,0,0], [objNull, []]],
['_frequency', -1]
];
if !(isServer) exitWith {};
private _signals = missionNamespace getVariable ['tsm_spectrum_device_signals', []];
_signals pushback [_source, _frequency];
missionNamespace setVariable ['tsm_spectrum_device_signals', _signals, true];
\ No newline at end of file
params [
['_source', [0,0,0], [objNull, []]]
];
private _signals = missionNamespace getVariable ['tsm_spectrum_device_signals', []];
private _index = _signals findIf {_x#0 isEqualTo _source};
if (_index > -1) then {
_signals deleteAt _index;
missionNamespace setVariable ['tsm_spectrum_device_signals', _signals, true];
};
\ No newline at end of file
if (handgunWeapon player isEqualTo tsm_spectrum_device_currentHandgun && { (handgunItems player select 0) isEqualTo tsm_spectrum_device_currentAntenna }) exitWith {};
tsm_spectrum_device_currentHandgun = handgunWeapon player;
tsm_spectrum_device_currentAntenna = handgunItems player select 0;
if !(tsm_spectrum_device_currentHandgun isEqualTo "hgun_esd_01_F") exitWith {};
if (tsm_spectrum_device_requireAntenna isEqualTo 1 && { tsm_spectrum_device_currentAntenna isEqualTo "" }) exitWith
{
missionNamespace setVariable ["#EM_FMin", 0];
missionNamespace setVariable ["#EM_FMax", 0];
missionNamespace setVariable ["#EM_SelMin", 0];
missionNamespace setVariable ["#EM_SelMax", 0];
};
private _range = call tsm_spectrum_device_fnc_setScanRange;
_range call tsm_spectrum_device_fnc_setSelectionRange;
\ No newline at end of file
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_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_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_maxDistance = ['spectrum_device', 'maxDistance', 1] call tsm_core_fnc_getConfigValue;
\ No newline at end of file
......@@ -37,4 +37,40 @@ class TSM_Config
*/
mode = 1;
};
class spectrum_device
{
/* Scan range of the device in MHZ
* If 2 elements given, the range the scanner supports.
* Ex: scanRange[] = {60, 120};
* If no elements given, use the scan range of the attached antenna.
* Ex: scanRange[] = {};
*/
scanRange[] = {};
/* Require an antenna to be attached for the device to function */
requireAntenna = 1;
/* Size of the selection range, as relative to the full scan range, 0 being disabled, 1 being 100% */
selectionRange = 0.1;
/* Signals outside of this angle can't be seen (as a cone in front of the player) */
angleRestriction = 180;
/* Off axis signal degredation factor */
angleDegradation = 0.3;
/* Update frequency in seconds, supports non-whole numbers, every game frame if 0 */
updateFrequency = 1;
/* Number of meters in which a signal can be detected */
maxDistance = 10000;
};
};
\ 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