Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explosives - Improve Support for custom IED ringtones #10731

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions addons/explosives/CfgAmmo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class CfgAmmo {
indirectHit = 500;
indirectHitRange = 7;
};

class PipeBombBase;
class SatchelCharge_Remote_Ammo: PipeBombBase {
GVAR(magazine) = "SatchelCharge_Remote_Mag";
Expand All @@ -118,6 +119,7 @@ class CfgAmmo {
GVAR(magazine) = "IEDUrbanBig_Remote_Mag";
GVAR(size) = 1;
soundTrigger[] = {"A3\Sounds_F\weapons\mines\mech_trigger_1", 0.8, 1, 40};
GVAR(ringtones)[] = {{QPATHTOF(Data\Audio\Cellphone_Ring.wss), 0.75, 3.16228, 1, 75}};
};
class ACE_IEDUrbanBig_Command_Ammo: IEDUrbanBig_Remote_Ammo {
mineTrigger = "RemoteTrigger";
Expand All @@ -132,6 +134,7 @@ class CfgAmmo {
GVAR(magazine) = "IEDUrbanSmall_Remote_Mag";
GVAR(size) = 0;
soundTrigger[] = {"A3\Sounds_F\weapons\mines\mech_trigger_1", 0.8, 1, 40};
GVAR(ringtones)[] = {{QPATHTOF(Data\Audio\Cellphone_Ring.wss), 0.75, 3.16228, 1, 75}};
};
class ACE_IEDUrbanSmall_Command_Ammo: IEDUrbanSmall_Remote_Ammo {
mineTrigger = "RemoteTrigger";
Expand All @@ -146,6 +149,7 @@ class CfgAmmo {
GVAR(magazine) = "IEDLandBig_Remote_Mag";
GVAR(size) = 1;
soundTrigger[] = {"A3\Sounds_F\weapons\mines\mech_trigger_1", 0.8, 1, 40};
GVAR(ringtones)[] = {{QPATHTOF(Data\Audio\Cellphone_Ring.wss), 0.75, 3.16228, 1, 75}};
};
class ACE_IEDLandBig_Command_Ammo: IEDLandBig_Remote_Ammo {
mineTrigger = "RemoteTrigger";
Expand All @@ -160,6 +164,7 @@ class CfgAmmo {
GVAR(magazine) = "IEDLandSmall_Remote_Mag";
GVAR(size) = 0;
soundTrigger[] = {"A3\Sounds_F\weapons\mines\mech_trigger_1", 0.8, 1, 40};
GVAR(ringtones)[] = {{QPATHTOF(Data\Audio\Cellphone_Ring.wss), 0.75, 3.16228, 1, 75}};
};
class ACE_IEDLandSmall_Command_Ammo: IEDLandSmall_Remote_Ammo {
mineTrigger = "RemoteTrigger";
Expand Down
29 changes: 19 additions & 10 deletions addons/explosives/functions/fnc_dialPhone.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/*
* Author: Garth 'L-H' de Wet
* Dials the number passed and detonates the explosive.
*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rogue change.

* Arguments:
* 0: Unit to do dialing <OBJECT>
* 1: Code to dial <STRING>
Expand All @@ -15,9 +14,7 @@
*
* Public: Yes
*/

params ["_unit", "_code"];
TRACE_2("params",_unit,_code);
Comment on lines -18 to -20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.


if (_unit getVariable [QGVAR(Dialing),false]) exitWith {};
if !(alive _unit) exitWith {};
Expand All @@ -28,22 +25,34 @@ private _arr = [];
for "_i" from 1 to _ran do {
_arr = _arr + ['.','..','...',''];
};

private _explosive = [_code] call FUNC(getSpeedDialExplosive);

private _ringtone = getArray (configOf (_explosive select 0) >> QGVAR(ringtones));
if (_ringtone isEqualTo []) then { _ringtone = [[QPATHTOF(Data\Audio\Cellphone_Ring.wss), 0.75, 3.16228, 1, 75]] };
//support random ringtones
tuntematonjr marked this conversation as resolved.
Show resolved Hide resolved
_ringtone = selectRandom _ringtone;
_ringtone params ["_ringtonePath", "_ringtoneLength", "_volume", "_soundPitch", "_distance"];

//Calculate the ringtone duration before detonation with slight randomness
private _ringtoneDuration = round(count _arr - (_ringtoneLength + (random 1.5)- 0.75) / 0.25) max 4;

TRACE_2("ringtone",_ringtone,_ringtoneDuration);
if (_unit == ace_player) then {
ctrlSetText [1400,"Calling"];
[LINKFUNC(dialingPhone), 0.25, [_unit,4,_arr,_code]] call CALLSTACK(CBA_fnc_addPerFrameHandler);
[LINKFUNC(dialingPhone), 0.25, [_unit,4,_arr,_explosive,_ringtonePath,_ringtoneDuration,_volume,_soundPitch,_distance]] call CALLSTACK(CBA_fnc_addPerFrameHandler);
} else {
private _explosive = [_code] call FUNC(getSpeedDialExplosive);
if ((count _explosive) > 0) then {
private _waitTime = 0.25 * _ringtoneDuration;
[{
params ["_unit", "_item"];

params ["_unit", "_item", "_ringtonePath"];
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];
playSound3D [_ringtonePath, objNull, false, (getPosASL (_item # 0)), _volume, _soundPitch, _distance];
};

_unit setVariable [QGVAR(Dialing), false, true];
}, [_unit, _explosive], 0.25 * (count _arr - 4)] call CBA_fnc_waitAndExecute;
}, [_unit, _explosive, _ringtonePath], _waitTime] call CBA_fnc_waitAndExecute;

[_explosive select 0,(0.25 * (count _arr - 1)) + (_explosive select 2), "ACE_Cellphone", _unit] call FUNC(startTimer);
[_explosive select 0,(_waitTime + 2) + (_explosive select 2), "ACE_Cellphone", _unit] call FUNC(startTimer);
};
};
22 changes: 11 additions & 11 deletions addons/explosives/functions/fnc_dialingPhone.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@
* 0: Unit to do dialing <OBJECT>
* 1: Index <NUMBER>
* 2: Dialing points <ARRAY>
* 3: IED code <STRING>
* 3: Explosive data <ARRAY>
* 4: Path to ringtone sound file <STRING>
* 5: Duration before the explosive rings <NUMBER>
*
* Return Value:
* None
*
* Example:
* [ace_explosives_fnc_dialingPhone, 0.25, [_unit,4,_arr,_code]] call CBA_fnc_addPerFrameHandler;
* [ace_explosives_fnc_dialingPhone, 0.25, [_unit,4,_arr, _explosive, _ringtonePath, _ringtoneDuration]] call CBA_fnc_addPerFrameHandler;
*
* Public: No
*/

params ["_args", "_pfID"];
_args params ["_unit", "_i", "_arr", "_code"];
_args params ["_unit", "_dialStep", "_arr", "_explosive", "_ringtonePath", "_ringtoneDuration", "_volume", "_soundPitch", "_distance"];

if ((_i mod 4) == 0) then {
if ((_dialStep mod 4) == 0) then {
private _pos = _unit modelToWorldVisualWorld (_unit selectionPosition "RightHand");
playSound3D [QUOTE(PATHTO_R(Data\Audio\DialTone.wss)), objNull, false, _pos, 5, 1, 5];
};
ctrlSetText [1400,format["Calling%1",_arr select (_i - 4)]];
ctrlSetText [1400,format["Calling%1",_arr select (_dialStep - 4)]];

private _explosive = [_code] call FUNC(getSpeedDialExplosive);

if (_i >= (count _arr + 2)) then {
if (_dialStep >= (count _arr + 2)) then {
[_pfID] call CALLSTACK(CBA_fnc_removePerFrameHandler);
if ((count _explosive) > 0) then {
[_unit, -1, [_explosive select 0, _explosive select 2], "ACE_Cellphone"] call FUNC(detonateExplosive);
Expand All @@ -40,13 +40,13 @@ if (_i >= (count _arr + 2)) then {
};
};

if (_i == (count _arr)) then {
if (_dialStep == _ringtoneDuration) then {
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];
playSound3D [_ringtonePath, objNull, false, (getPosASL (_explosive # 0)), _volume, _soundPitch, _distance];
};
};

_args set [1, _i + 1];
_args set [1, _dialStep + 1];
1 change: 1 addition & 0 deletions docs/wiki/framework/explosives-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class CfgAmmo {
ACE_explodeOnDefuse = 0.02; // (Optional) Add a chance for the explosive to detonate after being disarmed (in percent)
ACE_explosives_defuseObjectPosition[] = {-1.415, 0, 0.12}; // (Optional) The position relative to the model where the defuse helper object will be attached and thus the interaction point will be rendered
ACE_explosives_size = 0; // (Optional) Setting to 1 will use a defusal action with a larger radius (useful for large mines or mines with a wide pressure plane trigger area)
ACE_explosives_ringtones[] = {{"\z\addons\explosives\Data\Audio\Cellphone_Ring.wss", 0.75, 3.16228, 1, 75}}; // (Optional) Defines IED ringtone(s) to be randomly selected upon detonation by cellphone. Each entry includes a sound file path, duration (in seconds), volume, pitch, and maximum audible distance.
};
};
```
Expand Down