From 827ef91fced046842bb2d3b8bc2e9717bd3e66a9 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 15 Feb 2015 10:03:58 +0100 Subject: [PATCH 1/8] Ported CSE Ambiance sound module --- .../functions/fn_moduleAmbianceSoundLoop.sqf | 98 -------------- addons/missionModules/$PBOPREFIX$ | 1 + addons/missionModules/CfgEventHandlers.hpp | 6 + addons/missionModules/CfgFactionClasses.hpp | 6 + addons/missionModules/CfgVehicles.hpp | 68 ++++++++++ addons/missionModules/XEH_preInit.sqf | 7 + addons/missionModules/config.cpp | 17 +++ addons/missionModules/data/moduleSound.paa | Bin 0 -> 5625 bytes .../functions/fnc_moduleAmbianceSound.sqf | 123 ++++++++++++++++++ .../functions/script_component.hpp | 1 + addons/missionModules/script_component.hpp | 12 ++ 11 files changed, 241 insertions(+), 98 deletions(-) delete mode 100644 TO_MERGE/cse/sys_misc/functions/fn_moduleAmbianceSoundLoop.sqf create mode 100644 addons/missionModules/$PBOPREFIX$ create mode 100644 addons/missionModules/CfgEventHandlers.hpp create mode 100644 addons/missionModules/CfgFactionClasses.hpp create mode 100644 addons/missionModules/CfgVehicles.hpp create mode 100644 addons/missionModules/XEH_preInit.sqf create mode 100644 addons/missionModules/config.cpp create mode 100644 addons/missionModules/data/moduleSound.paa create mode 100644 addons/missionModules/functions/fnc_moduleAmbianceSound.sqf create mode 100644 addons/missionModules/functions/script_component.hpp create mode 100644 addons/missionModules/script_component.hpp diff --git a/TO_MERGE/cse/sys_misc/functions/fn_moduleAmbianceSoundLoop.sqf b/TO_MERGE/cse/sys_misc/functions/fn_moduleAmbianceSoundLoop.sqf deleted file mode 100644 index 4b4d93d453..0000000000 --- a/TO_MERGE/cse/sys_misc/functions/fn_moduleAmbianceSoundLoop.sqf +++ /dev/null @@ -1,98 +0,0 @@ -/** - * fn_moduleAmbianceSoundLoop.sqf - * @Descr: N/A - * @Author: Glowbal - * - * @Arguments: [] - * @Return: - * @PublicAPI: false - */ - -private ["_logic", "_units", "_activated","_ambianceSounds", "_soundFiles", "_minimalDistance","_maximalDistance", "_minimalDistance", "_maxDelayBetweenSounds", "_allUnits", "_newPos", "_targetUnit", "_soundToPlay", "_soundPath", "_unparsedSounds", "_list", "_splittedList", "_nilCheckPassedList"]; -_logic = [_this,0,objNull,[objNull]] call BIS_fnc_param; -_units = [_this,1,[],[[]]] call BIS_fnc_param; -_activated = [_this,2,true,[true]] call BIS_fnc_param; - -if (_activated && isServer) then { - _ambianceSounds = []; - _unparsedSounds = _logic getvariable ["soundFiles", ""]; - _minimalDistance = (_logic getvariable ["minimalDistance", 400]) max 1; - _maximalDistance = (_logic getvariable ["maximalDistance", 10]) max _minimalDistance; - _minDelayBetweensounds = (_logic getvariable ["minimalDelay", 10]) max 1; - _maxDelayBetweenSounds = (_logic getvariable ["maximalDelay", 170]) max _minDelayBetweensounds; - _volume = (_logic getvariable ["soundVolume", 30]) max 1; - _followPlayers = _logic getvariable ["followPlayers", false]; - - _splittedList = [_unparsedSounds, ","] call BIS_fnc_splitString; - - _nilCheckPassedList = ""; - { - _x = [_x] call cse_fnc_string_removeWhiteSpace; - _splittedList set [_foreachIndex, _x]; - }foreach _splittedList; - - _soundPath = [(str missionConfigFile), 0, -15] call BIS_fnc_trimString; - { - if (isclass (missionConfigFile >> "CfgSounds" >> _x)) then { - _ambianceSounds pushback (_soundPath + (getArray(missionConfigFile >> "CfgSounds" >> _x >> "sound") select 0)); - } else { - if (isclass (configFile >> "CfgSounds" >> _x)) then { - _ambianceSounds pushback ((getArray(configFile >> "CfgSounds" >> _x >> "sound") select 0)); - }; - }; - }foreach _splittedList; - - if (count _ambianceSounds == 0) exitwith { - [format["No Ambiance sounds available"]] call cse_fnc_debug; - }; - { - if !([".", _x, true] call BIS_fnc_inString) then { - [format["Ambiance soundfile does not contain a file extension %1", _x]] call cse_fnc_debug; - _ambianceSounds set [_foreachIndex, _x + ".wss"]; - }; - }foreach _ambianceSounds; - [format["Ambiance sounds %1", _ambianceSounds]] call cse_fnc_debug; - - while {alive _logic} do { - _allUnits = switch (true) do { - case isMultiplayer: {playableUnits}; - case isDedicated: {[_logic]}; - default {[player]}; - }; - - if (count _allUnits > 0) then { - _targetUnit = _allUnits select (round(random((count _allUnits)-1))); - - _newPos = (getPos _targetUnit); - if (!_followPlayers) then { - _newPos = getPos _logic; - }; - - if (random(1) >= 0.5) then { - if (random(1) >= 0.5) then { - _newPos set [0, (_newPos select 0) + (_minimalDistance + random(_maximalDistance))]; - } else { - _newPos set [0, (_newPos select 0) - (_minimalDistance + random(_maximalDistance))]; - }; - } else { - if (random(1) >= 0.5) then { - _newPos set [1, (_newPos select 1) + (_minimalDistance + random(_maximalDistance))]; - } else { - _newPos set [1, (_newPos select 1) - (_minimalDistance + random(_maximalDistance))]; - }; - }; - - if ({(_newPos distance _x < (_minimalDistance / 2))}count _allUnits == 0) then { - - _soundToPlay = _ambianceSounds select (round(random((count _ambianceSounds)-1))); - playSound3D [_soundToPlay, _targetUnit, false, _newPos, _volume, 1, 1000]; - - [format["Played a sound %1", _soundToPlay]] call cse_fnc_debug; - - sleep (_minDelayBetweensounds + random(_maxDelayBetweenSounds)) min _maxDelayBetweenSounds; - }; - }; - }; -}; - -true; \ No newline at end of file diff --git a/addons/missionModules/$PBOPREFIX$ b/addons/missionModules/$PBOPREFIX$ new file mode 100644 index 0000000000..ea1be0daee --- /dev/null +++ b/addons/missionModules/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\missionModules \ No newline at end of file diff --git a/addons/missionModules/CfgEventHandlers.hpp b/addons/missionModules/CfgEventHandlers.hpp new file mode 100644 index 0000000000..f0a9f14d91 --- /dev/null +++ b/addons/missionModules/CfgEventHandlers.hpp @@ -0,0 +1,6 @@ + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/missionModules/CfgFactionClasses.hpp b/addons/missionModules/CfgFactionClasses.hpp new file mode 100644 index 0000000000..792f4d31e3 --- /dev/null +++ b/addons/missionModules/CfgFactionClasses.hpp @@ -0,0 +1,6 @@ +class CfgFactionClasses { + class NO_CATEGORY; + class ACE_missionModules: NO_CATEGORY { + displayName = "ACE Mission Modules"; + }; +}; \ No newline at end of file diff --git a/addons/missionModules/CfgVehicles.hpp b/addons/missionModules/CfgVehicles.hpp new file mode 100644 index 0000000000..570883ee5f --- /dev/null +++ b/addons/missionModules/CfgVehicles.hpp @@ -0,0 +1,68 @@ +class CfgVehicles { + class Logic; + class Module_F: Logic { + class ArgumentsBaseUnits { + }; + }; + + // TODO make a curator variant for this + class cse_moduleAmbianceSound: Module_F { + scope = 2; + displayName = "Ambiance Sounds [ACE]"; + icon = QUOTE(PATHTOF(data\moduleSound.paa)); + category = "ACE_missionModules"; + function = QUOTE(FUNC(moduleAmbianceSound); + functionPriority = 1; + isGlobal = 1; + isTriggerActivated = 0; + author = "Glowbal"; + class Arguments { + class soundFiles { + displayName = "Sounds"; + description = "Classnames of the ambiance sounds played. Seperated by ','. "; + typeName = "STRING"; + defaultValue = ""; + }; + class minimalDistance { + displayName = "Minimal Distance"; + description = "Minimal Distance"; + typeName = "NUMBER"; + defaultValue = 400; + }; + class maximalDistance { + displayName = "Maximal Distance"; + description = "Maximal Distance"; + typeName = "NUMBER"; + defaultValue = 900; + }; + class minimalDelay { + displayName = "Minimal Delay"; + description = "Minimal Delay between sounds played"; + typeName = "NUMBER"; + defaultValue = 10; + }; + class maximalDelay { + displayName = "Maximal Delay"; + description = "Maximal Delay between sounds played"; + typeName = "NUMBER"; + defaultValue = 170; + }; + class followPlayers { + displayName = "Follow Players"; + description = "Follow players. If set to false, loop will play sounds only nearby logic position."; + typeName = "BOOL"; + defaultValue = 0; + }; + class soundVolume { + displayName = "Volume"; + description = "The volume of the sounds played"; + typeName = "NUMBER"; + defaultValue = 0; + }; + }; + class ModuleDescription { + description = "Ambiance sounds loop (synced across MP)"; + sync[] = {}; + }; + }; +}; diff --git a/addons/missionModules/XEH_preInit.sqf b/addons/missionModules/XEH_preInit.sqf new file mode 100644 index 0000000000..cadbbabdd1 --- /dev/null +++ b/addons/missionModules/XEH_preInit.sqf @@ -0,0 +1,7 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP(moduleAmbianceSound); + +ADDON = true; diff --git a/addons/missionModules/config.cpp b/addons/missionModules/config.cpp new file mode 100644 index 0000000000..0867b486c6 --- /dev/null +++ b/addons/missionModules/config.cpp @@ -0,0 +1,17 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {"cse_moduleAmbianceSound"}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author[] = {"Glowbal"}; + authorUrl = ""; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" +#include "CfgFactionClasses.hpp" +#include "CfgVehicles.hpp" diff --git a/addons/missionModules/data/moduleSound.paa b/addons/missionModules/data/moduleSound.paa new file mode 100644 index 0000000000000000000000000000000000000000..bfe3b8032717dcc98269b4b42a620cffe550ffc2 GIT binary patch literal 5625 zcmd5=e{2)i9e)QtpfrHPa-m>_7$qGojBP2JHAXidD=lKvOSnciRHiZp3io($CfVu3Ih4Y{*BB>0gjI}tEY4lCyKj^3 zi|MspB)_I9Qgx5++xQ+GAF#}rEAi6)SgR2uT;uV0M$+GvaQ(#H9}xS?WmyKjWzk^2 zNzcQW;MZidnf$!>++Lhj?%eeIpGtziBC+buc2ZUhGN$7o{p|Y_&10xliB==phYGcr8`S2cb3wu zSJO0FbEhH0o>*@a^2330*Os!%?HPIs=*>Ht3JmIghu|*BN=Fax<2*v*2zg37n~I_l zvuOp1~efUHq1t$YIb<=rbwS zTrcQpUhjzXYHsxVyH5nfdE>YxM~e3~1{1=bAg7M@d>{Fz$PcEznj%j-Sr-`;E@UQk zQ%W=8le|+&`CYHlo@`?-%h+-aPK=XB!7Q0@uvl zk~H~J)3;+sOn<@gdX~1F2=F@pO`4Y=pKA{{ih0US7~4l2ZHeSrF3!i~kXHre!}Y@c zP~XdDtC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X_O^x28Z$A&pS=)$^KtzKk;MPDzj+fwB>Q#-`x>urFlHnvF~!UO>diN z1yv&Jpc(olz3l-5or{nk44&+4GA;!F4$kl&=$B9LESij$36p&hUd;VmNUJ6YMgF6JLbOVk`ZbHcCR84R!G;@r-_u zAOuge55r}#NM0sQs>9M`hMq}%DBkSUY)Wi(n$)N*vDA>Kx9MZQ8d)rk1;xlSy{&nF z{&N3bnupD7Ptbb2a4^?R|X+6c1 zGkO0 + * 1: Units + * 2: Activated + * + * Return Value: + * Nothing + * + * Example: + * N/A + * + * Public: No + */ + +#include "script_component.hpp" + +private ["_logic", "_units", "_activated","_ambianceSounds", "_soundFiles", "_minimalDistance","_maximalDistance", "_minimalDistance", "_maxDelayBetweenSounds", "_allUnits", "_newPos", "_targetUnit", "_soundToPlay", "_soundPath", "_unparsedSounds", "_list", "_splittedList", "_nilCheckPassedList"]; +_logic = [_this,0,objNull,[objNull]] call BIS_fnc_param; +_units = [_this,1,[],[[]]] call BIS_fnc_param; +_activated = [_this,2,true,[true]] call BIS_fnc_param; + +// We only play this on the locality of the logic, since the sounds are broadcasted across the network +if (_activated && local _logic) then { + _ambianceSounds = []; + _unparsedSounds = _logic getvariable ["soundFiles", ""]; + _minimalDistance = (_logic getvariable ["minimalDistance", 400]) max 1; + _maximalDistance = (_logic getvariable ["maximalDistance", 10]) max _minimalDistance; + _minDelayBetweensounds = (_logic getvariable ["minimalDelay", 10]) max 1; + _maxDelayBetweenSounds = (_logic getvariable ["maximalDelay", 170]) max _minDelayBetweensounds; + _volume = (_logic getvariable ["soundVolume", 30]) max 1; + _followPlayers = _logic getvariable ["followPlayers", false]; + + _splittedList = [_unparsedSounds, ","] call BIS_fnc_splitString; + + _nilCheckPassedList = ""; + { + _x = [_x] call EFUNC(common,removeWhiteSpace); + _splittedList set [_foreachIndex, _x]; + }foreach _splittedList; + + _soundPath = [(str missionConfigFile), 0, -15] call BIS_fnc_trimString; + { + if (isclass (missionConfigFile >> "CfgSounds" >> _x)) then { + _ambianceSounds pushback (_soundPath + (getArray(missionConfigFile >> "CfgSounds" >> _x >> "sound") select 0)); + } else { + if (isclass (configFile >> "CfgSounds" >> _x)) then { + _ambianceSounds pushback ((getArray(configFile >> "CfgSounds" >> _x >> "sound") select 0)); + }; + }; + }foreach _splittedList; + + if (count _ambianceSounds == 0) exitwith {}; + { + if !([".", _x, true] call BIS_fnc_inString) then { + _ambianceSounds set [_foreachIndex, _x + ".wss"]; + }; + }foreach _ambianceSounds; + + [{ + private ["_args", "_logic", "_ambianceSounds", "_minimalDistance", "_maximalDistance", "_minDelayBetweensounds", "_maxDelayBetweenSounds", "_volume", "_followPlayers","_lastTimePlayed", "_newPos"] + _args = _this select 0; + _logic = _args select 0; + _lastTimePlayed = _args select 8; + + if (!alive _logic) exitwith { + [(_this select 1)] call cba_fnc_removePerFrameHandler; + }; + + if (_lastTimePlayed - time >= ((_minDelayBetweensounds + random(_maxDelayBetweenSounds)) min _maxDelayBetweenSounds)) then { + _ambianceSounds = _args select 1; + _minimalDistance = _args select 2; + _maximalDistance = _args select 3; + _minDelayBetweensounds = _args select 4; + _maxDelayBetweenSounds = _args select 5; + _volume = _args select 6; + _followPlayers = _args select 7; + + // Find all players in session. + _allUnits = if (isMultiplayer) then {playableUnits} else {[ACE_player]}; + + // Check if there are enough players to even start playing this sound. + if (count _allUnits > 0) then { + + // Select a target unit at random. + _targetUnit = _allUnits select (round(random((count _allUnits)-1))); + + // find the position from which we are going to play this sound from. + _newPos = (getPos _targetUnit); + if (!_followPlayers) then { + _newPos = getPos _logic; + }; + + // Randomize this position. + if (random(1) >= 0.5) then { + if (random(1) >= 0.5) then { + _newPos set [0, (_newPos select 0) + (_minimalDistance + random(_maximalDistance))]; + } else { + _newPos set [0, (_newPos select 0) - (_minimalDistance + random(_maximalDistance))]; + }; + } else { + if (random(1) >= 0.5) then { + _newPos set [1, (_newPos select 1) + (_minimalDistance + random(_maximalDistance))]; + } else { + _newPos set [1, (_newPos select 1) - (_minimalDistance + random(_maximalDistance))]; + }; + }; + + // If no unit is to close to this position, we will play the sound. + if ({(_newPos distance _x < (_minimalDistance / 2))}count _allUnits == 0) then { + + playSound3D [_ambianceSounds select (round(random((count _ambianceSounds)-1))), _targetUnit, false, _newPos, _volume, 1, 1000]; + _args set [8, time]; + }; + }; + }; + }, 0.1, [_logic, _ambianceSounds, _minimalDistance, _maximalDistance, _minDelayBetweensounds, _maxDelayBetweenSounds, _volume, _followPlayers, time] ] call CBA_fnc_addPerFrameHandler; +}; + +true; diff --git a/addons/missionModules/functions/script_component.hpp b/addons/missionModules/functions/script_component.hpp new file mode 100644 index 0000000000..e49740a89e --- /dev/null +++ b/addons/missionModules/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\missionModules\script_component.hpp" \ No newline at end of file diff --git a/addons/missionModules/script_component.hpp b/addons/missionModules/script_component.hpp new file mode 100644 index 0000000000..a567966c7b --- /dev/null +++ b/addons/missionModules/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT missionModules +#include "\z\ace\addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_MISSIONMODULES + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_MISSIONMODULES + #define DEBUG_SETTINGS DEBUG_SETTINGS_MISSIONMODULES +#endif + +#include "\z\ace\addons\main\script_macros.hpp" \ No newline at end of file From 6540158ce1e93a425957e01f1011c0e0b6f9dc1e Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 15 Feb 2015 10:05:48 +0100 Subject: [PATCH 2/8] Removed left over CSE prefix --- addons/missionModules/CfgVehicles.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/missionModules/CfgVehicles.hpp b/addons/missionModules/CfgVehicles.hpp index 570883ee5f..afdb58006b 100644 --- a/addons/missionModules/CfgVehicles.hpp +++ b/addons/missionModules/CfgVehicles.hpp @@ -6,7 +6,7 @@ class CfgVehicles { }; // TODO make a curator variant for this - class cse_moduleAmbianceSound: Module_F { + class ACE_moduleAmbianceSound: Module_F { scope = 2; displayName = "Ambiance Sounds [ACE]"; icon = QUOTE(PATHTOF(data\moduleSound.paa)); From da19a89be867d51cffbf000092ffd025cf25e061 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Mon, 16 Feb 2015 15:56:36 +0100 Subject: [PATCH 3/8] Replaced _targetUnit for ObjNull Replaced _targetUnit for objNull. --- addons/missionModules/functions/fnc_moduleAmbianceSound.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/missionModules/functions/fnc_moduleAmbianceSound.sqf b/addons/missionModules/functions/fnc_moduleAmbianceSound.sqf index f35f14b30c..95153be8d1 100644 --- a/addons/missionModules/functions/fnc_moduleAmbianceSound.sqf +++ b/addons/missionModules/functions/fnc_moduleAmbianceSound.sqf @@ -112,7 +112,7 @@ if (_activated && local _logic) then { // If no unit is to close to this position, we will play the sound. if ({(_newPos distance _x < (_minimalDistance / 2))}count _allUnits == 0) then { - playSound3D [_ambianceSounds select (round(random((count _ambianceSounds)-1))), _targetUnit, false, _newPos, _volume, 1, 1000]; + playSound3D [_ambianceSounds select (round(random((count _ambianceSounds)-1))), ObjNull, false, _newPos, _volume, 1, 1000]; _args set [8, time]; }; }; From d60081a9c311620e61926d8a7e87ac4da3a6e5cf Mon Sep 17 00:00:00 2001 From: Glowbal Date: Tue, 17 Feb 2015 07:49:37 +0100 Subject: [PATCH 4/8] Renamed missionModules to missionmodules. --- addons/missionModules/functions/script_component.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/missionModules/functions/script_component.hpp b/addons/missionModules/functions/script_component.hpp index e49740a89e..42d34d4801 100644 --- a/addons/missionModules/functions/script_component.hpp +++ b/addons/missionModules/functions/script_component.hpp @@ -1 +1 @@ -#include "\z\ace\addons\missionModules\script_component.hpp" \ No newline at end of file +#include "\z\ace\addons\missionmodules\script_component.hpp" \ No newline at end of file From d86e2464b3d35315e5c38b5a3e459a0b016e1ee5 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Tue, 17 Feb 2015 07:51:35 +0100 Subject: [PATCH 5/8] Removed missionModules --- addons/missionModules/$PBOPREFIX$ | 1 - addons/missionModules/CfgEventHandlers.hpp | 6 - addons/missionModules/CfgFactionClasses.hpp | 6 - addons/missionModules/CfgVehicles.hpp | 68 ---------- addons/missionModules/XEH_preInit.sqf | 7 - addons/missionModules/config.cpp | 17 --- addons/missionModules/data/moduleSound.paa | Bin 5625 -> 0 bytes .../functions/fnc_moduleAmbianceSound.sqf | 123 ------------------ .../functions/script_component.hpp | 1 - addons/missionModules/script_component.hpp | 12 -- 10 files changed, 241 deletions(-) delete mode 100644 addons/missionModules/$PBOPREFIX$ delete mode 100644 addons/missionModules/CfgEventHandlers.hpp delete mode 100644 addons/missionModules/CfgFactionClasses.hpp delete mode 100644 addons/missionModules/CfgVehicles.hpp delete mode 100644 addons/missionModules/XEH_preInit.sqf delete mode 100644 addons/missionModules/config.cpp delete mode 100644 addons/missionModules/data/moduleSound.paa delete mode 100644 addons/missionModules/functions/fnc_moduleAmbianceSound.sqf delete mode 100644 addons/missionModules/functions/script_component.hpp delete mode 100644 addons/missionModules/script_component.hpp diff --git a/addons/missionModules/$PBOPREFIX$ b/addons/missionModules/$PBOPREFIX$ deleted file mode 100644 index ea1be0daee..0000000000 --- a/addons/missionModules/$PBOPREFIX$ +++ /dev/null @@ -1 +0,0 @@ -z\ace\addons\missionModules \ No newline at end of file diff --git a/addons/missionModules/CfgEventHandlers.hpp b/addons/missionModules/CfgEventHandlers.hpp deleted file mode 100644 index f0a9f14d91..0000000000 --- a/addons/missionModules/CfgEventHandlers.hpp +++ /dev/null @@ -1,6 +0,0 @@ - -class Extended_PreInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_preInit)); - }; -}; diff --git a/addons/missionModules/CfgFactionClasses.hpp b/addons/missionModules/CfgFactionClasses.hpp deleted file mode 100644 index 792f4d31e3..0000000000 --- a/addons/missionModules/CfgFactionClasses.hpp +++ /dev/null @@ -1,6 +0,0 @@ -class CfgFactionClasses { - class NO_CATEGORY; - class ACE_missionModules: NO_CATEGORY { - displayName = "ACE Mission Modules"; - }; -}; \ No newline at end of file diff --git a/addons/missionModules/CfgVehicles.hpp b/addons/missionModules/CfgVehicles.hpp deleted file mode 100644 index afdb58006b..0000000000 --- a/addons/missionModules/CfgVehicles.hpp +++ /dev/null @@ -1,68 +0,0 @@ -class CfgVehicles { - class Logic; - class Module_F: Logic { - class ArgumentsBaseUnits { - }; - }; - - // TODO make a curator variant for this - class ACE_moduleAmbianceSound: Module_F { - scope = 2; - displayName = "Ambiance Sounds [ACE]"; - icon = QUOTE(PATHTOF(data\moduleSound.paa)); - category = "ACE_missionModules"; - function = QUOTE(FUNC(moduleAmbianceSound); - functionPriority = 1; - isGlobal = 1; - isTriggerActivated = 0; - author = "Glowbal"; - class Arguments { - class soundFiles { - displayName = "Sounds"; - description = "Classnames of the ambiance sounds played. Seperated by ','. "; - typeName = "STRING"; - defaultValue = ""; - }; - class minimalDistance { - displayName = "Minimal Distance"; - description = "Minimal Distance"; - typeName = "NUMBER"; - defaultValue = 400; - }; - class maximalDistance { - displayName = "Maximal Distance"; - description = "Maximal Distance"; - typeName = "NUMBER"; - defaultValue = 900; - }; - class minimalDelay { - displayName = "Minimal Delay"; - description = "Minimal Delay between sounds played"; - typeName = "NUMBER"; - defaultValue = 10; - }; - class maximalDelay { - displayName = "Maximal Delay"; - description = "Maximal Delay between sounds played"; - typeName = "NUMBER"; - defaultValue = 170; - }; - class followPlayers { - displayName = "Follow Players"; - description = "Follow players. If set to false, loop will play sounds only nearby logic position."; - typeName = "BOOL"; - defaultValue = 0; - }; - class soundVolume { - displayName = "Volume"; - description = "The volume of the sounds played"; - typeName = "NUMBER"; - defaultValue = 0; - }; - }; - class ModuleDescription { - description = "Ambiance sounds loop (synced across MP)"; - sync[] = {}; - }; - }; -}; diff --git a/addons/missionModules/XEH_preInit.sqf b/addons/missionModules/XEH_preInit.sqf deleted file mode 100644 index cadbbabdd1..0000000000 --- a/addons/missionModules/XEH_preInit.sqf +++ /dev/null @@ -1,7 +0,0 @@ -#include "script_component.hpp" - -ADDON = false; - -PREP(moduleAmbianceSound); - -ADDON = true; diff --git a/addons/missionModules/config.cpp b/addons/missionModules/config.cpp deleted file mode 100644 index 0867b486c6..0000000000 --- a/addons/missionModules/config.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "script_component.hpp" - -class CfgPatches { - class ADDON { - units[] = {"cse_moduleAmbianceSound"}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_common"}; - author[] = {"Glowbal"}; - authorUrl = ""; - VERSION_CONFIG; - }; -}; - -#include "CfgEventHandlers.hpp" -#include "CfgFactionClasses.hpp" -#include "CfgVehicles.hpp" diff --git a/addons/missionModules/data/moduleSound.paa b/addons/missionModules/data/moduleSound.paa deleted file mode 100644 index bfe3b8032717dcc98269b4b42a620cffe550ffc2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5625 zcmd5=e{2)i9e)QtpfrHPa-m>_7$qGojBP2JHAXidD=lKvOSnciRHiZp3io($CfVu3Ih4Y{*BB>0gjI}tEY4lCyKj^3 zi|MspB)_I9Qgx5++xQ+GAF#}rEAi6)SgR2uT;uV0M$+GvaQ(#H9}xS?WmyKjWzk^2 zNzcQW;MZidnf$!>++Lhj?%eeIpGtziBC+buc2ZUhGN$7o{p|Y_&10xliB==phYGcr8`S2cb3wu zSJO0FbEhH0o>*@a^2330*Os!%?HPIs=*>Ht3JmIghu|*BN=Fax<2*v*2zg37n~I_l zvuOp1~efUHq1t$YIb<=rbwS zTrcQpUhjzXYHsxVyH5nfdE>YxM~e3~1{1=bAg7M@d>{Fz$PcEznj%j-Sr-`;E@UQk zQ%W=8le|+&`CYHlo@`?-%h+-aPK=XB!7Q0@uvl zk~H~J)3;+sOn<@gdX~1F2=F@pO`4Y=pKA{{ih0US7~4l2ZHeSrF3!i~kXHre!}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U z=ZAa#5twV0X_O^x28Z$A&pS=)$^KtzKk;MPDzj+fwB>Q#-`x>urFlHnvF~!UO>diN z1yv&Jpc(olz3l-5or{nk44&+4GA;!F4$kl&=$B9LESij$36p&hUd;VmNUJ6YMgF6JLbOVk`ZbHcCR84R!G;@r-_u zAOuge55r}#NM0sQs>9M`hMq}%DBkSUY)Wi(n$)N*vDA>Kx9MZQ8d)rk1;xlSy{&nF z{&N3bnupD7Ptbb2a4^?R|X+6c1 zGkO0 - * 1: Units - * 2: Activated - * - * Return Value: - * Nothing - * - * Example: - * N/A - * - * Public: No - */ - -#include "script_component.hpp" - -private ["_logic", "_units", "_activated","_ambianceSounds", "_soundFiles", "_minimalDistance","_maximalDistance", "_minimalDistance", "_maxDelayBetweenSounds", "_allUnits", "_newPos", "_targetUnit", "_soundToPlay", "_soundPath", "_unparsedSounds", "_list", "_splittedList", "_nilCheckPassedList"]; -_logic = [_this,0,objNull,[objNull]] call BIS_fnc_param; -_units = [_this,1,[],[[]]] call BIS_fnc_param; -_activated = [_this,2,true,[true]] call BIS_fnc_param; - -// We only play this on the locality of the logic, since the sounds are broadcasted across the network -if (_activated && local _logic) then { - _ambianceSounds = []; - _unparsedSounds = _logic getvariable ["soundFiles", ""]; - _minimalDistance = (_logic getvariable ["minimalDistance", 400]) max 1; - _maximalDistance = (_logic getvariable ["maximalDistance", 10]) max _minimalDistance; - _minDelayBetweensounds = (_logic getvariable ["minimalDelay", 10]) max 1; - _maxDelayBetweenSounds = (_logic getvariable ["maximalDelay", 170]) max _minDelayBetweensounds; - _volume = (_logic getvariable ["soundVolume", 30]) max 1; - _followPlayers = _logic getvariable ["followPlayers", false]; - - _splittedList = [_unparsedSounds, ","] call BIS_fnc_splitString; - - _nilCheckPassedList = ""; - { - _x = [_x] call EFUNC(common,removeWhiteSpace); - _splittedList set [_foreachIndex, _x]; - }foreach _splittedList; - - _soundPath = [(str missionConfigFile), 0, -15] call BIS_fnc_trimString; - { - if (isclass (missionConfigFile >> "CfgSounds" >> _x)) then { - _ambianceSounds pushback (_soundPath + (getArray(missionConfigFile >> "CfgSounds" >> _x >> "sound") select 0)); - } else { - if (isclass (configFile >> "CfgSounds" >> _x)) then { - _ambianceSounds pushback ((getArray(configFile >> "CfgSounds" >> _x >> "sound") select 0)); - }; - }; - }foreach _splittedList; - - if (count _ambianceSounds == 0) exitwith {}; - { - if !([".", _x, true] call BIS_fnc_inString) then { - _ambianceSounds set [_foreachIndex, _x + ".wss"]; - }; - }foreach _ambianceSounds; - - [{ - private ["_args", "_logic", "_ambianceSounds", "_minimalDistance", "_maximalDistance", "_minDelayBetweensounds", "_maxDelayBetweenSounds", "_volume", "_followPlayers","_lastTimePlayed", "_newPos"] - _args = _this select 0; - _logic = _args select 0; - _lastTimePlayed = _args select 8; - - if (!alive _logic) exitwith { - [(_this select 1)] call cba_fnc_removePerFrameHandler; - }; - - if (_lastTimePlayed - time >= ((_minDelayBetweensounds + random(_maxDelayBetweenSounds)) min _maxDelayBetweenSounds)) then { - _ambianceSounds = _args select 1; - _minimalDistance = _args select 2; - _maximalDistance = _args select 3; - _minDelayBetweensounds = _args select 4; - _maxDelayBetweenSounds = _args select 5; - _volume = _args select 6; - _followPlayers = _args select 7; - - // Find all players in session. - _allUnits = if (isMultiplayer) then {playableUnits} else {[ACE_player]}; - - // Check if there are enough players to even start playing this sound. - if (count _allUnits > 0) then { - - // Select a target unit at random. - _targetUnit = _allUnits select (round(random((count _allUnits)-1))); - - // find the position from which we are going to play this sound from. - _newPos = (getPos _targetUnit); - if (!_followPlayers) then { - _newPos = getPos _logic; - }; - - // Randomize this position. - if (random(1) >= 0.5) then { - if (random(1) >= 0.5) then { - _newPos set [0, (_newPos select 0) + (_minimalDistance + random(_maximalDistance))]; - } else { - _newPos set [0, (_newPos select 0) - (_minimalDistance + random(_maximalDistance))]; - }; - } else { - if (random(1) >= 0.5) then { - _newPos set [1, (_newPos select 1) + (_minimalDistance + random(_maximalDistance))]; - } else { - _newPos set [1, (_newPos select 1) - (_minimalDistance + random(_maximalDistance))]; - }; - }; - - // If no unit is to close to this position, we will play the sound. - if ({(_newPos distance _x < (_minimalDistance / 2))}count _allUnits == 0) then { - - playSound3D [_ambianceSounds select (round(random((count _ambianceSounds)-1))), ObjNull, false, _newPos, _volume, 1, 1000]; - _args set [8, time]; - }; - }; - }; - }, 0.1, [_logic, _ambianceSounds, _minimalDistance, _maximalDistance, _minDelayBetweensounds, _maxDelayBetweenSounds, _volume, _followPlayers, time] ] call CBA_fnc_addPerFrameHandler; -}; - -true; diff --git a/addons/missionModules/functions/script_component.hpp b/addons/missionModules/functions/script_component.hpp deleted file mode 100644 index 42d34d4801..0000000000 --- a/addons/missionModules/functions/script_component.hpp +++ /dev/null @@ -1 +0,0 @@ -#include "\z\ace\addons\missionmodules\script_component.hpp" \ No newline at end of file diff --git a/addons/missionModules/script_component.hpp b/addons/missionModules/script_component.hpp deleted file mode 100644 index a567966c7b..0000000000 --- a/addons/missionModules/script_component.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#define COMPONENT missionModules -#include "\z\ace\addons\main\script_mod.hpp" - -#ifdef DEBUG_ENABLED_MISSIONMODULES - #define DEBUG_MODE_FULL -#endif - -#ifdef DEBUG_SETTINGS_MISSIONMODULES - #define DEBUG_SETTINGS DEBUG_SETTINGS_MISSIONMODULES -#endif - -#include "\z\ace\addons\main\script_macros.hpp" \ No newline at end of file From bfc748fbbef1d9745c0a0d0cb35133a17b9b9c6f Mon Sep 17 00:00:00 2001 From: Glowbal Date: Tue, 17 Feb 2015 07:51:51 +0100 Subject: [PATCH 6/8] Added missionmodules. --- addons/missionmodules/$PBOPREFIX$ | 1 + addons/missionmodules/CfgEventHandlers.hpp | 6 + addons/missionmodules/CfgFactionClasses.hpp | 6 + addons/missionmodules/CfgVehicles.hpp | 68 ++++++++++ addons/missionmodules/XEH_preInit.sqf | 7 + addons/missionmodules/config.cpp | 17 +++ addons/missionmodules/data/moduleSound.paa | Bin 0 -> 5625 bytes .../functions/fnc_moduleAmbianceSound.sqf | 123 ++++++++++++++++++ .../functions/script_component.hpp | 1 + addons/missionmodules/script_component.hpp | 12 ++ 10 files changed, 241 insertions(+) create mode 100644 addons/missionmodules/$PBOPREFIX$ create mode 100644 addons/missionmodules/CfgEventHandlers.hpp create mode 100644 addons/missionmodules/CfgFactionClasses.hpp create mode 100644 addons/missionmodules/CfgVehicles.hpp create mode 100644 addons/missionmodules/XEH_preInit.sqf create mode 100644 addons/missionmodules/config.cpp create mode 100644 addons/missionmodules/data/moduleSound.paa create mode 100644 addons/missionmodules/functions/fnc_moduleAmbianceSound.sqf create mode 100644 addons/missionmodules/functions/script_component.hpp create mode 100644 addons/missionmodules/script_component.hpp diff --git a/addons/missionmodules/$PBOPREFIX$ b/addons/missionmodules/$PBOPREFIX$ new file mode 100644 index 0000000000..ea1be0daee --- /dev/null +++ b/addons/missionmodules/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\missionModules \ No newline at end of file diff --git a/addons/missionmodules/CfgEventHandlers.hpp b/addons/missionmodules/CfgEventHandlers.hpp new file mode 100644 index 0000000000..f0a9f14d91 --- /dev/null +++ b/addons/missionmodules/CfgEventHandlers.hpp @@ -0,0 +1,6 @@ + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/missionmodules/CfgFactionClasses.hpp b/addons/missionmodules/CfgFactionClasses.hpp new file mode 100644 index 0000000000..792f4d31e3 --- /dev/null +++ b/addons/missionmodules/CfgFactionClasses.hpp @@ -0,0 +1,6 @@ +class CfgFactionClasses { + class NO_CATEGORY; + class ACE_missionModules: NO_CATEGORY { + displayName = "ACE Mission Modules"; + }; +}; \ No newline at end of file diff --git a/addons/missionmodules/CfgVehicles.hpp b/addons/missionmodules/CfgVehicles.hpp new file mode 100644 index 0000000000..afdb58006b --- /dev/null +++ b/addons/missionmodules/CfgVehicles.hpp @@ -0,0 +1,68 @@ +class CfgVehicles { + class Logic; + class Module_F: Logic { + class ArgumentsBaseUnits { + }; + }; + + // TODO make a curator variant for this + class ACE_moduleAmbianceSound: Module_F { + scope = 2; + displayName = "Ambiance Sounds [ACE]"; + icon = QUOTE(PATHTOF(data\moduleSound.paa)); + category = "ACE_missionModules"; + function = QUOTE(FUNC(moduleAmbianceSound); + functionPriority = 1; + isGlobal = 1; + isTriggerActivated = 0; + author = "Glowbal"; + class Arguments { + class soundFiles { + displayName = "Sounds"; + description = "Classnames of the ambiance sounds played. Seperated by ','. "; + typeName = "STRING"; + defaultValue = ""; + }; + class minimalDistance { + displayName = "Minimal Distance"; + description = "Minimal Distance"; + typeName = "NUMBER"; + defaultValue = 400; + }; + class maximalDistance { + displayName = "Maximal Distance"; + description = "Maximal Distance"; + typeName = "NUMBER"; + defaultValue = 900; + }; + class minimalDelay { + displayName = "Minimal Delay"; + description = "Minimal Delay between sounds played"; + typeName = "NUMBER"; + defaultValue = 10; + }; + class maximalDelay { + displayName = "Maximal Delay"; + description = "Maximal Delay between sounds played"; + typeName = "NUMBER"; + defaultValue = 170; + }; + class followPlayers { + displayName = "Follow Players"; + description = "Follow players. If set to false, loop will play sounds only nearby logic position."; + typeName = "BOOL"; + defaultValue = 0; + }; + class soundVolume { + displayName = "Volume"; + description = "The volume of the sounds played"; + typeName = "NUMBER"; + defaultValue = 0; + }; + }; + class ModuleDescription { + description = "Ambiance sounds loop (synced across MP)"; + sync[] = {}; + }; + }; +}; diff --git a/addons/missionmodules/XEH_preInit.sqf b/addons/missionmodules/XEH_preInit.sqf new file mode 100644 index 0000000000..cadbbabdd1 --- /dev/null +++ b/addons/missionmodules/XEH_preInit.sqf @@ -0,0 +1,7 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP(moduleAmbianceSound); + +ADDON = true; diff --git a/addons/missionmodules/config.cpp b/addons/missionmodules/config.cpp new file mode 100644 index 0000000000..0867b486c6 --- /dev/null +++ b/addons/missionmodules/config.cpp @@ -0,0 +1,17 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {"cse_moduleAmbianceSound"}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author[] = {"Glowbal"}; + authorUrl = ""; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" +#include "CfgFactionClasses.hpp" +#include "CfgVehicles.hpp" diff --git a/addons/missionmodules/data/moduleSound.paa b/addons/missionmodules/data/moduleSound.paa new file mode 100644 index 0000000000000000000000000000000000000000..bfe3b8032717dcc98269b4b42a620cffe550ffc2 GIT binary patch literal 5625 zcmd5=e{2)i9e)QtpfrHPa-m>_7$qGojBP2JHAXidD=lKvOSnciRHiZp3io($CfVu3Ih4Y{*BB>0gjI}tEY4lCyKj^3 zi|MspB)_I9Qgx5++xQ+GAF#}rEAi6)SgR2uT;uV0M$+GvaQ(#H9}xS?WmyKjWzk^2 zNzcQW;MZidnf$!>++Lhj?%eeIpGtziBC+buc2ZUhGN$7o{p|Y_&10xliB==phYGcr8`S2cb3wu zSJO0FbEhH0o>*@a^2330*Os!%?HPIs=*>Ht3JmIghu|*BN=Fax<2*v*2zg37n~I_l zvuOp1~efUHq1t$YIb<=rbwS zTrcQpUhjzXYHsxVyH5nfdE>YxM~e3~1{1=bAg7M@d>{Fz$PcEznj%j-Sr-`;E@UQk zQ%W=8le|+&`CYHlo@`?-%h+-aPK=XB!7Q0@uvl zk~H~J)3;+sOn<@gdX~1F2=F@pO`4Y=pKA{{ih0US7~4l2ZHeSrF3!i~kXHre!}Y@c zP~XdDtCPF%p;?fZ%~k(hpV7__KYu$I&W)uH29ukQ!Cc^o8gi!2->3UUe9E%THmf0Q zTsUN8<7HeGl+Vt~a$AbuYUH0o|BNJeHbGk-Z{+Ere3Dmnv_1+KqTMjB=U(a$b{;-6 zzc4iZ3Di4N{_5i{f3GXhO~_`GW%kmP#F*J;J)-sFmSP?uO!IU;(7&&hr;0QC@2ovz z3-%y>l5ihkZ6=ksK>1eVIAM@i^LD}cUF(EDfV@(07E3F~Wc@c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units + * 2: Activated + * + * Return Value: + * Nothing + * + * Example: + * N/A + * + * Public: No + */ + +#include "script_component.hpp" + +private ["_logic", "_units", "_activated","_ambianceSounds", "_soundFiles", "_minimalDistance","_maximalDistance", "_minimalDistance", "_maxDelayBetweenSounds", "_allUnits", "_newPos", "_targetUnit", "_soundToPlay", "_soundPath", "_unparsedSounds", "_list", "_splittedList", "_nilCheckPassedList"]; +_logic = [_this,0,objNull,[objNull]] call BIS_fnc_param; +_units = [_this,1,[],[[]]] call BIS_fnc_param; +_activated = [_this,2,true,[true]] call BIS_fnc_param; + +// We only play this on the locality of the logic, since the sounds are broadcasted across the network +if (_activated && local _logic) then { + _ambianceSounds = []; + _unparsedSounds = _logic getvariable ["soundFiles", ""]; + _minimalDistance = (_logic getvariable ["minimalDistance", 400]) max 1; + _maximalDistance = (_logic getvariable ["maximalDistance", 10]) max _minimalDistance; + _minDelayBetweensounds = (_logic getvariable ["minimalDelay", 10]) max 1; + _maxDelayBetweenSounds = (_logic getvariable ["maximalDelay", 170]) max _minDelayBetweensounds; + _volume = (_logic getvariable ["soundVolume", 30]) max 1; + _followPlayers = _logic getvariable ["followPlayers", false]; + + _splittedList = [_unparsedSounds, ","] call BIS_fnc_splitString; + + _nilCheckPassedList = ""; + { + _x = [_x] call EFUNC(common,removeWhiteSpace); + _splittedList set [_foreachIndex, _x]; + }foreach _splittedList; + + _soundPath = [(str missionConfigFile), 0, -15] call BIS_fnc_trimString; + { + if (isclass (missionConfigFile >> "CfgSounds" >> _x)) then { + _ambianceSounds pushback (_soundPath + (getArray(missionConfigFile >> "CfgSounds" >> _x >> "sound") select 0)); + } else { + if (isclass (configFile >> "CfgSounds" >> _x)) then { + _ambianceSounds pushback ((getArray(configFile >> "CfgSounds" >> _x >> "sound") select 0)); + }; + }; + }foreach _splittedList; + + if (count _ambianceSounds == 0) exitwith {}; + { + if !([".", _x, true] call BIS_fnc_inString) then { + _ambianceSounds set [_foreachIndex, _x + ".wss"]; + }; + }foreach _ambianceSounds; + + [{ + private ["_args", "_logic", "_ambianceSounds", "_minimalDistance", "_maximalDistance", "_minDelayBetweensounds", "_maxDelayBetweenSounds", "_volume", "_followPlayers","_lastTimePlayed", "_newPos"] + _args = _this select 0; + _logic = _args select 0; + _lastTimePlayed = _args select 8; + + if (!alive _logic) exitwith { + [(_this select 1)] call cba_fnc_removePerFrameHandler; + }; + + if (_lastTimePlayed - time >= ((_minDelayBetweensounds + random(_maxDelayBetweenSounds)) min _maxDelayBetweenSounds)) then { + _ambianceSounds = _args select 1; + _minimalDistance = _args select 2; + _maximalDistance = _args select 3; + _minDelayBetweensounds = _args select 4; + _maxDelayBetweenSounds = _args select 5; + _volume = _args select 6; + _followPlayers = _args select 7; + + // Find all players in session. + _allUnits = if (isMultiplayer) then {playableUnits} else {[ACE_player]}; + + // Check if there are enough players to even start playing this sound. + if (count _allUnits > 0) then { + + // Select a target unit at random. + _targetUnit = _allUnits select (round(random((count _allUnits)-1))); + + // find the position from which we are going to play this sound from. + _newPos = (getPos _targetUnit); + if (!_followPlayers) then { + _newPos = getPos _logic; + }; + + // Randomize this position. + if (random(1) >= 0.5) then { + if (random(1) >= 0.5) then { + _newPos set [0, (_newPos select 0) + (_minimalDistance + random(_maximalDistance))]; + } else { + _newPos set [0, (_newPos select 0) - (_minimalDistance + random(_maximalDistance))]; + }; + } else { + if (random(1) >= 0.5) then { + _newPos set [1, (_newPos select 1) + (_minimalDistance + random(_maximalDistance))]; + } else { + _newPos set [1, (_newPos select 1) - (_minimalDistance + random(_maximalDistance))]; + }; + }; + + // If no unit is to close to this position, we will play the sound. + if ({(_newPos distance _x < (_minimalDistance / 2))}count _allUnits == 0) then { + + playSound3D [_ambianceSounds select (round(random((count _ambianceSounds)-1))), ObjNull, false, _newPos, _volume, 1, 1000]; + _args set [8, time]; + }; + }; + }; + }, 0.1, [_logic, _ambianceSounds, _minimalDistance, _maximalDistance, _minDelayBetweensounds, _maxDelayBetweenSounds, _volume, _followPlayers, time] ] call CBA_fnc_addPerFrameHandler; +}; + +true; diff --git a/addons/missionmodules/functions/script_component.hpp b/addons/missionmodules/functions/script_component.hpp new file mode 100644 index 0000000000..42d34d4801 --- /dev/null +++ b/addons/missionmodules/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\missionmodules\script_component.hpp" \ No newline at end of file diff --git a/addons/missionmodules/script_component.hpp b/addons/missionmodules/script_component.hpp new file mode 100644 index 0000000000..a567966c7b --- /dev/null +++ b/addons/missionmodules/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT missionModules +#include "\z\ace\addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_MISSIONMODULES + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_MISSIONMODULES + #define DEBUG_SETTINGS DEBUG_SETTINGS_MISSIONMODULES +#endif + +#include "\z\ace\addons\main\script_macros.hpp" \ No newline at end of file From 1ea35548e0713cf2610475ec8186bcb879178a1a Mon Sep 17 00:00:00 2001 From: Glowbal Date: Thu, 19 Feb 2015 18:40:40 +0100 Subject: [PATCH 7/8] Fixed ambiance sounds module. --- addons/missionmodules/CfgVehicles.hpp | 4 ++-- .../functions/fnc_moduleAmbianceSound.sqf | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/missionmodules/CfgVehicles.hpp b/addons/missionmodules/CfgVehicles.hpp index afdb58006b..92c379efb2 100644 --- a/addons/missionmodules/CfgVehicles.hpp +++ b/addons/missionmodules/CfgVehicles.hpp @@ -11,7 +11,7 @@ class CfgVehicles { displayName = "Ambiance Sounds [ACE]"; icon = QUOTE(PATHTOF(data\moduleSound.paa)); category = "ACE_missionModules"; - function = QUOTE(FUNC(moduleAmbianceSound); + function = QUOTE(FUNC(moduleAmbianceSound)); functionPriority = 1; isGlobal = 1; isTriggerActivated = 0; @@ -57,7 +57,7 @@ class CfgVehicles { displayName = "Volume"; description = "The volume of the sounds played"; typeName = "NUMBER"; - defaultValue = 0; + defaultValue = 1; }; }; class ModuleDescription { diff --git a/addons/missionmodules/functions/fnc_moduleAmbianceSound.sqf b/addons/missionmodules/functions/fnc_moduleAmbianceSound.sqf index 95153be8d1..943d795b7a 100644 --- a/addons/missionmodules/functions/fnc_moduleAmbianceSound.sqf +++ b/addons/missionmodules/functions/fnc_moduleAmbianceSound.sqf @@ -38,7 +38,7 @@ if (_activated && local _logic) then { _nilCheckPassedList = ""; { - _x = [_x] call EFUNC(common,removeWhiteSpace); + _x = [_x] call EFUNC(common,string_removeWhiteSpace); _splittedList set [_foreachIndex, _x]; }foreach _splittedList; @@ -61,21 +61,22 @@ if (_activated && local _logic) then { }foreach _ambianceSounds; [{ - private ["_args", "_logic", "_ambianceSounds", "_minimalDistance", "_maximalDistance", "_minDelayBetweensounds", "_maxDelayBetweenSounds", "_volume", "_followPlayers","_lastTimePlayed", "_newPos"] + private ["_args", "_logic", "_ambianceSounds", "_minimalDistance", "_maximalDistance", "_minDelayBetweensounds", "_maxDelayBetweenSounds", "_volume", "_followPlayers","_lastTimePlayed", "_newPos"]; _args = _this select 0; _logic = _args select 0; + _minDelayBetweensounds = _args select 4; + _maxDelayBetweenSounds = _args select 5; _lastTimePlayed = _args select 8; if (!alive _logic) exitwith { [(_this select 1)] call cba_fnc_removePerFrameHandler; }; - if (_lastTimePlayed - time >= ((_minDelayBetweensounds + random(_maxDelayBetweenSounds)) min _maxDelayBetweenSounds)) then { + if (time - _lastTimePlayed >= ((_minDelayBetweensounds + random(_maxDelayBetweenSounds)) min _maxDelayBetweenSounds)) then { _ambianceSounds = _args select 1; _minimalDistance = _args select 2; _maximalDistance = _args select 3; - _minDelayBetweensounds = _args select 4; - _maxDelayBetweenSounds = _args select 5; + _volume = _args select 6; _followPlayers = _args select 7; @@ -111,13 +112,12 @@ if (_activated && local _logic) then { // If no unit is to close to this position, we will play the sound. if ({(_newPos distance _x < (_minimalDistance / 2))}count _allUnits == 0) then { - playSound3D [_ambianceSounds select (round(random((count _ambianceSounds)-1))), ObjNull, false, _newPos, _volume, 1, 1000]; _args set [8, time]; }; }; }; - }, 0.1, [_logic, _ambianceSounds, _minimalDistance, _maximalDistance, _minDelayBetweensounds, _maxDelayBetweenSounds, _volume, _followPlayers, time] ] call CBA_fnc_addPerFrameHandler; + }, 0.1, [_logic, _ambianceSounds, _minimalDistance, _maximalDistance, _minDelayBetweensounds, _maxDelayBetweenSounds, _volume, _followPlayers, time] ] call cba_fnc_addPerFrameHandler; }; true; From af3709f481226ecba3c8d470ddc02047a813ab87 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Thu, 19 Feb 2015 19:07:19 +0100 Subject: [PATCH 8/8] Fixed forgotten missionModules. --- addons/missionmodules/$PBOPREFIX$ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/missionmodules/$PBOPREFIX$ b/addons/missionmodules/$PBOPREFIX$ index ea1be0daee..6e7c7ebfc1 100644 --- a/addons/missionmodules/$PBOPREFIX$ +++ b/addons/missionmodules/$PBOPREFIX$ @@ -1 +1 @@ -z\ace\addons\missionModules \ No newline at end of file +z\ace\addons\missionmodules \ No newline at end of file