From 16a296e92b7e67b69add1d5ac4386aeb4fb6cb4f Mon Sep 17 00:00:00 2001 From: jaynus Date: Mon, 19 Jan 2015 20:13:12 -0800 Subject: [PATCH 1/5] laser_selfdesginate commit for commanche --- addons/laser_selfdesignate/$PBOPREFIX$ | 1 + .../laser_selfdesignate/CfgEventhandlers.hpp | 27 ++++++ addons/laser_selfdesignate/CfgUI.hpp | 32 +++++++ addons/laser_selfdesignate/CfgVehicles.hpp | 35 ++++++++ addons/laser_selfdesignate/CfgWeapons.hpp | 10 +++ addons/laser_selfdesignate/XEH_post_init.sqf | 3 + addons/laser_selfdesignate/XEH_pre_init.sqf | 12 +++ addons/laser_selfdesignate/config.cpp | 17 ++++ .../functions/fnc_laserHudDesignateOff.sqf | 20 +++++ .../functions/fnc_laserHudDesignateOn.sqf | 90 +++++++++++++++++++ .../functions/fnc_onGetin.sqf | 13 +++ .../functions/fnc_onGetout.sqf | 10 +++ .../functions/script_component.hpp | 1 + .../laser_selfdesignate/script_component.hpp | 12 +++ .../missileguidance/functions/fnc_fired.sqf | 4 +- 15 files changed, 285 insertions(+), 2 deletions(-) create mode 100644 addons/laser_selfdesignate/$PBOPREFIX$ create mode 100644 addons/laser_selfdesignate/CfgEventhandlers.hpp create mode 100644 addons/laser_selfdesignate/CfgUI.hpp create mode 100644 addons/laser_selfdesignate/CfgVehicles.hpp create mode 100644 addons/laser_selfdesignate/CfgWeapons.hpp create mode 100644 addons/laser_selfdesignate/XEH_post_init.sqf create mode 100644 addons/laser_selfdesignate/XEH_pre_init.sqf create mode 100644 addons/laser_selfdesignate/config.cpp create mode 100644 addons/laser_selfdesignate/functions/fnc_laserHudDesignateOff.sqf create mode 100644 addons/laser_selfdesignate/functions/fnc_laserHudDesignateOn.sqf create mode 100644 addons/laser_selfdesignate/functions/fnc_onGetin.sqf create mode 100644 addons/laser_selfdesignate/functions/fnc_onGetout.sqf create mode 100644 addons/laser_selfdesignate/functions/script_component.hpp create mode 100644 addons/laser_selfdesignate/script_component.hpp diff --git a/addons/laser_selfdesignate/$PBOPREFIX$ b/addons/laser_selfdesignate/$PBOPREFIX$ new file mode 100644 index 0000000000..3871f5df99 --- /dev/null +++ b/addons/laser_selfdesignate/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\Addons\laser_selfdesignate \ No newline at end of file diff --git a/addons/laser_selfdesignate/CfgEventhandlers.hpp b/addons/laser_selfdesignate/CfgEventhandlers.hpp new file mode 100644 index 0000000000..27cc988813 --- /dev/null +++ b/addons/laser_selfdesignate/CfgEventhandlers.hpp @@ -0,0 +1,27 @@ +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_pre_init)); + }; +}; + +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_post_init)); + }; +}; + +class Extended_GetIn_EventHandlers { + class B_Heli_Attack_01_F { + class ADDON { + getIn = QUOTE(call FUNC(onGetin)); + }; + } +}; + +class Extended_GetOut_EventHandlers { + class B_Heli_Attack_01_F { + class ADDON { + getOut = QUOTE(call FUNC(onGetout)); + }; + }; +}; diff --git a/addons/laser_selfdesignate/CfgUI.hpp b/addons/laser_selfdesignate/CfgUI.hpp new file mode 100644 index 0000000000..11fab908d7 --- /dev/null +++ b/addons/laser_selfdesignate/CfgUI.hpp @@ -0,0 +1,32 @@ +class RscPicture; +class RscText; +class RscControlsGroupNoScrollbars; +/* This disables air radar. We need to make this a seperate HUD addon +class RscInGameUI +{ + class RscUnitInfo + { + class CA_Radar: RscControlsGroupNoScrollbars + { + class controls + { + class CA_RadarBackground: RscPicture { + colorText[] = {0,0,0,0}; + text = ""; + }; + class CA_RadarIcon: RscPicture { + colorText[] = {0,0,0,0}; + }; + class CA_Heading: RscText { + colorText[] = {0,0,0,0}; + }; + }; + }; + }; +}; +class CfgInGameUI +{ + +}; + +*/ \ No newline at end of file diff --git a/addons/laser_selfdesignate/CfgVehicles.hpp b/addons/laser_selfdesignate/CfgVehicles.hpp new file mode 100644 index 0000000000..eed000544c --- /dev/null +++ b/addons/laser_selfdesignate/CfgVehicles.hpp @@ -0,0 +1,35 @@ +class CfgVehicles { + class AllVehicles; + + class Air: AllVehicles { + class Turrets; + }; + class Helicopter: Air + { + class Turrets: Turrets { + class MainTurret; + }; + // TODO: move these to a different HUD addon + // commanderCanSee = 2+32; + // gunnerCanSee = 2+32; + // driverCanSee = 2+32; + + }; + class Helicopter_Base_F: Helicopter { + class Turrets: Turrets { + class MainTurret: MainTurret {}; + }; + }; + class Heli_Attack_01_base_F: Helicopter_Base_F { + class Turrets: Turrets { + class MainTurret: MainTurret {}; + }; + }; + class B_Heli_Attack_01_F: Heli_Attack_01_base_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + stabilizedInAxes = 4; // This stablizes the turret a bit more for laser designation + }; + }; + }; +}; \ No newline at end of file diff --git a/addons/laser_selfdesignate/CfgWeapons.hpp b/addons/laser_selfdesignate/CfgWeapons.hpp new file mode 100644 index 0000000000..a966144b10 --- /dev/null +++ b/addons/laser_selfdesignate/CfgWeapons.hpp @@ -0,0 +1,10 @@ +class CfgWeapons { + class LauncherCore; + + class RocketPods: LauncherCore { + canLock = 1; // Disable locking unless newb mode + }; + class missiles_DAGR: RocketPods { + canLock = 1; // Disable locking unless newb mode + }; +}; \ No newline at end of file diff --git a/addons/laser_selfdesignate/XEH_post_init.sqf b/addons/laser_selfdesignate/XEH_post_init.sqf new file mode 100644 index 0000000000..6904ee6c47 --- /dev/null +++ b/addons/laser_selfdesignate/XEH_post_init.sqf @@ -0,0 +1,3 @@ +#include "script_component.hpp" +NO_DEDICATED; + diff --git a/addons/laser_selfdesignate/XEH_pre_init.sqf b/addons/laser_selfdesignate/XEH_pre_init.sqf new file mode 100644 index 0000000000..4e98fce7ec --- /dev/null +++ b/addons/laser_selfdesignate/XEH_pre_init.sqf @@ -0,0 +1,12 @@ +#include "script_component.hpp" + +PREP(onGetIn); +PREP(onGetOut); + +PREP(laserHudDesignateOn); +PREP(laserHudDesignateOff); + +GVAR(laser) = nil; +GVAR(laserActive) = false; + +FUNC(getPosASL) = {visiblePositionASL (_this select 0)}; \ No newline at end of file diff --git a/addons/laser_selfdesignate/config.cpp b/addons/laser_selfdesignate/config.cpp new file mode 100644 index 0000000000..5452ee4e22 --- /dev/null +++ b/addons/laser_selfdesignate/config.cpp @@ -0,0 +1,17 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = { "ace_main", "ace_laser" }; + version = VERSION; + }; +}; + +#include "CfgUI.hpp" + +#include "CfgEventhandlers.hpp" +#include "CfgWeapons.hpp" +#include "CfgVehicles.hpp" \ No newline at end of file diff --git a/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOff.sqf b/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOff.sqf new file mode 100644 index 0000000000..088f3d9303 --- /dev/null +++ b/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOff.sqf @@ -0,0 +1,20 @@ +#include "script_component.hpp" + +if(isNil QGVAR(laser)) exitWith { + false +}; +if(!local GVAR(laser)) then { + false +}; + +_handle = GVAR(laser) getVariable ["ACE_PFH_HANDLE", nil]; +if(!isNil "_handle") then { + [_handle] call cba_fnc_removePerFrameHandler; +}; + +REM(ACE_LASERS, GVAR(laser)); +deleteVehicle GVAR(laser); +GVAR(laser) = nil; +GVAR(laserActive) = false; + +true \ No newline at end of file diff --git a/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOn.sqf b/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOn.sqf new file mode 100644 index 0000000000..bac440c853 --- /dev/null +++ b/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOn.sqf @@ -0,0 +1,90 @@ +//#define DEBUG_MODE_FULL +#include "script_component.hpp" + +TRACE_1("enter", _this); + +FUNC(magnitude) = { + _this distance [0, 0, 0] +}; + +FUNC(mat_normalize3d) = { + private ["_mag"]; + PARAMS_3(_vx,_vy,_vz); + + _mag = _this call FUNC(magnitude); + if (_mag == 0) then {_mag = 1}; + [(_vx/_mag), (_vy/_mag), (_vz/_mag)] +}; + +FUNC(laserHudDesignatePFH) = { + _args = _this select 0; + _laserTarget = _args select 0; + _shooter = _args select 1; + + _vehicle = vehicle _shooter; + _weapon = currentWeapon _vehicle; + + if(!alive _shooter || isNull _vehicle || isNull _laserTarget || !GVAR(laserActive) ) exitWith { + [(_this select 1)] call cba_fnc_removePerFrameHandler; + }; + + // Retrieve the gunner and turret memory point information + _gunnerInfo = [_vehicle, _weapon] call CBA_fnc_getFirer; + + _turret = [_vehicle, _gunnerInfo select 1] call CBA_fnc_getTurret; + _pov = getText (_turret >> "memoryPointGunnerOptics"); + _gunBeg = getText (_turret >> "gunBeg"); + _gunEnd = getText (_turret >> "gunEnd"); + TRACE_3("", _pov, _gunBeg, _gunEnd); + + // Pull the PIP pov or barrel direction, depending on how the model is set up + _povPos = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition _pov ) ); + _povDir = [0,0,0]; + if(_pov == "pip0_pos") then { + _pipDir = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition "pip0_dir" ) ); + _povDir = [_povPos, _pipDir] call BIS_fnc_vectorDiff; + } else { + _gunBeginPos = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition _gunBeg ) ); + _gunEndPos = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition _gunEnd ) ); + _povDir = [_gunEndPos, _gunBeginPos] call BIS_fnc_vectorDiff; + }; + + TRACE_4("", _povDir, _povPos, _gunBeginPos, _gunEndPos); + + _result = [_povPos, _povDir] call EFUNC(laser,shootCone); + + if((count _result) > 0) then { + _resultPositions = _result select 2; + + if((count _resultPositions) > 0) then { + _firstResult = _resultPositions select 0; + _pos = _firstResult select 0; + + // If the laser has moved less than a half meter, then dont move it. + // Just regular use of lasers will commonly make them move this much, + // but not across multiple close frames. + // This loses accuracy a little, but saves position updates per frame. + //if( ((getPosASL _laserTarget) distance _pos) > 0.5) then { + _laserTarget setPosATL (ASLToATL _pos); + //}; +#ifdef DEBUG_MODE_FULL + drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], ASLToATL _pos, 0.75, 0.75, 0, "", 0.5, 0.025, "TahomaB"]; +#endif + }; + }; +}; + +if(isNil QGVAR(laser)) then { + _laserTarget = "LaserTarget" createVehicle (getpos player); + + GVAR(laserActive) = true; + + _handle = [FUNC(laserHudDesignatePFH), 0, [_laserTarget, player]] call cba_fnc_addPerFrameHandler; + _laserTarget setVariable ["ACE_PFH_HANDLE", _handle, false]; + + GVAR(laser) = _laserTarget; +} else { + [] call FUNC(laserHudDesignateOff); + [] call FUNC(laserHudDesignateOn); +}; + diff --git a/addons/laser_selfdesignate/functions/fnc_onGetin.sqf b/addons/laser_selfdesignate/functions/fnc_onGetin.sqf new file mode 100644 index 0000000000..d6f555c02f --- /dev/null +++ b/addons/laser_selfdesignate/functions/fnc_onGetin.sqf @@ -0,0 +1,13 @@ +#define DEBUG_MODE_FULL +#include "script_component.hpp" +// TODO: we should do this differently eventually +private["_onActionId", "_offActionId"]; +TRACE_1("ENTER", _this); + +// TODO: THIS SHOULD NOT BE ACTIONS EVENTUALLY + +_onActionId = player addAction ["Laser Designator On", { _this call FUNC(laserHudDesignateOn) }, [], 1, false, false, "", QUOTE( (gunner (vehicle player)) == player && !GVAR(laserActive))]; +player setVariable[QGVAR(onActionId), _onActionId, false]; + +_offActionId = player addAction ["Laser Designator Off", { _this call FUNC(laserHudDesignateOff) }, [], 1, false, false, "", QUOTE( (gunner (vehicle player)) == player && GVAR(laserActive))]; +player setVariable[QGVAR(offActionId), _offActionId, false]; \ No newline at end of file diff --git a/addons/laser_selfdesignate/functions/fnc_onGetout.sqf b/addons/laser_selfdesignate/functions/fnc_onGetout.sqf new file mode 100644 index 0000000000..2a32403c19 --- /dev/null +++ b/addons/laser_selfdesignate/functions/fnc_onGetout.sqf @@ -0,0 +1,10 @@ +#include "script_component.hpp" + +_onActionId = player getVariable[QGVAR(onActionId), -1]; +_offActionId = player getVariable[QGVAR(offActionId), -1]; + +player removeAction _onActionId; +player removeAction _offActionId; + +player setVariable[QGVAR(onActionId), -1, false]; +player setVariable[QGVAR(offActionId), -1, false]; \ No newline at end of file diff --git a/addons/laser_selfdesignate/functions/script_component.hpp b/addons/laser_selfdesignate/functions/script_component.hpp new file mode 100644 index 0000000000..38c6d2c44b --- /dev/null +++ b/addons/laser_selfdesignate/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\Addons\laser_selfdesignate\script_component.hpp" diff --git a/addons/laser_selfdesignate/script_component.hpp b/addons/laser_selfdesignate/script_component.hpp new file mode 100644 index 0000000000..c9742423df --- /dev/null +++ b/addons/laser_selfdesignate/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT laser_selfdesignate +#include "\z\ace\Addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_LASER_SELFDESIGNATE + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_LASER_SELFDESIGNATE + #define DEBUG_SETTINGS DEBUG_SETTINGS_LASER_SELFDESIGNATE +#endif + +#include "\z\ace\Addons\main\script_macros.hpp" diff --git a/addons/missileguidance/functions/fnc_fired.sqf b/addons/missileguidance/functions/fnc_fired.sqf index dd0cba4fb8..0cf299849f 100644 --- a/addons/missileguidance/functions/fnc_fired.sqf +++ b/addons/missileguidance/functions/fnc_fired.sqf @@ -6,6 +6,6 @@ PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); if(!local _shooter) exitWith { false }; if(_weapon == "missiles_DAGR") then { - //_this call FUNC(guidance_DAGR); - _this call FUNC(guidance_HellfireII); + _this call FUNC(guidance_DAGR); + //_this call FUNC(guidance_HellfireII); }; \ No newline at end of file From c5d03ce2c0b9f757cc28c6402b3dc75cad4f84cb Mon Sep 17 00:00:00 2001 From: jaynus Date: Mon, 19 Jan 2015 20:16:33 -0800 Subject: [PATCH 2/5] GBU and DAGR guidance initializations. --- addons/missileguidance/functions/fnc_fired.sqf | 15 +++++++++++---- .../functions/fnc_guidance_HellfireII.sqf | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/addons/missileguidance/functions/fnc_fired.sqf b/addons/missileguidance/functions/fnc_fired.sqf index 0cf299849f..3b4f4b3635 100644 --- a/addons/missileguidance/functions/fnc_fired.sqf +++ b/addons/missileguidance/functions/fnc_fired.sqf @@ -5,7 +5,14 @@ TRACE_1("enter", _this); PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); if(!local _shooter) exitWith { false }; -if(_weapon == "missiles_DAGR") then { - _this call FUNC(guidance_DAGR); - //_this call FUNC(guidance_HellfireII); -}; \ No newline at end of file + +switch _weapon do { + case "missiles_DAGR": { + _this call FUNC(guidance_DAGR); + }; + case "GBU12BombLauncher": { + _this call FUNC(guidance_LGB); + }; +}; + +//_this call FUNC(guidance_HellfireII); diff --git a/addons/missileguidance/functions/fnc_guidance_HellfireII.sqf b/addons/missileguidance/functions/fnc_guidance_HellfireII.sqf index d7d56b7d88..54044977a8 100644 --- a/addons/missileguidance/functions/fnc_guidance_HellfireII.sqf +++ b/addons/missileguidance/functions/fnc_guidance_HellfireII.sqf @@ -1,4 +1,4 @@ -#define DEBUG_MODE_FULL +//#define DEBUG_MODE_FULL #include "script_component.hpp" FUNC(guidance_Hellfire_LOAL_HI_PFH) = { From 7e621616d05cfd6967a55444d74b535367c6869d Mon Sep 17 00:00:00 2001 From: jaynus Date: Mon, 19 Jan 2015 20:19:33 -0800 Subject: [PATCH 3/5] function name error. --- addons/missileguidance/functions/fnc_guidance_HellfireII.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/missileguidance/functions/fnc_guidance_HellfireII.sqf b/addons/missileguidance/functions/fnc_guidance_HellfireII.sqf index 54044977a8..e6551ad4f4 100644 --- a/addons/missileguidance/functions/fnc_guidance_HellfireII.sqf +++ b/addons/missileguidance/functions/fnc_guidance_HellfireII.sqf @@ -21,7 +21,7 @@ FUNC(guidance_Hellfire_LOAL_HI_PFH) = { _shooter setVariable [QGVAR(launchTime), diag_tickTime, false]; }; - _targets = [_missile, ACE_DEFAULT_LASER_CODE, 70, _curVelocity] call ace__laser_fnc_findLaserDesignator; + _targets = [_missile, ACE_DEFAULT_LASER_CODE, 70, _curVelocity] call ace_laser_fnc_findLaserDesignator; _addHeight = [0,0,0]; if((_targets select 0)) then { _target = _targets select 1; From eaa157b4c5613fe9185fceee70e1ec11c9b5bad8 Mon Sep 17 00:00:00 2001 From: jaynus Date: Wed, 21 Jan 2015 20:35:27 -0800 Subject: [PATCH 4/5] Fixed script error on launch missing ; --- addons/weather/XEH_postInit.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/weather/XEH_postInit.sqf b/addons/weather/XEH_postInit.sqf index b2302d34b9..f6f385e140 100644 --- a/addons/weather/XEH_postInit.sqf +++ b/addons/weather/XEH_postInit.sqf @@ -58,7 +58,7 @@ _fnc_updateTemperature = { // Humidity GVAR(currentHumidity) = (GVAR(Humidity) select _month) / 100; - GVAR(currentHumidity) = GVAR(currentHumidity) + GVAR(currentHumidity) = GVAR(currentHumidity); if (rain > 0 && overcast > 0.7) then { GVAR(currentHumidity) = 1; From 81ae9e6e8fe2e7dfb0c6377dcff3c22b1bac7efe Mon Sep 17 00:00:00 2001 From: jaynus Date: Wed, 21 Jan 2015 21:31:58 -0800 Subject: [PATCH 5/5] Javelin fixed and firing TDA terminal kill. Direct selection needs to be completed. --- addons/wep_javelin/XEH_pre_init.sqf | 5 +- addons/wep_javelin/functions/fnc_fired.sqf | 65 ++++++++++++------- .../functions/fnc_translateToModelSpace.sqf | 16 +++++ .../functions/fnc_translateToWeaponSpace.sqf | 23 +++++++ 4 files changed, 86 insertions(+), 23 deletions(-) create mode 100644 addons/wep_javelin/functions/fnc_translateToModelSpace.sqf create mode 100644 addons/wep_javelin/functions/fnc_translateToWeaponSpace.sqf diff --git a/addons/wep_javelin/XEH_pre_init.sqf b/addons/wep_javelin/XEH_pre_init.sqf index 8682a8a2e9..f826c6cf93 100644 --- a/addons/wep_javelin/XEH_pre_init.sqf +++ b/addons/wep_javelin/XEH_pre_init.sqf @@ -1,4 +1,7 @@ #include "script_component.hpp" PREP(fired); -PREP(onGetLockedTarget); \ No newline at end of file +PREP(onGetLockedTarget); + +PREP(translateToWeaponSpace); +PREP(translateToModelSpace); \ No newline at end of file diff --git a/addons/wep_javelin/functions/fnc_fired.sqf b/addons/wep_javelin/functions/fnc_fired.sqf index df4f45e17e..d576975c96 100644 --- a/addons/wep_javelin/functions/fnc_fired.sqf +++ b/addons/wep_javelin/functions/fnc_fired.sqf @@ -6,19 +6,44 @@ PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); FUNC(guidance_Javelin_LOBL_HI_PFH) = { TRACE_1("enter", _this); + private["_pitch", "_yaw", "_wentTerminal", "_target", "_targetPos", "_curVelocity", "_missile" ]; _args = _this select 0; //PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); _shooter = _args select 0; _missile = _args select 6; + + if((count _this) > 2) then { + _wentTerminal = _this select 2; + } else { + _this set[2, false]; + _wentTerminal = false; + }; + + if((count _this) > 3) then { + _targets = _this select 3; + _target = _targets select 0; + _targetPos = _targets select 1; + } else { + _this set[3, [GVAR(currentTarget),GVAR(currentTargetPos)] ]; + _target = GVAR(currentTarget); + _targetPos = GVAR(currentTargetPos); + }; + _curVelocity = velocity _missile; - if(!alive _missile || isNull _missile || isNull _shooter) exitWith { + if(!alive _missile || isNull _missile) exitWith { [(_this select 1)] call cba_fnc_removePerFrameHandler; }; - TRACE_2("Setting launch parameters", GVAR(currentTarget), GVAR(currentTargetPos)); - _target = GVAR(currentTarget); + _launchPos = _shooter getVariable [QGVAR(launchPos), nil]; + if(isNil "_launchPos") then { + TRACE_1("Setting launch parameters", ""); + _launchPos = getPosASL _shooter; + _shooter setVariable [QGVAR(launchPos), _launchPos, false]; + _shooter setVariable [QGVAR(launchTime), diag_tickTime, false]; + }; + _addHeight = [0,0,0]; if(!isNil "_target") then { @@ -28,37 +53,28 @@ FUNC(guidance_Javelin_LOBL_HI_PFH) = { _missilePos = getPosASL _missile; // player sideChat "G!"; - _targetPos = GVAR(currentTargetPos); - + TRACE_4("Phase Check", _launchPos, _missilePos, _targetPos, (_missilePos distance _targetPos)); if((count _targetPos) > 0) then { - _distanceToTarget = _missilePos vectorDistance _targetPos; + _distanceToTarget = [(_missilePos select 0), (_missilePos select 1), (_targetPos select 2)] vectorDistance _targetPos; - _defPitch = 0.05; + _defPitch = 0.25; - if((_launchPos distance _missilePos) < 400 && (_targetPos distance _missilePos) > 400) then { - _addHeight = [0,0,(_targetPos select 2) + ((_launchPos distance _targetPos)*2)]; + if( (_missilePos select 2) < (_targetPos select 2) + 160 && !_wentTerminal) then { + _addHeight = [0,0,(_targetPos select 2) + ( (_distanceToTarget * 2) + 160)]; TRACE_1("Climb phase", _addHeight); - //_defPitch = 0.1; } else { - // Covered half the distance, go terminal - if((_missilePos distance _targetPos) < (_launchPos distance _targetPos) / 2) then { - TRACE_1("TERMINAL", ""); - } else { - if((_missilePos select 2) > (_targetPos select 2)) then { - _heightDiff = (_missilePos select 2) - (_targetPos select 2); - TRACE_1("Coasting", _heightDiff); - _addHeight = [0,0, _heightDiff]; - }; - }; + _wentTerminal = true; + _this set[2, _wentTerminal]; + TRACE_1("TERMINAL", ""); }; _targetPos = _targetPos vectorAdd _addHeight; _defYaw = 0.0035; - _targetVectorSeeker = [_missile, [_xVec, _yVec, _zVec], _targetPos] call FUNC(translateToWeaponSpace); _yaw = 0.0; + TRACE_5("", _missile, _xVec, _yVec, _zVec, _targetPos); if((_targetVectorSeeker select 0) < 0) then { _yaw = -_defYaw; } else { @@ -75,6 +91,9 @@ FUNC(guidance_Javelin_LOBL_HI_PFH) = { _pitch = _defPitch; }; }; + + TRACE_3("", _targetVectorSeeker, _pitch, _yaw); + #ifdef DEBUG_MODE_FULL drawLine3D [(ASLtoATL _targetPos) vectorAdd _addHeight, ASLtoATL _targetPos, [0,1,0,1]]; @@ -95,9 +114,11 @@ FUNC(guidance_Javelin_LOBL_HI_PFH) = { #endif if(accTime > 0) then { + TRACE_5("", _xVec, _yVec, _zVec, _yaw, _pitch); _outVector = [_missile, [_xVec, _yVec, _zVec], [_yaw, 1/accTime, _pitch]] call FUNC(translateToModelSpace); _vectorTo = _missilePos vectorFromTo _outVector; + TRACE_3("", _missile, _outVector, _vectorTo); _missile setVectorDirAndUp [_vectorTo, vectorUp _missile]; }; @@ -116,7 +137,7 @@ FUNC(guidance_Javelin_LOBL_HI) = { }; if(!local _shooter) exitWith { false }; -if(_weapon == "launch_B_Titan_short_F") then { +if(_ammo == "M_Titan_AT") then { _fireMode = _shooter getVariable ["ACE_FIRE_SELECTION", ACE_DEFAULT_FIRE_SELECTION]; switch (_fireMode select 0) do { diff --git a/addons/wep_javelin/functions/fnc_translateToModelSpace.sqf b/addons/wep_javelin/functions/fnc_translateToModelSpace.sqf new file mode 100644 index 0000000000..1e2e930ac7 --- /dev/null +++ b/addons/wep_javelin/functions/fnc_translateToModelSpace.sqf @@ -0,0 +1,16 @@ +_object = _this select 0; +_origin = getPosASL _object; +_matrix = _this select 1; +_xVec = _matrix select 0; +_yVec = _matrix select 1; +_zVec = _matrix select 2; + +_offset = _this select 2; + +_x = _offset select 0; +_y = _offset select 1; +_z = _offset select 2; + +_out = (((_xVec vectorMultiply _x) vectorAdd (_yVec vectorMultiply _y)) vectorAdd (_zVec vectorMultiply _z)) vectorAdd _origin; + +_out; \ No newline at end of file diff --git a/addons/wep_javelin/functions/fnc_translateToWeaponSpace.sqf b/addons/wep_javelin/functions/fnc_translateToWeaponSpace.sqf new file mode 100644 index 0000000000..d74fa17fa1 --- /dev/null +++ b/addons/wep_javelin/functions/fnc_translateToWeaponSpace.sqf @@ -0,0 +1,23 @@ + +_object = _this select 0; +_origin = getPosASL _object; +_matrix = _this select 1; +_xVec = _matrix select 0; +_yVec = _matrix select 1; +_zVec = _matrix select 2; + +_offset = _this select 2; + +_offset = _offset vectorDiff _origin; + +_x = _offset select 0; +_y = _offset select 1; +_z = _offset select 2; + +_out = [ + ((_xVec select 0)*_x) + ((_xVec select 1)*_y) + ((_xVec select 2)*_z), + ((_yVec select 0)*_x) + ((_yVec select 1)*_y) + ((_yVec select 2)*_z), + ((_zVec select 0)*_x) + ((_zVec select 1)*_y) + ((_zVec select 2)*_z) + ]; + +_out; \ No newline at end of file