ACE3/addons/mk6mortar/functions/fnc_csw_getProxyWeapon.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

69 lines
2.6 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: PabstMirror
* Compatibility With ACE_CSW (will be called by ace_csw, no dependency)
* Setting Init has finished, and this runs before csw attempts to unload weapon, should replicate functionality of mk6_fnc_mortarInit
*
* Arguments:
* 0: static <OBJECT>
* 1: Turret <ARRAY>
* 2: current weapon <STRING>
* 3: need proxy weapon (either assembly mode is true, or weapon has been emptied and is being reloaded) <BOOL>
*
* Return Value:
* Proxy Weapon <STRING>
*
* Example:
* [mortar, "mortar_82mm", true] call ace_mk6mortar_fnc_csw_getProxyWeapon
*
* Public: No
*/
params ["_mortar", "_turret", "_currentWeapon", "_proxyWeaponNeeded"];
TRACE_4("csw_getProxyWeapon",_mortar,_turret,_currentWeapon,_proxyWeaponNeeded);
private _newWeapon = "";
if (_proxyWeaponNeeded || GVAR(useAmmoHandling)) then {
if (_currentWeapon != "mortar_82mm") exitWith { ERROR_2("unknown weapon [%1 - %2]",typeOf _mortar,_currentWeapon); };
// Replace weapon with fast reloading version
_newWeapon = "ace_mortar_82mm";
TRACE_1("replacing weapon",_newWeapon);
// need to convert 8rnd mags to 1rnd mags for new weapon (we need to do this so the weapon is loaded with a compatible mag)
private _magsToRemove = [];
private _convertedMags = [];
{
_x params ["_xMag", "_xTurret", "_xAmmo"];
if (_xTurret isEqualTo _turret) then {
private _replaceMag = switch (true) do {
case (_xMag == "8Rnd_82mm_Mo_shells"): {"ACE_1Rnd_82mm_Mo_HE"};
case (_xMag == "8Rnd_82mm_Mo_Smoke_white"): {"ACE_1Rnd_82mm_Mo_Smoke"};
case (_xMag == "8Rnd_82mm_Mo_Flare_white"): {"ACE_1Rnd_82mm_Mo_Illum"};
case (_xMag == "8Rnd_82mm_Mo_guided"): {"ACE_1Rnd_82mm_Mo_HE_Guided"};
case (_xMag == "8Rnd_82mm_Mo_LG"): {"ACE_1Rnd_82mm_Mo_HE_LaserGuided"};
default {""};
};
if (_replaceMag != "") then {
_magsToRemove pushBackUnique [_xMag, _xTurret];
if (!GVAR(useAmmoHandling)) then {
TRACE_3("replacing",_xMag,_replaceMag,_xAmmo);
for "_i" from 1 to _xAmmo do {
_convertedMags pushBack [_replaceMag, _xTurret, 1];
};
};
} else {
WARNING("unknown mag %1", _xMag);
};
};
} forEach (magazinesAllTurrets _mortar);
// remove orignal mags and add 1rnd versions:
{ _mortar removeMagazinesTurret _x; } forEach _magsToRemove;
{ _mortar addMagazineTurret _x; } forEach _convertedMags;
};
_newWeapon