Add attackProfile and guidanceProfile onFired functions

This commit is contained in:
Brandon-PC\Brandon 2019-01-12 19:59:58 -07:00
parent f317b092eb
commit ebfbc56ee3
9 changed files with 101 additions and 10 deletions

View File

@ -74,8 +74,6 @@ class CfgAmmo {
defaultSeekerLockMode = "LOAL";
seekerLockModes[] = { "LOAL", "LOBL" };
onFired = QEFUNC(hot,onFired);
seekLastTargetPos = 0;
seekerAngle = 30;
seekerAccuracy = 1;

View File

@ -1,6 +1,6 @@
#include "script_component.hpp"
/*
* Author: Brandon (TCVM) (Code inspired by NouberNou)
* Author: Brandon (TCVM) (Code inspired by NouberNou's Dragon Guidance)
* Attack profile: Dragon Guidance
*
* Arguments:

View File

@ -5,6 +5,7 @@ class EGVAR(missileguidance,AttackProfiles) {
description = CSTRING(missileType_Description);
functionName = QFUNC(attackProfile_WIRE);
onFired = QFUNC(wire_onFired);
};
};
class EGVAR(missileguidance,SeekerTypes) {
@ -14,6 +15,7 @@ class EGVAR(missileguidance,SeekerTypes) {
description = CSTRING(SACLOS_Description);
functionName = QFUNC(seekerType_SACLOS);
onFired = QFUNC(SACLOS_onFired);
};
};

View File

@ -70,8 +70,6 @@ class CfgAmmo {
defaultSeekerLockMode = "LOAL";
seekerLockModes[] = { "LOAL", "LOBL" };
onFired = QFUNC(onFired);
seekLastTargetPos = 0; // seek last target position [if seeker loses LOS of target, continue to last known pos]
seekerAngle = 30; // Angle from the shooter's view that can track the missile
seekerAccuracy = 1; // seeker accuracy multiplier

View File

@ -1,4 +1,5 @@
PREP(seekerType_SACLOS);
PREP(attackProfile_WIRE);
PREP(onFired);
PREP(wire_onFired);
PREP(SACLOS_onFired);

View File

@ -0,0 +1,35 @@
#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_hot_fnc_SACLOS_onFired
*
* Public: No
*/
params ["_firedEH", "", "", "", "_stateParams"];
_firedEH params ["_shooter","_weapon","","","","","_projectile"];
_stateParams params ["", "_seekerStateParams"];
private _config = ([_projectile] call CBA_fnc_getObjectConfig) >> "ace_missileguidance";
private _distanceAheadOfMissile = [_config >> "missileLeadDistance", "NUMBER", DEFAULT_LEAD_DISTANCE] call CBA_fnc_getConfigEntry;
if (_shooter isKindOf "Plane") then { WARNING("SACLOS fired from planes unsupported"); };
private _turretPath = [_shooter, _weapon] call CBA_fnc_turretPathWeapon;
private _turretConfig = [_shooter, _turretPath] call CBA_fnc_getTurret;
private _memoryPointGunnerOptics = getText(_turretConfig >> "memoryPointGunnerOptics");
private _animationSourceBody = getText(_turretConfig >> "animationSourceBody");
private _animationSourceGun = getText(_turretConfig >> "animationSourceGun");
_seekerStateParams set [0, _memoryPointGunnerOptics];
_seekerStateParams set [1, _animationSourceBody];
_seekerStateParams set [2, _animationSourceGun];
_seekerStateParams set [3, _distanceAheadOfMissile];

View File

@ -19,7 +19,7 @@
params ["_seekerTargetPos", "_args", "_attackProfileStateParams"];
_args params ["_firedEH"];
_firedEH params ["_shooter","","","","","","_projectile"];
_attackProfileStateParams params["_maxCorrectableDistance", "_wireCut", "_randomVector", "_crosshairOffset", "_seekerMaxRangeSqr", "_wireCutSource"];
_attackProfileStateParams params["_maxCorrectableDistance", "_wireCut", "_randomVector", "_crosshairOffset", "_seekerMaxRangeSqr", "", "_wireCutSource"];
private _projectilePos = getPosASL _projectile;

View File

@ -0,0 +1,45 @@
#include "script_component.hpp"
/*
* Author: Brandon (TCVM)
* Sets up wireGuided state arrays (called from missileGuidance's onFired).
*
* Arguments:
* Guidance Arg Array <ARRAY>
*
* Return Value:
* None
*
* Example:
* [] call ace_hot_fnc_wire_onFired
*
* Public: No
*/
params ["_firedEH", "", "", "_seekerParams", "_stateParams"];
_firedEH params ["_shooter","_weapon","","","","","_projectile", "_gunner"];
_stateParams params ["", "", "_attackProfileStateParams"];
_seekerParams params ["", "", "_seekerMaxRange", "_seekerMinRange"];
private _config = ([_projectile] call CBA_fnc_getObjectConfig) >> "ace_missileguidance";
private _maxCorrectableDistance = [_config >> "correctionDistance", "NUMBER", DEFAULT_CORRECTION_DISTANCE] call CBA_fnc_getConfigEntry;
private _crosshairOffset = [_config >> "offsetFromCrosshair", "ARRAY", [0, 0, 0]] call CBA_fnc_getConfigEntry;
private _maxDistanceSqr = _seekerMaxRange * _seekerMaxRange;
private _minDistanceSqr = _seekerMinRange * _seekerMinRange;
// AI don't know how to use the crosshair offset becauze they dum dum
if ((_gunner != ACE_PLAYER) && {_gunner != (ACE_controlledUAV select 1)}) then {
_crosshairOffset = [0, 0, 0];
};
private _turretPath = [_shooter, _weapon] call CBA_fnc_turretPathWeapon;
private _turretConfig = [_shooter, _turretPath] call CBA_fnc_getTurret;
private _wireCutSource = _shooter selectionPosition getText(_turretConfig >> "missileEnd");
_attackProfileStateParams set [0, _maxCorrectableDistance];
_attackProfileStateParams set [1, false]; // _wireCut
_attackProfileStateParams set [2, [0, 0, 0]]; // _randomVector
_attackProfileStateParams set [3, _crosshairOffset]; // crosshair offset
_attackProfileStateParams set [4, _maxDistanceSqr]; // max distance squared used for wire cut
_attackProfileStateParams set [5, _minDistanceSqr];
_attackProfileStateParams set [6, _wireCutSource];

View File

@ -109,19 +109,31 @@ private _args = [_this,
[
getNumber ( _config >> "seekerAngle" ),
getNumber ( _config >> "seekerAccuracy" ),
getNumber ( _config >> "seekerMaxRange" )
getNumber ( _config >> "seekerMaxRange" ),
getNumber ( _config >> "seekerMinRange" )
],
[ diag_tickTime, [], [], _lastKnownPosState]
];
// Run the "onFired" function passing the full guidance args array
private _onFiredFunc = getText (_config >> "onFired");
private _onFiredFunc = getText (configFile >> QGVAR(AttackProfiles) >> _attackProfile >> "onFired");
TRACE_1("",_onFiredFunc);
if (_onFiredFunc != "") then {
_args call (missionNamespace getVariable _onFiredFunc);
};
_onFiredFunc = getText (configFile >> QGVAR(SeekerTypes) >> _seekerType >> "onFired");
TRACE_1("",_onFiredFunc);
if (_onFiredFunc != "") then {
_args call (missionNamespace getVariable _onFiredFunc);
};
// Run the "onFired" function passing the full guidance args array
_onFiredFunc = getText (_config >> "onFired");
TRACE_1("",_onFiredFunc);
if (_onFiredFunc != "") then {
_args call (missionNamespace getVariable _onFiredFunc);
};
// Reverse:
// _args params ["_firedEH", "_launchParams", "_flightParams", "_seekerParams", "_stateParams"];