ACE3/addons/artillerytables/functions/fnc_turretChanged.sqf
PabstMirror 8e3fd45500
Artillery rangletables (universal) (#6853)
* Initial

* Update artillerytables.cpp

* Pass by value, remove c17 features

* Tweak accuracy

* SQF work

- improve compat with a3 mlrs with remote cam (animationSourcePhase)
- handle non [0] turrets (rhs prp)
- add config entries
- use vectorCos to fix fp error (thanks commy)

* Support per mag air friction

* tweak friction

* Integrate with mk6

* more acos fixes

* Handle invalid memPointGunOptic (CUP_BM21_Base)

* Cleanup

* cleanup/tweaks

* Update checkConfigs.sqf

* Finish cleanup of ace_mk6mortar

* Update stringtable.xml

* fix bwc for ACE_RangeTable_82mm

* Update fnc_rangeTableCanUse.sqf

* build 32dll, fix some headers

* strncpy and move testing to seperate file

* Move to sub-category

* Update for ACE_Extensions changes and add warning to ace_common

* Update stringtable.xml

* Update addons/common/functions/fnc_checkFiles.sqf

Co-Authored-By: jonpas <jonpas33@gmail.com>

* Update stringtable.xml

* Update stringtable.xml

* test extension.yml update logical operator

* Revert "test extension.yml update logical operator"

This reverts commit b1871724ad.

* more guess and test
2019-12-17 10:14:45 -06:00

71 lines
3.2 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: PabstMirror
* Turret changed, determine if we are in the gunner seat of an artillery vehicle.
*
* Arguments:
* 0: Player <OBJECT>
* 1: Turret <ARRAY>
*
* Return Value:
* Nothing
*
* Example:
* [player, [0]] call ace_artillerytables_fnc_turretChanged
*
* Public: No
*/
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))
} else {
getNumber (_vehicleCfg >> "artilleryScanner")
};
TRACE_4("turretChanged",_player,_typeOf,_turret,_showGunLaying);
if (GVAR(pfID) >= 0) then {
TRACE_1("removing pfEH and display",GVAR(pfID));
[GVAR(pfID)] call CBA_fnc_removePerFrameHandler;
GVAR(pfID) = -1;
if (!isNull (uiNamespace getVariable [QGVAR(display), displayNull])) then {
([QGVAR(modeDisplay)] call BIS_fnc_rscLayer) cutText ["", "PLAIN"];
};
};
if ((alive _player) && {_showGunLaying > 0} && {_player == gunner _vehicle}) then {
private _turretCfg = [_typeOf, _turret] call CBA_fnc_getTurret;
private _turretAnimBody = getText (_turretCfg >> "animationSourceBody");
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");
private _invalidGunnerMem = (_vehicle selectionPosition [_memoryPointGunnerOptics, "Memory"]) isEqualTo [0,0,0];
if (_invalidGunnerMem) then { INFO_3("[%1-%2] turret's memoryPointGunnerOptics invalid [%3]",typeOf _vehicle,_turret,_memoryPointGunnerOptics); };
private _weaponsTurret = _vehicle weaponsTurret _turret;
if ((count _weaponsTurret) != 1) then { WARNING_2("not singular weapon in turret - %1 - %2",_typeOf,_turret); };
private _weapon = _weaponsTurret param [0, ""];
private _fireModes = getArray (configFile >> "CfgWeapons" >> _weapon >> "modes");
_fireModes = (_fireModes apply {configFile >> "CfgWeapons" >> _weapon >> _x}) select {1 == getNumber (_x >> "showToPlayer")};
_fireModes = _fireModes apply {[getNumber (_x >> "artilleryCharge"), configName _x]};
_fireModes sort true;
_fireModes = _fireModes apply {_x select 1};
GVAR(pfID) = [LINKFUNC(turretPFEH), 0, [_vehicle, _turret, _fireModes, _useAltElevation, _turretAnimBody, _invalidGunnerMem]] call CBA_fnc_addPerFrameHandler;
TRACE_4("added pfEH",GVAR(pfID),_useAltElevation,_turretAnimBody,_invalidGunnerMem);
#ifdef DEBUG_MODE_FULL
private _ballisticsComputer = getNumber (configFile >> "CfgWeapons" >> _weapon >> "ballisticsComputer");
private _elevationMode = getNumber (_turretCfg >> "elevationMode");
private _discreteDistance = getArray (_turretCfg >> "discreteDistance");
TRACE_4("",_weapon,_ballisticsComputer,_elevationMode,_discreteDistance);
#endif
};