cleanup/tweaks

This commit is contained in:
PabstMirror 2019-03-22 14:06:42 -05:00
parent 6274d67edb
commit 9756b22238
9 changed files with 25 additions and 34 deletions

View File

@ -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;
};
};

View File

@ -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;

View File

@ -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");
[{

View File

@ -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);

View File

@ -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");

View File

@ -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 <OBJECT>
@ -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");

View File

@ -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;

View File

@ -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)},

View File

@ -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"