Add MCLOS guidance

This commit is contained in:
BaerMitUmlaut 2019-05-13 00:42:57 +02:00
parent ab8fa78377
commit 003ca565b5
8 changed files with 115 additions and 6 deletions

View File

@ -58,4 +58,11 @@ class GVAR(SeekerTypes) {
functionName = QFUNC(seekerType_Optic);
};
class MCLOS {
name = "";
visualName = "";
description = "";
functionName = QFUNC(seekerType_MCLOS);
};
};

View File

@ -1,5 +1,6 @@
LOG("prep");
PREP(cycleAttackProfileKeyDown);
PREP(mclosKeyHandler);
PREP(changeMissileDirection);
@ -30,3 +31,4 @@ PREP(attackProfile_JAV_TOP);
// Seeker search functions
PREP(seekerType_SALH);
PREP(seekerType_Optic);
PREP(seekerType_MCLOS);

View File

@ -1,13 +1,33 @@
#include "script_component.hpp"
#include "\a3\editor_f\Data\Scripts\dikCodes.h"
[QGVAR(handoff), {_this call FUNC(handleHandoff)}] call CBA_fnc_addEventHandler;
["ACE3 Weapons", QGVAR(cycleFireMode), localize LSTRING(CycleFireMode),
{
["ACE3 Weapons", QGVAR(cycleFireMode), LLSTRING(CycleFireMode), {
[] call FUNC(cycleAttackProfileKeyDown);
false
},
{
}, {
false
},
[15, [false, true, false]], false] call CBA_fnc_addKeybind; //Ctrl+Tab Key
}, [DIK_TAB, [false, true, false]], false] call CBA_fnc_addKeybind; //Ctrl+Tab Key
// MCLOS keybindings
["ACE3 Weapons", QGVAR(mclosUp), LLSTRING(MCLOS_Up), {
[MCLOS_UP, true] call FUNC(mclosKeyhandler)
}, {
[MCLOS_UP, false] call FUNC(mclosKeyhandler)
}, [DIK_W, [false, false, false]]] call CBA_fnc_addKeybind;
["ACE3 Weapons", QGVAR(mclosLeft), LLSTRING(MCLOS_Left), {
[MCLOS_LEFT, true] call FUNC(mclosKeyhandler)
}, {
[MCLOS_LEFT, false] call FUNC(mclosKeyhandler)
}, [DIK_A, [false, false, false]]] call CBA_fnc_addKeybind;
["ACE3 Weapons", QGVAR(mclosDown), LLSTRING(MCLOS_Down), {
[MCLOS_DOWN, true] call FUNC(mclosKeyhandler)
}, {
[MCLOS_DOWN, false] call FUNC(mclosKeyhandler)
}, [DIK_S, [false, false, false]]] call CBA_fnc_addKeybind;
["ACE3 Weapons", QGVAR(mclosRight), LLSTRING(MCLOS_Right), {
[MCLOS_RIGHT, true] call FUNC(mclosKeyhandler)
}, {
[MCLOS_RIGHT, false] call FUNC(mclosKeyhandler)
}, [DIK_D, [false, false, false]]] call CBA_fnc_addKeybind;

View File

@ -11,4 +11,7 @@ PREP_RECOMPILE_END;
// As weapons take config changes, there is little point in being able to disable guidance
if (isNil QGVAR(enabled)) then { GVAR(enabled) = 2; };
GVAR(mclosMissile) = objNull;
GVAR(mclosInput) = [0, 0, 0, 0];
ADDON = true;

View File

@ -0,0 +1,22 @@
#include "script_component.hpp"
/*
* Author: BaerMitUmlaut
* Handles guidance input for MCLOS guided missiles.
*
* Arguments:
* 0: Direction (0 = up, 1 = right,...) <NUMBER>
* 1: Key is pressed (true) or released (false) <BOOL>
*
* Return Value:
* True if missile guidance is active, false if not <BOOL>
*
* Example:
* ["up", true] call ace_missileguidance_fnc_mclosKeyHandler;
*
* Public: No
*/
params ["_dir", "_keyDown"];
if (isNull GVAR(mclosMissile)) exitWith {false};
GVAR(mclosInput) set [_dir, parseNumber _keyDown];
true

View File

@ -0,0 +1,34 @@
#include "script_component.hpp"
/*
* Author: BaerMitUmlaut
* MCLOS guidance "seeker".
*
* Arguments:
* 1: Guidance Arg Array <ARRAY>
*
* Return Value:
* Missile Aim PosASL <ARRAY>
*
* Example:
* [[], [...]] call ace_missileguidance_fnc_seekerType_MCLOS;
*
* Public: No
*/
params ["", "_args"];
_args params ["_firedEH", "", "", "", "_stateParams"];
_firedEH params ["", "", "", "", "", "", "_projectile"];
_stateParams params ["", "_seekerState"];
_seekerState params ["_initialized"];
if (isNil "_initialized") then {
// Missile just launched, reset
GVAR(mclosMissile) = _projectile;
GVAR(mclosInput) = [0, 0, 0, 0];
_seekerState pushBack true;
};
private _vx = GVAR(mclosInput)#MCLOS_RIGHT - GVAR(mclosInput)#MCLOS_LEFT;
private _vz = GVAR(mclosInput)#MCLOS_UP - GVAR(mclosInput)#MCLOS_DOWN;
private _steerVector = vectorNormalized [_vx, 1, _vz];
(getPosASL _projectile) vectorAdd (_projectile vectorModelToWorld _steerVector)

View File

@ -15,4 +15,9 @@
#define DEBUG_SETTINGS DEBUG_SETTINGS_MISSILEGUIDANCE
#endif
#define MCLOS_UP 0
#define MCLOS_RIGHT 1
#define MCLOS_DOWN 2
#define MCLOS_LEFT 3
#include "\z\ace\addons\main\script_macros.hpp"

View File

@ -193,5 +193,21 @@
<Chinesesimp>循环切换开火模式</Chinesesimp>
<Chinese>循環切換開火模式</Chinese>
</Key>
<Key ID="STR_ACE_MissileGuidance_MCLOS_Up">
<English>MCLOS Steer up</English>
<German>MCLOS Nach oben steuern</German>
</Key>
<Key ID="STR_ACE_MissileGuidance_MCLOS_Down">
<English>MCLOS Steer down</English>
<German>MCLOS Nach unten steuern</German>
</Key>
<Key ID="STR_ACE_MissileGuidance_MCLOS_Left">
<English>MCLOS Steer left</English>
<German>MCLOS Nach links steuern</German>
</Key>
<Key ID="STR_ACE_MissileGuidance_MCLOS_Right">
<English>MCLOS Steer right</English>
<German>MCLOS Nach rechts steuern</German>
</Key>
</Package>
</Project>