mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Fix Advanced Throwing floating IR grenades and block vanilla throwing (#4365)
* Fix #4362 - floating primed IR grenades * Fix #4363 - block vanilla throwing while prepared * Respect last thrown time with vanilla throwing and dropping primed throwable,
This commit is contained in:
parent
ebdc883855
commit
062f6deec8
@ -83,6 +83,13 @@ GVAR(ammoMagLookup) = call CBA_fnc_createNamespace;
|
|||||||
// Fired XEH
|
// Fired XEH
|
||||||
[QGVAR(throwFiredXEH), FUNC(throwFiredXEH)] call CBA_fnc_addEventHandler;
|
[QGVAR(throwFiredXEH), FUNC(throwFiredXEH)] call CBA_fnc_addEventHandler;
|
||||||
|
|
||||||
|
// Set last thrown time on Vanilla Throwing and Advanced Throwing
|
||||||
|
["ace_firedPlayer", {
|
||||||
|
if (_weapon == "Throw") then {
|
||||||
|
_unit setVariable [QGVAR(lastThrownTime), CBA_missionTime];
|
||||||
|
};
|
||||||
|
}] call CBA_fnc_addEventHandler;
|
||||||
|
|
||||||
|
|
||||||
// Display handlers
|
// Display handlers
|
||||||
["KeyDown", {_this call FUNC(onKeyDown)}] call CBA_fnc_addDisplayHandler;
|
["KeyDown", {_this call FUNC(onKeyDown)}] call CBA_fnc_addDisplayHandler;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* 0: Unit <OBJECT>
|
* 0: Unit <OBJECT>
|
||||||
* 1: Pick Up <BOOL> (default: false)
|
* 1: Ignore Last Thrown Time <BOOL> (default: false)
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* Can Prepare <BOOL>
|
* Can Prepare <BOOL>
|
||||||
@ -16,10 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params ["_unit", ["_pickUp", false]];
|
params ["_unit", ["_ignoreLastThrownTime", false]];
|
||||||
|
|
||||||
// Don't delay when picking up
|
// Don't delay when picking up
|
||||||
if (_pickUp) then {
|
if (_ignoreLastThrownTime) then {
|
||||||
_unit setVariable [QGVAR(lastThrownTime), -1];
|
_unit setVariable [QGVAR(lastThrownTime), -1];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
if (dialog || {!(ACE_player getVariable [QGVAR(inHand), false])} || {!([ACE_player] call FUNC(canPrepare))}) exitWith {
|
if (dialog || {!(ACE_player getVariable [QGVAR(inHand), false])} || {!([ACE_player, true] call FUNC(canPrepare))}) exitWith {
|
||||||
[ACE_player, "In dialog or no throwable in hand or cannot prepare throwable"] call FUNC(exitThrowMode);
|
[ACE_player, "In dialog or no throwable in hand or cannot prepare throwable"] call FUNC(exitThrowMode);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -71,16 +71,25 @@ private _throwableType = getText (configFile >> "CfgMagazines" >> _throwableMag
|
|||||||
if (!([ACE_player] call FUNC(canThrow)) && {!_primed}) exitWith {
|
if (!([ACE_player] call FUNC(canThrow)) && {!_primed}) exitWith {
|
||||||
if (!isNull _activeThrowable) then {
|
if (!isNull _activeThrowable) then {
|
||||||
deleteVehicle _activeThrowable;
|
deleteVehicle _activeThrowable;
|
||||||
|
// Restore muzzle ammo to original
|
||||||
|
ACE_player setAmmo (ACE_player getVariable [QGVAR(activeMuzzle), ["", 0]]);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isNull _activeThrowable || {(_throwableType != typeOf _activeThrowable) && {!_primed}}) then {
|
if (isNull _activeThrowable || {(_throwableType != typeOf _activeThrowable) && {!_primed}}) then {
|
||||||
if (!isNull _activeThrowable) then {
|
if (!isNull _activeThrowable) then {
|
||||||
deleteVehicle _activeThrowable;
|
deleteVehicle _activeThrowable;
|
||||||
|
// Restore muzzle ammo to original
|
||||||
|
ACE_player setAmmo (ACE_player getVariable [QGVAR(activeMuzzle), ["", 0]]);
|
||||||
};
|
};
|
||||||
_activeThrowable = _throwableType createVehicleLocal [0, 0, 0];
|
_activeThrowable = _throwableType createVehicleLocal [0, 0, 0];
|
||||||
_activeThrowable enableSimulation false;
|
_activeThrowable enableSimulation false;
|
||||||
ACE_player setVariable [QGVAR(activeThrowable), _activeThrowable];
|
ACE_player setVariable [QGVAR(activeThrowable), _activeThrowable];
|
||||||
|
|
||||||
|
// Set muzzle ammo to 0 to block vanilla throwing, save to variable for later restoration
|
||||||
|
private _muzzle = _throwableType call FUNC(getMuzzle);
|
||||||
|
ACE_player setVariable [QGVAR(activeMuzzle), [_muzzle, ACE_player ammo _muzzle]];
|
||||||
|
ACE_player setAmmo [_muzzle, 0];
|
||||||
};
|
};
|
||||||
|
|
||||||
// Exit in case of explosion in hand
|
// Exit in case of explosion in hand
|
||||||
|
@ -25,13 +25,21 @@ if !(_unit getVariable [QGVAR(inHand), false]) exitWith {};
|
|||||||
systemChat format ["Exit Throw Mode: %1", _reason];
|
systemChat format ["Exit Throw Mode: %1", _reason];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
private _activeThrowable = _unit getVariable [QGVAR(activeThrowable), objNull];
|
||||||
if !(_unit getVariable [QGVAR(primed), false]) then {
|
if !(_unit getVariable [QGVAR(primed), false]) then {
|
||||||
deleteVehicle (_unit getVariable [QGVAR(activeThrowable), objNull]);
|
deleteVehicle _activeThrowable;
|
||||||
|
// Set muzzle ammo to original
|
||||||
|
_unit setAmmo (_unit getVariable [QGVAR(activeMuzzle), ["", 0]]);
|
||||||
|
} else {
|
||||||
|
_unit setVariable [QGVAR(lastThrownTime), CBA_missionTime];
|
||||||
|
// Fix floating for throwables without proper physics (eg. IR Grenade)
|
||||||
|
_activeThrowable setVelocity [0, 0, -0.1];
|
||||||
};
|
};
|
||||||
|
|
||||||
_unit setVariable [QGVAR(inHand), false];
|
_unit setVariable [QGVAR(inHand), false];
|
||||||
_unit setVariable [QGVAR(primed), false];
|
_unit setVariable [QGVAR(primed), false];
|
||||||
_unit setVariable [QGVAR(activeThrowable), objNull];
|
_unit setVariable [QGVAR(activeThrowable), objNull];
|
||||||
|
_unit setVariable [QGVAR(activeMuzzle), ["", 0]];
|
||||||
_unit setVariable [QGVAR(throwType), THROW_TYPE_DEFAULT];
|
_unit setVariable [QGVAR(throwType), THROW_TYPE_DEFAULT];
|
||||||
_unit setVariable [QGVAR(throwSpeed), THROW_SPEED_DEFAULT];
|
_unit setVariable [QGVAR(throwSpeed), THROW_SPEED_DEFAULT];
|
||||||
_unit setVariable [QGVAR(dropMode), false];
|
_unit setVariable [QGVAR(dropMode), false];
|
||||||
|
@ -26,7 +26,7 @@ private _throwableMag = (currentThrowable _unit) select 0;
|
|||||||
_unit removeItem _throwableMag;
|
_unit removeItem _throwableMag;
|
||||||
|
|
||||||
private _throwableType = getText (configFile >> "CfgMagazines" >> _throwableMag >> "ammo");
|
private _throwableType = getText (configFile >> "CfgMagazines" >> _throwableMag >> "ammo");
|
||||||
private _muzzle = _throwableMag call FUNC(getMuzzle);
|
private _muzzle = (_unit getVariable [QGVAR(activeMuzzle), ["", 0]]) select 0;
|
||||||
|
|
||||||
// Create actual throwable globally
|
// Create actual throwable globally
|
||||||
private _activeThrowableOld = _unit getVariable [QGVAR(activeThrowable), objNull];
|
private _activeThrowableOld = _unit getVariable [QGVAR(activeThrowable), objNull];
|
||||||
|
@ -54,8 +54,6 @@ if (!(_unit getVariable [QGVAR(primed), false])) then {
|
|||||||
_activeThrowable setVelocity _newVelocity;
|
_activeThrowable setVelocity _newVelocity;
|
||||||
};
|
};
|
||||||
|
|
||||||
_unit setVariable [QGVAR(lastThrownTime), CBA_missionTime];
|
|
||||||
|
|
||||||
// Invoke listenable event
|
// Invoke listenable event
|
||||||
["ace_throwableThrown", [_unit, _activeThrowable]] call CBA_fnc_localEvent;
|
["ace_throwableThrown", [_unit, _activeThrowable]] call CBA_fnc_localEvent;
|
||||||
}, [
|
}, [
|
||||||
|
Loading…
Reference in New Issue
Block a user