diff --git a/addons/laser/CfgEventhandlers.hpp b/addons/laser/CfgEventhandlers.hpp index 1fcfc0244f..bad89fd048 100644 --- a/addons/laser/CfgEventhandlers.hpp +++ b/addons/laser/CfgEventhandlers.hpp @@ -1,11 +1,11 @@ class Extended_PreInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_pre_init)); - }; + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_pre_init)); + }; }; class Extended_PostInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_post_init)); - }; + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_post_init)); + }; }; diff --git a/addons/laser/CfgVehicles.hpp b/addons/laser/CfgVehicles.hpp index 1c5887bd38..07b8055f0e 100644 --- a/addons/laser/CfgVehicles.hpp +++ b/addons/laser/CfgVehicles.hpp @@ -1,9 +1,9 @@ class CfgVehicles { - class All; + class All; - class LaserTarget: All { - class EventHandlers { - init = QUOTE(_this call FUNC(laser_init)); - }; - }; + class LaserTarget: All { + class EventHandlers { + init = QUOTE(_this call FUNC(laser_init)); + }; + }; }; \ No newline at end of file diff --git a/addons/laser/XEH_pre_init.sqf b/addons/laser/XEH_pre_init.sqf index 8a4b3166b8..8b39c429b6 100644 --- a/addons/laser/XEH_pre_init.sqf +++ b/addons/laser/XEH_pre_init.sqf @@ -14,7 +14,7 @@ PREP(translateToWeaponSpace); PREP(laser_init); -GVAR(laser) = nil; // a single hud draws 1 laser at a time +GVAR(laser) = nil; // a single hud draws 1 laser at a time PREP(laserTargetPFH); diff --git a/addons/laser/config.cpp b/addons/laser/config.cpp index 711bd743b6..4b209b866e 100644 --- a/addons/laser/config.cpp +++ b/addons/laser/config.cpp @@ -1,13 +1,13 @@ #include "script_component.hpp" class CfgPatches { - class ADDON { - units[] = {}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = { "ace_common" }; - VERSION_CONFIG; - }; + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = { "ace_common" }; + VERSION_CONFIG; + }; }; #include "CfgEventhandlers.hpp" diff --git a/addons/laser/functions/fnc_checkLos.sqf b/addons/laser/functions/fnc_checkLos.sqf index f0df153887..9888642a80 100644 --- a/addons/laser/functions/fnc_checkLos.sqf +++ b/addons/laser/functions/fnc_checkLos.sqf @@ -7,7 +7,7 @@ _designator = _this select 2; _seeker = _this select 3; _spacing = 100; if((count _this) > 4) then { - _spacing = _this select 4; + _spacing = _this select 4; }; _return = true; @@ -21,11 +21,11 @@ _pos2 = [(_pos2 select 0) + _x, (_pos2 select 1) + _y, (_pos2 select 2) + _z]; // player sideChat format["new los check"]; if(terrainIntersect [_pos2, _pos1]) then { - _return = false; + _return = false; } else { - if(lineIntersects [_pos2, _pos1]) then { // should take as arguments and add to this command objects to exclude - target and observer - // player sideChat format["with: %1", lineIntersectsWith [_pos1, _pos2]]; - _return = false; - }; + if(lineIntersects [_pos2, _pos1]) then { // should take as arguments and add to this command objects to exclude - target and observer + // player sideChat format["with: %1", lineIntersectsWith [_pos1, _pos2]]; + _return = false; + }; }; _return; \ No newline at end of file diff --git a/addons/laser/functions/fnc_findLaserDesignator.sqf b/addons/laser/functions/fnc_findLaserDesignator.sqf index 8a2e4caf29..73a9462457 100644 --- a/addons/laser/functions/fnc_findLaserDesignator.sqf +++ b/addons/laser/functions/fnc_findLaserDesignator.sqf @@ -1,70 +1,70 @@ #include "script_component.hpp" private ["_missile", "_headingPitch", "_found", "_vectorTo", "_polarTo", "_dir", "_vertOk", "_horzOk", "_fov", - "_closestDistance", "_pos1", "_pos2", "_disCheck", "_currentTarget", "_potentialTargets", "_offset", "_vector"]; + "_closestDistance", "_pos1", "_pos2", "_disCheck", "_currentTarget", "_potentialTargets", "_offset", "_vector"]; _missile = _this select 0; _laserCode = _this select 1; _fov = if (count _this > 2) then {_this select 2} else {75}; _vector = if (count _this > 3) then {_this select 3} else {vectorDir _missile}; _offset = if (count _this > 4) then {_this select 4} else {[0,0,0]}; -_headingPitch = _vector call CBA_fnc_vect2polar; +_headingPitch = _vector call CBA_fnc_vect2polar; _currentTarget = nil; _found = false; LOG("Searching lasers"); if(!(isNil "ACE_LASERS")) then { - _potentialTargets = []; - TRACE_1("", ACE_LASERS); - - { - if(!(isNull _x)) then { - _sensorPos = ATLtoASL(_missile modelToWorld _offset); - _vectorTo = [_sensorPos, ([_x] call FUNC(getPosASL))] call BIS_fnc_vectorFromXToY; - _polarTo = _vectorTo call CBA_fnc_vect2polar; - _dir = _polarTo select 1; - _dir = _dir - (_headingPitch select 1); - - TRACE_4("Calc", _sensorPos, _vectorTo, _polarTo, _dir); - - if (_dir < 0) then {_dir = _dir + 360}; - if (_dir > 360) then {_dir = _dir - 360}; - _vertOk = false; - _horzOk = false; - if(_dir < _fov || {_dir > (360-_fov)}) then { - _horzOk = true; - }; - if(abs((abs(_polarTo select 2))-(abs(_headingPitch select 2))) < _fov) then { - _vertOk = true; - }; - - TRACE_2("Results", _vertOk, _horzOk); - - if(_vertOk && {_horzOk}) then { - // Does the laser currently have our current code, if we have one? - _targetCode = _x getVariable ["ACE_LASERTARGET_CODE", ACE_DEFAULT_LASER_CODE]; - TRACE_1("Target in sight, checking code", _targetCode, _laserCode); - if(_targetCode == _laserCode) then { - _potentialTargets set[(count _potentialTargets), _x]; - }; - }; - }; - - } forEach ACE_LASERS; - - TRACE_1("", _potentialTargets); - - _closestDistance = 100000; - { - _pos1 = (getPosASL _missile); - _pos2 = ([_x] call FUNC(getPosASL)); - _disCheck = _pos1 distance _pos2; - // shouldn't this bail out when a valid target is found instead of iterating over all potential targets ? - if(_disCheck < _closestDistance && {[_pos1, _pos2, _x, _missile] call FUNC(checkLos)}) then { - _found = true; - _currentTarget = _x; - _closestDistance = _disCheck; - }; - } forEach _potentialTargets; + _potentialTargets = []; + TRACE_1("", ACE_LASERS); + + { + if(!(isNull _x)) then { + _sensorPos = ATLtoASL(_missile modelToWorld _offset); + _vectorTo = [_sensorPos, ([_x] call FUNC(getPosASL))] call BIS_fnc_vectorFromXToY; + _polarTo = _vectorTo call CBA_fnc_vect2polar; + _dir = _polarTo select 1; + _dir = _dir - (_headingPitch select 1); + + TRACE_4("Calc", _sensorPos, _vectorTo, _polarTo, _dir); + + if (_dir < 0) then {_dir = _dir + 360}; + if (_dir > 360) then {_dir = _dir - 360}; + _vertOk = false; + _horzOk = false; + if(_dir < _fov || {_dir > (360-_fov)}) then { + _horzOk = true; + }; + if(abs((abs(_polarTo select 2))-(abs(_headingPitch select 2))) < _fov) then { + _vertOk = true; + }; + + TRACE_2("Results", _vertOk, _horzOk); + + if(_vertOk && {_horzOk}) then { + // Does the laser currently have our current code, if we have one? + _targetCode = _x getVariable ["ACE_LASERTARGET_CODE", ACE_DEFAULT_LASER_CODE]; + TRACE_1("Target in sight, checking code", _targetCode, _laserCode); + if(_targetCode == _laserCode) then { + _potentialTargets set[(count _potentialTargets), _x]; + }; + }; + }; + + } forEach ACE_LASERS; + + TRACE_1("", _potentialTargets); + + _closestDistance = 100000; + { + _pos1 = (getPosASL _missile); + _pos2 = ([_x] call FUNC(getPosASL)); + _disCheck = _pos1 distance _pos2; + // shouldn't this bail out when a valid target is found instead of iterating over all potential targets ? + if(_disCheck < _closestDistance && {[_pos1, _pos2, _x, _missile] call FUNC(checkLos)}) then { + _found = true; + _currentTarget = _x; + _closestDistance = _disCheck; + }; + } forEach _potentialTargets; }; [_found, _currentTarget] \ No newline at end of file diff --git a/addons/laser/functions/fnc_findStrongestRay.sqf b/addons/laser/functions/fnc_findStrongestRay.sqf index db85ce8b3d..e4238361cb 100644 --- a/addons/laser/functions/fnc_findStrongestRay.sqf +++ b/addons/laser/functions/fnc_findStrongestRay.sqf @@ -7,43 +7,43 @@ _outliers = []; _spot = []; _testPos = (_list select 0) select 0; { - _samplePos = _x select 0; - if(!lineIntersects [_samplePos, _checkPos] && {!terrainIntersectASL [_samplePos, _checkPos]}) then { - if(_samplePos distance _testPos < 2) then { - _spot pushBack _samplePos; - } else { - _outliers pushBack _samplePos; - }; - }; + _samplePos = _x select 0; + if(!lineIntersects [_samplePos, _checkPos] && {!terrainIntersectASL [_samplePos, _checkPos]}) then { + if(_samplePos distance _testPos < 2) then { + _spot pushBack _samplePos; + } else { + _outliers pushBack _samplePos; + }; + }; } forEach _list; _spots pushBack _spot; if(count _outliers > 0) then { - for "_i" from 1 to 3 do { - _remainingSpots = _outliers; - _outliers = []; - _spot = []; - _testPos = (_remainingSpots select 0); - { - _samplePos = _x; - if(!lineIntersects [_samplePos, _checkPos] && {!terrainIntersectASL [_samplePos, _checkPos]}) then { - if(_samplePos distance _testPos < 2) then { - _spot pushBack _samplePos; - } else { - _outliers pushBack _samplePos; - }; - }; - } forEach _remainingSpots; - _spots pushBack _spot; - }; + for "_i" from 1 to 3 do { + _remainingSpots = _outliers; + _outliers = []; + _spot = []; + _testPos = (_remainingSpots select 0); + { + _samplePos = _x; + if(!lineIntersects [_samplePos, _checkPos] && {!terrainIntersectASL [_samplePos, _checkPos]}) then { + if(_samplePos distance _testPos < 2) then { + _spot pushBack _samplePos; + } else { + _outliers pushBack _samplePos; + }; + }; + } forEach _remainingSpots; + _spots pushBack _spot; + }; }; _largest = 0; _largestSpot = []; { - if((count _x) > _largest) then { - _largest = (count _x); - _largestSpot = _x; - }; + if((count _x) > _largest) then { + _largest = (count _x); + _largestSpot = _x; + }; } forEach _spots; // player sideChat format["g: %1", _spots]; _largestSpot select (random (floor(count _largestSpot))); \ No newline at end of file diff --git a/addons/laser/functions/fnc_laserTargetPFH.sqf b/addons/laser/functions/fnc_laserTargetPFH.sqf index bf526f464e..bdab413685 100644 --- a/addons/laser/functions/fnc_laserTargetPFH.sqf +++ b/addons/laser/functions/fnc_laserTargetPFH.sqf @@ -6,8 +6,8 @@ _args = _this select 0; _laserTarget = _args select 0; if(isNull _laserTarget || !alive player) exitWith { - [(_this select 1)] call cba_fnc_removePerFrameHandler; - REM(ACE_LASERS, _laserTarget); + [(_this select 1)] call cba_fnc_removePerFrameHandler; + REM(ACE_LASERS, _laserTarget); }; _end = diag_tickTime; @@ -18,8 +18,8 @@ _pos = [_laserTarget] call FUNC(getPosASL); drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\select_target_ca.paa", [1,0,0,1], (ASLtoATL _pos), 0.75, 0.75, 0, "", 0.5, 0.025, "TahomaB"]; { - drawLine3D [ASLtoATL (_x select 0), ASLtoATL (_x select 1), (_x select 2)]; - drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", (_x select 2), ASLtoATL (_x select 1), 0.75, 0.75, 0, "", 0.5, 0.025, "TahomaB"]; + drawLine3D [ASLtoATL (_x select 0), ASLtoATL (_x select 1), (_x select 2)]; + drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", (_x select 2), ASLtoATL (_x select 1), 0.75, 0.75, 0, "", 0.5, 0.025, "TahomaB"]; } forEach DRAW_LINES; DRAW_LINES = []; #endif diff --git a/addons/laser/functions/fnc_laser_init.sqf b/addons/laser/functions/fnc_laser_init.sqf index 4c6b0b5f2a..9fcb439032 100644 --- a/addons/laser/functions/fnc_laser_init.sqf +++ b/addons/laser/functions/fnc_laser_init.sqf @@ -16,10 +16,10 @@ REM(ACE_LASERS, objNull); if(!(local _laserTarget)) exitWith { }; // The target is local, so its on this client if(!isDedicated) then { - _laserTarget setVariable ["ACE_LASERTARGET_SHOOTER", player, true]; - - [FUNC(laserTargetPFH), 0, [_laserTarget, player]] call cba_fnc_addPerFrameHandler; + _laserTarget setVariable ["ACE_LASERTARGET_SHOOTER", player, true]; + + [FUNC(laserTargetPFH), 0, [_laserTarget, player]] call cba_fnc_addPerFrameHandler; } else { - // server side ownership of laser - //_laserTarget setVariable ["ACE_LASERTARGET_SHOOTER", nil, false]; + // server side ownership of laser + //_laserTarget setVariable ["ACE_LASERTARGET_SHOOTER", nil, false]; }; diff --git a/addons/laser/functions/fnc_shootCone.sqf b/addons/laser/functions/fnc_shootCone.sqf index 8d2d7fef66..e33edd10bc 100644 --- a/addons/laser/functions/fnc_shootCone.sqf +++ b/addons/laser/functions/fnc_shootCone.sqf @@ -17,50 +17,50 @@ _vecRotateMap = [_cp, _p1, _p2] call FUNC(rotateVectLineGetMap); _result = [_pos, _vec] call FUNC(shootRay); _resultPos = _result select 0; if(!isNil "_resultPos") then { - _distance = _result select 1; - if(_distance < _shortestReturn) then { - _shortestReturn = _distance; - }; - if(_distance > _longestReturn) then { - _longestReturn = _distance; - }; - _resultPositions set[(count _resultPositions), _result]; + _distance = _result select 1; + if(_distance < _shortestReturn) then { + _shortestReturn = _distance; + }; + if(_distance > _longestReturn) then { + _longestReturn = _distance; + }; + _resultPositions set[(count _resultPositions), _result]; #ifdef DEBUG_MODE_FULL - DRAW_LINES set[(count DRAW_LINES), [_pos, _resultPos, [0, 1, 0, 1]]]; + DRAW_LINES set[(count DRAW_LINES), [_pos, _resultPos, [0, 1, 0, 1]]]; #endif }; _count = 8; _pos2 = [ - (_pos select 0)+((_vec select 0)*1000), - (_pos select 1)+((_vec select 1)*1000), - (_pos select 2)+((_vec select 2)*1000) - ]; + (_pos select 0)+((_vec select 0)*1000), + (_pos select 1)+((_vec select 1)*1000), + (_pos select 2)+((_vec select 2)*1000) + ]; { - for "_i" from 0 to ceil(_count*_x) do { - _radOffset = random 360; - _offset = [_vecRotateMap, (((360/_count)*_i)+_radOffset) mod 360] call FUNC(rotateVectLine); - _offsetPos = [ - (_pos2 select 0)+((_offset select 0)*(_divergence*_x)), - (_pos2 select 1)+((_offset select 1)*(_divergence*_x)), - (_pos2 select 2)+((_offset select 2)*(_divergence*_x)) - ]; - _offsetVector = [_pos, _offsetPos] call BIS_fnc_vectorFromXtoY; - _result = [_pos, _offsetVector] call FUNC(shootRay); - _resultPos = _result select 0; - if(!isNil "_resultPos") then { - _distance = _result select 1; - if(_distance < _shortestReturn) then { - _shortestReturn = _distance; - }; - if(_distance > _longestReturn) then { - _longestReturn = _distance; - }; - _resultPositions set[(count _resultPositions), _result]; + for "_i" from 0 to ceil(_count*_x) do { + _radOffset = random 360; + _offset = [_vecRotateMap, (((360/_count)*_i)+_radOffset) mod 360] call FUNC(rotateVectLine); + _offsetPos = [ + (_pos2 select 0)+((_offset select 0)*(_divergence*_x)), + (_pos2 select 1)+((_offset select 1)*(_divergence*_x)), + (_pos2 select 2)+((_offset select 2)*(_divergence*_x)) + ]; + _offsetVector = [_pos, _offsetPos] call BIS_fnc_vectorFromXtoY; + _result = [_pos, _offsetVector] call FUNC(shootRay); + _resultPos = _result select 0; + if(!isNil "_resultPos") then { + _distance = _result select 1; + if(_distance < _shortestReturn) then { + _shortestReturn = _distance; + }; + if(_distance > _longestReturn) then { + _longestReturn = _distance; + }; + _resultPositions set[(count _resultPositions), _result]; #ifdef DEBUG_MODE_FULL - DRAW_LINES set[(count DRAW_LINES), [_pos, _resultPos, [0, 1, 0, 1]]]; + DRAW_LINES set[(count DRAW_LINES), [_pos, _resultPos, [0, 1, 0, 1]]]; #endif - }; - }; + }; + }; } forEach [1,0.5,0.25]; [_longestReturn, _shortestReturn, _resultPositions]; \ No newline at end of file diff --git a/addons/laser/functions/fnc_shootRay.sqf b/addons/laser/functions/fnc_shootRay.sqf index 768194e351..62847d16b6 100644 --- a/addons/laser/functions/fnc_shootRay.sqf +++ b/addons/laser/functions/fnc_shootRay.sqf @@ -9,22 +9,22 @@ _resultPos = nil; _fidelity = [1000,100,10,1,0.1]; _lastPos = +_pos; { - scopeName "mainSearch"; - for "_i" from 1 to 10 do { - _nextPos = [ - (_lastPos select 0)+((_vec select 0)*_x), - (_lastPos select 1)+((_vec select 1)*_x), - (_lastPos select 2)+((_vec select 2)*_x) - ]; - - if(lineIntersects [_lastPos, _nextPos] || terrainIntersectASL [_lastPos, _nextPos]) then { - _resultPos = _lastPos; - breakTo "mainSearch"; - } else { - _distance = _distance + _x; - _lastPos = _nextPos; - }; - }; + scopeName "mainSearch"; + for "_i" from 1 to 10 do { + _nextPos = [ + (_lastPos select 0)+((_vec select 0)*_x), + (_lastPos select 1)+((_vec select 1)*_x), + (_lastPos select 2)+((_vec select 2)*_x) + ]; + + if(lineIntersects [_lastPos, _nextPos] || terrainIntersectASL [_lastPos, _nextPos]) then { + _resultPos = _lastPos; + breakTo "mainSearch"; + } else { + _distance = _distance + _x; + _lastPos = _nextPos; + }; + }; } forEach _fidelity; [_resultPos, _distance]; \ No newline at end of file diff --git a/addons/laser/functions/fnc_translateToWeaponSpace.sqf b/addons/laser/functions/fnc_translateToWeaponSpace.sqf index 406d81b145..2c7dc5e6da 100644 --- a/addons/laser/functions/fnc_translateToWeaponSpace.sqf +++ b/addons/laser/functions/fnc_translateToWeaponSpace.sqf @@ -14,9 +14,9 @@ _y = _offset select 1; _z = _offset select 2; _out = [ - ((_xVec select 0)*_x) + ((_xVec select 1)*_y) + ((_xVec select 2)*_z), - ((_yVec select 0)*_x) + ((_yVec select 1)*_y) + ((_yVec select 2)*_z), - ((_zVec select 0)*_x) + ((_zVec select 1)*_y) + ((_zVec select 2)*_z) - ]; + ((_xVec select 0)*_x) + ((_xVec select 1)*_y) + ((_xVec select 2)*_z), + ((_yVec select 0)*_x) + ((_yVec select 1)*_y) + ((_yVec select 2)*_z), + ((_zVec select 0)*_x) + ((_zVec select 1)*_y) + ((_zVec select 2)*_z) + ]; _out; \ No newline at end of file diff --git a/addons/laser/script_component.hpp b/addons/laser/script_component.hpp index afca689204..2be1e9e14b 100644 --- a/addons/laser/script_component.hpp +++ b/addons/laser/script_component.hpp @@ -2,11 +2,11 @@ #include "\z\ace\Addons\main\script_mod.hpp" #ifdef DEBUG_ENABLED_LASER - #define DEBUG_MODE_FULL + #define DEBUG_MODE_FULL #endif #ifdef DEBUG_SETTINGS_LASER - #define DEBUG_SETTINGS DEBUG_SETTINGS_LASER + #define DEBUG_SETTINGS DEBUG_SETTINGS_LASER #endif #include "\z\ace\Addons\main\script_macros.hpp" diff --git a/addons/laser_selfdesignate/CfgEventhandlers.hpp b/addons/laser_selfdesignate/CfgEventhandlers.hpp index ea33d05bcb..953687bb2b 100644 --- a/addons/laser_selfdesignate/CfgEventhandlers.hpp +++ b/addons/laser_selfdesignate/CfgEventhandlers.hpp @@ -13,7 +13,7 @@ class Extended_PostInit_EventHandlers { class Extended_GetIn_EventHandlers { class B_Heli_Attack_01_F { class ADDON { - getIn = QUOTE(call FUNC(onGetin)); + getIn = QUOTE(_this call FUNC(onGetin)); }; }; }; @@ -21,7 +21,7 @@ class Extended_GetIn_EventHandlers { class Extended_GetOut_EventHandlers { class B_Heli_Attack_01_F { class ADDON { - getOut = QUOTE(call FUNC(onGetout)); + getOut = QUOTE(_this call FUNC(onGetout)); }; }; }; diff --git a/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOff.sqf b/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOff.sqf index 088f3d9303..2f4c437d28 100644 --- a/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOff.sqf +++ b/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOff.sqf @@ -1,15 +1,15 @@ #include "script_component.hpp" if(isNil QGVAR(laser)) exitWith { - false + false }; if(!local GVAR(laser)) then { - false + false }; _handle = GVAR(laser) getVariable ["ACE_PFH_HANDLE", nil]; if(!isNil "_handle") then { - [_handle] call cba_fnc_removePerFrameHandler; + [_handle] call cba_fnc_removePerFrameHandler; }; REM(ACE_LASERS, GVAR(laser)); diff --git a/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOn.sqf b/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOn.sqf index bac440c853..a58284ee34 100644 --- a/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOn.sqf +++ b/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOn.sqf @@ -4,87 +4,94 @@ TRACE_1("enter", _this); FUNC(magnitude) = { - _this distance [0, 0, 0] + _this distance [0, 0, 0] }; FUNC(mat_normalize3d) = { - private ["_mag"]; - PARAMS_3(_vx,_vy,_vz); + private ["_mag"]; + PARAMS_3(_vx,_vy,_vz); - _mag = _this call FUNC(magnitude); - if (_mag == 0) then {_mag = 1}; - [(_vx/_mag), (_vy/_mag), (_vz/_mag)] + _mag = _this call FUNC(magnitude); + if (_mag == 0) then {_mag = 1}; + [(_vx/_mag), (_vy/_mag), (_vz/_mag)] }; FUNC(laserHudDesignatePFH) = { - _args = _this select 0; - _laserTarget = _args select 0; - _shooter = _args select 1; - - _vehicle = vehicle _shooter; - _weapon = currentWeapon _vehicle; - - if(!alive _shooter || isNull _vehicle || isNull _laserTarget || !GVAR(laserActive) ) exitWith { - [(_this select 1)] call cba_fnc_removePerFrameHandler; - }; - - // Retrieve the gunner and turret memory point information - _gunnerInfo = [_vehicle, _weapon] call CBA_fnc_getFirer; - - _turret = [_vehicle, _gunnerInfo select 1] call CBA_fnc_getTurret; - _pov = getText (_turret >> "memoryPointGunnerOptics"); - _gunBeg = getText (_turret >> "gunBeg"); - _gunEnd = getText (_turret >> "gunEnd"); - TRACE_3("", _pov, _gunBeg, _gunEnd); + private["_args", "_laserTarget", "_shooter", "_vehicle", "_weapon", "_gunnerInfo", "_turret", "_pov", "_gunBeg", "_gunEnd", "_povPos", "_povDir", "_result", "_resultPositions", "_firstResult"]; + _args = _this select 0; + _laserTarget = _args select 0; + _shooter = _args select 1; + + _vehicle = vehicle _shooter; + _weapon = currentWeapon _vehicle; + + TRACE_1("", _args); + + if(!alive _shooter || isNull _vehicle || isNull _laserTarget || !GVAR(laserActive) ) exitWith { + [(_this select 1)] call cba_fnc_removePerFrameHandler; + }; + + // Retrieve the gunner and turret memory point information + _gunnerInfo = [_vehicle, _weapon] call CBA_fnc_getFirer; + + _turret = [_vehicle, _gunnerInfo select 1] call CBA_fnc_getTurret; + _pov = getText (_turret >> "memoryPointGunnerOptics"); + _gunBeg = getText (_turret >> "gunBeg"); + _gunEnd = getText (_turret >> "gunEnd"); + TRACE_3("", _pov, _gunBeg, _gunEnd); - // Pull the PIP pov or barrel direction, depending on how the model is set up - _povPos = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition _pov ) ); - _povDir = [0,0,0]; - if(_pov == "pip0_pos") then { - _pipDir = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition "pip0_dir" ) ); - _povDir = [_povPos, _pipDir] call BIS_fnc_vectorDiff; - } else { - _gunBeginPos = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition _gunBeg ) ); - _gunEndPos = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition _gunEnd ) ); - _povDir = [_gunEndPos, _gunBeginPos] call BIS_fnc_vectorDiff; - }; - - TRACE_4("", _povDir, _povPos, _gunBeginPos, _gunEndPos); - - _result = [_povPos, _povDir] call EFUNC(laser,shootCone); - - if((count _result) > 0) then { - _resultPositions = _result select 2; + // Pull the PIP pov or barrel direction, depending on how the model is set up + _povPos = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition _pov ) ); + _povDir = [0,0,0]; + if(_pov == "pip0_pos") then { + _pipDir = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition "pip0_dir" ) ); + _povDir = [_povPos, _pipDir] call BIS_fnc_vectorDiff; + } else { + _gunBeginPos = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition _gunBeg ) ); + _gunEndPos = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition _gunEnd ) ); + _povDir = [_gunEndPos, _gunBeginPos] call BIS_fnc_vectorDiff; + }; + + TRACE_4("", _povDir, _povPos, _gunBeginPos, _gunEndPos); + + _result = [_povPos, _povDir] call EFUNC(laser,shootCone); + + if((count _result) > 0) then { + _resultPositions = _result select 2; - if((count _resultPositions) > 0) then { - _firstResult = _resultPositions select 0; - _pos = _firstResult select 0; - - // If the laser has moved less than a half meter, then dont move it. - // Just regular use of lasers will commonly make them move this much, - // but not across multiple close frames. - // This loses accuracy a little, but saves position updates per frame. - //if( ((getPosASL _laserTarget) distance _pos) > 0.5) then { - _laserTarget setPosATL (ASLToATL _pos); - //}; + if((count _resultPositions) > 0) then { + _firstResult = _resultPositions select 0; + _pos = _firstResult select 0; + + // If the laser has moved less than a half meter, then dont move it. + // Just regular use of lasers will commonly make them move this much, + // but not across multiple close frames. + // This loses accuracy a little, but saves position updates per frame. + //if( ((getPosASL _laserTarget) distance _pos) > 0.5) then { + _laserTarget setPosATL (ASLToATL _pos); + //}; #ifdef DEBUG_MODE_FULL - drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], ASLToATL _pos, 0.75, 0.75, 0, "", 0.5, 0.025, "TahomaB"]; + drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], ASLToATL _pos, 0.75, 0.75, 0, "", 0.5, 0.025, "TahomaB"]; #endif - }; - }; + }; + }; }; +private "_laserTarget"; +private "_handle"; + if(isNil QGVAR(laser)) then { - _laserTarget = "LaserTarget" createVehicle (getpos player); - - GVAR(laserActive) = true; - - _handle = [FUNC(laserHudDesignatePFH), 0, [_laserTarget, player]] call cba_fnc_addPerFrameHandler; - _laserTarget setVariable ["ACE_PFH_HANDLE", _handle, false]; - - GVAR(laser) = _laserTarget; + + _laserTarget = "LaserTargetW" createVehicle (getpos player); + + GVAR(laserActive) = true; + + _handle = [FUNC(laserHudDesignatePFH), 0, [_laserTarget, player]] call cba_fnc_addPerFrameHandler; + _laserTarget setVariable ["ACE_PFH_HANDLE", _handle, false]; + + GVAR(laser) = _laserTarget; } else { - [] call FUNC(laserHudDesignateOff); - [] call FUNC(laserHudDesignateOn); + [] call FUNC(laserHudDesignateOff); + [] call FUNC(laserHudDesignateOn); }; diff --git a/addons/laser_selfdesignate/script_component.hpp b/addons/laser_selfdesignate/script_component.hpp index c9742423df..46e9c48d2f 100644 --- a/addons/laser_selfdesignate/script_component.hpp +++ b/addons/laser_selfdesignate/script_component.hpp @@ -2,11 +2,11 @@ #include "\z\ace\Addons\main\script_mod.hpp" #ifdef DEBUG_ENABLED_LASER_SELFDESIGNATE - #define DEBUG_MODE_FULL + #define DEBUG_MODE_FULL #endif #ifdef DEBUG_SETTINGS_LASER_SELFDESIGNATE - #define DEBUG_SETTINGS DEBUG_SETTINGS_LASER_SELFDESIGNATE + #define DEBUG_SETTINGS DEBUG_SETTINGS_LASER_SELFDESIGNATE #endif #include "\z\ace\Addons\main\script_macros.hpp" diff --git a/addons/missileguidance/CfgAmmo.hpp b/addons/missileguidance/CfgAmmo.hpp index 1fdd580724..df876ae2ae 100644 --- a/addons/missileguidance/CfgAmmo.hpp +++ b/addons/missileguidance/CfgAmmo.hpp @@ -1,10 +1,10 @@ class CfgAmmo { - class MissileBase; - - class M_PG_AT : MissileBase { - irLock = 0; - laserLock = 0; - airLock = 0; - manualControl = 0; - }; + class MissileBase; + + class M_PG_AT : MissileBase { + irLock = 0; + laserLock = 0; + airLock = 0; + manualControl = 0; + }; }; \ No newline at end of file diff --git a/addons/missileguidance/CfgEventhandlers.hpp b/addons/missileguidance/CfgEventhandlers.hpp index faa5edef0b..2775490d11 100644 --- a/addons/missileguidance/CfgEventhandlers.hpp +++ b/addons/missileguidance/CfgEventhandlers.hpp @@ -1,17 +1,17 @@ class Extended_PreInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_pre_init)); - }; + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_pre_init)); + }; }; class Extended_PostInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_post_init)); - }; + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_post_init)); + }; }; class Extended_FiredBIS_EventHandlers { - class AllVehicles { - ADDON = QUOTE(_this call FUNC(fired)); - }; + class AllVehicles { + ADDON = QUOTE(_this call FUNC(fired)); + }; }; \ No newline at end of file diff --git a/addons/missileguidance/CfgWeapons.hpp b/addons/missileguidance/CfgWeapons.hpp index d2961604b6..739ef3c5e0 100644 --- a/addons/missileguidance/CfgWeapons.hpp +++ b/addons/missileguidance/CfgWeapons.hpp @@ -1,34 +1,34 @@ class Mode_SemiAuto; class CfgWeapons { - class CannonCore; - class LauncherCore; - - class RocketPods: LauncherCore { - canLock = 1; - }; - class missiles_DAGR: RocketPods { - canLock = 1; - }; - /* - class autocannon_Base_F: CannonCore { - canLock = 1; - }; - class cannon_120mm: CannonCore { - canLock = 1; - - class player : Mode_SemiAuto { - canLock = 1; - }; - }; - class gatling_25mm: CannonCore { - canLock = 1; - }; - class autocannon_35mm: CannonCore { - canLock = 1; - }; - - class launch_NLAW_F: Launcher_Base_F - { - canLock = 1; - };*/ + class CannonCore; + class LauncherCore; + + class RocketPods: LauncherCore { + canLock = 1; + }; + class missiles_DAGR: RocketPods { + canLock = 1; + }; + /* + class autocannon_Base_F: CannonCore { + canLock = 1; + }; + class cannon_120mm: CannonCore { + canLock = 1; + + class player : Mode_SemiAuto { + canLock = 1; + }; + }; + class gatling_25mm: CannonCore { + canLock = 1; + }; + class autocannon_35mm: CannonCore { + canLock = 1; + }; + + class launch_NLAW_F: Launcher_Base_F + { + canLock = 1; + };*/ }; \ No newline at end of file diff --git a/addons/missileguidance/config.cpp b/addons/missileguidance/config.cpp index 6720559ccc..9c5842a065 100644 --- a/addons/missileguidance/config.cpp +++ b/addons/missileguidance/config.cpp @@ -1,13 +1,13 @@ #include "script_component.hpp" class CfgPatches { - class ADDON { - units[] = {}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = { "ace_common", "ace_laser" }; - VERSION_CONFIG; - }; + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = { "ace_common", "ace_laser" }; + VERSION_CONFIG; + }; }; #include "CfgEventhandlers.hpp" diff --git a/addons/missileguidance/functions/fnc_fired.sqf b/addons/missileguidance/functions/fnc_fired.sqf index 3b4f4b3635..dbe6abfec7 100644 --- a/addons/missileguidance/functions/fnc_fired.sqf +++ b/addons/missileguidance/functions/fnc_fired.sqf @@ -7,12 +7,12 @@ PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); if(!local _shooter) exitWith { false }; switch _weapon do { - case "missiles_DAGR": { - _this call FUNC(guidance_DAGR); - }; - case "GBU12BombLauncher": { - _this call FUNC(guidance_LGB); - }; + case "missiles_DAGR": { + _this call FUNC(guidance_DAGR); + }; + case "GBU12BombLauncher": { + _this call FUNC(guidance_LGB); + }; }; //_this call FUNC(guidance_HellfireII); diff --git a/addons/missileguidance/functions/fnc_guidance_DAGR.sqf b/addons/missileguidance/functions/fnc_guidance_DAGR.sqf index 4461c1223f..3bef324931 100644 --- a/addons/missileguidance/functions/fnc_guidance_DAGR.sqf +++ b/addons/missileguidance/functions/fnc_guidance_DAGR.sqf @@ -2,112 +2,119 @@ #include "script_component.hpp" FUNC(guidance_DIRECT_LOAL_PFH) = { - //TRACE_1("enter", _this); - _args = _this select 0; - //PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); - _shooter = _args select 0; - _dagr = _args select 6; - _curVelocity = velocity _dagr; - - if(!alive _dagr || isNull _dagr || isNull _shooter) exitWith { - [(_this select 1)] call cba_fnc_removePerFrameHandler; - }; - - _targets = [_dagr, ACE_DEFAULT_LASER_CODE, 70, _curVelocity] call ace_laser_fnc_findLaserDesignator; - TRACE_2("Targets", _target, _targets); - - if((_targets select 0)) then { - _target = _targets select 1; - - // player sideChat "FUCK!"; - // drop ["\a3\data_f\Cl_basic","","Billboard",1,20,(getPos _dagr),[0,0,0],1,1.275,1.0,0.0,[5],[[1,0,0,1]],[0],0.0,2.0,"","",""]; - - - _yVec = vectorDir _dagr; - _zVec = vectorUp _dagr; - _xVec = vectorNormalized (_yVec vectorCrossProduct _zVec); - - _dagrPos = getPosASL _dagr; - // player sideChat "G!"; - _targetPos = getPosASL _target; - if((count _targetPos) > 0) then { - _distanceToTarget = _dagrPos vectorDistance _targetPos; - - _addHeight = [0,0,(_dagrPos distance _targetPos)*0.02]; - #ifdef DEBUG_MODE_FULL - drawLine3D [(ASLtoATL _targetPos) vectorAdd _addHeight, ASLtoATL _targetPos, [0,1,0,1]]; - #endif - - _targetPos = _targetPos vectorAdd _addHeight; + //TRACE_1("enter", _this); + private["_args", "_shooter", "_dagr", "_curVelocity", "_targets", "_target", "_yVec", "_xVec", "_zVec", "_dagrPos", "_shooterPos", "_distanceToTarget", "_distanceToShooter", "_def"]; + _args = _this select 0; + //PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); + _shooter = _args select 0; + _dagr = _args select 6; + _curVelocity = velocity _dagr; + + if(!alive _dagr || isNull _dagr || isNull _shooter) exitWith { + [(_this select 1)] call cba_fnc_removePerFrameHandler; + }; + + _targets = [_dagr, ACE_DEFAULT_LASER_CODE, 70, _curVelocity] call ace_laser_fnc_findLaserDesignator; + TRACE_2("Targets", _target, _targets); + + if((_targets select 0)) then { + _target = _targets select 1; + + // player sideChat "FUCK!"; + // drop ["\a3\data_f\Cl_basic","","Billboard",1,20,(getPos _dagr),[0,0,0],1,1.275,1.0,0.0,[5],[[1,0,0,1]],[0],0.0,2.0,"","",""]; + + + _yVec = vectorDir _dagr; + _zVec = vectorUp _dagr; + _xVec = vectorNormalized (_yVec vectorCrossProduct _zVec); + + _dagrPos = getPosASL _dagr; + // player sideChat "G!"; + _targetPos = getPosASL _target; + _shooterPos = getPosASL _shooter; + + if((count _targetPos) > 0) then { + _distanceToTarget = _dagrPos vectorDistance _targetPos; + _distanceToShooter = _dagrPos vectorDistance _shooterPos; + + _addHeight = [0,0,(_dagrPos distance _targetPos)*0.02]; + #ifdef DEBUG_MODE_FULL + drawLine3D [(ASLtoATL _targetPos) vectorAdd _addHeight, ASLtoATL _targetPos, [0,1,0,1]]; + #endif + + _targetPos = _targetPos vectorAdd _addHeight; - _def = 0.0050; - - _targetVectorSeeker = [_dagr, [_xVec, _yVec, _zVec], _targetPos] call FUNC(translateToWeaponSpace); - // _targetVectorSeeker = _dagr worldToModel (ASLtoATL _targetPos); - // _targetVectorSeeker = [0,0,0] vectorFromTo _targetVectorSeeker; - _yaw = 0.0; - if((_targetVectorSeeker select 0) < 0) then { - _yaw = -_def; - } else { - if((_targetVectorSeeker select 0) > 0) then { - _yaw = _def; - }; - }; - - _pitch = 0.0; - if((_targetVectorSeeker select 2) < 0) then { - _pitch = -_def; - } else { - if((_targetVectorSeeker select 2) > 0) then { - _pitch = _def; - }; - }; - #ifdef DEBUG_MODE_FULL - drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,1,1,1], ASLtoATL _dagrPos, 0.75, 0.75, 0, str _vectorTo, 1, 0.025, "TahomaB"]; - drawLine3D [ASLtoATL _dagrPos, ASLtoATL _targetPos, [1,0,0,1]]; - - _distance = ([getPos startPos, _dagrPos] call BIS_fnc_distance2D); - _marker = createMarkerLocal [format["m%1", MARKERCOUNT], [_distance, _dagrPos select 2]]; - _marker setMarkerTypeLocal "mil_dot"; - _marker setMarkerColorLocal "ColorRed"; + _def = 0.0030; + if(_distanceToShooter > 100) then { + _def = 0.0020; + }; + + _targetVectorSeeker = [_dagr, [_xVec, _yVec, _zVec], _targetPos] call FUNC(translateToWeaponSpace); + // _targetVectorSeeker = _dagr worldToModel (ASLtoATL _targetPos); + // _targetVectorSeeker = [0,0,0] vectorFromTo _targetVectorSeeker; + _yaw = 0.0; + if((_targetVectorSeeker select 0) < 0) then { + _yaw = -_def; + } else { + if((_targetVectorSeeker select 0) > 0) then { + _yaw = _def; + }; + }; + + _pitch = 0.0; + if((_targetVectorSeeker select 2) < 0) then { + _pitch = -_def; + } else { + if((_targetVectorSeeker select 2) > 0) then { + _pitch = _def; + }; + }; + #ifdef DEBUG_MODE_FULL + drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,1,1,1], ASLtoATL _dagrPos, 0.75, 0.75, 0, str _vectorTo, 1, 0.025, "TahomaB"]; + drawLine3D [ASLtoATL _dagrPos, ASLtoATL _targetPos, [1,0,0,1]]; + + _distance = ([getPos startPos, _dagrPos] call BIS_fnc_distance2D); + _marker = createMarkerLocal [format["m%1", MARKERCOUNT], [_distance, _dagrPos select 2]]; + _marker setMarkerTypeLocal "mil_dot"; + _marker setMarkerColorLocal "ColorRed"; - MARKERCOUNT = MARKERCOUNT + 1; - #endif - - if(accTime > 0) then { - _outVector = [_dagr, [_xVec, _yVec, _zVec], [_yaw, 1/accTime, _pitch]] call FUNC(translateToModelSpace); - // _outVector = _dagr modelToWorld [_yaw, 1, _pitch]; - // _outVector = ATLtoASL _outVector; - _vectorTo = _dagrPos vectorFromTo _outVector; - - // hintSilent format["v: %1", _vectorTo]; - - // _dagr setVectorDir _vectorTo; - _dagr setVectorDirAndUp [_vectorTo, vectorUp _dagr]; - }; - - #ifdef DEBUG_MODE_FULL - hintSilent format["d: %1", _distanceToTarget]; - #endif - }; - }; + MARKERCOUNT = MARKERCOUNT + 1; + #endif + + if(accTime > 0) then { + _outVector = [_dagr, [_xVec, _yVec, _zVec], [_yaw, 1/accTime, _pitch]] call FUNC(translateToModelSpace); + // _outVector = _dagr modelToWorld [_yaw, 1, _pitch]; + // _outVector = ATLtoASL _outVector; + _vectorTo = _dagrPos vectorFromTo _outVector; + + // hintSilent format["v: %1", _vectorTo]; + + // _dagr setVectorDir _vectorTo; + _dagr setVectorDirAndUp [_vectorTo, vectorUp _dagr]; + }; + + #ifdef DEBUG_MODE_FULL + hintSilent format["d: %1", _distanceToTarget]; + #endif + }; + }; }; FUNC(guidance_DAGR_DIRECT_LOAL) = { - PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); - - GVAR(lastTime) = time; - [FUNC(guidance_DIRECT_LOAL_PFH), 0, _this] call cba_fnc_addPerFrameHandler; + PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); + + GVAR(lastTime) = time; + [FUNC(guidance_DIRECT_LOAL_PFH), 0, _this] call cba_fnc_addPerFrameHandler; }; PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); _fireMode = _shooter getVariable ["ACE_FIRE_SELECTION", ACE_DEFAULT_FIRE_SELECTION]; switch (_fireMode select 0) do { - // Default to FIREMODE_DIRECT_LOAL - // FIREMODE_DIRECT_LOAL - default { - LOG("Initiating DAGR FIREMODE_DIRECT_LOAL"); - _this call FUNC(guidance_DAGR_DIRECT_LOAL); - }; + // Default to FIREMODE_DIRECT_LOAL + // FIREMODE_DIRECT_LOAL + default { + LOG("Initiating DAGR FIREMODE_DIRECT_LOAL"); + _this call FUNC(guidance_DAGR_DIRECT_LOAL); + }; }; \ No newline at end of file diff --git a/addons/missileguidance/functions/fnc_guidance_HellfireII.sqf b/addons/missileguidance/functions/fnc_guidance_HellfireII.sqf index e6551ad4f4..72b8da8c67 100644 --- a/addons/missileguidance/functions/fnc_guidance_HellfireII.sqf +++ b/addons/missileguidance/functions/fnc_guidance_HellfireII.sqf @@ -2,248 +2,248 @@ #include "script_component.hpp" FUNC(guidance_Hellfire_LOAL_HI_PFH) = { - //TRACE_1("enter", _this); - _args = _this select 0; - //PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); - _shooter = _args select 0; - _missile = _args select 6; - _curVelocity = velocity _missile; - - if(!alive _missile || isNull _missile || isNull _shooter) exitWith { - [(_this select 1)] call cba_fnc_removePerFrameHandler; - }; - - _launchPos = _shooter getVariable [QGVAR(launchPos), nil]; - if(isNil "_launchPos") then { - TRACE_1("Setting launch parameters", ""); - _launchPos = getPosASL _shooter; - _shooter setVariable [QGVAR(launchPos), _launchPos, false]; - _shooter setVariable [QGVAR(launchTime), diag_tickTime, false]; - }; - - _targets = [_missile, ACE_DEFAULT_LASER_CODE, 70, _curVelocity] call ace_laser_fnc_findLaserDesignator; - _addHeight = [0,0,0]; - if((_targets select 0)) then { - _target = _targets select 1; - TRACE_2("Targets", _target, _targets); - - _yVec = vectorDir _missile; - _zVec = vectorUp _missile; - _xVec = vectorNormalized (_yVec vectorCrossProduct _zVec); - - _missilePos = getPosASL _missile; - // player sideChat "G!"; - _targetPos = getPosASL _target; - TRACE_4("Phase Check", _launchPos, _missilePos, _targetPos, (_missilePos distance _targetPos)); - if((count _targetPos) > 0) then { - _distanceToTarget = _missilePos vectorDistance _targetPos; - - _defPitch = 0.05; - - if((_launchPos distance _missilePos) < 400 && (_targetPos distance _missilePos) > 400) then { - _addHeight = [0,0,(_targetPos select 2) + ((_launchPos distance _targetPos)*2)]; - TRACE_1("Climb phase", _addHeight); - //_defPitch = 0.1; - } else { - // Covered half the distance, go terminal - if((_missilePos distance _targetPos) < (_launchPos distance _targetPos) / 2) then { - TRACE_1("TERMINAL", ""); - } else { - if((_missilePos select 2) > (_targetPos select 2)) then { - _heightDiff = (_missilePos select 2) - (_targetPos select 2); - TRACE_1("Coasting", _heightDiff); - _addHeight = [0,0, _heightDiff]; - }; - }; - }; - _targetPos = _targetPos vectorAdd _addHeight; - - _defYaw = 0.0035; - - - _targetVectorSeeker = [_missile, [_xVec, _yVec, _zVec], _targetPos] call FUNC(translateToWeaponSpace); - _yaw = 0.0; - if((_targetVectorSeeker select 0) < 0) then { - _yaw = -_defYaw; - } else { - if((_targetVectorSeeker select 0) > 0) then { - _yaw = _defYaw; - }; - }; - - _pitch = 0.0; - if((_targetVectorSeeker select 2) < 0) then { - _pitch = -_defPitch; - } else { - if((_targetVectorSeeker select 2) > 0) then { - _pitch = _defPitch; - }; - }; - #ifdef DEBUG_MODE_FULL - drawLine3D [(ASLtoATL _targetPos) vectorAdd _addHeight, ASLtoATL _targetPos, [0,1,0,1]]; - - _light = "#lightpoint" createVehicleLocal (getPos _missile); - _light setLightBrightness 1.0; - _light setLightAmbient [1.0, 0.0, 0.0]; - _light setLightColor [1.0, 0.0, 0.0]; - - drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,1,1,1], ASLtoATL _missilePos, 0.75, 0.75, 0, str _vectorTo, 1, 0.025, "TahomaB"]; - drawLine3D [ASLtoATL _missilePos, ASLtoATL _targetPos, [1,0,0,1]]; - - _distance = ([getPos startPos, _missilePos] call BIS_fnc_distance2D); - _marker = createMarkerLocal [format["m%1", MARKERCOUNT], [_distance, _missilePos select 2]]; - _marker setMarkerTypeLocal "mil_dot"; - _marker setMarkerColorLocal "ColorRed"; + //TRACE_1("enter", _this); + _args = _this select 0; + //PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); + _shooter = _args select 0; + _missile = _args select 6; + _curVelocity = velocity _missile; + + if(!alive _missile || isNull _missile || isNull _shooter) exitWith { + [(_this select 1)] call cba_fnc_removePerFrameHandler; + }; + + _launchPos = _shooter getVariable [QGVAR(launchPos), nil]; + if(isNil "_launchPos") then { + TRACE_1("Setting launch parameters", ""); + _launchPos = getPosASL _shooter; + _shooter setVariable [QGVAR(launchPos), _launchPos, false]; + _shooter setVariable [QGVAR(launchTime), diag_tickTime, false]; + }; + + _targets = [_missile, ACE_DEFAULT_LASER_CODE, 70, _curVelocity] call ace_laser_fnc_findLaserDesignator; + _addHeight = [0,0,0]; + if((_targets select 0)) then { + _target = _targets select 1; + TRACE_2("Targets", _target, _targets); + + _yVec = vectorDir _missile; + _zVec = vectorUp _missile; + _xVec = vectorNormalized (_yVec vectorCrossProduct _zVec); + + _missilePos = getPosASL _missile; + // player sideChat "G!"; + _targetPos = getPosASL _target; + TRACE_4("Phase Check", _launchPos, _missilePos, _targetPos, (_missilePos distance _targetPos)); + if((count _targetPos) > 0) then { + _distanceToTarget = _missilePos vectorDistance _targetPos; + + _defPitch = 0.05; + + if((_launchPos distance _missilePos) < 400 && (_targetPos distance _missilePos) > 400) then { + _addHeight = [0,0,(_targetPos select 2) + ((_launchPos distance _targetPos)*2)]; + TRACE_1("Climb phase", _addHeight); + //_defPitch = 0.1; + } else { + // Covered half the distance, go terminal + if((_missilePos distance _targetPos) < (_launchPos distance _targetPos) / 2) then { + TRACE_1("TERMINAL", ""); + } else { + if((_missilePos select 2) > (_targetPos select 2)) then { + _heightDiff = (_missilePos select 2) - (_targetPos select 2); + TRACE_1("Coasting", _heightDiff); + _addHeight = [0,0, _heightDiff]; + }; + }; + }; + _targetPos = _targetPos vectorAdd _addHeight; + + _defYaw = 0.0035; + + + _targetVectorSeeker = [_missile, [_xVec, _yVec, _zVec], _targetPos] call FUNC(translateToWeaponSpace); + _yaw = 0.0; + if((_targetVectorSeeker select 0) < 0) then { + _yaw = -_defYaw; + } else { + if((_targetVectorSeeker select 0) > 0) then { + _yaw = _defYaw; + }; + }; + + _pitch = 0.0; + if((_targetVectorSeeker select 2) < 0) then { + _pitch = -_defPitch; + } else { + if((_targetVectorSeeker select 2) > 0) then { + _pitch = _defPitch; + }; + }; + #ifdef DEBUG_MODE_FULL + drawLine3D [(ASLtoATL _targetPos) vectorAdd _addHeight, ASLtoATL _targetPos, [0,1,0,1]]; + + _light = "#lightpoint" createVehicleLocal (getPos _missile); + _light setLightBrightness 1.0; + _light setLightAmbient [1.0, 0.0, 0.0]; + _light setLightColor [1.0, 0.0, 0.0]; + + drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,1,1,1], ASLtoATL _missilePos, 0.75, 0.75, 0, str _vectorTo, 1, 0.025, "TahomaB"]; + drawLine3D [ASLtoATL _missilePos, ASLtoATL _targetPos, [1,0,0,1]]; + + _distance = ([getPos startPos, _missilePos] call BIS_fnc_distance2D); + _marker = createMarkerLocal [format["m%1", MARKERCOUNT], [_distance, _missilePos select 2]]; + _marker setMarkerTypeLocal "mil_dot"; + _marker setMarkerColorLocal "ColorRed"; - MARKERCOUNT = MARKERCOUNT + 1; - #endif - - if(accTime > 0) then { - _outVector = [_missile, [_xVec, _yVec, _zVec], [_yaw, 1/accTime, _pitch]] call FUNC(translateToModelSpace); - - _vectorTo = _missilePos vectorFromTo _outVector; - _missile setVectorDirAndUp [_vectorTo, vectorUp _missile]; - }; - - #ifdef DEBUG_MODE_FULL - hintSilent format["d: %1", _distanceToTarget]; - #endif - }; - }; + MARKERCOUNT = MARKERCOUNT + 1; + #endif + + if(accTime > 0) then { + _outVector = [_missile, [_xVec, _yVec, _zVec], [_yaw, 1/accTime, _pitch]] call FUNC(translateToModelSpace); + + _vectorTo = _missilePos vectorFromTo _outVector; + _missile setVectorDirAndUp [_vectorTo, vectorUp _missile]; + }; + + #ifdef DEBUG_MODE_FULL + hintSilent format["d: %1", _distanceToTarget]; + #endif + }; + }; }; FUNC(guidance_Hellfire_LOAL_DIR_PFH) = { - //TRACE_1("enter", _this); - _args = _this select 0; - //PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); - _shooter = _args select 0; - _missile = _args select 6; - _curVelocity = velocity _missile; - - if(!alive _missile || isNull _missile || isNull _shooter) exitWith { - [(_this select 1)] call cba_fnc_removePerFrameHandler; - }; - - _launchPos = _shooter getVariable [QGVAR(launchPos), nil]; - if(isNil "_launchPos") then { - TRACE_1("Setting launch parameters", ""); - _launchPos = getPosASL _shooter; - _shooter setVariable [QGVAR(launchPos), _launchPos, false]; - _shooter setVariable [QGVAR(launchTime), diag_tickTime, false]; - }; - - _targets = [_missile, ACE_DEFAULT_LASER_CODE, 70, _curVelocity] call ace__laser_fnc_findLaserDesignator; - _addHeight = [0,0,0]; - if((_targets select 0)) then { - _target = _targets select 1; - TRACE_2("Targets", _target, _targets); - - _yVec = vectorDir _missile; - _zVec = vectorUp _missile; - _xVec = vectorNormalized (_yVec vectorCrossProduct _zVec); - - _missilePos = getPosASL _missile; - // player sideChat "G!"; - _targetPos = getPosASL _target; - TRACE_4("Phase Check", _launchPos, _missilePos, _targetPos, (_missilePos distance _targetPos)); - if((count _targetPos) > 0) then { - _distanceToTarget = _missilePos vectorDistance _targetPos; - - if((_launchPos distance _missilePos) < 400 && (_targetPos distance _missilePos) > 400) then { - _addHeight = [0,0,(_targetPos select 2) + (_missilePos distance _targetPos)*0.5]; - TRACE_1("Climb phase", _addHeight); - } else { - // Covered half the distance, go terminal - if((_missilePos distance _targetPos) < (_launchPos distance _targetPos) / 2) then { - TRACE_1("TERMINAL", ""); - } else { - if((_missilePos select 2) > (_targetPos select 2)) then { - _heightDiff = (_missilePos select 2) - (_targetPos select 2); - TRACE_1("Coasting", _heightDiff); - _addHeight = [0,0, _heightDiff]; - }; - }; - }; - _targetPos = _targetPos vectorAdd _addHeight; - - _defYaw = 0.0035; - _defPitch = 0.0075; - - _targetVectorSeeker = [_missile, [_xVec, _yVec, _zVec], _targetPos] call FUNC(translateToWeaponSpace); - _yaw = 0.0; - if((_targetVectorSeeker select 0) < 0) then { - _yaw = -_defYaw; - } else { - if((_targetVectorSeeker select 0) > 0) then { - _yaw = _defYaw; - }; - }; - - _pitch = 0.0; - if((_targetVectorSeeker select 2) < 0) then { - _pitch = -_defPitch; - } else { - if((_targetVectorSeeker select 2) > 0) then { - _pitch = _defPitch; - }; - }; - #ifdef DEBUG_MODE_FULL - drawLine3D [(ASLtoATL _targetPos) vectorAdd _addHeight, ASLtoATL _targetPos, [0,1,0,1]]; - - _light = "#lightpoint" createVehicleLocal (getPos _missile); - _light setLightBrightness 1.0; - _light setLightAmbient [1.0, 0.0, 0.0]; - _light setLightColor [1.0, 0.0, 0.0]; - - drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,1,1,1], ASLtoATL _missilePos, 0.75, 0.75, 0, str _vectorTo, 1, 0.025, "TahomaB"]; - drawLine3D [ASLtoATL _missilePos, ASLtoATL _targetPos, [1,0,0,1]]; - - _distance = ([getPos startPos, _missilePos] call BIS_fnc_distance2D); - _marker = createMarkerLocal [format["m%1", MARKERCOUNT], [_distance, _missilePos select 2]]; - _marker setMarkerTypeLocal "mil_dot"; - _marker setMarkerColorLocal "ColorRed"; + //TRACE_1("enter", _this); + _args = _this select 0; + //PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); + _shooter = _args select 0; + _missile = _args select 6; + _curVelocity = velocity _missile; + + if(!alive _missile || isNull _missile || isNull _shooter) exitWith { + [(_this select 1)] call cba_fnc_removePerFrameHandler; + }; + + _launchPos = _shooter getVariable [QGVAR(launchPos), nil]; + if(isNil "_launchPos") then { + TRACE_1("Setting launch parameters", ""); + _launchPos = getPosASL _shooter; + _shooter setVariable [QGVAR(launchPos), _launchPos, false]; + _shooter setVariable [QGVAR(launchTime), diag_tickTime, false]; + }; + + _targets = [_missile, ACE_DEFAULT_LASER_CODE, 70, _curVelocity] call ace__laser_fnc_findLaserDesignator; + _addHeight = [0,0,0]; + if((_targets select 0)) then { + _target = _targets select 1; + TRACE_2("Targets", _target, _targets); + + _yVec = vectorDir _missile; + _zVec = vectorUp _missile; + _xVec = vectorNormalized (_yVec vectorCrossProduct _zVec); + + _missilePos = getPosASL _missile; + // player sideChat "G!"; + _targetPos = getPosASL _target; + TRACE_4("Phase Check", _launchPos, _missilePos, _targetPos, (_missilePos distance _targetPos)); + if((count _targetPos) > 0) then { + _distanceToTarget = _missilePos vectorDistance _targetPos; + + if((_launchPos distance _missilePos) < 400 && (_targetPos distance _missilePos) > 400) then { + _addHeight = [0,0,(_targetPos select 2) + (_missilePos distance _targetPos)*0.5]; + TRACE_1("Climb phase", _addHeight); + } else { + // Covered half the distance, go terminal + if((_missilePos distance _targetPos) < (_launchPos distance _targetPos) / 2) then { + TRACE_1("TERMINAL", ""); + } else { + if((_missilePos select 2) > (_targetPos select 2)) then { + _heightDiff = (_missilePos select 2) - (_targetPos select 2); + TRACE_1("Coasting", _heightDiff); + _addHeight = [0,0, _heightDiff]; + }; + }; + }; + _targetPos = _targetPos vectorAdd _addHeight; + + _defYaw = 0.0035; + _defPitch = 0.0075; + + _targetVectorSeeker = [_missile, [_xVec, _yVec, _zVec], _targetPos] call FUNC(translateToWeaponSpace); + _yaw = 0.0; + if((_targetVectorSeeker select 0) < 0) then { + _yaw = -_defYaw; + } else { + if((_targetVectorSeeker select 0) > 0) then { + _yaw = _defYaw; + }; + }; + + _pitch = 0.0; + if((_targetVectorSeeker select 2) < 0) then { + _pitch = -_defPitch; + } else { + if((_targetVectorSeeker select 2) > 0) then { + _pitch = _defPitch; + }; + }; + #ifdef DEBUG_MODE_FULL + drawLine3D [(ASLtoATL _targetPos) vectorAdd _addHeight, ASLtoATL _targetPos, [0,1,0,1]]; + + _light = "#lightpoint" createVehicleLocal (getPos _missile); + _light setLightBrightness 1.0; + _light setLightAmbient [1.0, 0.0, 0.0]; + _light setLightColor [1.0, 0.0, 0.0]; + + drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,1,1,1], ASLtoATL _missilePos, 0.75, 0.75, 0, str _vectorTo, 1, 0.025, "TahomaB"]; + drawLine3D [ASLtoATL _missilePos, ASLtoATL _targetPos, [1,0,0,1]]; + + _distance = ([getPos startPos, _missilePos] call BIS_fnc_distance2D); + _marker = createMarkerLocal [format["m%1", MARKERCOUNT], [_distance, _missilePos select 2]]; + _marker setMarkerTypeLocal "mil_dot"; + _marker setMarkerColorLocal "ColorRed"; - MARKERCOUNT = MARKERCOUNT + 1; - #endif - - if(accTime > 0) then { - _outVector = [_missile, [_xVec, _yVec, _zVec], [_yaw, 1/accTime, _pitch]] call FUNC(translateToModelSpace); - - _vectorTo = _missilePos vectorFromTo _outVector; - _missile setVectorDirAndUp [_vectorTo, vectorUp _missile]; - }; - - #ifdef DEBUG_MODE_FULL - hintSilent format["d: %1", _distanceToTarget]; - #endif - }; - }; + MARKERCOUNT = MARKERCOUNT + 1; + #endif + + if(accTime > 0) then { + _outVector = [_missile, [_xVec, _yVec, _zVec], [_yaw, 1/accTime, _pitch]] call FUNC(translateToModelSpace); + + _vectorTo = _missilePos vectorFromTo _outVector; + _missile setVectorDirAndUp [_vectorTo, vectorUp _missile]; + }; + + #ifdef DEBUG_MODE_FULL + hintSilent format["d: %1", _distanceToTarget]; + #endif + }; + }; }; FUNC(guidance_Hellfire_LOAL_HI) = { - PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); - - GVAR(lastTime) = time; - [FUNC(guidance_Hellfire_LOAL_HI_PFH), 0, _this] call cba_fnc_addPerFrameHandler; + PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); + + GVAR(lastTime) = time; + [FUNC(guidance_Hellfire_LOAL_HI_PFH), 0, _this] call cba_fnc_addPerFrameHandler; }; FUNC(guidance_Hellfire_LOAL_DIR) = { - PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); - - GVAR(lastTime) = time; - [FUNC(guidance_Hellfire_LOAL_DIR_PFH), 0, _this] call cba_fnc_addPerFrameHandler; + PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); + + GVAR(lastTime) = time; + [FUNC(guidance_Hellfire_LOAL_DIR_PFH), 0, _this] call cba_fnc_addPerFrameHandler; }; PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); _fireMode = _shooter getVariable ["ACE_FIRE_SELECTION", ACE_DEFAULT_FIRE_SELECTION]; switch (_fireMode select 0) do { - // Default to FIREMODE_DIRECT_LOAL - // FIREMODE_DIRECT_LOAL - default { - LOG("Initiating Hellfire II FIREMODE_LOAL_DIR"); - _this call FUNC(guidance_Hellfire_LOAL_HI); - }; + // Default to FIREMODE_DIRECT_LOAL + // FIREMODE_DIRECT_LOAL + default { + LOG("Initiating Hellfire II FIREMODE_LOAL_DIR"); + _this call FUNC(guidance_Hellfire_LOAL_HI); + }; }; \ No newline at end of file diff --git a/addons/missileguidance/functions/fnc_guidance_LGB.sqf b/addons/missileguidance/functions/fnc_guidance_LGB.sqf index e9e8754f19..940c94d34e 100644 --- a/addons/missileguidance/functions/fnc_guidance_LGB.sqf +++ b/addons/missileguidance/functions/fnc_guidance_LGB.sqf @@ -2,108 +2,108 @@ #include "script_component.hpp" FUNC(guidance_LGB_LOAL_PFH) = { - //TRACE_1("enter", _this); - _args = _this select 0; - //PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); - _lgb = _args select 6; - _curVelocity = velocity _lgb; - - if(!alive _lgb) exitWith { - [(_this select 1)] call cba_fnc_removePerFrameHandler; - }; - - _targets = [_lgb, ACE_DEFAULT_LASER_CODE, 70, _curVelocity] call uo_laser_fnc_findLaserDesignator; - //TRACE_2("Targets", _target, _targets); - - if((_targets select 0)) then { - _target = _targets select 1; - - // player sideChat "FUCK!"; - // drop ["\a3\data_f\Cl_basic","","Billboard",1,20,(getPos _lgb),[0,0,0],1,1.275,1.0,0.0,[5],[[1,0,0,1]],[0],0.0,2.0,"","",""]; - - - _yVec = vectorDir _lgb; - _zVec = vectorUp _lgb; - _xVec = vectorNormalized (_yVec vectorCrossProduct _zVec); - - _lgbPos = getPosASL _lgb; - // player sideChat "G!"; - _targetPos = getPosASL _target; - if((count _targetPos) > 0) then { - // player sideChat format["f: %1", _targetPos]; - _addHeight = [0,0,(_lgbPos distance _targetPos)*0.06]; - // drawLine3D [(ASLtoATL _targetPos) vectorAdd _addHeight, ASLtoATL _targetPos, [0,1,0,1]]; - _targetPos = _targetPos vectorAdd _addHeight; - - - - _def = 0.0025; - - _targetVectorSeeker = [_lgb, [_xVec, _yVec, _zVec], _targetPos] call FUNC(translateToWeaponSpace); - // _targetVectorSeeker = _lgb worldToModel (ASLtoATL _targetPos); - // _targetVectorSeeker = [0,0,0] vectorFromTo _targetVectorSeeker; - _yaw = 0.0; - if((_targetVectorSeeker select 0) < 0) then { - _yaw = -_def; - } else { - if((_targetVectorSeeker select 0) > 0) then { - _yaw = _def; - }; - }; - - _pitch = 0.0; - if((_targetVectorSeeker select 2) < 0) then { - _pitch = -_def; - } else { - if((_targetVectorSeeker select 2) > 0) then { - _pitch = _def; - }; - }; - #ifdef DEBUG_MODE_FULL - drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,1,1,1], ASLtoATL _lgbPos, 0.75, 0.75, 0, str _vectorTo, 1, 0.025, "TahomaB"]; - drawLine3D [ASLtoATL _lgbPos, ASLtoATL _targetPos, [1,0,0,1]]; - - _distance = ([getPos startPos, _lgbPos] call BIS_fnc_distance2D); - _marker = createMarkerLocal [format["m%1", MARKERCOUNT], [_distance, _lgbPos select 2]]; - _marker setMarkerTypeLocal "mil_dot"; - _marker setMarkerColorLocal "ColorRed"; + //TRACE_1("enter", _this); + _args = _this select 0; + //PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); + _lgb = _args select 6; + _curVelocity = velocity _lgb; + + if(!alive _lgb) exitWith { + [(_this select 1)] call cba_fnc_removePerFrameHandler; + }; + + _targets = [_lgb, ACE_DEFAULT_LASER_CODE, 70, _curVelocity] call uo_laser_fnc_findLaserDesignator; + //TRACE_2("Targets", _target, _targets); + + if((_targets select 0)) then { + _target = _targets select 1; + + // player sideChat "FUCK!"; + // drop ["\a3\data_f\Cl_basic","","Billboard",1,20,(getPos _lgb),[0,0,0],1,1.275,1.0,0.0,[5],[[1,0,0,1]],[0],0.0,2.0,"","",""]; + + + _yVec = vectorDir _lgb; + _zVec = vectorUp _lgb; + _xVec = vectorNormalized (_yVec vectorCrossProduct _zVec); + + _lgbPos = getPosASL _lgb; + // player sideChat "G!"; + _targetPos = getPosASL _target; + if((count _targetPos) > 0) then { + // player sideChat format["f: %1", _targetPos]; + _addHeight = [0,0,(_lgbPos distance _targetPos)*0.06]; + // drawLine3D [(ASLtoATL _targetPos) vectorAdd _addHeight, ASLtoATL _targetPos, [0,1,0,1]]; + _targetPos = _targetPos vectorAdd _addHeight; + + + + _def = 0.0025; + + _targetVectorSeeker = [_lgb, [_xVec, _yVec, _zVec], _targetPos] call FUNC(translateToWeaponSpace); + // _targetVectorSeeker = _lgb worldToModel (ASLtoATL _targetPos); + // _targetVectorSeeker = [0,0,0] vectorFromTo _targetVectorSeeker; + _yaw = 0.0; + if((_targetVectorSeeker select 0) < 0) then { + _yaw = -_def; + } else { + if((_targetVectorSeeker select 0) > 0) then { + _yaw = _def; + }; + }; + + _pitch = 0.0; + if((_targetVectorSeeker select 2) < 0) then { + _pitch = -_def; + } else { + if((_targetVectorSeeker select 2) > 0) then { + _pitch = _def; + }; + }; + #ifdef DEBUG_MODE_FULL + drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,1,1,1], ASLtoATL _lgbPos, 0.75, 0.75, 0, str _vectorTo, 1, 0.025, "TahomaB"]; + drawLine3D [ASLtoATL _lgbPos, ASLtoATL _targetPos, [1,0,0,1]]; + + _distance = ([getPos startPos, _lgbPos] call BIS_fnc_distance2D); + _marker = createMarkerLocal [format["m%1", MARKERCOUNT], [_distance, _lgbPos select 2]]; + _marker setMarkerTypeLocal "mil_dot"; + _marker setMarkerColorLocal "ColorRed"; - MARKERCOUNT = MARKERCOUNT + 1; - #endif - - if(accTime > 0) then { - _outVector = [_lgb, [_xVec, _yVec, _zVec], [_yaw, 1/accTime, _pitch]] call FUNC(translateToModelSpace); - // _outVector = _lgb modelToWorld [_yaw, 1, _pitch]; - // _outVector = ATLtoASL _outVector; - _vectorTo = _lgbPos vectorFromTo _outVector; - - // hintSilent format["v: %1", _vectorTo]; - - // _lgb setVectorDir _vectorTo; - _lgb setVectorDirAndUp [_vectorTo, vectorUp _lgb]; - }; - - #ifdef DEBUG_MODE_FULL - hintSilent format["d: %1", _lgbPos vectorDistance _targetPos]; - #endif - }; - }; + MARKERCOUNT = MARKERCOUNT + 1; + #endif + + if(accTime > 0) then { + _outVector = [_lgb, [_xVec, _yVec, _zVec], [_yaw, 1/accTime, _pitch]] call FUNC(translateToModelSpace); + // _outVector = _lgb modelToWorld [_yaw, 1, _pitch]; + // _outVector = ATLtoASL _outVector; + _vectorTo = _lgbPos vectorFromTo _outVector; + + // hintSilent format["v: %1", _vectorTo]; + + // _lgb setVectorDir _vectorTo; + _lgb setVectorDirAndUp [_vectorTo, vectorUp _lgb]; + }; + + #ifdef DEBUG_MODE_FULL + hintSilent format["d: %1", _lgbPos vectorDistance _targetPos]; + #endif + }; + }; }; FUNC(guidance_LGB_LOAL) = { - PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); - - [FUNC(guidance_LGB_LOAL_PFH), 0, _this] call cba_fnc_addPerFrameHandler; + PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); + + [FUNC(guidance_LGB_LOAL_PFH), 0, _this] call cba_fnc_addPerFrameHandler; }; PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); _fireMode = _shooter getVariable ["ACE_FIRE_SELECTION", ACE_DEFAULT_FIRE_SELECTION]; switch (_fireMode select 0) do { - // Default to FIREMODE_DIRECT_LOAL - // FIREMODE_DIRECT_LOAL - default { - LOG("Initiating FIREMODE_DIRECT_LOAL"); - _this call FUNC(guidance_LGB_LOAL); - }; + // Default to FIREMODE_DIRECT_LOAL + // FIREMODE_DIRECT_LOAL + default { + LOG("Initiating FIREMODE_DIRECT_LOAL"); + _this call FUNC(guidance_LGB_LOAL); + }; }; \ No newline at end of file diff --git a/addons/missileguidance/functions/fnc_translateToWeaponSpace.sqf b/addons/missileguidance/functions/fnc_translateToWeaponSpace.sqf index 406d81b145..2c7dc5e6da 100644 --- a/addons/missileguidance/functions/fnc_translateToWeaponSpace.sqf +++ b/addons/missileguidance/functions/fnc_translateToWeaponSpace.sqf @@ -14,9 +14,9 @@ _y = _offset select 1; _z = _offset select 2; _out = [ - ((_xVec select 0)*_x) + ((_xVec select 1)*_y) + ((_xVec select 2)*_z), - ((_yVec select 0)*_x) + ((_yVec select 1)*_y) + ((_yVec select 2)*_z), - ((_zVec select 0)*_x) + ((_zVec select 1)*_y) + ((_zVec select 2)*_z) - ]; + ((_xVec select 0)*_x) + ((_xVec select 1)*_y) + ((_xVec select 2)*_z), + ((_yVec select 0)*_x) + ((_yVec select 1)*_y) + ((_yVec select 2)*_z), + ((_zVec select 0)*_x) + ((_zVec select 1)*_y) + ((_zVec select 2)*_z) + ]; _out; \ No newline at end of file diff --git a/addons/missileguidance/script_component.hpp b/addons/missileguidance/script_component.hpp index 886764be2b..377469cdee 100644 --- a/addons/missileguidance/script_component.hpp +++ b/addons/missileguidance/script_component.hpp @@ -2,11 +2,11 @@ #include "\z\ace\Addons\main\script_mod.hpp" #ifdef DEBUG_ENABLED_MISSILEGUIDANCE - #define DEBUG_MODE_FULL + #define DEBUG_MODE_FULL #endif #ifdef DEBUG_SETTINGS_MISSILEGUIDANCE - #define DEBUG_SETTINGS DEBUG_SETTINGS_MISSILEGUIDANCE + #define DEBUG_SETTINGS DEBUG_SETTINGS_MISSILEGUIDANCE #endif #include "\z\ace\Addons\main\script_macros.hpp"