added spectrum device scripts
This commit is contained in:
parent
0dc06e0e6e
commit
ddf329073f
66
functions/Spectrum/fn_findTarget.sqf
Normal file
66
functions/Spectrum/fn_findTarget.sqf
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
Author: Djeeberjr
|
||||||
|
|
||||||
|
Description:
|
||||||
|
Points the Sectrum device to a spesific object
|
||||||
|
|
||||||
|
Parameter(s):
|
||||||
|
0: OBJECT - target of the scan
|
||||||
|
1: NUMBER - interval of update e.g. 0.3
|
||||||
|
2: NUMBER - Frequency to scan on (UI only)
|
||||||
|
3: NUMBER - Cutoff signale after angle e.g. 90
|
||||||
|
4: NUMBER - Min distance to target befor device goes 100%
|
||||||
|
5: NUMBER - Max distance the target can be detected. Signal strength relativ to max distance.
|
||||||
|
6: OBJECT - receiver object most of the time the player
|
||||||
|
*/
|
||||||
|
|
||||||
|
_this spawn {
|
||||||
|
params ["_target","_interval","_scanFreq","_angleCutoff","_minDistance","_maxDistance",["_receiverObject",player]];
|
||||||
|
|
||||||
|
missionNamespace setVariable ["#EM_FMin", _scanFreq - 3];
|
||||||
|
missionNamespace setVariable ["#EM_FMax", _scanFreq + 3];
|
||||||
|
|
||||||
|
missionNamespace setVariable ["#EM_SelMin", _scanFreq - 0.3];
|
||||||
|
missionNamespace setVariable ["#EM_SelMax", _scanFreq + 0.3];
|
||||||
|
|
||||||
|
missionNamespace setVariable ["#EM_Progress", 0];
|
||||||
|
|
||||||
|
while {alive _receiverObject} do {
|
||||||
|
|
||||||
|
// Get distance
|
||||||
|
_objectDistance = round (_receiverObject distance _target);
|
||||||
|
|
||||||
|
// Get angle difference to target range from 0 to 180
|
||||||
|
_objectRelativeDirection = round (_receiverObject getRelDir _target);
|
||||||
|
if (_objectRelativeDirection >= 180) then{
|
||||||
|
_objectRelativeDirection = (360 - _objectRelativeDirection);
|
||||||
|
}else{
|
||||||
|
_objectRelativeDirection = _objectRelativeDirection;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Apply angle cutoff
|
||||||
|
if (_objectRelativeDirection > _angleCutoff) then {
|
||||||
|
_objectRelativeDirection = 180; // Set angle to max value
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
_dirSignalStrength = 1 - linearConversion [0,_angleCutoff,_objectRelativeDirection,0,1,true];
|
||||||
|
|
||||||
|
_distSignalStrength = 1 - linearConversion [0,_maxDistance,_objectDistance,0,1,true];
|
||||||
|
|
||||||
|
_absSignalStrength = _dirSignalStrength * _distSignalStrength;
|
||||||
|
|
||||||
|
if (_objectDistance < _minDistance) then {
|
||||||
|
_absSignalStrength = 1;
|
||||||
|
_distSignalStrength = 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
missionNamespace setVariable ["#EM_Values", [
|
||||||
|
_scanFreq,
|
||||||
|
linearConversion [0,1,_absSignalStrength,missionNamespace getVariable "#EM_SMin",missionNamespace getVariable "#EM_SMax"]
|
||||||
|
]];
|
||||||
|
missionNamespace setVariable ["#EM_Progress", _distSignalStrength];
|
||||||
|
|
||||||
|
sleep _interval;
|
||||||
|
};
|
||||||
|
};
|
@ -9,4 +9,5 @@ class DLib{
|
|||||||
#include "Util\CfgFunctions.hpp"
|
#include "Util\CfgFunctions.hpp"
|
||||||
#include "Zeus\CfgFunctions.hpp"
|
#include "Zeus\CfgFunctions.hpp"
|
||||||
#include "Other\CfgFunctions.hpp"
|
#include "Other\CfgFunctions.hpp"
|
||||||
|
#include "Spectrum\CfgFunctions.hpp"
|
||||||
}
|
}
|
4
includes/Spectrum/CfgFunctions.hpp
Normal file
4
includes/Spectrum/CfgFunctions.hpp
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
class Spectrum{
|
||||||
|
file="DLib\functions\Spectrum";
|
||||||
|
class findTarget{};
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user