From 659b5faa071ef9c25dc23c3a15c9264dd23c3c93 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sat, 16 Mar 2019 11:56:58 -0500 Subject: [PATCH] Integrate with mk6 --- addons/artillerytables/CfgMagazines.hpp | 6 ++++++ addons/artillerytables/CfgVehicles.hpp | 5 ++++- addons/artillerytables/XEH_postInit.sqf | 1 + addons/artillerytables/config.cpp | 1 + addons/artillerytables/dev/checkConfigs.sqf | 18 ++++++++++++++++++ .../artillerytables/functions/fnc_firedEH.sqf | 2 +- .../functions/fnc_interactMenuOpened.sqf | 16 ++++++++-------- .../functions/fnc_rangeTableOpen.sqf | 8 ++++---- .../functions/fnc_turretPFEH.sqf | 3 +-- addons/mk6mortar/config.cpp | 2 +- addons/mk6mortar/functions/fnc_handleFired.sqf | 1 + .../fnc_handlePlayerVehicleChanged.sqf | 11 ++++++----- .../mk6mortar/functions/fnc_rangeTableOpen.sqf | 4 ++++ 13 files changed, 56 insertions(+), 22 deletions(-) create mode 100644 addons/artillerytables/CfgMagazines.hpp create mode 100644 addons/artillerytables/dev/checkConfigs.sqf diff --git a/addons/artillerytables/CfgMagazines.hpp b/addons/artillerytables/CfgMagazines.hpp new file mode 100644 index 0000000000..e6abdcf06e --- /dev/null +++ b/addons/artillerytables/CfgMagazines.hpp @@ -0,0 +1,6 @@ +class CfgMagazines { + class 32Rnd_155mm_Mo_shells; + class 8Rnd_82mm_Mo_shells: 32Rnd_155mm_Mo_shells { + GVAR(airFriction) = -0.0001; + }; +}; diff --git a/addons/artillerytables/CfgVehicles.hpp b/addons/artillerytables/CfgVehicles.hpp index 7a7a2ae379..edb1dfce2f 100644 --- a/addons/artillerytables/CfgVehicles.hpp +++ b/addons/artillerytables/CfgVehicles.hpp @@ -1,3 +1,6 @@ class CfgVehicles { - + class StaticMortar; + class Mortar_01_base_F: StaticMortar { + GVAR(showGunLaying) = 2; + }; }; diff --git a/addons/artillerytables/XEH_postInit.sqf b/addons/artillerytables/XEH_postInit.sqf index 6a4d790ef8..6560f11c2c 100644 --- a/addons/artillerytables/XEH_postInit.sqf +++ b/addons/artillerytables/XEH_postInit.sqf @@ -33,4 +33,5 @@ #ifdef DEBUG_MODE_FULL #include "dev\showShotInfo.sqf" +#include "dev\checkConfigs.sqf" #endif diff --git a/addons/artillerytables/config.cpp b/addons/artillerytables/config.cpp index 929e73798b..c2d9ff206b 100644 --- a/addons/artillerytables/config.cpp +++ b/addons/artillerytables/config.cpp @@ -19,6 +19,7 @@ class ACE_Extensions { }; #include "CfgEventHandlers.hpp" +#include "CfgMagazines.hpp" #include "CfgVehicles.hpp" #include "CfgWeapons.hpp" diff --git a/addons/artillerytables/dev/checkConfigs.sqf b/addons/artillerytables/dev/checkConfigs.sqf new file mode 100644 index 0000000000..a818a512b2 --- /dev/null +++ b/addons/artillerytables/dev/checkConfigs.sqf @@ -0,0 +1,18 @@ +diag_log text "-------------------------------------------"; +INFO("Showing entries with custom configs"); +diag_log text "-------------------------------------------"; + +private _customMags = configProperties [(configFile >> "CfgMagazines"), 'isClass _x && {isNumber (_x >> QGVAR(airFriction))}', true]; +_customMags = _customMags apply {[configName _x, getNumber (_x >> QGVAR(airFriction))]}; +diag_log text format ["CfgMagazines with custom airFriction [%1]", count _customMags]; +diag_log text format ["%1", _customMags]; + +private _customVeh = configProperties [(configFile >> "CfgVehicles"), 'isClass _x && {isNumber (_x >> QGVAR(showGunLaying))}', true]; +_customVeh = _customVeh apply {[configName _x, getNumber (_x >> QGVAR(showGunLaying))]}; +diag_log text format ["CfgVehicles with custom showGunLaying [%1]", count _customVeh]; +diag_log text format ["%1", _customVeh]; + +private _customVeh = configProperties [(configFile >> "CfgVehicles"), 'isClass _x && {isNumber (_x >> QGVAR(applyCorrections))}', true]; +_customVeh = _customVeh apply {[configName _x, getNumber (_x >> QGVAR(applyCorrections))]}; +diag_log text format ["CfgVehicles with custom applyCorrections [%1]", count _customVeh]; +diag_log text format ["%1", _customVeh]; diff --git a/addons/artillerytables/functions/fnc_firedEH.sqf b/addons/artillerytables/functions/fnc_firedEH.sqf index 9431d7138b..e1d1a160fc 100644 --- a/addons/artillerytables/functions/fnc_firedEH.sqf +++ b/addons/artillerytables/functions/fnc_firedEH.sqf @@ -26,7 +26,7 @@ params ["_vehicle", "", "", "", "", "_magazine", "_projectile", "_gunner"]; TRACE_4("firedEH",_vehicle,_magazine,_projectile,_gunner); if (!([_gunner] call EFUNC(common,isPlayer))) exitWith {}; // AI don't know how to use (this does give them more range than a player) -if ((_vehicle turretUnit [0]) != _gunner) exitWith {}; +if ((gunner _vehicle) != _gunner) exitWith {}; // check if primaryGunner // Get airFriction diff --git a/addons/artillerytables/functions/fnc_interactMenuOpened.sqf b/addons/artillerytables/functions/fnc_interactMenuOpened.sqf index 1c5b2630df..96ee254981 100644 --- a/addons/artillerytables/functions/fnc_interactMenuOpened.sqf +++ b/addons/artillerytables/functions/fnc_interactMenuOpened.sqf @@ -4,8 +4,7 @@ * Interaction menu opened, search for nearby artillery vehicles. * * Arguments: - * 0: Vehicle - * 1: Player + * 0: Menu Type (1 is self interaction) * * Return Value: * Can Open @@ -20,7 +19,7 @@ params ["_menuType"]; TRACE_1("interactMenuOpened",_menuType); if (_menuType != 1) exitWith {}; -// if (!("ACE_artilleryTable" in (ace_player call EFUNC(common,uniqueItems)))) exitWith {}; +if (!("ACE_artilleryTable" in (ace_player call EFUNC(common,uniqueItems)))) exitWith {}; private _vehicleAdded = ace_player getVariable [QGVAR(vehiclesAdded), []]; private _rangeTablesShown = ace_player getVariable [QGVAR(rangeTablesShown), []]; @@ -65,8 +64,8 @@ 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, (180 / PI) * _currentTraverseRad] call FUNC(rotateVector3d); - private _neutralX = (acos (_turretRot vectorCos _weaponDir)) - ((180 / PI) * _currentElevRad); + private _turretRot = [vectorDir _vehicle, vectorUp _vehicle, deg _currentTraverseRad] call FUNC(rotateVector3d); + private _neutralX = (acos (_turretRot vectorCos _weaponDir)) - (deg _currentElevRad); _neutralX = (round (_neutralX * 10)) / 10; // minimize floating point errors private _minElev = _neutralX + getNumber (_turretCfg >> "minElev"); private _maxElev = _neutralX + getNumber (_turretCfg >> "maxElev"); @@ -77,6 +76,9 @@ TRACE_2("searching for new vehicles",_vehicleAdded,_rangeTablesShown); getNumber (_vehicleCfg >> "artilleryScanner") }; private _advCorrection = GVAR(advancedCorrections) && {_applyCorrections == 1}; + if ((missionNamespace getVariable [QEGVAR(mk6Mortar,airResistanceEnabled), false]) && {_vehicle isKindOf "Mortar_01_base_F"}) then { + _advCorrection = true; + }; // check weapon and limits in case different vehicles use the same weapon (cammo variants should still produce the same array) private _info = [_weapon, _minElev, _maxElev, _advCorrection]; @@ -94,9 +96,7 @@ TRACE_2("searching for new vehicles",_vehicleAdded,_rangeTablesShown); }; private _condition = { //IGNORE_PRIVATE_WARNING ["_player"]; - // ("ACE_artilleryTable" in (_player call EFUNC(common,uniqueItems))) - // && {[_player, objNull, ["notOnMap", "isNotSitting"]] call EFUNC(common,canInteractWith)} - true + ("ACE_artilleryTable" in (_player call EFUNC(common,uniqueItems))) && {[_player, objNull, ["notOnMap", "isNotSitting", "isNotInside"]] call EFUNC(common,canInteractWith)} }; private _displayName = format ["%1%2", getText (_vehicleCfg >> "displayName"),["","*"] select _advCorrection]; private _action = [format ['QGVAR(%1)',_index], _displayName, QPATHTOF(UI\icon_rangeTable.paa), _statement, _condition, {}, _info] call EFUNC(interact_menu,createAction); diff --git a/addons/artillerytables/functions/fnc_rangeTableOpen.sqf b/addons/artillerytables/functions/fnc_rangeTableOpen.sqf index 909b2271d0..b072ec6220 100644 --- a/addons/artillerytables/functions/fnc_rangeTableOpen.sqf +++ b/addons/artillerytables/functions/fnc_rangeTableOpen.sqf @@ -19,7 +19,7 @@ */ params ["_weaponName", "_elevMin", "_elevMax", "_advCorrection"]; -TRACE_3("rangeTableOpen",_weaponName,_elevMin,_elevMax); +TRACE_4("rangeTableOpen",_weaponName,_elevMin,_elevMax,_advCorrection); BEGIN_COUNTER(rangeTableOpen); @@ -49,7 +49,7 @@ _mags = _mags apply { }; TRACE_2("",_magParamsArray,_mags); if ((count _magParamsArray) == 2) then { // test if all magazines share the parameters - _mags = [["", "", (_mags select 0) select 2, (_mags select 0) select 3]]; // simplify + _mags = [["", "All Magazines", (_mags select 0) select 2, (_mags select 0) select 3]]; // simplify }; // Get Firemodes: @@ -65,13 +65,13 @@ GVAR(magModeData) = []; _x params ["_xDisplayNameShort", "_xDisplayName", "_xInitSpeed", "_xAirFriction"]; if (_allSameCharge) then { _ctrlChargeList lbAdd format ["%1", _xDisplayNameShort]; - _ctrlChargeList lbSetTooltip [count GVAR(magModeData), format ["%1 m/s\n%2",_xInitSpeed toFixed 1, _xDisplayName]]; + _ctrlChargeList lbSetTooltip [count GVAR(magModeData), format ["%1\n%2 m/s\n%3", _xDisplayName, _xInitSpeed toFixed 1, _xAirFriction]]; GVAR(magModeData) pushBack [_xInitSpeed, _xAirFriction]; } else { { _x params ["_xModeCharge"]; _ctrlChargeList lbAdd format ["[Charge %1] %2", _forEachIndex, _xDisplayNameShort]; // forEachIndex is from firemodes - _ctrlChargeList lbSetTooltip [count GVAR(magModeData), format ["%1 m/s\n%2", (_xInitSpeed * _xModeCharge) toFixed 1, _xDisplayName]]; + _ctrlChargeList lbSetTooltip [count GVAR(magModeData), format ["%1\n%2 m/s\n%3", _xDisplayName, (_xInitSpeed * _xModeCharge) toFixed 1, _xAirFriction]]; GVAR(magModeData) pushBack [_xInitSpeed * _xModeCharge, _xAirFriction]; } forEach _fireModes; }; diff --git a/addons/artillerytables/functions/fnc_turretPFEH.sqf b/addons/artillerytables/functions/fnc_turretPFEH.sqf index 0a49039aa3..67f49d5deb 100644 --- a/addons/artillerytables/functions/fnc_turretPFEH.sqf +++ b/addons/artillerytables/functions/fnc_turretPFEH.sqf @@ -16,7 +16,6 @@ */ (_this select 0) params ["_vehicle", "_turret", "_fireModes", "_useAltElevation", "_turretAnimBody"]; - if (shownArtilleryComputer && {GVAR(disableArtilleryComputer)}) then { // Still Don't like this solution, but it works closeDialog 0; @@ -70,7 +69,7 @@ if (_useRealWeaponDir) 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, (180 / PI) * _currentTraverseRad] call FUNC(rotateVector3d); + private _turretRot = [vectorDir _vehicle, vectorUp _vehicle, deg _currentTraverseRad] call FUNC(rotateVector3d); _realElevation = acos (_turretRot vectorDotProduct _weaponDir) + ((_turretRot call CBA_fnc_vect2polar) select 2); if (_realElevation > 90) then { _realElevation = 180 - _realElevation; }; // does not flip azimuth! }; diff --git a/addons/mk6mortar/config.cpp b/addons/mk6mortar/config.cpp index f387632446..61203bc9ae 100644 --- a/addons/mk6mortar/config.cpp +++ b/addons/mk6mortar/config.cpp @@ -7,7 +7,7 @@ class CfgPatches { "ACE_Box_82mm_Mo_Illum","ACE_Box_82mm_Mo_Combo"}; weapons[] = {"ACE_RangeTable_82mm","ace_mortar_82mm"}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_interaction"}; + requiredAddons[] = {"ace_interaction", "ace_artillerytables"}; author = ECSTRING(common,ACETeam); authors[] = {"PabstMirror","Grey","VKing"}; url = ECSTRING(main,URL); diff --git a/addons/mk6mortar/functions/fnc_handleFired.sqf b/addons/mk6mortar/functions/fnc_handleFired.sqf index 02a8e51ce0..35b4151a7e 100644 --- a/addons/mk6mortar/functions/fnc_handleFired.sqf +++ b/addons/mk6mortar/functions/fnc_handleFired.sqf @@ -31,6 +31,7 @@ if (GVAR(useAmmoHandling) && {_vehicle getVariable [QGVAR(initialized),false] && }; if (!GVAR(airResistanceEnabled)) exitWith {}; +if (EGVAR(artillerytables,advancedCorrections)) exitWith { TRACE_1("defer to artillerytables",_this); }; // Large enough distance to not simulate any wind deflection if (_vehicle distance ACE_player > 8000) exitWith {false}; diff --git a/addons/mk6mortar/functions/fnc_handlePlayerVehicleChanged.sqf b/addons/mk6mortar/functions/fnc_handlePlayerVehicleChanged.sqf index fd53bcf3d4..d791378079 100644 --- a/addons/mk6mortar/functions/fnc_handlePlayerVehicleChanged.sqf +++ b/addons/mk6mortar/functions/fnc_handlePlayerVehicleChanged.sqf @@ -77,9 +77,10 @@ if (_lastFireMode != -1) then { //Calc real azimuth/elevation //(looking at the sky VS looking at ground will radicaly change fire direction because BIS) - private _realAzimuth = -1; - private _realElevation = -1; + private _realAzimuth = missionNamespace getVariable [QEGVAR(artillerytables,predictedAzimuth), -1]; + private _realElevation = missionNamespace getVariable [QEGVAR(artillerytables,predictedElevation), -1]; +/* private _useRealWeaponDir = (ctrlText (_display displayCtrl 173)) == "--"; if (_useRealWeaponDir && {(_mortarVeh ammo (currentWeapon _mortarVeh)) == 0}) then { // With no ammo, distance display will be empty, but gun will still fire at wonky angle if aimed at ground @@ -104,7 +105,7 @@ if (_lastFireMode != -1) then { private _elevationDiff = (cos (_realAzimuth - _upVectorDir)) * acos ((vectorUp _mortarVeh) select 2); _realElevation = ((180 / PI) * (_mortarVeh animationPhase "mainGun")) + 75 - _elevationDiff; }; - +*/ //Update Heading Display: if (_notGunnerView || (!GVAR(allowCompass))) then { (_display displayCtrl 80156) ctrlSetText ""; @@ -118,10 +119,10 @@ if (_lastFireMode != -1) then { //Update CurrentElevation Display and "charge" text if (_notGunnerView) then { - (_display displayCtrl 80085) ctrlSetStructuredText parseText ""; + // (_display displayCtrl 80085) ctrlSetStructuredText parseText ""; (_display displayCtrl 80175) ctrlSetText ""; } else { - (_display displayCtrl 80085) ctrlSetStructuredText parseText _chargeText; + // (_display displayCtrl 80085) ctrlSetStructuredText parseText _chargeText; if (_useMils) then { (_display displayCtrl 80175) ctrlSetText str ((round (_realElevation * 6400 / 360)) % 6400); diff --git a/addons/mk6mortar/functions/fnc_rangeTableOpen.sqf b/addons/mk6mortar/functions/fnc_rangeTableOpen.sqf index f55e2bcd99..00dc2a19d0 100644 --- a/addons/mk6mortar/functions/fnc_rangeTableOpen.sqf +++ b/addons/mk6mortar/functions/fnc_rangeTableOpen.sqf @@ -14,6 +14,10 @@ * * Public: No */ +if (true) exitWith { // todo: more cleanup later + TRACE_1("defer to artillerytables",_this); + ["mortar_82mm", 45, 88, GVAR(airResistanceEnabled) || EGVAR(artillerytables,advancedCorrections)] call EFUNC(artillerytables,rangeTableOpen); +}; #define LIST_CHARGE ((uiNamespace getVariable "ACE_82mm_RangeTable_Dialog") displayCtrl 1501)