mirror of
https://github.com/acemod/ACE3.git
synced 2025-07-26 05:12:54 +00:00
Advanced Throwing - Cleanup (#10495)
* Fix adv. throwing for multiple round grenades * Cleanup adv. throwing * Minor optimisation and cleanup
This commit is contained in:
@ -3,7 +3,6 @@ PREP(canThrow);
|
||||
PREP(drawArc);
|
||||
PREP(drawThrowable);
|
||||
PREP(exitThrowMode);
|
||||
PREP(getMuzzle);
|
||||
PREP(moduleInit);
|
||||
PREP(onKeyDown);
|
||||
PREP(onMouseButtonDown);
|
||||
|
@ -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};
|
||||
|
||||
|
@ -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
|
||||
|
@ -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];
|
||||
};
|
||||
|
@ -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 {
|
||||
|
@ -1,25 +0,0 @@
|
||||
#include "..\script_component.hpp"
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
* Retrieve muzzle name from config.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Magazine Classname <STRING>
|
||||
*
|
||||
* 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 [])
|
@ -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);
|
||||
|
@ -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));
|
||||
|
@ -20,6 +20,7 @@
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_unit", "", "_muzzle", "", "_ammo"];
|
||||
TRACE_1("Fired",_this);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -1,4 +1,4 @@
|
||||
private _category = format ["ACE %1", localize LSTRING(Category)];
|
||||
private _category = format ["ACE %1", LLSTRING(Category)];
|
||||
[
|
||||
QGVAR(enabled),
|
||||
"CHECKBOX",
|
||||
|
Reference in New Issue
Block a user