ACE3/addons/hot/functions/fnc_onFired.sqf
Brandon Danyluk 1511ecc1c0 SACLOS and HOT Missiles (#6708)
* abc

* Revert "abc"

This reverts commit bcb4214bd9.

* Update to current commit

* Added HOT1 Missile and SACLOS/Wire guidance

* Added all HOT variants. Added polish to code

* Fixed bug with pylons

* Changed how seeker angle is calculated. When the wire snaps the missile goes haywire. Fixed bug where HOT2/3 missiles weren't getting missile guidance

* Replaced Wiesel FireFIST launcher with  HOT Launcher

* Remove debug defines

* Tweak thrust

* Fix formatting issues. Added true randomness. Added ACE prefixes. Added string table. Tweaked missile dynamics

* Fix bug where attack profile correction was wrong due to magnitude always being 50. Add stringtable values for relevant strings. Added reload time to Wiesel ATGM. Added "onFired" to initialize values

* Moved wire-snapping logic to attack profile

* Missile flight dynamics tweaked

* Add a crosshair offset. The missile sits in this offset relative to the crosshair

* Add LOS checks. Fix bug where wire-cutting didnt work.

* Tweak explosive range for a kill radius of ~20m. Add fragmentation

* Add AI Flags

* Person in control of missile may not be the shooter

* Fix RPT spam on missile out of LOS. Tweak missile dynamics. Add wire break sound cue

* Fix bug where missile didn't go to a fake target in front of it when out of LOS

* Use a better, more generic way to calculate direction camera is facing

* Use ACE Macros for frag values. Get config entry with CBA

* Add Wiki entry

* Add new lines to wiki. Allow for SQF expressions in config for maxCorrectableDistance

* Add CPP code tag

* Fix wiki grammer error

* Re-convert back to CBA_fnc_getConfigEntry

* UAV Gunner support, cleanup

* Fix bug where SACLOS for launcher guided weapons was off

* Add the ability to define how far ahead of the missile the attack profile will seek toward
2018-12-06 20:27:30 -06:00

54 lines
2.4 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: Brandon (TCVM)
* Sets up missile guidance state arrays (called from missileGuidance's onFired).
*
* Arguments:
* Guidance Arg Array <ARRAY>
*
* Return Value:
* None
*
* Example:
* [] call ace_hot_fnc_onFired
*
* Public: No
*/
params ["_firedEH", "", "", "_seekerParams", "_stateParams"];
_firedEH params ["_shooter","_weapon","","","","","_projectile", "_gunner"];
_stateParams params ["", "_seekerStateParams", "_attackProfileStateParams"];
_seekerParams params ["", "", "_seekerMaxRange"];
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 _distanceAheadOfMissile = [_config >> "missileLeadDistance", "NUMBER", DEFAULT_LEAD_DISTANCE] call CBA_fnc_getConfigEntry;
// 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];
};
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 _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, _wireCutSource];
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];