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

Add option for multiple sound sources #161

Merged
merged 2 commits into from
May 10, 2016
Merged
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
6 changes: 6 additions & 0 deletions addons/shootingrange/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ class CfgVehicles {
typeName = "STRING";
defaultValue = "";
};
class SoundSources {
displayName = CSTRING(SoundSources);
description = CSTRING(SoundSourcesDesc);
typeName = "STRING";
defaultValue = "";
};
class Mode {
displayName = CSTRING(Mode);
description = CSTRING(ModeDesc);
Expand Down
1 change: 1 addition & 0 deletions addons/shootingrange/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ PREP(create);
PREP(handleHitPart);
PREP(moduleInit);
PREP(notifyVicinity);
PREP(playSoundSignal);
PREP(popupPFH);
PREP(popupPFHexit);
PREP(setConfigCountdownTime);
Expand Down
5 changes: 4 additions & 1 deletion addons/shootingrange/functions/fnc_create.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* 10: Trigger Markers <ARRAY> (default: [])
* 11: Pop on Trigger Exit <BOOL> (default: true)
* 12: Invalid Targets <ARRAY> (default: [])
* 13: Sound Sources <ARRAY> (default: [])
*
* Return Value:
* None
Expand All @@ -42,7 +43,8 @@ params [
["_defaultCountdownTime", COUNTDOWNTIME_DEFAULT, [0] ],
["_triggerMarkers", [], [[]] ],
["_popOnTriggerExit", POPONTRIGGEREXIT_DEFAULT, [true] ],
["_targetsInvalid", [], [[]] ]
["_targetsInvalid", [], [[]] ],
["_soundSources", [], [[]] ]
];

// Verify data
Expand Down Expand Up @@ -130,6 +132,7 @@ _countdownTimes sort true;
if (_x getVariable [QGVAR(mode), 0] == 0) then {
_x setVariable [QGVAR(mode), _mode, true];
};
_x setVariable [QGVAR(soundSources), _controllers + _soundSources];

// Main
private _actionRange = [
Expand Down
2 changes: 1 addition & 1 deletion addons/shootingrange/functions/fnc_handleHitPart.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ if (_shooter != _starter) exitWith {
};


[_controller, "Beep_Target", 25] call CBA_fnc_globalSay3d;
[_controller, "Beep_Target"] call FUNC(playSoundSignal);

// Mark target as already hit
_target setVariable [QGVAR(alreadyHit), true];
Expand Down
5 changes: 4 additions & 1 deletion addons/shootingrange/functions/fnc_moduleInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ _targetsInvalid = _targetsInvalid apply { [missionNamespace getVariable _x, objN
// Exctract controller objects
private _controllers = [_logic getVariable "Controllers", true, true] call ACE_Common_fnc_parseList;

// Exctract sound source objects
private _soundSources = [_logic getVariable "SoundSources", true, true] call ACE_Common_fnc_parseList;

// Extract target change event
private _mode = _logic getVariable "Mode";

Expand Down Expand Up @@ -88,6 +91,6 @@ private _popOnTriggerExit = _logic getVariable "PopOnTriggerExit";


// Prepare with actions
[_name, _targets, _controllers, _mode, _durations, _defaultDuration, _targetAmounts, _defaultTargetAmount, _pauseDurations, _defaultPauseDuration, _countdownTimes, _defaultCountdownTime, _triggerMarkers, _popOnTriggerExit, _targetsInvalid] call FUNC(create);
[_name, _targets, _controllers, _mode, _durations, _defaultDuration, _targetAmounts, _defaultTargetAmount, _pauseDurations, _defaultPauseDuration, _countdownTimes, _defaultCountdownTime, _triggerMarkers, _popOnTriggerExit, _targetsInvalid, _soundSources] call FUNC(create);

ACE_LOGINFO("Shooting Range Module Initialized");
26 changes: 26 additions & 0 deletions addons/shootingrange/functions/fnc_playSoundSignal.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Author: Jonpas
* Plays sound signal on all controllers and extra sound sources.
*
* Arguments:
* 0: Controller <OBJECT>
* 1: Sound Classname (CfgSound) <STRING>
* 2: Range <NUMBER> (default: 25)
*
* Return Value:
* None
*
* Example:
* [controller, "FD_Timer_F", 25] call tac_shootingrange_fnc_playSoundSignal;
*
* Public: No
*/
#include "script_component.hpp"

params ["_controller", "_sound", ["_range", 25]];

private _soundSources = _controller getVariable [QGVAR(soundSources), []];

{
[_x, _sound, _range] call CBA_fnc_globalSay3d;
} forEach _soundSources;
4 changes: 2 additions & 2 deletions addons/shootingrange/functions/fnc_start.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ if (_mode > 1) then {

// Countdown timer notification
[_textCountdown] call ACE_Common_fnc_displayTextStructured;
[_controller, "FD_Timer_F", 25] call CBA_fnc_globalSay3d;
[_controller, "FD_Timer_F"] call FUNC(playSoundSignal);

}, [_controller, _textCountdown], _execTime] call ACE_Common_fnc_waitAndExecute;

Expand All @@ -139,7 +139,7 @@ if (_mode > 1) then {

// Final countdown notification
[localize LSTRING(Go)] call ACE_Common_fnc_displayTextStructured;
[_controller, "FD_Start_F", 25] call CBA_fnc_globalSay3d;
[_controller, "FD_Start_F"] call FUNC(playSoundSignal);

// Notify supervisor(s) (closer than start/stop notifications)
private _playerName = [ACE_player, true] call ACE_Common_fnc_getName;
Expand Down
2 changes: 1 addition & 1 deletion addons/shootingrange/functions/fnc_stop.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ params ["_controller", "_controllers", "_name", "_targets", "_targetsInvalid", [

// Notification
private _playerName = [ACE_player, true] call ACE_Common_fnc_getName;
[_controller, "FD_Finish_F", 25] call CBA_fnc_globalSay3d;
[_controller, "FD_Finish_F"] call FUNC(playSoundSignal);

if (_success) then {
// Check for zero divisor
Expand Down
6 changes: 6 additions & 0 deletions addons/shootingrange/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
<English>List of object names used as controllers, separated by commas.</English>
<German>Liste der Objektnamen, die als Regler genutzt werden. Durch Kommas trennen.</German>
</Key>
<Key ID="STR_TAC_ShootingRange_SoundSources">
<English>Sound Sources</English>
</Key>
<Key ID="STR_TAC_ShootingRange_SoundSourcesDesc">
<English>List of object names used as sound sources (in addition to controllers), separated by commas.</English>
</Key>
<Key ID="STR_TAC_ShootingRange_Mode">
<English>Mode</English>
<German>Modus</German>
Expand Down