From 9756b2223825769fb28c2893f6eb2d5b446d6d33 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 22 Mar 2019 14:06:42 -0500 Subject: [PATCH] cleanup/tweaks --- addons/artillerytables/CfgVehicles.hpp | 5 +++-- addons/artillerytables/XEH_preInit.sqf | 14 -------------- addons/artillerytables/dev/showShotInfo.sqf | 10 +++++++--- addons/artillerytables/functions/fnc_firedEH.sqf | 2 +- .../functions/fnc_interactMenuOpened.sqf | 2 +- .../functions/fnc_turretChanged.sqf | 11 ++++------- .../artillerytables/functions/fnc_turretPFEH.sqf | 3 ++- addons/artillerytables/initSettings.sqf | 6 ++++-- addons/artillerytables/script_component.hpp | 6 +++--- 9 files changed, 25 insertions(+), 34 deletions(-) diff --git a/addons/artillerytables/CfgVehicles.hpp b/addons/artillerytables/CfgVehicles.hpp index edb1dfce2f..04424e6079 100644 --- a/addons/artillerytables/CfgVehicles.hpp +++ b/addons/artillerytables/CfgVehicles.hpp @@ -1,6 +1,7 @@ class CfgVehicles { - class StaticMortar; - class Mortar_01_base_F: StaticMortar { + class StaticWeapon; + class StaticMortar: StaticWeapon { + // Small mortars seem to need the alternate elevation calculations, GVAR(showGunLaying) = 2; }; }; diff --git a/addons/artillerytables/XEH_preInit.sqf b/addons/artillerytables/XEH_preInit.sqf index 3f5a0848a5..9361d05015 100644 --- a/addons/artillerytables/XEH_preInit.sqf +++ b/addons/artillerytables/XEH_preInit.sqf @@ -8,18 +8,4 @@ PREP_RECOMPILE_END; #include "initSettings.sqf" -DFUNC(rotateVector3d) = { - params ["_vector", "_rotAxis", "_angle"]; - - _vector params ["_x", "_y", "_z"]; - (vectorNormalized _rotAxis) params ["_u", "_v", "_w"]; - - private _f = (_u*_x + _v*_y + _w*_z) * (1-cos(_angle)); - [ - _u*_f + _x*cos(_angle) + (_v*_z - _w*_y)*sin(_angle), - _v*_f + _y*cos(_angle) + (_w*_x - _u*_z)*sin(_angle), - _w*_f + _z*cos(_angle) + (_u*_y - _v*_x)*sin(_angle) - ] -}; - ADDON = true; diff --git a/addons/artillerytables/dev/showShotInfo.sqf b/addons/artillerytables/dev/showShotInfo.sqf index 4275c16479..81a29dca22 100644 --- a/addons/artillerytables/dev/showShotInfo.sqf +++ b/addons/artillerytables/dev/showShotInfo.sqf @@ -7,9 +7,13 @@ INFO("showing shot info"); ((velocity _proj) call CBA_fnc_vect2Polar) params ["_mag", "_dir", "_elev"]; private _shootPos = getPosASL _shooter; if (_dir < 0) then {_dir = _dir + 360;}; - hintSilent format ["%1 m/s\nAz: %2 [%3]\nEl: %4 [%5]\nError: %6",_mag toFixed 1, _dir toFixed 2, ((6400 / 360) * _dir) toFixed 0, _elev toFixed 2, ((6400 / 360) * _elev) toFixed 0, - _elev - (missionNamespace getVariable [QGVAR(predictedElevation), 0])]; - TRACE_1("elev offset",_elev - GVAR(predictedElevation)); + + private _offsetElev = _elev - (missionNamespace getVariable [QGVAR(predictedElevation), -999]); + private _offsetAz = _dir - (missionNamespace getVariable [QGVAR(predictedAzimuth), -999]); + + hintSilent format ["%1 m/s\nAz: %2 [%3]\nEl: %4 [%5]\nError Az: %6\nError EL: %7",_mag toFixed 1, _dir toFixed 2, ((6400 / 360) * _dir) toFixed 0, _elev toFixed 2, ((6400 / 360) * _elev) toFixed 0, + _offsetAz toFixed 3, _offsetElev toFixed 3]; + TRACE_2("",_offsetAz,_offsetElev); private _submunitionAmmo = getText (configFile >> "CfgAmmo" >> _ammo >> "submunitionAmmo"); [{ diff --git a/addons/artillerytables/functions/fnc_firedEH.sqf b/addons/artillerytables/functions/fnc_firedEH.sqf index e1d1a160fc..b2053136e8 100644 --- a/addons/artillerytables/functions/fnc_firedEH.sqf +++ b/addons/artillerytables/functions/fnc_firedEH.sqf @@ -35,7 +35,7 @@ if (isNumber (configFile >> "CfgMagazines" >> _magazine >> QGVAR(airFriction))) _airFriction = getNumber (configFile >> "CfgMagazines" >> _magazine >> QGVAR(airFriction)); }; TRACE_1("",_airFriction); -if (_airFriction == 0) exitWith {}; // 0 disables everything +if (_airFriction >= 0) exitWith {}; // 0 disables everything, >0 makes no sense BEGIN_COUNTER(adjustmentsCalc); diff --git a/addons/artillerytables/functions/fnc_interactMenuOpened.sqf b/addons/artillerytables/functions/fnc_interactMenuOpened.sqf index 80e1d025a8..d169b896c1 100644 --- a/addons/artillerytables/functions/fnc_interactMenuOpened.sqf +++ b/addons/artillerytables/functions/fnc_interactMenuOpened.sqf @@ -64,7 +64,7 @@ TRACE_2("searching for new vehicles",_vehicleAdded,_rangeTablesShown); // Some turrets (MK6) have a neutralX rotation that we need to add to min/max config elevation to get actual limits private _weaponDir = _vehicle weaponDirection _weapon; - private _turretRot = [vectorDir _vehicle, vectorUp _vehicle, deg _currentTraverseRad] call FUNC(rotateVector3d); + private _turretRot = [vectorDir _vehicle, vectorUp _vehicle, deg _currentTraverseRad] call CBA_fnc_vectRotate3D; private _neutralX = (acos ((_turretRot vectorCos _weaponDir) min 1)) - (deg _currentElevRad); // vectorCos can return values outside of -1..1 _neutralX = (round (_neutralX * 10)) / 10; // minimize floating point errors private _minElev = _neutralX + getNumber (_turretCfg >> "minElev"); diff --git a/addons/artillerytables/functions/fnc_turretChanged.sqf b/addons/artillerytables/functions/fnc_turretChanged.sqf index 5a91342ce5..3d6b13bf84 100644 --- a/addons/artillerytables/functions/fnc_turretChanged.sqf +++ b/addons/artillerytables/functions/fnc_turretChanged.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: PabstMirror - * Turret changed. + * Turret changed, determine if we are in the gunner seat of an artillery vehicle. * * Arguments: * 0: Player @@ -20,6 +20,7 @@ params ["_player", "_turret"]; private _vehicle = vehicle _player; private _typeOf = typeOf _vehicle; private _vehicleCfg = configFile >> "CfgVehicles" >> _typeOf; + // config "ace_artillerytables_showGunLaying" [0 disabled, 1 enabled, 2 enabled w/ alt elevationMode] falls back to artilleryScanner private _showGunLaying = if (isNumber (_vehicleCfg >> QGVAR(showGunLaying))) then { getNumber (_vehicleCfg >> QGVAR(showGunLaying)) @@ -40,10 +41,7 @@ if (GVAR(pfID) >= 0) then { if ((alive _player) && {_showGunLaying > 0} && {_player == gunner _vehicle}) then { private _turretCfg = [_typeOf, _turret] call CBA_fnc_getTurret; private _turretAnimBody = getText (_turretCfg >> "animationSourceBody"); - - // Ugh, see FUNC(turretPFEH) for why this is needed - private _useAltElevation = (_showGunLaying == 2) - || {(["Mortar_01_base_F", "rhs_2b14_82mm_Base", "RHS_M252_Base", "CUP_B_M1129_MC_MK19_Desert", "LIB_GrWr34", "LIB_BM37"] findIf {_typeOf isKindOf _x}) > -1;}; + private _useAltElevation = (_showGunLaying == 2); // StaticMortars need elevation calculated differently, see FUNC(turretPFEH) // If the memory point is invalid, then the turret will always use real weapon dir (e.g. CUP BM21) private _memoryPointGunnerOptics = getText (_turretCfg >> "memoryPointGunnerOptics"); @@ -61,8 +59,7 @@ if ((alive _player) && {_showGunLaying > 0} && {_player == gunner _vehicle}) the _fireModes = _fireModes apply {_x select 1}; GVAR(pfID) = [LINKFUNC(turretPFEH), 0, [_vehicle, _turret, _fireModes, _useAltElevation, _turretAnimBody, _invalidGunnerMem]] call CBA_fnc_addPerFrameHandler; - TRACE_1("added pfEH",GVAR(pfID)); - + TRACE_4("added pfEH",GVAR(pfID),_useAltElevation,_turretAnimBody,_invalidGunnerMem); #ifdef DEBUG_MODE_FULL private _ballisticsComputer = getNumber (configFile >> "CfgWeapons" >> _weapon >> "ballisticsComputer"); diff --git a/addons/artillerytables/functions/fnc_turretPFEH.sqf b/addons/artillerytables/functions/fnc_turretPFEH.sqf index 6a392a6bad..b7dce95f18 100644 --- a/addons/artillerytables/functions/fnc_turretPFEH.sqf +++ b/addons/artillerytables/functions/fnc_turretPFEH.sqf @@ -69,7 +69,7 @@ if (_useRealWeaponDir || _invalidGunnerMem) then { private _currentTraverseRad = _vehicle animationSourcePhase _turretAnimBody; if (isNil "_currentTraverseRad") then { _currentTraverseRad = _vehicle animationPhase _turretAnimBody; }; // Get turret roatation around it's z axis, then calc weapon elev in it's projection - private _turretRot = [vectorDir _vehicle, vectorUp _vehicle, deg _currentTraverseRad] call FUNC(rotateVector3d); + private _turretRot = [vectorDir _vehicle, vectorUp _vehicle, deg _currentTraverseRad] call CBA_fnc_vectRotate3D; _realElevation = (acos ((_turretRot vectorCos _weaponDir) min 1)) + ((_turretRot call CBA_fnc_vect2polar) select 2); if (_realElevation > 90) then { _realElevation = 180 - _realElevation; }; // does not flip azimuth! }; @@ -84,6 +84,7 @@ _ctrlAzimuth ctrlSetText Format ["AZ: %1", [DEGTOMILS * _realAzimuth, 4, 0] call _ctrlElevation ctrlSetText Format ["EL: %1", [DEGTOMILS * _realElevation, 4, 0] call CBA_fnc_formatNumber]; _ctrlCharge ctrlSetText format ["CH: %1", _currentChargeMode]; +// avalible for other addons (mk6) GVAR(predictedAzimuth) = _realAzimuth; GVAR(predictedElevation) = _realElevation; diff --git a/addons/artillerytables/initSettings.sqf b/addons/artillerytables/initSettings.sqf index 1ef30f7765..7069e0ef50 100644 --- a/addons/artillerytables/initSettings.sqf +++ b/addons/artillerytables/initSettings.sqf @@ -1,9 +1,11 @@ // CBA Settings [ADDON: ace_artillerytables]: +private _categoryName = format ["ACE %1", localize "str_a3_cfgmarkers_nato_art"]; + [ QGVAR(advancedCorrections), "CHECKBOX", [LSTRING(advancedCorrections_displayName), LSTRING(advancedCorrections_description)], - ["ACE Artillery", QUOTE(COMPONENT_BEAUTIFIED)], + [_categoryName, QUOTE(COMPONENT_BEAUTIFIED)], false, // default value true, // isGlobal {[QGVAR(advancedCorrections), _this] call EFUNC(common,cbaSettings_settingChanged)}, @@ -13,7 +15,7 @@ [ QGVAR(disableArtilleryComputer), "CHECKBOX", [LSTRING(disableArtilleryComputer_displayName), LSTRING(disableArtilleryComputer_description)], - ["ACE Artillery", QUOTE(COMPONENT_BEAUTIFIED)], + [_categoryName, QUOTE(COMPONENT_BEAUTIFIED)], false, // default value true, // isGlobal {[QGVAR(disableArtilleryComputer), _this] call EFUNC(common,cbaSettings_settingChanged)}, diff --git a/addons/artillerytables/script_component.hpp b/addons/artillerytables/script_component.hpp index 56c0480999..128c3c17ff 100644 --- a/addons/artillerytables/script_component.hpp +++ b/addons/artillerytables/script_component.hpp @@ -2,9 +2,9 @@ #define COMPONENT_BEAUTIFIED ArtilleryTables #include "\z\ace\addons\main\script_mod.hpp" -#define DEBUG_MODE_FULL -#define DISABLE_COMPILE_CACHE -#define ENABLE_PERFORMANCE_COUNTERS +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE +// #define ENABLE_PERFORMANCE_COUNTERS #include "\z\ace\addons\main\script_macros.hpp"