From c436541f1c163eaca68380cf007e01b805dc74a7 Mon Sep 17 00:00:00 2001 From: jaynus Date: Tue, 14 Apr 2015 09:36:39 -0700 Subject: [PATCH] Reworked, fun fun. --- addons/missileguidance/CfgAmmo.hpp | 10 +++++----- addons/missileguidance/XEH_pre_init.sqf | 1 + .../functions/fnc_attackProfile_TOP.sqf | 4 ++-- .../functions/fnc_changeMissileDirection.sqf | 11 +++++++++++ addons/missileguidance/functions/fnc_guidancePFH.sqf | 3 +-- 5 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 addons/missileguidance/functions/fnc_changeMissileDirection.sqf diff --git a/addons/missileguidance/CfgAmmo.hpp b/addons/missileguidance/CfgAmmo.hpp index 7ad1be1fd5..ebff1a65ae 100644 --- a/addons/missileguidance/CfgAmmo.hpp +++ b/addons/missileguidance/CfgAmmo.hpp @@ -43,8 +43,8 @@ class CfgAmmo { class ADDON { enabled = 1; - minDeflection = 0.0005; // Minium flap deflection for guidance - maxDeflection = 0.0025; // Maximum flap deflection for guidance + minDeflection = 0.00025; // Minium flap deflection for guidance + maxDeflection = 0.00025; // Maximum flap deflection for guidance incDeflection = 0.0005; // The incrmeent in which deflection adjusts. //minDeflection = 0.005; //maxDeflection = 0.5; @@ -113,9 +113,9 @@ class CfgAmmo { class ADDON { enabled = 1; - minDeflection = 0.005; // Minium flap deflection for guidance - maxDeflection = 0.25; // Maximum flap deflection for guidance - incDeflection = 0.005; // The incrmeent in which deflection adjusts. + minDeflection = 0.00005; // Minium flap deflection for guidance + maxDeflection = 0.025; // Maximum flap deflection for guidance + incDeflection = 0.00005; // The incrmeent in which deflection adjusts. //minDeflection = 0.005; //maxDeflection = 0.5; //incDeflection = 0.005; diff --git a/addons/missileguidance/XEH_pre_init.sqf b/addons/missileguidance/XEH_pre_init.sqf index 403d6245ca..4a5beaa329 100644 --- a/addons/missileguidance/XEH_pre_init.sqf +++ b/addons/missileguidance/XEH_pre_init.sqf @@ -2,6 +2,7 @@ PREP(rotateVectLineGetMap); PREP(rotateVectLine); +PREP(changeMissileDirection); PREP(checkSeekerAngle); PREP(checkLos); diff --git a/addons/missileguidance/functions/fnc_attackProfile_TOP.sqf b/addons/missileguidance/functions/fnc_attackProfile_TOP.sqf index fc9afed104..4e83e046ff 100644 --- a/addons/missileguidance/functions/fnc_attackProfile_TOP.sqf +++ b/addons/missileguidance/functions/fnc_attackProfile_TOP.sqf @@ -1,4 +1,4 @@ -#define DEBUG_MODE_FULL +//#define DEBUG_MODE_FULL #include "script_component.hpp" #define STAGE_LAUNCH 1 @@ -64,7 +64,7 @@ switch( (_state select 0) ) do { }; case STAGE_TERMINAL: { TRACE_1("STAGE_TERMINAL",""); - + //_returnTargetPos = _seekerTargetPos vectorAdd [0,0,_distanceToTarget * 0.02]; }; }; diff --git a/addons/missileguidance/functions/fnc_changeMissileDirection.sqf b/addons/missileguidance/functions/fnc_changeMissileDirection.sqf new file mode 100644 index 0000000000..fda7ba9d07 --- /dev/null +++ b/addons/missileguidance/functions/fnc_changeMissileDirection.sqf @@ -0,0 +1,11 @@ +#include "script_component.hpp" +private ["_projectile", "_v", "_l", "_r"]; + +_projectile = _this select 0; +_v = _this select 1; + +_l = sqrt ((_v select 0) ^ 2 + (_v select 1) ^ 2); +_r = -(_v select 2) / _l; + +_projectile setVectorDirAndUp [ _v, [(_v select 0) * _r,(_v select 1) * _r, _l] ]; +_projectile setVelocity (_v vectorMultiply (vectorMagnitude (velocity _projectile))); \ No newline at end of file diff --git a/addons/missileguidance/functions/fnc_guidancePFH.sqf b/addons/missileguidance/functions/fnc_guidancePFH.sqf index a461cf9163..f7fd56c164 100644 --- a/addons/missileguidance/functions/fnc_guidancePFH.sqf +++ b/addons/missileguidance/functions/fnc_guidancePFH.sqf @@ -85,8 +85,7 @@ TRACE_4("", _targetVector, _targetRelativeVector, _adjustVector, _finalAdjustVec if(accTime > 0) then { _changeVector = (vectorDir _projectile) vectorAdd _finalAdjustVector; - //_changeVector = (vectorDir _projectile) vectorAdd _adjustVector; // Test direct to target - _projectile setVectorDirAndUp [_changeVector, vectorUp _projectile]; + [_projectile, _changeVector] call FUNC(changeMissileDirection); }; #ifdef DEBUG_MODE_FULL