From 6fd65589cb8b0e8cd850c8d59987b851f452ccf5 Mon Sep 17 00:00:00 2001 From: "Brandon-PC\\Brandon" Date: Thu, 3 Jan 2019 02:14:58 -0700 Subject: [PATCH] Ports over NouberNou's dragon guidance --- addons/dragon/$PBOPREFIX$ | 1 + addons/dragon/ACE_GuidanceConfig.hpp | 10 ++++ addons/dragon/CfgAmmo.hpp | 53 ++++++++++++++++++ addons/dragon/CfgEventHandlers.hpp | 11 ++++ addons/dragon/CfgMagazines.hpp | 0 addons/dragon/CfgWeapons.hpp | 6 ++ addons/dragon/README.md | 11 ++++ addons/dragon/XEH_PREP.hpp | 2 + addons/dragon/XEH_preInit.sqf | 9 +++ addons/dragon/XEH_preStart.sqf | 3 + addons/dragon/config.cpp | 21 +++++++ .../functions/fnc_attackProfile_DRAGON.sqf | 55 +++++++++++++++++++ addons/dragon/functions/script_component.hpp | 1 + addons/dragon/script_component.hpp | 17 ++++++ 14 files changed, 200 insertions(+) create mode 100644 addons/dragon/$PBOPREFIX$ create mode 100644 addons/dragon/ACE_GuidanceConfig.hpp create mode 100644 addons/dragon/CfgAmmo.hpp create mode 100644 addons/dragon/CfgEventHandlers.hpp create mode 100644 addons/dragon/CfgMagazines.hpp create mode 100644 addons/dragon/CfgWeapons.hpp create mode 100644 addons/dragon/README.md create mode 100644 addons/dragon/XEH_PREP.hpp create mode 100644 addons/dragon/XEH_preInit.sqf create mode 100644 addons/dragon/XEH_preStart.sqf create mode 100644 addons/dragon/config.cpp create mode 100644 addons/dragon/functions/fnc_attackProfile_DRAGON.sqf create mode 100644 addons/dragon/functions/script_component.hpp create mode 100644 addons/dragon/script_component.hpp diff --git a/addons/dragon/$PBOPREFIX$ b/addons/dragon/$PBOPREFIX$ new file mode 100644 index 0000000000..41f191d39b --- /dev/null +++ b/addons/dragon/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\dragon \ No newline at end of file diff --git a/addons/dragon/ACE_GuidanceConfig.hpp b/addons/dragon/ACE_GuidanceConfig.hpp new file mode 100644 index 0000000000..62a18700e2 --- /dev/null +++ b/addons/dragon/ACE_GuidanceConfig.hpp @@ -0,0 +1,10 @@ +class ACEGVAR(missileguidance,AttackProfiles) { + class DRAGON { + name = "FGM-77 Dragon"; + visualName = "FGM-77 Dragon"; + description = "FGM-77 Dragon"; + + functionName = QFUNC(attackProfile_DRAGON); + }; +}; + diff --git a/addons/dragon/CfgAmmo.hpp b/addons/dragon/CfgAmmo.hpp new file mode 100644 index 0000000000..ef861d95c3 --- /dev/null +++ b/addons/dragon/CfgAmmo.hpp @@ -0,0 +1,53 @@ +class CfgAmmo { + class MissileBase; + class CUP_M_47_AT_EP1: MissileBase { + thrust = 0; + initTime = 0; + thrustTime = 0; + sideAirFriction = 0.5; + effectsMissile = ""; + effectFlare = ""; + airFriction = 0.5; + irLock = 0; + manualControl = 0; + deflecting = 0; + fuseDistance = 5; + whistleDist = 2; + timeToLive = 20; + lockType = 0; + + class ace_missileguidance { + enabled = 1; + + minDeflection = 0; // Minium flap deflection for guidance + maxDeflection = 0; // Maximum flap deflection for guidance + incDeflection = 0; // The incrmeent in which deflection adjusts. + + canVanillaLock = 0; // Can this default vanilla lock? Only applicable to non-cadet mode + + // Guidance type for munitions + defaultSeekerType = "SACLOS"; + seekerTypes[] = { "SACLOS" }; + + defaultSeekerLockMode = "LOAL"; + seekerLockModes[] = { "LOAL", "LOBL" }; + + onFired = QACEFUNC(hot,onFired); + + seekLastTargetPos = 0; // seek last target position [if seeker loses LOS of target, continue to last known pos] + seekerAngle = 15; // Angle from the shooter's view that can track the missile + seekerAccuracy = 1; // seeker accuracy multiplier + + seekerMinRange = 75; + seekerMaxRange = 1000; // Range from the missile which the seeker can visually search + + correctionDistance = 15; // distance from center of crosshair where missile sits. If the missile leaves this the missile will ground itself + missileLeadDistance = 0; // distance ahead of the missile where the SACLOS system will project to + offsetFromCrosshair[] = { 0, 0, 0 }; // where the missile wants to stay in relation to the center of the crosshair. + + // Attack profile type selection + defaultAttackProfile = "DRAGON"; + attackProfiles[] = {"DRAGON"}; + }; + }; +} \ No newline at end of file diff --git a/addons/dragon/CfgEventHandlers.hpp b/addons/dragon/CfgEventHandlers.hpp new file mode 100644 index 0000000000..93e3311cf2 --- /dev/null +++ b/addons/dragon/CfgEventHandlers.hpp @@ -0,0 +1,11 @@ +class Extended_PreStart_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preStart)); + }; +}; + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/dragon/CfgMagazines.hpp b/addons/dragon/CfgMagazines.hpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/addons/dragon/CfgWeapons.hpp b/addons/dragon/CfgWeapons.hpp new file mode 100644 index 0000000000..305bf1297e --- /dev/null +++ b/addons/dragon/CfgWeapons.hpp @@ -0,0 +1,6 @@ +class CfgWeapons { + class Launcher_Base_F; + class CUP_launch_M47: Launcher_Base_F { + + }; +}; \ No newline at end of file diff --git a/addons/dragon/README.md b/addons/dragon/README.md new file mode 100644 index 0000000000..9e11f5fb65 --- /dev/null +++ b/addons/dragon/README.md @@ -0,0 +1,11 @@ +ace_dragon +=================== + +Adds M47 Dragon Missile. + + +## Maintainers + +The people responsible for merging changes to this component or answering potential questions. + +- [Name](https://github.com/name) diff --git a/addons/dragon/XEH_PREP.hpp b/addons/dragon/XEH_PREP.hpp new file mode 100644 index 0000000000..0eded7977f --- /dev/null +++ b/addons/dragon/XEH_PREP.hpp @@ -0,0 +1,2 @@ +PREP(attackProfile_DRAGON); + diff --git a/addons/dragon/XEH_preInit.sqf b/addons/dragon/XEH_preInit.sqf new file mode 100644 index 0000000000..b47cf6628d --- /dev/null +++ b/addons/dragon/XEH_preInit.sqf @@ -0,0 +1,9 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP_RECOMPILE_START; +#include "XEH_PREP.hpp" +PREP_RECOMPILE_END; + +ADDON = true; diff --git a/addons/dragon/XEH_preStart.sqf b/addons/dragon/XEH_preStart.sqf new file mode 100644 index 0000000000..022888575e --- /dev/null +++ b/addons/dragon/XEH_preStart.sqf @@ -0,0 +1,3 @@ +#include "script_component.hpp" + +#include "XEH_PREP.hpp" diff --git a/addons/dragon/config.cpp b/addons/dragon/config.cpp new file mode 100644 index 0000000000..668c14254a --- /dev/null +++ b/addons/dragon/config.cpp @@ -0,0 +1,21 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = COMPONENT_NAME; + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author = ECSTRING(common,ACETeam); + authors[] = {""}; + url = ECSTRING(main,URL); + VERSION_CONFIG; + }; +}; + +#include "ACE_GuidanceConfig.hpp" +#include "CfgEventHandlers.hpp" +#include "CfgWeapons.hpp" +#include "CfgMagazines.hpp" +#include "CfgAmmo.hpp" diff --git a/addons/dragon/functions/fnc_attackProfile_DRAGON.sqf b/addons/dragon/functions/fnc_attackProfile_DRAGON.sqf new file mode 100644 index 0000000000..a16778b48f --- /dev/null +++ b/addons/dragon/functions/fnc_attackProfile_DRAGON.sqf @@ -0,0 +1,55 @@ +#include "script_component.hpp" +/* + * Author: Brandon (TCVM) (Code inspired by NouberNou) + * Attack profile: Dragon Guidance + * + * Arguments: + * 0: Seeker Target PosASL + * 1: Guidance Arg Array + * 2: Attack Profile State + * + * Return Value: + * Missile Aim PosASL - Unused + * + * Example: + * [[1,2,3], [], []] call ace_hot_fnc_attackProfile_WIRE; + * + * Public: No + * + */ +params ["_seekerTargetPos", "_args", "_attackProfileStateParams"]; +_args params ["_firedEH", "", "", "", "_stateParams"]; +_firedEH params ["_shooter","_weapon","","","","","_projectile"]; +_attackProfileStateParams params["_maxCorrectableDistance", "_wireCut", "_randomVector", "_crosshairOffset", "_seekerMaxRangeSqr", "_wireCutSource", ["_lastTime", 0]]; +_stateParams params ["_lastRunTime"]; + +private _projectilePos = getPosASL _projectile; + +if ((((getPosASL _shooter) vectorDistanceSqr _projectilePos) > _seekerMaxRangeSqr) || { _wireCut }) exitWith { + // wire snap, random direction + if (_randomVector isEqualTo [0, 0, 0]) then { + _randomVector = RANDOM_VECTOR_3D vectorMultiply 300; + _attackProfileStateParams set [1, true]; + _attackProfileStateParams set [2, _randomVector]; + + playSound3D ["a3\sounds_f\air\sfx\SL_rope_break.wss", objNull, false, AGLtoASL (_shooter modelToWorld _wireCutSource), 150, 1, 25]; + }; + _projectilePos vectorAdd _randomVector +}; +_maxCorrectableDistance = 30; +// if the time between updates is less than the pop time we want to fire the rockets +if ((_lastTime - CBA_missionTime) <= 0) then { + _attackProfileStateParams set [6, CBA_missionTime + 0.3]; + + private _vectorToCrosshair = vectorNormalized (_projectile worldToModel (ASLToAGL _seekerTargetPos)); + private _vectorToPos = vectorNormalized (((_projectile vectorWorldToModelVisual (_shooter weaponDirection _weapon)) vectorMultiply (100 * 0.3)) vectorAdd (_vectorToCrosshair vectorMultiply _maxCorrectableDistance)); + + if ((_vectorToPos select 2) < 0) then { + _vectorToPos set [2, 0]; + }; + + _projectile setVelocityModelSpace ((velocityModelSpace _projectile) vectorAdd (_vectorToPos vectorMultiply 6.5)); +}; + +// Return position in-front of projectile. Because we simulate the velocity updates in this function we dont want missile guidance taking over +_projectilePos vectorAdd (AGLtoASL (_projectile vectorModelToWorld [0, 50, 0])) diff --git a/addons/dragon/functions/script_component.hpp b/addons/dragon/functions/script_component.hpp new file mode 100644 index 0000000000..386679ecf6 --- /dev/null +++ b/addons/dragon/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\dragon\script_component.hpp" \ No newline at end of file diff --git a/addons/dragon/script_component.hpp b/addons/dragon/script_component.hpp new file mode 100644 index 0000000000..d8c5e8e8ae --- /dev/null +++ b/addons/dragon/script_component.hpp @@ -0,0 +1,17 @@ +#define COMPONENT dragon +#define COMPONENT_BEAUTIFIED M47 Dragon +#include "\z\ace\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL + #define DISABLE_COMPILE_CACHE +// #define ENABLE_PERFORMANCE_COUNTERS + +#ifdef DEBUG_ENABLED_DRAGON + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_DRAGON + #define DEBUG_SETTINGS DEBUG_SETTINGS_DRAGON +#endif + +#include "\z\ace\addons\main\script_macros.hpp"