- Restore the config of detector sounds through CfgSounds

- Add the possibility of switching between headphones or speaker
- Move detector actions to their own submenu
This commit is contained in:
esteldunedain 2016-07-06 22:14:26 -03:00
parent 34654fffb7
commit f73b6b1aad
14 changed files with 168 additions and 36 deletions

View File

@ -2,9 +2,7 @@ class ACE_detector {
class detectors {
class ACE_VMM3 {
radius = 2.5;
name = "ace_detector_1";
sound = QUOTE(PATHTO_R(sounds\metal_detector.wss));
pitchs[] = {1, 0.9, 0.8, 0.7};
sounds[] = {"ace_detector_1", "ace_detector_2", "ace_detector_3", "ace_detector_4"};
};
class ACE_VMH3: ACE_VMM3 {
};

View File

@ -0,0 +1,22 @@
class CfgSounds {
class ace_detector_1 {
name = "ace_detector_1";
sound[] = {QUOTE(PATHTOF(sounds\metal_detector.wss)), "db+1", 1};
titles[] = {};
};
class ace_detector_2 {
name = "ace_detector_2";
sound[] = {QUOTE(PATHTOF(sounds\metal_detector.wss)), "db+1", 0.9};
titles[] = {};
};
class ace_detector_3 {
name = "ace_detector_3";
sound[] = {QUOTE(PATHTOF(sounds\metal_detector.wss)), "db+1", 0.8};
titles[] = {};
};
class ace_detector_4 {
name = "ace_detector_4";
sound[] = {QUOTE(PATHTOF(sounds\metal_detector.wss)), "db+1", 0.7};
titles[] = {};
};
};

View File

@ -11,6 +11,12 @@ class CfgVehicles {
class CAManBase: Man {
class ACE_SelfActions {
class ACE_Equipment {
class GVAR(metalDetector) {
displayName = CSTRING(MetalDetector);
condition = QUOTE([ACE_player] call FUNC(hasDetector));
statement = "";
icon = "" //TODO
exceptions[] = {};
class GVAR(activate) {
displayName = CSTRING(ActivateDetector);
condition = QUOTE(call FUNC(canActivateDetector));
@ -25,6 +31,21 @@ class CfgVehicles {
icon = QPATHTOF(ui\icon_mineDetectorOff.paa);
exceptions[] = {};
};
class GVAR(connectHeadphones) {
displayName = CSTRING(ConnectHeadphones);
condition = QUOTE(call FUNC(canConnectHeadphones));
statement = QUOTE([ARR_2(ACE_player, true)] call FUNC(connectHeadphones));
icon = "" //TODO
exceptions[] = {};
};
class GVAR(disconnectHeadphones) {
displayName = CSTRING(DisconnectHeadphones);
condition = QUOTE(call FUNC(canDisconnectHeadphones));
statement = QUOTE([ARR_2(ACE_player, false)] call FUNC(connectHeadphones));
icon = "" //TODO
exceptions[] = {};
};
};
};
};
};

View File

@ -1,6 +1,9 @@
PREP(canActivateDetector);
PREP(canConnectHeadphones);
PREP(canDeactivateDetector);
PREP(canDisconnectHeadphones);
PREP(connectHeadphones);
PREP(activateDetector);
PREP(deactivateDetector);
PREP(hasDetector);

View File

@ -18,4 +18,5 @@ class CfgPatches {
#include "CfgWeapons.hpp"
#include "CfgAmmo.hpp"
#include "CfgVehicles.hpp"
#include "CfgSounds.hpp"
#include "ACE_detector.hpp"

View File

@ -16,4 +16,5 @@
#include "script_component.hpp"
([ACE_player] call FUNC(hasDetector)) && !([ACE_player, currentWeapon ACE_player] call FUNC(isDetectorEnabled));
([ACE_player] call FUNC(hasDetector)) &&
!([ACE_player, currentWeapon ACE_player] call FUNC(isDetectorEnabled));

View File

@ -0,0 +1,20 @@
/*
* Author: esteldunedain
* Check if headphones can be connected to the mine detector
*
* Arguments:
* None
*
* Return Value:
* Can be connected <BOOL>
*
* Example:
* [] call ace_minedetector_fnc_canConnectHeadphones
*
* Public: No
*/
#include "script_component.hpp"
!(ACE_player getVariable [QGVAR(isUsingHeadphones), false]) &&
{[ACE_player] call FUNC(hasDetector)};

View File

@ -16,4 +16,5 @@
#include "script_component.hpp"
([ACE_player] call FUNC(hasDetector)) && {[ACE_player, currentWeapon ACE_player] call FUNC(isDetectorEnabled)};
([ACE_player] call FUNC(hasDetector)) &&
{[ACE_player, currentWeapon ACE_player] call FUNC(isDetectorEnabled)};

View File

@ -0,0 +1,20 @@
/*
* Author: esteldunedain
* Check if headphones can be disconnected from the mine detector
*
* Arguments:
* None
*
* Return Value:
* Can be disconnected <BOOL>
*
* Example:
* [] call ace_minedetector_fnc_canDisconnectHeadphones
*
* Public: No
*/
#include "script_component.hpp"
(ACE_player getVariable [QGVAR(isUsingHeadphones), false]) &&
{[ACE_player] call FUNC(hasDetector)};

View File

@ -0,0 +1,27 @@
/*
* Author: esteldunedain
* Connect/disconnect headphones to the mine detector
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Connect? <BOOLEAN>
*
* Return Value:
* None
*
* Example:
* [_unit, true] call ace_minedetector_fnc_connectHeadphones
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_state"];
_unit setVariable [QGVAR(isUsingHeadphones), _state];
if (_state) then {
[localize LSTRING(HeadphonesConnected)] call EFUNC(common,displayTextStructured);
} else {
[localize LSTRING(HeadphonesDisconnected)] call EFUNC(common,displayTextStructured);
};

View File

@ -49,11 +49,12 @@ private _distanceTiming = switch (true) do {
if (CBA_missionTime - _lastPlayed < _distanceTiming) exitWith {};
_args set [3, CBA_missionTime];
_detectorConfig params ["", "", "_sound", "_pitchs"];
private _pitch = switch (true) do {
case (_distance >= 2): {_pitchs select 3};
case (_distance >= 1.25): {_pitchs select 2};
case (_distance >= 0.5): {_pitchs select 1};
default {_pitchs select 0};
_detectorConfig params ["", "", "_soundClasses"];
private _soundClass = switch (true) do {
case (_distance >= 2): {_soundClasses select 3};
case (_distance >= 1.25): {_soundClasses select 2};
case (_distance >= 0.5): {_soundClasses select 1};
default {_soundClasses select 0};
};
[_unit, _sound, _pitch] call FUNC(playDetectorSound);
[_unit, _soundClass] call FUNC(playDetectorSound);

View File

@ -25,8 +25,7 @@ if (isNil "_detectorConfig") then {
_detectorConfig = [
_detectorType,
getNumber (_cfgEntry >> "radius"),
getText (_cfgEntry >> "sound"),
getArray (_cfgEntry >> "pitchs")
getArray (_cfgEntry >> "sounds")
];
} else {
_detectorConfig = [];

View File

@ -4,8 +4,7 @@
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Sound file name <STRING>
* 2: Sound pitch <NUMBER>
* 1: Sound class <STRING>
*
* Return Value:
* None
@ -18,7 +17,7 @@
#include "script_component.hpp"
params ["_unit", "_sound", "_pitch"];
params ["_unit", "_soundClass"];
if (isNull _unit) exitWith {
ACE_LOGERROR_1("unit does not exist [%1]",_unit);
@ -27,6 +26,9 @@ if (!alive _unit) exitWith {
ACE_LOGERROR_1("unit is not alive [%1]",_unit);
};
private _posASL = AGLtoASL (_unit modelToWorld (_unit selectionPosition "granat"));
playSound3D [_sound, objNull, false, _posASL, 5, _pitch, 15];
if (_unit getVariable [QGVAR(isUsingHeadphones), false]) then {
_unit say2D _soundClass;
} else {
private _posASL = AGLtoASL (_unit modelToWorld (_unit selectionPosition "granat"));
[_soundClass, _posASL, 5, 15] call EFUNC(common,playConfigSound3D);
};

View File

@ -5,13 +5,29 @@
<English>Metal detector</English>
<French>Détecteur de métaux</French>
</Key>
<Key ID="STR_ACE_MineDetector_MetalDetector">
<English>Metal detector</English>
<French>Détecteur de métaux</French>
</Key>
<Key ID="STR_ACE_MineDetector_ActivateDetector">
<English>Activate Detector</English>
<French>Activer le détecteur</French>
<English>Activate</English>
<French>Activer</French>
</Key>
<Key ID="STR_ACE_MineDetector_DeactivateDetector">
<English>Deactivate Detector</English>
<French>Désactiver le détecteur</French>
<English>Deactivate</English>
<French>Désactiver</French>
</Key>
<Key ID="STR_ACE_MineDetector_ConnectHeadphones">
<English>Connect Headphones</English>
</Key>
<Key ID="STR_ACE_MineDetector_DisconnectHeadphones">
<English>Disconnect Headphones</English>
</Key>
<Key ID="STR_ACE_MineDetector_HeadphonesConnected">
<English>Headphones Connected</English>
</Key>
<Key ID="STR_ACE_MineDetector_HeadphonesDisconnected">
<English>Headphones Disconnected</English>
</Key>
</Package>
</Project>