Hunter Killer (Commander Override) (#8496)

* Hunter Killer (Commander Override) - Initial Demo

* Just do a one-time slew

* Update fnc_eachFrame.sqf

* Update addons/hunterkiller/functions/script_component.hpp

Co-authored-by: jonpas <jonpas33@gmail.com>

* Update for ArmA 2.08

* cleanup

* Rework Observe / Control configs

* Add to all 2035 tanks

* Update script_component.hpp

* Use eyeDirection on commander turrets

* Update docs/wiki/framework/hunterkiller-framework.md

Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>

* Add to all 2035, support ture/false setVars

* remove from apcs because mods don't know how to do inheritance

Co-authored-by: jonpas <jonpas33@gmail.com>
Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>
This commit is contained in:
PabstMirror 2022-09-01 13:38:22 -05:00 committed by GitHub
parent 6556a256a9
commit 981a8ea352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 351 additions and 1 deletions

View File

@ -0,0 +1 @@
z\ace\addons\hunterkiller

View File

@ -0,0 +1,15 @@
class Extended_PreStart_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_SCRIPT(XEH_preStart));
};
};
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_SCRIPT(XEH_preInit));
};
};
class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_SCRIPT(XEH_postInit));
};
};

View File

@ -0,0 +1,24 @@
class CfgVehicles {
class Tank_F;
class MBT_01_base_F: Tank_F {
ADDON = 1; // same as ADDON[] = {{{0}, 1}, {{0,0}, 3}};
};
class MBT_01_arty_base_F: MBT_01_base_F {
ADDON = 0;
};
class MBT_01_mlrs_base_F: MBT_01_base_F {
ADDON = 0;
};
class MBT_02_base_F: Tank_F {
ADDON = 1;
};
class MBT_02_arty_base_F: MBT_02_base_F {
ADDON = 0;
};
class MBT_03_base_F: Tank_F {
ADDON = 1;
};
class MBT_04_base_F: Tank_F {
ADDON = 1;
};
};

View File

@ -0,0 +1,4 @@
ace_hunterkiller
==========
Allows a tank commander to re-aim the main turret or to aim their turret at the what the main turret is looking at

View File

@ -0,0 +1,5 @@
LOG("prep");
PREP(keydown);
PREP(slew);
PREP(turretChangedEH);

View File

@ -0,0 +1,28 @@
#include "script_component.hpp"
#include "\a3\ui_f\hpp\defineDIKCodes.inc"
[QGVAR(slew), LINKFUNC(slew)] call CBA_fnc_addEventHandler;
if (!hasInterface) exitWith {};
GVAR(mode) = 0;
GVAR(targetTurret) = [];
["CBA_settingsInitialized", {
["turret", LINKFUNC(turretChangedEH), true] call CBA_fnc_addPlayerEventHandler;
}] call CBA_fnc_addEventHandler;
["ACE3 Vehicles", QGVAR(observe), [format ["%1 - %2", LLSTRING(displayName), LLSTRING(observe)], LLSTRING(observe_description)],
{
[false] call FUNC(keyDown)
}, {
false
}, [DIK_Q, [false, false, false]]] call CBA_fnc_addKeybind;
["ACE3 Vehicles", QGVAR(override), [format ["%1 - %2", LLSTRING(displayName), LLSTRING(override)], LLSTRING(override_description)],
{
[true] call FUNC(keyDown)
}, {
false
}, [DIK_E, [false, false, false]]] call CBA_fnc_addKeybind;

View File

@ -0,0 +1,9 @@
#include "script_component.hpp"
ADDON = false;
PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;
ADDON = true;

View File

@ -0,0 +1,3 @@
#include "script_component.hpp"
#include "XEH_PREP.hpp"

View File

@ -0,0 +1,17 @@
#include "script_component.hpp"
class CfgPatches {
class ADDON {
name = COMPONENT_NAME;
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common"};
author = ECSTRING(common,ACETeam);
url = ECSTRING(main,URL);
VERSION_CONFIG;
};
};
#include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp"

View File

