Skip to content

Commit

Permalink
Merge branch 'master' into missile_sdb
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCandianVendingMachine authored Feb 14, 2025
2 parents 79372de + 4f86527 commit 7ad02ae
Show file tree
Hide file tree
Showing 19 changed files with 268 additions and 6 deletions.
16 changes: 16 additions & 0 deletions addons/common/CfgSounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,20 @@ class CfgSounds {
sound[] = {QPATHTOF(sounds\ACE_click.wav), 1, 1, 200};
titles[] = {};
};
class ACE_Sound_Click_10db {
sound[] = {QPATHTOF(sounds\ACE_click.wav), "db-10", 1, 200};
titles[] = {};
};
class ACE_Sound_Click_20db {
sound[] = {QPATHTOF(sounds\ACE_click.wav), "db-20", 1, 200};
titles[] = {};
};
class ACE_Sound_Click_30db {
sound[] = {QPATHTOF(sounds\ACE_click.wav), "db-30", 1, 200};
titles[] = {};
};
class ACE_Sound_Click_40db {
sound[] = {QPATHTOF(sounds\ACE_click.wav), "db-40", 1, 200};
titles[] = {};
};
};
8 changes: 8 additions & 0 deletions addons/missileguidance/ACE_GuidanceConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down
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/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ PREP(handleHandoff);

PREP(shouldFilterRadarHit);

PREP(MCLOS_buttonPressed);

// Attack Profiles
PREP(attackProfile_AIR);
PREP(attackProfile_DIR);
Expand All @@ -47,6 +49,7 @@ PREP(navigationType_direct);
PREP(seekerType_SALH);
PREP(seekerType_Optic);
PREP(seekerType_SACLOS);
PREP(seekerType_MCLOS);
PREP(seekerType_Doppler);
PREP(seekerType_MWR);
PREP(seekerType_GPS);
Expand All @@ -59,6 +62,7 @@ PREP(gps_attackOnFired);
// Seeker OnFired
PREP(doppler_onFired);
PREP(SACLOS_onFired);
PREP(MCLOS_onFired);
PREP(mwr_onFired);
PREP(gps_seekerOnFired);
PREP(IR_onFired);
Expand Down
37 changes: 32 additions & 5 deletions addons/missileguidance/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,14 +1,41 @@
#include "script_component.hpp"
#include "\a3\ui_f\hpp\defineDIKCodes.inc"

[QGVAR(handoff), LINKFUNC(handleHandoff)] call CBA_fnc_addEventHandler;

["ACE3 Weapons", QGVAR(cycleFireMode), localize LSTRING(CycleFireMode), {
[] call FUNC(cycleAttackProfileKeyDown);
false
["ACE3 Weapons", QGVAR(cycleFireMode), LLSTRING(CycleFireMode), {
[] call FUNC(cycleAttackProfileKeyDown)
}, {
false
}, [DIK_TAB, [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), LLSTRING(mclosUp), {
[[0, 0, 1], ACE_player] call FUNC(MCLOS_buttonPressed)
}, {
[[0, 0, -1], ACE_player] call FUNC(MCLOS_buttonPressed)
},
[DIK_NUMPAD8, [false, false, false]], false, 0] call CBA_fnc_addKeybind; // Numpad 8

["ACE3 Weapons", QGVAR(mclosDown), LLSTRING(mclosDown), {
[[0, 0, -1], ACE_player] call FUNC(MCLOS_buttonPressed)
}, {
[[0, 0, 1], ACE_player] call FUNC(MCLOS_buttonPressed)
},
[DIK_NUMPAD2, [false, false, false]], false, 0] call CBA_fnc_addKeybind; // Numpad 2

["ACE3 Weapons", QGVAR(mclosLeft), LLSTRING(mclosLeft), {
[[1, 0, 0], ACE_player] call FUNC(MCLOS_buttonPressed)
}, {
[[-1, 0, 0], ACE_player] call FUNC(MCLOS_buttonPressed)
},
[DIK_NUMPAD6, [false, false, false]], false, 0] call CBA_fnc_addKeybind; // Numpad 6

["ACE3 Weapons", QGVAR(mclosRight), LLSTRING(mclosRight), {
[[-1, 0, 0], ACE_player] call FUNC(MCLOS_buttonPressed)
}, {
[[1, 0, 0], ACE_player] call FUNC(MCLOS_buttonPressed)
},
[15, [false, true, false]], false] call CBA_fnc_addKeybind; //Ctrl+Tab Key
[DIK_NUMPAD4, [false, false, false]], false, 0] call CBA_fnc_addKeybind; // Numpad 4

if (!hasInterface) exitWith {};

Expand Down
4 changes: 3 additions & 1 deletion addons/missileguidance/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ class CfgPatches {
#include "CfgAmmo.hpp"
#include "CfgMagazines.hpp"
#include "CfgWeapons.hpp"

#include "GPSDialog.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);
};
22 changes: 22 additions & 0 deletions addons/missileguidance/dev/mock_vehicles.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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;
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) };
};
};
};
};
7 changes: 7 additions & 0 deletions addons/missileguidance/dev/mock_weapons.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class MissileLauncher;
class GVAR(mock_w_Malyutka): MissileLauncher {
displayName = "Test Malyutka";
GVAR(hasMCLOSControl) = 1;
magazineReloadTime=1;
magazines[] = { QGVAR(mock_m_Malyutka) };
};
44 changes: 44 additions & 0 deletions addons/missileguidance/functions/fnc_MCLOS_buttonPressed.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "..\script_component.hpp"
/*
* Author: tcvm
* Handles MCLOS guidance via keyboard keys
*
* Arguments:
* 0: Acceleration vector <ARRAY>
* 1: Unit <OBJECT>
*
* Return Value:
* If the button is pressed with an MCLOS context
*
* Example:
* [[0, 0, 1], player] call ace_missileguidance_fnc_MCLOS_buttonPressed
*
* Public: No
*/

