mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
be9797d11d
* Add grenade rolling * Added some safeguards * Use `setVectorDirAndUp` instead of rotation * Don't allow players to roll grenades when in vehicles * Grenades - Rolling only add PFEH when needed (#10015) * Grenades - Rolling only add PFEH when needed * Corrected minor typo, moved variable init in preInit, fixed bugs --------- Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * Don't switch modes if grenade can't be thrown * Minor tweaks --------- Co-authored-by: PabstMirror <pabstmirror@gmail.com>
84 lines
2.5 KiB
Plaintext
84 lines
2.5 KiB
Plaintext
#include "..\script_component.hpp"
|
|
/*
|
|
* Author: commy2
|
|
* Select the next throwing mode and display message.
|
|
*
|
|
* Arguments:
|
|
* None
|
|
*
|
|
* Return Value:
|
|
* Handeled <BOOL>
|
|
*
|
|
* Example:
|
|
* [] call ace_grenades_fnc_nextMode
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
private _mode = GVAR(currentThrowMode);
|
|
|
|
if (_mode == 4) then {
|
|
_mode = 0;
|
|
} else {
|
|
_mode = _mode + 1;
|
|
};
|
|
|
|
private _currentThrowable = currentThrowable ACE_player;
|
|
|
|
// Make sure grenade can be rolled if in roll mode (detonation time has to be >= 1 second and player isn't in a vehicle)
|
|
if (
|
|
_mode == 3 &&
|
|
{_currentThrowable isNotEqualTo []} &&
|
|
{
|
|
!isNull objectParent ACE_player ||
|
|
{getNumber (configFile >> "CfgAmmo" >> getText (configFile >> "CfgMagazines" >> _currentThrowable select 0 >> "ammo") >> "explosionTime") < MIN_EXPLOSION_TIME_FOR_ROLL}
|
|
}
|
|
) then {
|
|
_mode = _mode + 1;
|
|
};
|
|
|
|
private _hint = localize ([
|
|
LSTRING(NormalThrow),
|
|
LSTRING(HighThrow),
|
|
LSTRING(PreciseThrow),
|
|
LSTRING(RollGrenade),
|
|
LSTRING(DropGrenade)
|
|
] select _mode);
|
|
|
|
[_hint] call EFUNC(common,displayTextStructured);
|
|
|
|
GVAR(throwModePFEH) call CBA_fnc_removePerFrameHandler;
|
|
GVAR(currentThrowMode) = _mode;
|
|
|
|
// If in rolling mode, check every frame if current throwable is rollable
|
|
if (GVAR(currentThrowMode) == 3) then {
|
|
GVAR(currentThrowable) = _currentThrowable;
|
|
|
|
GVAR(throwModePFEH) = {
|
|
private _currentThrowable = currentThrowable ACE_player;
|
|
|
|
if (GVAR(currentThrowable) isEqualTo _currentThrowable) exitWith {};
|
|
|
|
GVAR(currentThrowable) = _currentThrowable;
|
|
|
|
// Make sure grenade can be rolled if in roll mode (detonation time has to be >= 1 second and player isn't in a vehicle)
|
|
if !(
|
|
GVAR(currentThrowMode) == 3 &&
|
|
{_currentThrowable isNotEqualTo []} &&
|
|
{
|
|
!isNull objectParent ACE_player ||
|
|
{getNumber (configFile >> "CfgAmmo" >> getText (configFile >> "CfgMagazines" >> _currentThrowable select 0 >> "ammo") >> "explosionTime") < MIN_EXPLOSION_TIME_FOR_ROLL}
|
|
}
|
|
) exitWith {};
|
|
|
|
// Force the user into the normal throw mode
|
|
// Next throw mode after roll would be drop, which isn't ideal if the user tries to throw unknowingly...
|
|
[format [LLSTRING(RollGrenadeDisabled), LLSTRING(NormalThrow)], 2] call EFUNC(common,displayTextStructured);
|
|
|
|
GVAR(throwModePFEH) call CBA_fnc_removePerFrameHandler;
|
|
GVAR(currentThrowMode) = 0;
|
|
} call CBA_fnc_addPerFrameHandler;
|
|
};
|
|
|
|
true
|