@ -0,0 +1,49 @@
#include "script_component.hpp"
/*
* Author: PabstMirror
* Slew keybind pressed
*
* Arguments:
* 0: Override if true, Observe if false <BOOL>
*
* Return Value:
* None
*
* Example:
* [true] call ace_hunterkiller_fnc_keydown
*
* Public: No
*/
if ((GVAR(mode) == MODE_NO_ACTIONS) || {!([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith))}) exitWith {
false
};
params ["_modeOverride"];
TRACE_1("keydown",_modeOverride);
if ((_modeOverride) && {!(GVAR(mode) in [MODE_OVERRIDE, MODE_OBSERVE_AND_OVERRIDE])}) exitWith { false };
if ((!_modeOverride) && {!(GVAR(mode) in [MODE_OBSERVE, MODE_OBSERVE_AND_OVERRIDE])}) exitWith { false };
private _vehicle = vehicle ACE_player;
private _playerTurret = _vehicle unitTurret ACE_player;
private _sourceTurret = [GVAR(targetTurret), _playerTurret] select _modeOverride;
private _puppetTurret = [_playerTurret, GVAR(targetTurret)] select _modeOverride;
TRACE_3("",_modeOverride,_sourceTurret,_puppetTurret);
private _eyePos = eyePos _vehicle;
private _lookDir = if ((getNumber (([_vehicle, _sourceTurret] call CBA_fnc_getTurret) >> "primaryObserver")) == 1) then {
TRACE_1("using commander",_sourceTurret);
// CBA_fnc_turretDir fails on "CUP_B_M1A2SEP_TUSK_II_NATO", but eyeDirection should be correct on commander turrets
eyeDirection _vehicle
} else {
([1] + ([_vehicle, _sourceTurret] call CBA_fnc_turretDir)) call CBA_fnc_polar2vect
};
private _lookPoint = _eyePos vectorAdd (_lookDir vectorMultiply 5000);
TRACE_1("sending event",_lookDir);
[QGVAR(slew), [_vehicle, _puppetTurret, _lookPoint, _modeOverride], _vehicle, _puppetTurret] call CBA_fnc_turretEvent;
playSound "ACE_Sound_Click";
true // return (key used)

View File

@ -0,0 +1,32 @@
#include "script_component.hpp"
/*
* Author: PabstMirror
* Slews turret to target pos and shows visual feedback
*
* Arguments:
* 0: Vehicle <OBJECT>
* 1: Turret (will be local) <ARRAY>
* 2: Look PosASL <ARRAY>
* 3: Override <BOOL>
*
* Return Value:
* None
*
* Example:
* [vehicle, [0], [0,0,0], true] call ace_hunterkiller_fnc_slew
*
* Public: No
*/
params ["_vehicle", "_turret", "_posASL", "_isOverride"];
TRACE_4("slew",_vehicle,_turret,_posASL,_isOverride);
_vehicle lockCameraTo [_posASL, _turret, true];
if (hasInterface && {(_vehicle turretUnit _turret) isEqualTo ace_player}) then {
private _displayText = if (_isOverride) then { LLSTRING(override) } else { LLSTRING(observe) };
QGVAR(text) cutText [format ["<br/><br/><br/><br/><br/><t color='#ff0000' size='1.25'>[%1]</t>", _displayText], "PLAIN", -1, false, true];
[{
QGVAR(text) cutText ["", "PLAIN"];
}, [], 1] call CBA_fnc_waitAndExecute;
};

View File

@ -0,0 +1,52 @@
#include "script_component.hpp"
/*
* Author: PabstMirror
* Turret changed event handler. Determine if in a master turret
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Turret <ARRAY>
*
* Return Value:
* None
*
* Example:
* [player, [0]] call ace_hunterkiller_fnc_turretChangedEH
*
* Public: No
*/
params ["_player", "_playerTurret"];
TRACE_2("turretChangedEH",_player,_playerTurret);
GVAR(mode) = 0;
GVAR(targetTurret) = [];
if (_playerTurret isEqualTo []) exitWith {};
private _vehicle = vehicle _player;
private _config = configOf _vehicle;
// setVar can be real array or true/false
private _hkArray = _vehicle getVariable [QUOTE(ADDON), nil];
if (isNil "_hkArray") then {
_hkArray = if (isArray (_config >> QUOTE(ADDON))) then {
getArray (_config >> QUOTE(ADDON))
} else {
((getNumber (_config >> QUOTE(ADDON))) == 1)
};
};
if (_hkArray isEqualTo true) then { _hkArray = [[[0], 1], [[0,0], 3]]; };
if (_hkArray isEqualTo false) then { _hkArray = []; };
TRACE_1("",_hkArray);
if ((count _hkArray) != 2) exitWith {};
{
_x params ["_xTurret", "_xMode"];
TRACE_2("x",_playerTurret,_xTurret);
if (_xTurret isEqualTo _playerTurret) exitWith {
TRACE_3("seat active",typeOf _vehicle,_xTurret,_xMode);
GVAR(mode) = _xMode;
GVAR(targetTurret) = _hkArray # ((_forEachIndex + 1) % 2) # 0;
};
} forEach _hkArray;

