-
Notifications
You must be signed in to change notification settings - Fork 740
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Laser guidance for all designators (#3308)
* Fix laser and missileguidance over water * Return a normalized vector in EFUNC(common,getTurretDirection) * Make laser dispersion simulation optional, default off * Prototype for ace_laser_designate * Remove vanilla laser handling from ace_laser in favor of the new code on ace_laser_designate * Simplify laser into one module Rewrite large parts of laser Merge laser_designate Delete lase_selfDesignate * Cleanup missile guidance * Headers, fix laser over water * Cleanup * Test * Change setting to scalar, more cleanup * Add seeker debug drawing
- Loading branch information
1 parent
74dfa6c
commit ab6fc8e
Showing
64 changed files
with
738 additions
and
1,038 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class ACE_Settings { | ||
class GVAR(dispersionCount) { | ||
value = 2; | ||
typeName = "SCALAR"; | ||
displayName = CSTRING(dispersionCount_displayName); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,15 @@ | ||
|
||
PREP(rotateVectLineGetMap); | ||
PREP(rotateVectLine); | ||
PREP(shootRay); | ||
PREP(shootCone); | ||
PREP(checkLos); | ||
|
||
PREP(findStrongestRay); | ||
|
||
PREP(onLaserDesignatorDraw); | ||
|
||
PREP(seekerFindLaserSpot); | ||
PREP(laserOn); | ||
PREP(addLaserTarget); | ||
PREP(dev_drawVisibleLaserTargets); | ||
PREP(findLaserSource); | ||
PREP(handleLaserTargetCreation); | ||
PREP(keyLaserCodeChange); | ||
PREP(laserOff); | ||
PREP(handleLaserOn); | ||
PREP(handleLaserOff); | ||
|
||
PREP(drawVisibleLaserTargets); | ||
|
||
PREP(laser_init); | ||
PREP(vanillaLaserSeekerHandler); | ||
PREP(laserOn); | ||
PREP(laserTargetPFH); | ||
|
||
PREP(unitTurretCanLockLaser); | ||
PREP(keyLaserCodeUp); | ||
PREP(keyLaserCodeDown); | ||
PREP(onLaserDesignatorDraw); | ||
PREP(rotateVectLine); | ||
PREP(rotateVectLineGetMap); | ||
PREP(seekerFindLaserSpot); | ||
PREP(shootCone); | ||
PREP(shootRay); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "script_component.hpp" | ||
|
||
#include "initKeybinds.sqf" | ||
|
||
// Global Laser EHs | ||
["ace_laserOn", { | ||
params ["_uuid", "_args"]; | ||
TRACE_2("ace_laserOn eh",_uuid,_args); | ||
[GVAR(laserEmitters), _uuid, _args] call CBA_fnc_hashSet; | ||
}] call CBA_fnc_addEventHandler; | ||
|
||
["ace_laserOff", { | ||
params ["_uuid"]; | ||
TRACE_1("ace_laserOn eh",_uuid); | ||
if ([GVAR(laserEmitters), _uuid] call CBA_fnc_hashHasKey) then { | ||
[GVAR(laserEmitters), _uuid] call CBA_fnc_hashRem; | ||
}; | ||
}] call CBA_fnc_addEventHandler; | ||
|
||
// Shows detector and mine posistions in 3d when debug is on | ||
#ifdef DRAW_LASER_INFO | ||
addMissionEventHandler ["Draw3D", {_this call FUNC(dev_drawVisibleLaserTargets)}]; | ||
#endif |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Author: esteldunedain | ||
* Adds a vanilla laser target to the tracker PFH and globaly turns it on | ||
* | ||
* Argument: | ||
* 0: TargetObject (vanilla laser) <OBJECT> | ||
* 1: Vehicle <OBJECT> | ||
* | ||
* Return value: | ||
* None | ||
* | ||
* Example: | ||
* [laserTarget player, player] call ace_laser_fnc_addLaserTarget; | ||
* | ||
* Public: No | ||
*/ | ||
#include "script_component.hpp" | ||
|
||
params ["_targetObject", "_vehicle"]; | ||
TRACE_2("params",_targetObject,_vehicle); | ||
|
||
// Get the designator variables, or use defaults | ||
private _waveLength = _vehicle getVariable [QEGVAR(laser,waveLength), ACE_DEFAULT_LASER_WAVELENGTH]; | ||
private _laserCode = _vehicle getVariable [QEGVAR(laser,code), ACE_DEFAULT_LASER_CODE]; | ||
private _beamSpread = _vehicle getVariable [QEGVAR(laser,beamSpread), ACE_DEFAULT_LASER_BEAMSPREAD]; | ||
TRACE_3("codes",_waveLength,_laserCode,_beamSpread); | ||
|
||
// Laser method is the method ACE_Laser will use to determine from where to where it should project the designator cone | ||
_vehicle setVariable [QGVAR(targetObject), _targetObject, true]; | ||
|
||
private _laserMethod = QFUNC(findLaserSource); | ||
|
||
private _vehicleSourceSelection = ""; | ||
if (_vehicle isKindOf "CaManBase") then { | ||
_vehicleSourceSelection = "pilot"; | ||
} else { | ||
{ // Go through turrets on vehicle and find the laser | ||
private _turretPath = _x; | ||
{ | ||
if ((getNumber (configFile >> "CfgWeapons" >> _x >> "laser")) > 0) exitWith { | ||
_vehicleSourceSelection = getText (([_vehicle, _turretPath] call CBA_fnc_getTurret) >> "memoryPointGunnerOptics"); | ||
TRACE_3("",_turretPath,_x,_vehicleSourceSelection); | ||
}; | ||
} forEach (_vehicle weaponsTurret _turretPath); | ||
} forEach (allTurrets [_vehicle, true]); | ||
}; | ||
|
||
private _methodArgs = [_vehicleSourceSelection]; | ||
|
||
TRACE_6("Laser on:",_vehicle,_laserMethod,_waveLength,_laserCode,_beamSpread,_methodArgs); | ||
private _laserUuid = [_vehicle, _vehicle, _laserMethod, _waveLength, _laserCode, _beamSpread, _methodArgs] call FUNC(laserOn); | ||
|
||
GVAR(trackedLaserTargets) pushBack [_targetObject, _vehicle, _laserUuid]; | ||
TRACE_1("",GVAR(trackedLaserTargets)); | ||
|
||
if (GVAR(pfehID) == -1) then { | ||
TRACE_1("starting pfeh",count GVAR(trackedLaserTargets)); | ||
GVAR(pfehID) = [DFUNC(laserTargetPFH), 0, []] call CBA_fnc_addPerFrameHandler; | ||
}; |
This file was deleted.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
addons/laser/functions/fnc_dev_drawVisibleLaserTargets.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Dev Debug Function | ||
// Displays lasers and attempts to lock on to codes 1111 and 1112 from a target vehicle's view | ||
// On Screen Debug: | ||
// Red - Vanilla Laser Targets | ||
// Yellow - Array (vehicle pos/weapon) Laser Targets | ||
// Green - Rays | ||
// Blue - Seeker Locks | ||
|
||
#include "script_component.hpp" | ||
|
||
// Try searching for lasers from a given vehicle position [BLUE]: | ||
private _seekerVehicle = vehicle ace_player; | ||
private _testSeekerPosASL = AGLtoASL (_seekerVehicle modelToWorldVisual [0,0,1]); | ||
private _testSeekerDir = vectorDirVisual _seekerVehicle; | ||
{ | ||
private _code = _x; | ||
private _results = [_testSeekerPosASL, _testSeekerDir, 45, [1550,1550], _code, _seekerVehicle] call FUNC(seekerFindLaserSpot); | ||
private _resultPos = _results select 0; | ||
if (!isNil "_resultPos") then { | ||
// Draw lock results | ||
drawLine3D [ASLtoAGL _testSeekerPosASL, ASLtoAGL _resultPos, [0,0,1,1]]; | ||
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\select_target_ca.paa", [0,0,1,1], (ASLtoAGL _resultPos), 1.5, 1.5, 45, format ["%1 from %2", _code, _results select 1], 0.5, 0.025, "TahomaB"]; | ||
}; | ||
} forEach [1111, 1112]; // Scan at codes 1111 and 1112 | ||
|
||
|
||
// Draw all lasers | ||
[GVAR(laserEmitters), { | ||
// TRACE_2("",_key,_value); | ||
_value params ["_obj", "_owner", "_laserMethod", "_waveLength", "_laserCode", "_beamSpread"]; | ||
|
||
// Draw vanila lasers [RED] | ||
if (_laserMethod isEqualTo QFUNC(findLaserSource)) then { // Normal vanilla laserTarget func | ||
private _targetObject = _obj getVariable [QGVAR(targetObject), objNull]; | ||
private _targetPosASL = getPosASL _targetObject; | ||
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\select_target_ca.paa", [1,0,0,1], (ASLtoAGL _targetPosASL), 0.5, 0.5, 0, "", 0.5, 0.025, "TahomaB"]; | ||
|
||
(_value call FUNC(findLaserSource)) params ["_laserPosASL", "_laserDir"]; | ||
private _resultsRay = [_laserPosASL, _laserDir, _obj] call FUNC(shootRay); | ||
|
||
private _rayPos = _resultsRay select 0; | ||
if (isNil "_rayPos") then { | ||
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\select_target_ca.paa", [1,0,0,1], (ASLtoAGL _targetPosASL), 2, 2, 0, "Nil Ray", 0.5, 0.025, "TahomaB"]; | ||
} else { | ||
private _diff = _rayPos vectorDistance (getPosASL _targetObject); // Diff from ray position compared to actual | ||
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\select_target_ca.paa", [1,0,0,1], (ASLtoAGL _rayPos), 2, 2, 0, format ["Diff %1",_diff], 0.5, 0.025, "TahomaB"]; | ||
}; | ||
}; | ||
// Draw array weapon lasers [YELLOW] | ||
if ((_laserMethod isEqualType []) && {(count _laserMethod) == 2}) then { | ||
_laserMethod params ["_modelPosition", "_weaponName"]; | ||
private _laserPosASL = AGLtoASL (_obj modelToWorldVisual _modelPosition); | ||
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\select_target_ca.paa", [1,1,0,1], (ASLtoAGL _laserPosASL), 0.5, 0.5, 0, _weaponName, 0.5, 0.025, "TahomaB"]; | ||
private _laserDir = _obj weaponDirection _weaponName; | ||
private _resultsRay = [_laserPosASL, _laserDir, _obj] call FUNC(shootRay); | ||
private _rayPos = _resultsRay select 0; | ||
if (!isNil "_rayPos") then { | ||
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\select_target_ca.paa", [1,1,0,1], (ASLtoAGL _rayPos), 2, 2, 0, _weaponName, 0.5, 0.025, "TahomaB"]; | ||
}; | ||
}; | ||
}] call CBA_fnc_hashEachPair; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.