params ["_accelerationDirection", "_player"];

private _shooter = vehicle _player;
if (_player == _shooter) exitWith {};
private _turret = _shooter unitTurret _player;

if (((_shooter weaponsTurret _turret) findIf {
(getNumber (configFile >> "CfgWeapons" >> _x >> QGVAR(hasMCLOSControl))) == 1
}) == -1) exitWith { false };


playSound "ACE_Sound_Click_20db";

private _currentDirection = _shooter getVariable [QGVAR(MCLOS_direction), [0, 0, 0]];
// Send data across network for handling non-local projectiles
// This is the case in a wanted development for a proper Malyutka implementation where projectiles will
// have their locality change via script
_shooter setVariable [QGVAR(MCLOS_direction), _currentDirection vectorAdd _accelerationDirection, true];

// Shouldn't have too many projectiles sent across the network. Planned max is 4 at a time
private _controlled = _shooter getVariable [QGVAR(mclos_projectiles), []];
_controlled = _controlled select { !isNull _x };
_shooter setVariable [QGVAR(mclos_projectiles), _controlled, true];

// if we are controlling missiles, we want the input to be captured
_controlled isNotEqualTo []
31 changes: 31 additions & 0 deletions addons/missileguidance/functions/fnc_MCLOS_onFired.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "..\script_component.hpp"
/*
* Author: tcvm
* Sets up MCLOS state arrays (called from missileGuidance's onFired).
*
* Arguments:
* Guidance Arg Array <ARRAY>
*
* Return Value:
* None
*
* Example:
* [] call ace_missileguidance_fnc_MCLOS_onFired
*
* Public: No
*/
params ["_firedEH", "", "", "", "_stateParams"];
_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), []];
_controlled pushBack _projectile;
_source setVariable [QGVAR(mclos_projectiles), _controlled];

_projectile setVariable [QGVAR(source), _source];
1 change: 1 addition & 0 deletions addons/missileguidance/functions/fnc_line_onFired.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ _firedEH params ["","","","","","","_projectile"];
private _ammoConfig = configOf _projectile;
private _p = getNumber (_ammoConfig >> QUOTE(ADDON) >> "lineGainP");
private _d = getNumber (_ammoConfig >> QUOTE(ADDON) >> "lineGainD");
if ((_p == 0) && {_d == 0}) then { WARNING_1("Ammo %1 has zero P/D",typeOf _projectile) };
private _correctionDistance = getNumber (_ammoConfig >> QUOTE(ADDON) >> "correctionDistance");

if (_correctionDistance == 0) then {
Expand Down
55 changes: 55 additions & 0 deletions addons/missileguidance/functions/fnc_seekerType_MCLOS.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include "..\script_component.hpp"
/*
* Author: tcvm
* MCLOS 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_MCLOS
*
* Public: No
*/
params ["", "_args"];
_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]]);

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);

private _hOffset = (_projectilePos # 2) - (_projectedPath # 2);
private _vv = (velocity _projectile) # 2;
_mclosInput = switch (true) do {
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];

_returnPos

1 change: 1 addition & 0 deletions addons/missileguidance/functions/fnc_wire_onFired.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ params ["_firedEH", "", "", "_seekerParams", "_stateParams"];
_firedEH params ["_shooter","_weapon","","","","","_projectile", "_gunner"];
_stateParams params ["", "", "_attackProfileStateParams"];
_seekerParams params ["", "", "_seekerMaxRange", "_seekerMinRange"];
if (_seekerMaxRange < 1) then { WARNING_2("Ammo %1 has very short max range %2",typeOf _projectile,_seekerMaxRange) };

private _config = configOf _projectile >> "ace_missileguidance";
private _maxCorrectableDistance = [_config >> "correctionDistance", "NUMBER", DEFAULT_CORRECTION_DISTANCE] call CBA_fnc_getConfigEntry;
Expand Down
1 change: 1 addition & 0 deletions addons/missileguidance/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// #define DEBUG_MODE_FULL
// #define DISABLE_COMPILE_CACHE
// #define ENABLE_PERFORMANCE_COUNTERS
// #define CREATE_MOCK_PLATFORMS

#ifdef DEBUG_ENABLED_MISSILEGUIDANCE
#define DEBUG_MODE_FULL
Expand Down
12 changes: 12 additions & 0 deletions addons/missileguidance/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -262,5 +262,17 @@
<Turkish>Gelişmiş Füze Güdüm Sistemi</Turkish>
<Hungarian>Fejlett rakétairányító</Hungarian>
</Key>
<Key ID="STR_ACE_MissileGuidance_mclosDown">
<English>MCLOS Down</English>
</Key>
<Key ID="STR_ACE_MissileGuidance_mclosLeft">
<English>MCLOS Left</English>
</Key>
<Key ID="STR_ACE_MissileGuidance_mclosRight">
<English>MCLOS Right</English>
</Key>
<Key ID="STR_ACE_MissileGuidance_mclosUp">
<English>MCLOS Up</English>
</Key>
</Package>
</Project>

0 comments on commit 7ad02ae

Please sign in to comment.