67 lines
2.1 KiB
Plaintext
67 lines
2.1 KiB
Plaintext
/*
|
|
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;
|
|
};
|
|
};
|