diff --git a/addons/advanced_throwing/XEH_PREP.hpp b/addons/advanced_throwing/XEH_PREP.hpp index abd49514ae8..92ad6141762 100644 --- a/addons/advanced_throwing/XEH_PREP.hpp +++ b/addons/advanced_throwing/XEH_PREP.hpp @@ -3,7 +3,6 @@ PREP(canThrow); PREP(drawArc); PREP(drawThrowable); PREP(exitThrowMode); -PREP(getMuzzle); PREP(moduleInit); PREP(onKeyDown); PREP(onMouseButtonDown); diff --git a/addons/advanced_throwing/XEH_postInit.sqf b/addons/advanced_throwing/XEH_postInit.sqf index dd7a3f12806..8990abd8505 100644 --- a/addons/advanced_throwing/XEH_postInit.sqf +++ b/addons/advanced_throwing/XEH_postInit.sqf @@ -11,7 +11,7 @@ if (!hasInterface) exitWith {}; GVAR(tempWindInfo) = false; // Add keybinds -["ACE3 Weapons", QGVAR(prepare), localize LSTRING(Prepare), { +["ACE3 Weapons", QGVAR(prepare), LLSTRING(Prepare), { // Condition if !([ACE_player] call FUNC(canPrepare)) exitWith {false}; if (EGVAR(common,isReloading)) exitWith {true}; @@ -22,7 +22,7 @@ GVAR(tempWindInfo) = false; true }, {false}, [34, [true, false, false]], false] call CBA_fnc_addKeybind; // Shift + G -["ACE3 Weapons", QGVAR(dropModeToggle), localize LSTRING(DropModeToggle), { +["ACE3 Weapons", QGVAR(dropModeToggle), LLSTRING(DropModeToggle), { // Condition if (!(ACE_player getVariable [QGVAR(inHand), false]) || {underwater ACE_player}) exitWith {false}; @@ -35,7 +35,7 @@ GVAR(tempWindInfo) = false; true }, {false}, [34, [false, true, false]], false] call CBA_fnc_addKeybind; // Ctrl + G -["ACE3 Weapons", QGVAR(dropModeHold), localize LSTRING(DropModeHold), { +["ACE3 Weapons", QGVAR(dropModeHold), LLSTRING(DropModeHold), { // Condition if !(ACE_player getVariable [QGVAR(inHand), false]) exitWith {false}; diff --git a/addons/advanced_throwing/functions/fnc_canThrow.sqf b/addons/advanced_throwing/functions/fnc_canThrow.sqf index 8b2987eafac..d545e02b1d8 100644 --- a/addons/advanced_throwing/functions/fnc_canThrow.sqf +++ b/addons/advanced_throwing/functions/fnc_canThrow.sqf @@ -19,13 +19,15 @@ params ["_unit"]; if !(_unit getVariable [QGVAR(inHand), false]) exitWith {false}; -if (!isNull objectParent _unit) exitWith { +private _vehicle = objectParent _unit; + +if (!isNull _vehicle) exitWith { private _startPos = eyePos _unit; private _aimLinePos = AGLToASL (positionCameraToWorld [0, 0, 1]); private _intersections = lineIntersectsSurfaces [_startPos, _aimLinePos, _unit, objNull, false]; //TRACE_1("Intersections",_intersections); - (_intersections select {(vehicle _unit) in (_x select 3)}) isEqualTo [] + _intersections findIf {_vehicle in (_x select 3)} == -1 }; true diff --git a/addons/advanced_throwing/functions/fnc_drawThrowable.sqf b/addons/advanced_throwing/functions/fnc_drawThrowable.sqf index 72696d8ff09..099d2119205 100644 --- a/addons/advanced_throwing/functions/fnc_drawThrowable.sqf +++ b/addons/advanced_throwing/functions/fnc_drawThrowable.sqf @@ -23,21 +23,22 @@ private _primed = ACE_player getVariable [QGVAR(primed), false]; private _activeThrowable = ACE_player getVariable [QGVAR(activeThrowable), objNull]; // Exit if throwable died primed in hand -if (isNull _activeThrowable && {_primed}) exitWith { +if (_primed && {isNull _activeThrowable}) exitWith { [ACE_player, "Throwable died primed in hand"] call FUNC(exitThrowMode); }; private _throwable = currentThrowable ACE_player; // Inventory check -if (_throwable isEqualTo [] && {!_primed}) exitWith { +if (!_primed && {_throwable isEqualTo []}) exitWith { [ACE_player, "No valid throwables"] call FUNC(exitThrowMode); }; -private _throwableMag = _throwable param [0, "#none"]; +_throwable params ["_throwableMag", "_muzzle"]; // If not primed, double check we actually have the magazine in inventory -if ((!_primed) && {!((_throwableMag in (uniformItems ACE_player)) || {_throwableMag in (vestItems ACE_player)} || {_throwableMag in (backpackItems ACE_player)})}) exitWith { +// Can't use ace_common_fnc_hasMagazine, as it doesn't account for empty mags (grenade is emptied so that it can't be thrown via vanilla keybind) +if (!_primed && {!(_throwableMag in (magazines [ACE_player, true]))}) exitWith { [ACE_player, "No valid throwable (glitched currentThrowable)"] call FUNC(exitThrowMode); }; @@ -64,13 +65,11 @@ _phi = [_phi, 360 - _phi] select (_phi > 180); private _power = linearConversion [0, 180, _phi - 30, 1, 0.3, true]; ACE_player setVariable [QGVAR(throwSpeed), _throwSpeed * _power]; -#ifdef DEBUG_MODE_FULL -hintSilent format ["Heading: %1\nPower: %2\nSpeed: %3\nThrowMag: %4\nMuzzle & ammo: %5", _phi, _power, _throwSpeed * _power, _throwableMag, ACE_player getVariable [QGVAR(activeMuzzle), ["", -1]]]; -#endif +TRACE_5("",_phi,_power,_throwSpeed * _power,_throwableMag,ACE_player getVariable ARR_2([QGVAR(activeMuzzle),ARR_2(["",-1])])); private _throwableType = getText (configFile >> "CfgMagazines" >> _throwableMag >> "ammo"); -if (!([ACE_player] call FUNC(canThrow)) && {!_primed}) exitWith { +if (!_primed && {!([ACE_player] call FUNC(canThrow))}) exitWith { if (!isNull _activeThrowable) then { deleteVehicle _activeThrowable; // Restore muzzle ammo (setAmmo has no impact if no applicable throwable in inventory) @@ -78,7 +77,7 @@ if (!([ACE_player] call FUNC(canThrow)) && {!_primed}) exitWith { }; }; -if (isNull _activeThrowable || {(_throwableType != typeOf _activeThrowable) && {!_primed}}) then { +if (isNull _activeThrowable || {!_primed && {_throwableType != typeOf _activeThrowable}}) then { if (!isNull _activeThrowable) then { deleteVehicle _activeThrowable; // Restore muzzle ammo (setAmmo has no impact if no applicable throwable in inventory) @@ -89,7 +88,6 @@ if (isNull _activeThrowable || {(_throwableType != typeOf _activeThrowable) && { ACE_player setVariable [QGVAR(activeThrowable), _activeThrowable]; // Set muzzle ammo to 0 to block vanilla throwing - private _muzzle = _throwableMag call FUNC(getMuzzle); ACE_player setVariable [QGVAR(activeMuzzle), [_muzzle, ACE_player ammo _muzzle]]; ACE_player setAmmo [_muzzle, 0]; }; diff --git a/addons/advanced_throwing/functions/fnc_exitThrowMode.sqf b/addons/advanced_throwing/functions/fnc_exitThrowMode.sqf index e47f085db67..0489adb5f90 100644 --- a/addons/advanced_throwing/functions/fnc_exitThrowMode.sqf +++ b/addons/advanced_throwing/functions/fnc_exitThrowMode.sqf @@ -21,9 +21,7 @@ TRACE_2("params",_unit,_reason); if !(_unit getVariable [QGVAR(inHand), false]) exitWith {}; -#ifdef DEBUG_MODE_FULL - systemChat format ["Exit Throw Mode: %1", _reason]; -#endif +TRACE_1("Exit Throw Mode",_reason); private _activeThrowable = _unit getVariable [QGVAR(activeThrowable), objNull]; if !(_unit getVariable [QGVAR(primed), false]) then { diff --git a/addons/advanced_throwing/functions/fnc_getMuzzle.sqf b/addons/advanced_throwing/functions/fnc_getMuzzle.sqf deleted file mode 100644 index eab95825e4a..00000000000 --- a/addons/advanced_throwing/functions/fnc_getMuzzle.sqf +++ /dev/null @@ -1,25 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: PabstMirror - * Retrieve muzzle name from config. - * - * Arguments: - * 0: Magazine Classname - * - * Return Value: - * None - * - * Example: - * "magazine" call ace_advanced_throwing_fnc_getMuzzle - * - * Public: No - */ - -params ["_magazineClassname"]; - -_magazineClassname = toLowerANSI _magazineClassname; -private _throwMuzzles = getArray (configFile >> "CfgWeapons" >> "Throw" >> "muzzles"); - -_throwMuzzles = _throwMuzzles select {_magazineClassname in ((getArray (configFile >> "CfgWeapons" >> "Throw" >> _x >> "magazines")) apply {toLowerANSI _x})}; - -[_throwMuzzles select 0, ""] select (_throwMuzzles isEqualTo []) diff --git a/addons/advanced_throwing/functions/fnc_prime.sqf b/addons/advanced_throwing/functions/fnc_prime.sqf index 923fe9550c4..1cead20cf6e 100644 --- a/addons/advanced_throwing/functions/fnc_prime.sqf +++ b/addons/advanced_throwing/functions/fnc_prime.sqf @@ -44,11 +44,11 @@ if (_ammoCount == 1) then { _unit setAmmo [_muzzle, 0]; private _throwableType = getText (_config >> "ammo"); +private _ammoConfig = configFile >> "CfgAmmo" >> _throwableType; // Handle weird scripted grenades (RHS) which could cause unexpected behaviour -private _nonInheritedCfg = configProperties [configFile >> "CfgAmmo" >> _throwableType, 'configName _x == QGVAR(replaceWith)', false]; -if ((count _nonInheritedCfg) == 1) then { - _throwableType = getText (_nonInheritedCfg select 0); +if (inheritsFrom (_ammoConfig >> QGVAR(replaceWith)) isEqualTo _ammoConfig) then { + _throwableType = getText (_ammoConfig >> QGVAR(replaceWith)); }; // Create actual throwable globally @@ -76,7 +76,7 @@ if (_showHint) then { private _displayNameShort = getText (_config >> "displayNameShort"); private _picture = getText (_config >> "picture"); - [[_displayNameShort, localize LSTRING(Primed)] joinString " ", _picture] call EFUNC(common,displayTextPicture); + [[_displayNameShort, LLSTRING(Primed)] joinString " ", _picture] call EFUNC(common,displayTextPicture); // Change controls hint for RMB call FUNC(updateControlsHint); diff --git a/addons/advanced_throwing/functions/fnc_throw.sqf b/addons/advanced_throwing/functions/fnc_throw.sqf index d1773373411..33b3fdb4dc7 100644 --- a/addons/advanced_throwing/functions/fnc_throw.sqf +++ b/addons/advanced_throwing/functions/fnc_throw.sqf @@ -50,7 +50,7 @@ if !(_unit getVariable [QGVAR(primed), false]) then { }; // Calculate torque of thrown grenade - private _config = configFile >> "CfgAmmo" >> typeOf _activeThrowable; + private _config = configOf _activeThrowable; private _torqueDir = getArray (_config >> QGVAR(torqueDirection)); _torqueDir = if (_torqueDir isEqualTypeArray [0,0,0]) then { vectorNormalized _torqueDir } else { [0,0,0] }; private _torqueMag = getNumber (_config >> QGVAR(torqueMagnitude)); diff --git a/addons/advanced_throwing/functions/fnc_throwFiredXEH.sqf b/addons/advanced_throwing/functions/fnc_throwFiredXEH.sqf index bbbcbf3274f..73a472881f6 100644 --- a/addons/advanced_throwing/functions/fnc_throwFiredXEH.sqf +++ b/addons/advanced_throwing/functions/fnc_throwFiredXEH.sqf @@ -20,6 +20,7 @@ * * Public: No */ + params ["_unit", "", "_muzzle", "", "_ammo"]; TRACE_1("Fired",_this); diff --git a/addons/advanced_throwing/functions/fnc_updateControlsHint.sqf b/addons/advanced_throwing/functions/fnc_updateControlsHint.sqf index 52f1a3b9e23..f8b16ba8bc7 100644 --- a/addons/advanced_throwing/functions/fnc_updateControlsHint.sqf +++ b/addons/advanced_throwing/functions/fnc_updateControlsHint.sqf @@ -19,14 +19,14 @@ if (!GVAR(showMouseControls)) exitWith {}; private _primed = ACE_player getVariable [QGVAR(primed), false]; -private _mmb = [localize LSTRING(ChangeMode), localize LSTRING(Extend)] select (ACE_player getVariable [QGVAR(dropMode), false]); +private _mmb = [LLSTRING(ChangeMode), LLSTRING(Extend)] select (ACE_player getVariable [QGVAR(dropMode), false]); if (!_primed) then { - _mmb = [_mmb, localize LSTRING(Cook)] joinString " / "; + _mmb = [_mmb, LLSTRING(Cook)] joinString " / "; }; [ - localize LSTRING(Throw), - [localize ELSTRING(common,Cancel), ""] select _primed, + LLSTRING(Throw), + [LELSTRING(common,Cancel), ""] select _primed, _mmb ] call EFUNC(interaction,showMouseHint); diff --git a/addons/advanced_throwing/initSettings.inc.sqf b/addons/advanced_throwing/initSettings.inc.sqf index d8396637c57..ea873c93835 100644 --- a/addons/advanced_throwing/initSettings.inc.sqf +++ b/addons/advanced_throwing/initSettings.inc.sqf @@ -1,4 +1,4 @@ -private _category = format ["ACE %1", localize LSTRING(Category)]; +private _category = format ["ACE %1", LLSTRING(Category)]; [ QGVAR(enabled), "CHECKBOX",