mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Fix NLAW and PLOS
The missile pitches up due to initial angle stuff. I don't know if this is behaviour we want to fix or not?
This commit is contained in:
parent
9d26335271
commit
19dcf00aff
@ -70,7 +70,8 @@ if ((_pitchRate != 0 || {_yawRate != 0}) && {_profileAdjustedTargetPos isNotEqua
|
||||
|
||||
if (GVAR(debug_drawGuidanceInfo)) then {
|
||||
private _projectilePosAGL = ASLToAGL _projectilePos;
|
||||
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], _projectilePosAGL vectorAdd [0, 0, 1], 0.75, 0.75, 0, format ["cmdPitch: %1 cmdYaw %2", _commandedAcceleration#2, _commandedAcceleration#0], 1, 0.025, "TahomaB"];
|
||||
private _cmdAccelLocal = _projectile vectorWorldToModelVisual _commandedAcceleration;
|
||||
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], _projectilePosAGL vectorAdd [0, 0, 1], 0.75, 0.75, 0, format ["cmdPitch: %1 cmdYaw %2", _cmdAccelLocal#2, _cmdAccelLocal#0], 1, 0.025, "TahomaB"];
|
||||
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,1,0,1], _projectilePosAGL vectorAdd [0, 0, 2], 0.75, 0.75, 0, _navigationType, 1, 0.025, "TahomaB"];
|
||||
drawLine3D [_projectilePosAGL, _projectilePosAGL vectorAdd _commandedAcceleration, [1, 0, 1, 1]];
|
||||
};
|
||||
@ -109,7 +110,6 @@ if ((_pitchRate != 0 || {_yawRate != 0}) && {_profileAdjustedTargetPos isNotEqua
|
||||
};
|
||||
|
||||
TRACE_9("pitch/yaw/roll",_pitch,_yaw,_roll,_yawChange,_pitchChange,_pitchRate,_yawRate,_clampedPitch,_clampedYaw);
|
||||
|
||||
_pitch = _pitch + _clampedPitch * _timestep;
|
||||
_yaw = _yaw + _clampedYaw * _timestep;
|
||||
|
||||
|
@ -156,7 +156,7 @@ private _args = [_this,
|
||||
getNumber ( _config >> "seekerMaxRange" ),
|
||||
getNumber ( _config >> "seekerMinRange" )
|
||||
],
|
||||
[ diag_tickTime, [], [], _lastKnownPosState, _navigationParameters, [_pitchYaw select 1, 0, 1.5 + (_pitchYaw select 2)]],
|
||||
[ diag_tickTime, [], [], _lastKnownPosState, _navigationParameters, [_pitchYaw select 1, 0, _pitchYaw select 2]],
|
||||
[
|
||||
// target data from missile. Must be filled by seeker for navigation to work
|
||||
[0, 0, 0], // direction to target
|
||||
|
@ -12,3 +12,9 @@ class EGVAR(missileguidance,SeekerTypes) {
|
||||
functionName = QFUNC(seeker);
|
||||
};
|
||||
};
|
||||
class EGVAR(missileguidance,NavigationTypes) {
|
||||
class GVAR(PLOS) {
|
||||
functionName = QFUNC(navigation);
|
||||
onFired = QFUNC(navigation_onFired);
|
||||
};
|
||||
};
|
||||
|
@ -18,8 +18,8 @@ class CfgAmmo {
|
||||
defaultSeekerLockMode = "LOBL";
|
||||
seekerLockModes[] = {"LOBL"};
|
||||
|
||||
defaultNavigationType = "LineOfSight";
|
||||
navigationTypes[] = { "LineOfSight" };
|
||||
defaultNavigationType = QGVAR(PLOS);
|
||||
navigationTypes[] = { QGVAR(PLOS) };
|
||||
|
||||
seekLastTargetPos = 0; // seek last target position [if seeker loses LOS of target, continue to last known pos]
|
||||
seekerAngle = 45; // Angle in front of the missile which can be searched
|
||||
|
@ -4,3 +4,5 @@ PREP(attackProfile);
|
||||
PREP(keyDown);
|
||||
PREP(onFired);
|
||||
PREP(seeker);
|
||||
PREP(navigation);
|
||||
PREP(navigation_onFired);
|
||||
|
@ -18,14 +18,13 @@
|
||||
*/
|
||||
|
||||
params ["_seekerTargetPos", "_args", "_attackProfileStateParams"];
|
||||
|
||||
#ifdef DRAW_NLAW_INFO
|
||||
_args params ["_firedEH", "_launchParams"];
|
||||
_launchParams params ["","_targetLaunchParams", "", "_attackProfile"];
|
||||
_targetLaunchParams params ["", "", "_launchPos"];
|
||||
_firedEH params ["","","","","","","_projectile"];
|
||||
|
||||
// Use seeker (if terminal)
|
||||
if (_seekerTargetPos isNotEqualTo [0,0,0]) exitWith {_seekerTargetPos};
|
||||
|
||||
_attackProfileStateParams params ["_startTime", "_startLOS", "_yawChange", "_pitchChange"];
|
||||
(_startLOS call CBA_fnc_vect2Polar) params ["", "_yaw", "_pitch"];
|
||||
|
||||
@ -36,14 +35,6 @@ private _flightTime = CBA_missionTime - _startTime;
|
||||
private _realYaw = _yaw + _yawChange * _flightTime;
|
||||
private _realPitch = _pitch + _pitchChange * _flightTime;
|
||||
|
||||
private _returnTargetPos = _launchPos vectorAdd ([_distanceFromLaunch, _realYaw, _realPitch] call CBA_fnc_polar2vect);
|
||||
|
||||
if (_attackProfile == QGVAR(overflyTopAttack)) then { // Add 2m height in OTA attack mode
|
||||
_returnTargetPos = _returnTargetPos vectorAdd [0,0,2];
|
||||
};
|
||||
|
||||
|
||||
#ifdef DRAW_NLAW_INFO
|
||||
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,1,1], ASLtoAGL _launchPos, 0.75, 0.75, 0, "LAUNCH", 1, 0.025, "TahomaB"];
|
||||
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [0,1,1,1], ASLtoAGL (_launchPos vectorAdd (_startLOS vectorMultiply (_distanceFromLaunch + 50))), 0.75, 0.75, 0, "Original LOS", 1, 0.025, "TahomaB"];
|
||||
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,1,0,1], ASLtoAGL (_launchPos vectorAdd ([_distanceFromLaunch + 50, _realYaw, _realPitch] call CBA_fnc_polar2vect)), 0.75, 0.75, 0, format ["Predicted @%1sec",(floor(_flightTime * 10)/10)], 1, 0.025, "TahomaB"];
|
||||
@ -56,5 +47,4 @@ if ((count _test) > 0) then {
|
||||
};
|
||||
#endif
|
||||
|
||||
// TRACE_1("Adjusted target position", _returnTargetPos);
|
||||
_returnTargetPos;
|
||||
[0, 0, 1]
|
||||
|
@ -74,7 +74,7 @@ playSound "ACE_Sound_Click";
|
||||
_args set [1, _yaw];
|
||||
_args set [2, _pitch];
|
||||
|
||||
#ifdef DEBUG_MODE_FULL
|
||||
#ifdef DRAW_NLAW_INFO
|
||||
hintSilent format ["Instantaneous\nYaw: %1\n Pitch: %2\nGVAR\nYaw: %3\nPitch: %4", _yawChange, _pitchChange, GVAR(yawChange), GVAR(pitchChange)];
|
||||
#endif
|
||||
}, .25, [CBA_missionTime, _yaw, _pitch, true]] call CBA_fnc_addPerFrameHandler;
|
||||
|
26
addons/nlaw/functions/fnc_navigation.sqf
Normal file
26
addons/nlaw/functions/fnc_navigation.sqf
Normal file
@ -0,0 +1,26 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: Brandon (TCVM)
|
||||
* Holds angle as fed to by seeker
|
||||
*
|
||||
* Arguments:
|
||||
* Guidance Arg Array <ARRAY>
|
||||
*
|
||||
* Return Value:
|
||||
* Commanded acceleration normal to LOS in world space <ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* [] call ace_missileguidance_fnc_navigationType_line
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
params ["_args", "_timestep", "_seekerTargetPos", "_profileAdjustedTargetPos", "_targetData", "_navigationParams"];
|
||||
_args params ["_firedEH"];
|
||||
_firedEH params ["","","","","","","_projectile"];
|
||||
_args params ["", "", "_flightParams"];
|
||||
_flightParams params ["_pitchRate", "_yawRate"];
|
||||
|
||||
_navigationParams params ["_yawChange", "_pitchChange", "_startTime"];
|
||||
|
||||
_projectile vectorModelToWorldVisual [2 * _yawChange, 0, 2 * _pitchChange]
|
||||
|
62
addons/nlaw/functions/fnc_navigation_onFired.sqf
Normal file
62
addons/nlaw/functions/fnc_navigation_onFired.sqf
Normal file
@ -0,0 +1,62 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
* Sets up missile guidance state arrays (called from missileGuidance's onFired).
|
||||
*
|
||||
* Arguments:
|
||||
* Guidance Arg Array <ARRAY>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [] call ace_nlaw_fnc_onFired
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_firedEH", "_launchParams", "_flightParams", "_seekerParams", "_stateParams"];
|
||||
_firedEH params ["_shooter","","","","","","_projectile"];
|
||||
_launchParams params ["","_targetLaunchParams","","_attackProfile"];
|
||||
_targetLaunchParams params ["_target"];
|
||||
_stateParams params ["", "", "", "", "_navigationParams"];
|
||||
|
||||
// Reset _launchPos origin as projectile's height instead of player's foot
|
||||
_targetLaunchParams set [2, getPosASL _projectile];
|
||||
|
||||
// Get state params:
|
||||
TRACE_3("start of attack profile",_attackProfile,_shooter,vectorDir _projectile);
|
||||
|
||||
private _firedLOS = _shooter weaponDirection (currentWeapon _shooter);
|
||||
private _yawChange = 0;
|
||||
private _pitchChange = 0;
|
||||
|
||||
if (_shooter == ACE_player) then {
|
||||
TRACE_2("isPlayer",GVAR(yawChange),GVAR(pitchChange));
|
||||
_yawChange = GVAR(yawChange);
|
||||
_pitchChange = GVAR(pitchChange);
|
||||
TRACE_1("los check",_firedLOS call CBA_fnc_vect2Polar);
|
||||
} else {
|
||||
if ((!isNil "_target") && {!isNull _target}) then {
|
||||
_firedLOS = (getPosASL _projectile) vectorFromTo (aimPos _target);
|
||||
(((eyePos _shooter) vectorFromTo (aimPos _target)) call CBA_fnc_vect2Polar) params ["", "_startYaw", "_startPitch"];
|
||||
// Add some random error to AI's velocity prediction:
|
||||
private _random = random [(_shooter skillFinal "aimingAccuracy") min 0.9, 1, 2-((_shooter skillFinal "aimingAccuracy") min 0.9)];
|
||||
(((eyePos _shooter) vectorFromTo ((aimPos _target) vectorAdd ((velocity _target) vectorMultiply (_random)))) call CBA_fnc_vect2Polar) params ["", "_predictedYaw", "_predictedPitch"];
|
||||
_yawChange = ([_predictedYaw - _startYaw] call CBA_fnc_simplifyAngle180);
|
||||
_pitchChange = ([_predictedPitch - _startPitch] call CBA_fnc_simplifyAngle180);
|
||||
TRACE_1("AI",_target);
|
||||
} else {
|
||||
TRACE_1("AI - no target",_target);
|
||||
};
|
||||
};
|
||||
|
||||
// Limit Max Deflection
|
||||
_yawChange = -10 max _yawChange min 10;
|
||||
_pitchChange = -10 max _pitchChange min 10;
|
||||
|
||||
TRACE_3("attackProfileStateParams",_firedLOS,_yawChange,_pitchChange);
|
||||
_navigationParams set [0, _yawChange];
|
||||
_navigationParams set [1, _pitchChange];
|
||||
_navigationParams set [2, CBA_missionTime];
|
||||
|
@ -27,7 +27,7 @@ _targetLaunchParams set [2, getPosASL _projectile];
|
||||
// Get state params:
|
||||
TRACE_3("start of attack profile",_attackProfile,_shooter,vectorDir _projectile);
|
||||
|
||||
private _firedLOS = _shooter weaponDirection (currentWeapon _shooter);
|
||||
private _firedLOS = vectorDir _projectile;
|
||||
private _yawChange = 0;
|
||||
private _pitchChange = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user