mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
fix NLAW navigation profile
This commit is contained in:
parent
25b1b47f5f
commit
aff19ec6ea
@ -1,7 +1,7 @@
|
|||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
/*
|
/*
|
||||||
* Author: Brandon (TCVM)
|
* Author: Brandon (TCVM)
|
||||||
* Holds angle as fed to by seeker
|
* Attempts to hold angle as fed to by seeker. Does so with a simple proportional controller
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* Guidance Arg Array <ARRAY>
|
* Guidance Arg Array <ARRAY>
|
||||||
@ -14,13 +14,54 @@
|
|||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
// arbitrary constant
|
||||||
|
#define PROPORTIONALITY_CONSTANT 3
|
||||||
params ["_args", "_timestep", "_seekerTargetPos", "_profileAdjustedTargetPos", "_targetData", "_navigationParams"];
|
params ["_args", "_timestep", "_seekerTargetPos", "_profileAdjustedTargetPos", "_targetData", "_navigationParams"];
|
||||||
_args params ["_firedEH"];
|
_args params ["_firedEH"];
|
||||||
_firedEH params ["","","","","","","_projectile"];
|
_firedEH params ["","","","","","","_projectile"];
|
||||||
_args params ["", "", "_flightParams"];
|
|
||||||
_flightParams params ["_pitchRate", "_yawRate"];
|
|
||||||
|
|
||||||
_navigationParams params ["_yawChange", "_pitchChange", "_startTime"];
|
_navigationParams params ["_yawChange", "_pitchChange", "_lastPitch", "_lastYaw"];
|
||||||
|
|
||||||
_projectile vectorModelToWorldVisual [2 * _yawChange, 0, 2 * _pitchChange]
|
// for some reason we need to double this. I don't know why, but it just works
|
||||||
|
_pitchChange = _pitchChange * 2;
|
||||||
|
_yawChange = _yawChange * 2;
|
||||||
|
|
||||||
|
((velocity _projectile) call CBA_fnc_vect2polar) params ["", "_currentYaw", "_currentPitch"];
|
||||||
|
|
||||||
|
private _pitchRate = if (_timestep == 0) then {
|
||||||
|
0
|
||||||
|
} else {
|
||||||
|
(_currentPitch - _lastPitch) / _timestep
|
||||||
|
};
|
||||||
|
_navigationParams set [2, _currentPitch];
|
||||||
|
|
||||||
|
private _pitchModifier = if (_pitchChange == 0) then {
|
||||||
|
1
|
||||||
|
} else {
|
||||||
|
abs (_pitchRate / _pitchChange);
|
||||||
|
};
|
||||||
|
private _desiredPitchChange = (_pitchChange - _pitchRate) * PROPORTIONALITY_CONSTANT * _pitchModifier;
|
||||||
|
|
||||||
|
private _yawRate = if (_timestep == 0) then {
|
||||||
|
0
|
||||||
|
} else {
|
||||||
|
(_currentYaw - _lastYaw) / _timestep
|
||||||
|
};
|
||||||
|
_navigationParams set [3, _currentYaw];
|
||||||
|
|
||||||
|
private _yawModifier = if (_yawChange == 0) then {
|
||||||
|
1
|
||||||
|
} else {
|
||||||
|
abs (_yawRate / _yawChange);
|
||||||
|
};
|
||||||
|
private _desiredYawChange = (_yawChange - _yawRate) * PROPORTIONALITY_CONSTANT * _yawModifier;
|
||||||
|
|
||||||
|
#ifdef DRAW_NLAW_INFO
|
||||||
|
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,1,1], ASLtoAGL getPosASLVisual _projectile, 0.75, 0.75, 0, format ["dP [%1] dY: [%2]", _desiredPitchChange, _desiredYawChange], 1, 0.025, "TahomaB"];
|
||||||
|
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,1,1], [0, 0, 1] vectorAdd ASLtoAGL getPosASLVisual _projectile, 0.75, 0.75, 0, format ["pitch proportional [%1] yaw proportional [%2]", _pitchModifier, _yawModifier], 1, 0.025, "TahomaB"];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TRACE_6("nlaw navigation",_yawChange,_desiredYawChange,_pitchChange,_desiredPitchChange,_yawRate,_pitchRate);
|
||||||
|
|
||||||
|
_projectile vectorModelToWorldVisual [_yawChange + _desiredYawChange, 0, _pitchChange + _desiredPitchChange]
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Guidance Arg Array <ARRAY>
|
* Guidance Arg Array <ARRAY>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* None
|
* Navigation Parameters <ARRAY>
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* [] call ace_nlaw_fnc_onFired
|
* [] call ace_nlaw_fnc_onFired
|
||||||
@ -55,8 +55,12 @@ if (_shooter == ACE_player) then {
|
|||||||
_yawChange = -10 max _yawChange min 10;
|
_yawChange = -10 max _yawChange min 10;
|
||||||
_pitchChange = -10 max _pitchChange min 10;
|
_pitchChange = -10 max _pitchChange min 10;
|
||||||
|
|
||||||
|
((velocity _projectile) call CBA_fnc_vect2polar) params ["", "_currentYaw", "_currentPitch"];
|
||||||
|
|
||||||
TRACE_3("attackProfileStateParams",_firedLOS,_yawChange,_pitchChange);
|
TRACE_3("attackProfileStateParams",_firedLOS,_yawChange,_pitchChange);
|
||||||
_navigationParams set [0, _yawChange];
|
_navigationParams set [0, _yawChange];
|
||||||
_navigationParams set [1, _pitchChange];
|
_navigationParams set [1, _pitchChange];
|
||||||
_navigationParams set [2, CBA_missionTime];
|
_navigationParams set [3, _currentPitch]; // last pitch
|
||||||
|
_navigationParams set [4, _currentYaw]; // last yaw
|
||||||
|
_navigationParams
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user