Explosives - Fix cellphone ringing if RF blocking present (#8991)

This commit is contained in:
Whigital 2022-09-10 20:02:53 +02:00 committed by GitHub
parent accba4dd34
commit b9ce02acf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 57 additions and 11 deletions

View File

@ -39,3 +39,4 @@ PREP(startTimer);
PREP(triggerType);
PREP(allowDefuse);
PREP(isAllowedDefuse);
PREP(checkDetonateHandlers);

View File

@ -0,0 +1,38 @@
#include "script_component.hpp"
/*
* Author: PabstMirror, Whigital
* Check if there is a handler blocking detonation
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Max range (-1 to ignore) <NUMBER>
* 2: Explosive <OBJECT>
* 3: Fuse time <NUMBER>
* 4: Trigger Item Classname <STRING>
*
* Return Value:
* Detonation Allowed <BOOL>
*
* Example:
* [player, -1, Explosive, 1, "ACE_Cellphone"] call ACE_Explosives_fnc_checkDetonateHandlers;
*
* Public: No
*/
params ["_unit", "_range", "_explosive", "_fuseTime", ["_triggerClassname", "#unknown", [""]]];
TRACE_5("checkDetonateHandlers",_unit,_range,_explosive,_fuseTime,_triggerClassname);
private _detonationAllowed = true;
{
// Pass [Unit<OBJECT>, MaxRange <NUMBER>, Explosive <OBJECT>, FuzeTime <NUMBER>, TriggerItem <STRING>]
private _handlerResult = [_unit, _range, _explosive, _fuseTime, _triggerClassname] call _x;
if (_handlerResult isEqualTo false) then {
TRACE_1("Handler Blocking",_forEachIndex);
_detonationAllowed = false;
break;
};
} forEach GVAR(detonationHandlers);
_detonationAllowed

View File

@ -28,12 +28,8 @@ private _ignoreRange = (_range == -1);
if (!_ignoreRange && {(_unit distance (_item select 0)) > _range}) exitWith {TRACE_1("out of range",_range); false};
private _result = true;
{
// Pass [Unit<OBJECT>, MaxRange <NUMBER>, Explosive <OBJECT>, FuzeTime <NUMBER>, TriggerItem <STRING>]
private _handlerResult = [_unit, _range, _item select 0, _item select 1, _triggerClassname] call _x;
if (_handlerResult isEqualTo false) then {TRACE_1("Handler Failed",_forEachIndex); _result = false};
} forEach GVAR(detonationHandlers);
if (!_result) exitWith {false};
if !([_unit, _range, _item select 0, _item select 1, _triggerClassname] call FUNC(checkDetonateHandlers)) exitWith {false};
if (getNumber (ConfigFile >> "CfgAmmo" >> typeOf (_item select 0) >> "TriggerWhenDestroyed") == 0) then {
private _previousExp = _item select 0;

View File

@ -35,9 +35,15 @@ if (_unit == ace_player) then {
private _explosive = [_code] call FUNC(getSpeedDialExplosive);
if ((count _explosive) > 0) then {
[{
playSound3D [QUOTE(PATHTO_R(Data\Audio\Cellphone_Ring.wss)),objNull, false, getPosASL (_this select 1),3.16228,1,75];
(_this select 0) setVariable [QGVAR(Dialing), false, true];
}, [_unit,_explosive select 0], 0.25 * (count _arr - 4)] call CBA_fnc_waitAndExecute;
params ["_unit", "_item"];
if ([_unit, -1, (_item # 0), (_item # 2), "ACE_Cellphone"] call FUNC(checkDetonateHandlers)) then {
playSound3D [QUOTE(PATHTO_R(Data\Audio\Cellphone_Ring.wss)), objNull, false, (getPosASL (_item # 0)), 3.16228, 1, 75];
};
_unit setVariable [QGVAR(Dialing), false, true];
}, [_unit, _explosive], 0.25 * (count _arr - 4)] call CBA_fnc_waitAndExecute;
[_explosive select 0,(0.25 * (count _arr - 1)) + (_explosive select 2), "ACE_Cellphone", _unit] call FUNC(startTimer);
};
};

View File

@ -39,9 +39,14 @@ if (_i >= (count _arr + 2)) then {
ctrlSetText [1400,"Call Ended!"];
};
};
if (_i == (count _arr)) then {
if ((count _explosive) > 0) then {
playSound3D [QUOTE(PATHTO_R(Data\Audio\Cellphone_Ring.wss)),objNull, false, getPosASL (_explosive select 0),3.16228,1,75];
if (
((count _explosive) > 0) &&
{[_unit, -1, (_explosive # 0), (_explosive # 2), "ACE_Cellphone"] call FUNC(checkDetonateHandlers)}
) then {
playSound3D [QUOTE(PATHTO_R(Data\Audio\Cellphone_Ring.wss)), objNull, false, (getPosASL (_explosive # 0)), 3.16228, 1, 75];
};
};
_args set [1, _i + 1];