add MCLOS guidance

This commit is contained in:
Brandon Danyluk 2021-05-08 02:49:07 -06:00
parent fc7b310529
commit 5315b11177
9 changed files with 151 additions and 8 deletions

View File

@ -88,6 +88,14 @@ class GVAR(SeekerTypes) {
functionName = QFUNC(seekerType_SACLOS);
onFired = QFUNC(SACLOS_onFired);
};
class MCLOS {
name = "";
visualName = "";
description = "";
functionName = QFUNC(seekerType_MCLOS);
onFired = QFUNC(MCLOS_onFired);
};
class MillimeterWaveRadar {
name = "";
visualName = "";

View File

@ -18,6 +18,8 @@ PREP(handleHandoff);
PREP(shouldFilterRadarHit);
PREP(mclosButtonPressed);
// Attack Profiles
PREP(attackProfile_AIR);
PREP(attackProfile_DIR);
@ -43,6 +45,7 @@ PREP(navigationType_direct);
PREP(seekerType_SALH);
PREP(seekerType_Optic);
PREP(seekerType_SACLOS);
PREP(seekerType_MCLOS);
PREP(seekerType_Doppler);
PREP(seekerType_MWR);
PREP(seekerType_IR);
@ -54,6 +57,7 @@ PREP(gps_attackOnFired);
// Seeker OnFired
PREP(SACLOS_onFired);
PREP(MCLOS_onFired);
PREP(doppler_onFired);
PREP(mwr_onFired);
PREP(IR_onFired);

View File

@ -2,16 +2,51 @@
[QGVAR(handoff), {_this call FUNC(handleHandoff)}] call CBA_fnc_addEventHandler;
["ACE3 Weapons", QGVAR(cycleFireMode), localize LSTRING(CycleFireMode),
{
["ACE3 Weapons", QGVAR(cycleFireMode), localize LSTRING(CycleFireMode), {
[] call FUNC(cycleAttackProfileKeyDown);
false
},
{
}, {
false
},
[15, [false, true, false]], false] call CBA_fnc_addKeybind; //Ctrl+Tab Key
// Each MCLOS argument is the vector which acceleration will be applied
["ACE3 Weapons", QGVAR(mclosUp), localize LSTRING(mclosUp), {
[[0, 0, 1], ACE_PLAYER] call FUNC(mclosButtonPressed);
false
}, {
[[0, 0, -1], ACE_PLAYER] call FUNC(mclosButtonPressed);
false
},
[0x48, [false, false, false]], false, 0] call CBA_fnc_addKeybind; // Numpad 8
["ACE3 Weapons", QGVAR(mclosDown), localize LSTRING(mclosDown), {
[[0, 0, -1], ACE_PLAYER] call FUNC(mclosButtonPressed);
false
}, {
[[0, 0, 1], ACE_PLAYER] call FUNC(mclosButtonPressed);
false
},
[0x50, [false, false, false]], false, 0] call CBA_fnc_addKeybind; // Numpad 2
["ACE3 Weapons", QGVAR(mclosLeft), localize LSTRING(mclosLeft), {
[[1, 0, 0], ACE_PLAYER] call FUNC(mclosButtonPressed);
false
}, {
[[-1, 0, 0], ACE_PLAYER] call FUNC(mclosButtonPressed);
false
},
[0x4D, [false, false, false]], false, 0] call CBA_fnc_addKeybind; // Numpad 6
["ACE3 Weapons", QGVAR(mclosRight), localize LSTRING(mclosRight), {
[[-1, 0, 0], ACE_PLAYER] call FUNC(mclosButtonPressed);
false
}, {
[[1, 0, 0], ACE_PLAYER] call FUNC(mclosButtonPressed);
false
},
[0x4B, [false, false, false]], false, 0] call CBA_fnc_addKeybind; // Numpad 4
GVAR(dev_fnc_projectileCamera) = compile preprocessFileLineNumbers QPATHTOF(dev\projectileCamera.sqf);
if (!hasInterface) exitWith {};

View File

@ -0,0 +1,20 @@
#include "script_component.hpp"
/*
* Author: Brandon (TCVM)
* Sets up SACLOS state arrays (called from missileGuidance's onFired).
*
* Arguments:
* Guidance Arg Array <ARRAY>
*
* Return Value:
* None
*
* Example:
* [] call ace_missileguidance_fnc_SACLOS_onFired
*
* Public: No
*/
params ["_firedEH", "", "", "", "_stateParams"];
_firedEH params ["_shooter","_weapon","","","","","_projectile"];
_stateParams params ["", "_seekerStateParams"];

View File

@ -35,7 +35,10 @@ if ((_distanceToProjectile > _seekerMaxRangeSqr) || { _wireCut }) exitWith {
playSound3D ["a3\sounds_f\air\sfx\SL_rope_break.wss", objNull, false, AGLtoASL (_shooter modelToWorld _wireCutSource), 5, 1, 150];
};
_projectilePos vectorAdd _randomVector
private _randomDir = _projectilePos vectorAdd _randomVector;
_targetData set [0, _projectilePos vectorFromTo _randomDir];
_targetData set [2, _randomDir distance _projectilePos];
_randomDir
};
if (_seekerTargetPos isEqualTo [0, 0, 0] || { _distanceToProjectile < _seekerMinRangeSqr }) exitWith {
@ -46,6 +49,6 @@ if (_seekerTargetPos isEqualTo [0, 0, 0] || { _distanceToProjectile < _seekerMin
// return position 50m infront of projectile and a bit up to get out of the way of the ground
_projectilePos vectorAdd (_projectile vectorModelToWorld [0, 50, 3])
};
systemChat str _crosshairOffset;
_seekerTargetPos vectorAdd _crosshairOffset

View File

@ -0,0 +1,29 @@
#include "script_component.hpp"
/*
* Author: Brandon (TCVM)
* Handles MCLOS guidance via keyboard keys
*
* Arguments:
* Acceleration vector
*
* Return Value:
* None
*
* Example:
* [0, 0, 1] call ace_missileguidance_fnc_mclosButtonPressed
*
* Public: No
*/
params ["_accelerationDirection", "_player"];
private _projectiles = _player getVariable [QGVAR(MCLOS_Projectiles), []];
_projectiles = _projectiles select { _x isNotEqualTo objNull };
_player setVariable [QGVAR(MCLOS_Projectiles), _projectiles];
private _vehicleHasMCLOS = 1 == getNumber ((configOf vehicle _player) >> QGVAR(hasMCLOSControl));
if (_vehicleHasMCLOS) then {
playSound "ACE_Sound_Click";
};
private _currentDirection = _player getVariable [QGVAR(MCLOS_direction), [0, 0, 0]];
_player setVariable [QGVAR(MCLOS_direction), _currentDirection vectorAdd _accelerationDirection];

View File

@ -23,8 +23,8 @@ _navigationParams params ["_proportionalGain", "", "_derivativeGain", "_lastErro
private _targetDistance = _projectile vectorWorldToModelVisual (_targetDir vectorMultiply _distance);
private _relativeDirection = _projectile vectorWorldToModelVisual _targetDir;
private _errorX = 1 min (_targetDistance#0 / _correctionDistance);
private _errorY = 1 min (_targetDistance#2 / _correctionDistance);
private _errorX = -1 max (1 min (_targetDistance#0 / _correctionDistance));
private _errorY = -1 max (1 min (_targetDistance#2 / _correctionDistance));
private _pX = _proportionalGain * _errorX;
private _dX = if (_timestep != 0) then {

View File

@ -0,0 +1,32 @@
#include "script_component.hpp"
/*
* Author: Brandon (TCVM)
* SACLOS seeker
*
* Arguments:
* 1: Guidance Arg Array <ARRAY>
* 2: Seeker State <ARRAY>
*
* Return Value:
* Position of wanted missile pos relative to the camera direction <ARRAY>
*
* Example:
* [] call ace_missileguidance_fnc_seekerType_SACLOS
*
* Public: No
*/
params ["", "_args"];
_args params ["_firedEH", "", "_flightParams"];
_firedEH params ["_shooter","","","","","","_projectile"];
_flightParams params ["_pitchRate", "_yawRate"];
private _projectilePos = getPosASLVisual _projectile;
private _accelerationDirection = _projectile vectorModelToWorldVisual (_shooter getVariable [QGVAR(MCLOS_direction), [0, 0, 0]]);
private _returnPos = _projectilePos vectorAdd (_accelerationDirection vectorMultiply (_pitchRate max _yawRate));
_targetData set [0, _projectilePos vectorFromTo _returnPos];
_targetData set [2, _returnPos distance _projectilePos];
_returnPos

View File

@ -247,5 +247,17 @@
<Key ID="STR_ACE_MissileGuidance_GPS_ui_pp_short">
<English>PP</English>
</Key>
<Key ID="STR_ACE_MissileGuidance_mclosUp">
<English>MCLOS Up</English>
</Key>
<Key ID="STR_ACE_MissileGuidance_mclosDown">
<English>MCLOS Down</English>
</Key>
<Key ID="STR_ACE_MissileGuidance_mclosRight">
<English>MCLOS Right</English>
</Key>
<Key ID="STR_ACE_MissileGuidance_mclosLeft">
<English>MCLOS Left</English>
</Key>
</Package>
</Project>