View File

@ -0,0 +1 @@
#include "\z\ace\addons\hunterkiller\script_component.hpp"

View File

@ -0,0 +1,14 @@
#define COMPONENT hunterkiller
#define COMPONENT_BEAUTIFIED Hunter Killer
#include "\z\ace\addons\main\script_mod.hpp"
// #define DEBUG_MODE_FULL
// #define DISABLE_COMPILE_CACHE
// #define ENABLE_PERFORMANCE_COUNTERS
#include "\z\ace\addons\main\script_macros.hpp"
#define MODE_NO_ACTIONS 0
#define MODE_OBSERVE 1
#define MODE_OVERRIDE 2
#define MODE_OBSERVE_AND_OVERRIDE 3

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project name="ACE">
<Package name="HunterKiller">
<Key ID="STR_ACE_HunterKiller_displayName">
<English>Hunter Killer</English>
</Key>
<Key ID="STR_ACE_HunterKiller_override">
<English>Override</English>
</Key>
<Key ID="STR_ACE_HunterKiller_override_description">
<English>Force other turret to slew onto your viewpoint</English>
</Key>
<Key ID="STR_ACE_HunterKiller_observe">
<English>Observe</English>
</Key>
<Key ID="STR_ACE_HunterKiller_observe_description">
<English>Slew your turret onto other turret's viewpoint</English>
</Key>
</Package>
</Project>

View File

@ -10,7 +10,7 @@
#define VERSION_AR MAJOR,MINOR,PATCHLVL,BUILD
// MINIMAL required version for the Mod. Components can specify others..
#define REQUIRED_VERSION 2.06
#define REQUIRED_VERSION 2.08
#define REQUIRED_CBA_VERSION {3,15,7}
#ifdef COMPONENT_BEAUTIFIED

View File

@ -0,0 +1,26 @@
---
layout: wiki
title: Hunter Killer
component: hunterkiller
description: Allows commander turret to slew gunner to their target
group: feature
category: realism
parent: wiki
mod: ace
version:
major: 3
minor: 15
patch: 1
---
## 1. Overview
Allows a gunner and commander to observe and remote control the other's weapon to their own target
## 2. Usage
### 2.1 Observe other turret
- Press <kbd>Q</kbd>
### 2.2 Override other turret
- Place the crosshair on the enemy vehicle.
- Press <kbd>E</kbd>

View File

@ -0,0 +1,50 @@
---
layout: wiki
title: HunterKiller Framework
description: Explains configs of the hunter-killer addon
group: framework
order: 5
parent: wiki
mod: ace
version:
major: 3
minor: 15
patch: 1
---
## 1. Array Info
HunterKiller needs a 2 element array to know what seats to run on.
Each element is a tuple of a turret path and operating mode.
```cpp
// NO_ACTIONS = 0
// OBSERVE = 1
// OVERRIDE = 2
// OBSERVE_AND_OVERRIDE = 3
```
## 2. Configs
```cpp
class CfgVehicles {
class MyTankA {
ace_hunterkiller = 1; // enable with default settings
};
class MyTankB {
ace_hunterkiller[] = {{{0}, 1}, {{0,0}, 3}}; // Default settings: (gunner can observe, commander can observe and override gunner)
};
class MRAP_03_hmg_base_F {
ace_hunterkiller[] = {{{0}, 1}, {{1}, 2}}; // e.g. vehicle where commander is [1] instead of [0,0]
};
};
```
## 2. Variables
```cpp
this setVariable ["ace_hunterkiller", true]; // enable for vic using default settings
this setVariable ["ace_hunterkiller", [[[0], 1], [[0,0], 3]]]; // enable using custom array
this setVariable ["ace_hunterkiller", false]; // disabled
this setVariable ["ace_hunterkiller", []]; // disabled
```