Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MCLOS - Add support for AI #10701

Merged
merged 2 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions addons/missileguidance/CfgAmmo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,8 @@ class CfgAmmo {
enabled = 1;
};
};

#ifdef CREATE_MOCK_PLATFORMS
#include "dev\mock_ammo.hpp"
#endif
};
4 changes: 4 additions & 0 deletions addons/missileguidance/CfgMagazines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,8 @@ class CfgMagazines {
count = 24;
pylonWeapon = QGVAR(dagr);
};

#ifdef CREATE_MOCK_PLATFORMS
#include "dev\mock_magazines.hpp"
#endif
};
4 changes: 4 additions & 0 deletions addons/missileguidance/CfgWeapons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ class CfgWeapons {
lockingTargetSound[] = {"",0,1};
lockedTargetSound[] = {"",0,1};
};

#ifdef CREATE_MOCK_PLATFORMS
#include "dev\mock_weapons.hpp"
#endif
};
4 changes: 4 additions & 0 deletions addons/missileguidance/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ class CfgPatches {
#include "CfgAmmo.hpp"
#include "CfgMagazines.hpp"
#include "CfgWeapons.hpp"
#ifdef CREATE_MOCK_PLATFORMS
#include "dev\mock_vehicles.hpp"
#endif

15 changes: 15 additions & 0 deletions addons/missileguidance/dev/mock_ammo.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class M_Titan_AA_static;
class GVAR(mock_a_Malyutka): M_Titan_AA_static {
aiAmmoUsageFlags="64 + 128 + 256 + 512";
weaponLockSystem = 0;
airLock = 0;
lockType = 0;
manualControl = 0;
thrust = 80;
maxSpeed = 100;
airFriction = 0.5;
sideairfriction = 0.14;
class ADDON: GVAR(type_Malyutka) {
enabled = 1;
};
};
4 changes: 4 additions & 0 deletions addons/missileguidance/dev/mock_magazines.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class 1Rnd_GAA_missiles;
class GVAR(mock_m_Malyutka): 1Rnd_GAA_missiles {
ammo = QGVAR(mock_a_Malyutka);
};
23 changes: 23 additions & 0 deletions addons/missileguidance/dev/mock_vehicles.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class CfgVehicles {
class Car_F;
class LSV_02_base_F: Car_F {
class Turrets;
};
class LSV_02_AT_base_F: LSV_02_base_F {
class Turrets: Turrets {
class MainTurret;
};
};
class O_LSV_02_AT_F: LSV_02_AT_base_F {};
class GVAR(mock_lsv_Malyutka): O_LSV_02_AT_F {
scope = 1;
GVAR(hasMCLOSControl) = 1;
displayName = "[ACE] Test Malyutka LSV";
class Turrets: Turrets {
class MainTurret: MainTurret {
weapons[] = { QGVAR(mock_w_Malyutka) };
magazines[] = { QGVAR(mock_m_Malyutka), QGVAR(mock_m_Malyutka), QGVAR(mock_m_Malyutka), QGVAR(mock_m_Malyutka), QGVAR(mock_m_Malyutka), QGVAR(mock_m_Malyutka), QGVAR(mock_m_Malyutka), QGVAR(mock_m_Malyutka) };
};
};
};
};
6 changes: 6 additions & 0 deletions addons/missileguidance/dev/mock_weapons.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class MissileLauncher;
class GVAR(mock_w_Malyutka): MissileLauncher {
displayName = "Test Malyutka";
magazineReloadTime=1;
magazines[] = { QGVAR(mock_m_Malyutka) };
};
8 changes: 6 additions & 2 deletions addons/missileguidance/functions/fnc_MCLOS_onFired.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@
* Public: No
*/
params ["_firedEH", "", "", "", "_stateParams"];
_firedEH params ["_shooter","_weapon","","","","","_projectile"];
_stateParams params ["", "_seekerStateParams"];
_firedEH params ["_shooter","_weapon","","","","","_projectile", "_gunner"];

if !(_gunner call EFUNC(common,isPlayer)) then {
// AI shot - save shot info (ToDo: Handle offset for optics/launch dir?)
// _stateParams params ["", "_seekerStateParams"];
_stateParams set [1, [getPosASLVisual _projectile, vectorNormalized velocity _projectile]];
};
private _source = vehicle _shooter;

private _controlled = _source getVariable [QGVAR(mclos_projectiles), []];
Expand Down
29 changes: 26 additions & 3 deletions addons/missileguidance/functions/fnc_seekerType_MCLOS.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,39 @@
* Public: No
*/
params ["", "_args"];
_args params ["_firedEH", "", "_flightParams"];
_firedEH params ["","","","","","","_projectile","_gunner"];
_args params ["_firedEH", "", "_flightParams", "", "_stateParams"];
_firedEH params ["_shooter","","","","","","_projectile","_gunner"];
_flightParams params ["_pitchRate", "_yawRate"];
_stateParams params ["", "_seekerStateParams"];

private _projectilePos = getPosASLVisual _projectile;
private _source = _projectile getVariable [QGVAR(source), _projectile];
private _mclosInput = (_source getVariable [QGVAR(MCLOS_direction), [0, 0, 0]]);

private _accelerationDirection = _projectile vectorModelToWorldVisual (_source getVariable [QGVAR(MCLOS_direction), [0, 0, 0]]);
if (_seekerStateParams isNotEqualTo []) then { // Handle AI
_seekerStateParams params ["_launchPos", "_launchVec"];
if (!(alive _shooter && {alive _gunner} && {(vehicle _gunner) == _shooter} && {_gunner call EFUNC(common,isAwake)})) exitWith {};

private _distance = _launchPos vectorDistance _projectilePos;
private _projectedPath = _launchPos vectorAdd (_launchVec vectorMultiply _distance);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this only aims for the point the ai was aiming when they fired. if the target moves, this inherently misses. i think we could do something similar to SACLOS where we figure out the position the gunner is looking but as SACLOS shows that isn't easy. this is good for now, just wanted to note this


private _source = _projectile getVariable [QGVAR(source), _projectile];
private _hOffset = (_projectilePos # 2) - (_projectedPath # 2);
private _vv = (velocity _projectile) # 2;
_mclosInput = switch (true) do {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't support side-to-side travel

case (_hOffset < 0): { [0, 0, 1] }; // gross h adjust
case (_hOffset > 50): { [0, 0, -1] };
case ((_hOffset + 2 * _vv) < 0): { [0, 0, 1] }; // gross v adjust
case ((_hOffset + 2 * _vv) > 10): { [0, 0, -1] };
case ((_hOffset + _vv) > 5): { [0, 0, -1] }; // fine v adjust
default { [0, 0, 0] };
};
};

private _accelerationDirection = _projectile vectorModelToWorldVisual _mclosInput;
private _returnPos = _projectilePos vectorAdd (_accelerationDirection vectorMultiply (_pitchRate max _yawRate));

//IGNORE_PRIVATE_WARNING["_targetData"]
_targetData set [0, _projectilePos vectorFromTo _returnPos];
_targetData set [2, _returnPos distance _projectilePos];

Expand Down