Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 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
9 changes: 9 additions & 0 deletions addons/fire/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,13 @@ class CfgVehicles {
scope = 1;
displayName = "";
};

class Man;
class CAManBase: Man {
GVAR(screamSounds)[] = {
QGVAR(scream_1), QGVAR(scream_2), QGVAR(scream_3), QGVAR(scream_4), QGVAR(scream_5),
QGVAR(scream_6), QGVAR(scream_7), QGVAR(scream_8), QGVAR(scream_9), QGVAR(scream_10),
QGVAR(scream_11), QGVAR(scream_12), QGVAR(scream_13), QGVAR(scream_14), QGVAR(scream_15)
};
};
};
2 changes: 2 additions & 0 deletions addons/fire/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
PREP(addScreamSounds);
PREP(burn);
PREP(burnEffects);
PREP(burnIndicator);
PREP(burnReaction);
PREP(burnSimulation);
PREP(fireManagerPFH);
PREP(getScreamSounds);
PREP(initUnit);
PREP(isBurning);
PREP(medical_canPatDown);
Expand Down
2 changes: 2 additions & 0 deletions addons/fire/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ PREP_RECOMPILE_END;

#include "initSettings.inc.sqf"

GVAR(screamSounds) = createHashMap;

ADDON = true;
35 changes: 35 additions & 0 deletions addons/fire/functions/fnc_addScreamSounds.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "..\script_component.hpp"
/*
* Author: DartRuffian
* Adds custom fire scream sounds for a unit class.
*
* Arguments:
* 0: Unit class <STRING>
* 1: Array of CfgSounds classes <ARRAY of STRINGs>
* 2: Append to existing sounds array <BOOL> (default: true)
* - true : Passed sounds will be added to unit's existing sounds
* - false: Passed sounds will replace unit's existing sounds
*
* Return Value:
* Succeeded <BOOL>
*
* Example:
* [typeOf player, ["sound1", "sound2"]] call ace_fire_fnc_addScreamSounds
*
* Public: Yes
*/

params [["_unitClass", "", [""]], ["_screams", [], [[]]], ["_append", true, [false]]];
TRACE_3("fnc_addScreamSounds",_unitClass,_screams,_overwrite);

if (_unitClass == "" || _screams isEqualTo [] || !(_unitClass isKindOf "CAManBase")) exitWith { false };

if (_append) then {
private _existingScreams = _unitClass call FUNC(getScreamSounds);
_existingScreams append _screams;
GVAR(screamSounds) set [_unitClass, _existingScreams];
} else {
GVAR(screamSounds) set [_unitClass, _screams];
};

true // return
7 changes: 6 additions & 1 deletion addons/fire/functions/fnc_burnReaction.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ if (
_unit call EFUNC(common,throwWeapon);
};

[QGVAR(playScream), [format [QGVAR(scream_%1), floor (1 + random 15)], _unit]] call CBA_fnc_globalEvent;
// There is a potential issue if a client side mod defines new sounds and adds them
// Since the class that's broadcasted would not be defined on other clients
private _scream = selectRandom (_unit call FUNC(getScreamSounds));
if (!isNil "_scream" && {_scream != ""}) then {
[QGVAR(playScream), [_scream, _unit]] call CBA_fnc_globalEvent;
};
36 changes: 36 additions & 0 deletions addons/fire/functions/fnc_getScreamSounds.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "..\script_component.hpp"
/*
* Author: DartRuffian
* Returns a list of scream sounds that a unit will play when on fire.
*
* Arguments:
* 0: Unit <OBJECT or STRING>
*
* Return Value:
* Scream sounds <ARRAY of STRINGs>
*
* Example:
* player call ace_fire_fnc_getScreamSounds
*
* Public: Yes
*/

params [["_unitClass", objNull, [objNull, ""]]];
TRACE_1("fnc_getScreamSounds",_unitClass);

if (_unitClass isEqualType objNull) then {
_unitClass = typeOf _unitClass;
};
if (_unitClass == "" || !(_unitClass isKindOf "CAManBase")) exitWith { [] };

// If unit is defined in hash, grab sounds and return
// If not, check each parent of the class until a value is defined
GVAR(screamSounds) getOrDefaultCall [toLowerANSI _unitClass, {
private _cfg = configFile >> "CfgVehicles" >> _unitClass;
private _return = getArray (_cfg >> QGVAR(screamSounds));
while {!isNull _cfg} do {
_cfg = inheritsFrom _cfg;
if ((toLowerANSI configName _cfg) in GVAR(screamSounds)) exitWith { _return = GVAR(screamSounds) get (toLowerANSI configName _cfg) };
};
_return
}, true] // return
58 changes: 57 additions & 1 deletion docs/wiki/framework/fire-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Use `CBA_fnc_serverEvent` to use the following features. Events are defined only

| | Arguments | Type(s) | Optional (default value) |
|----| --------- | ------- | ------------------------ |
| 0 | Fire source ID | Array/Boolean/Code/Config/Group/Namespace/NaN/Number/Object/Side/String | Required |
| 0 | Fire source ID | Array/Boolean/Code/Config/Group/Namespace/NaN/Number/Object/Side/String | Required |

## 2. Variables

Expand All @@ -47,6 +47,7 @@ _unit setVariable ["ace_fire_enableScreams", false, _isGlobal];
```

## 3. Config Values

### 3.1 Adding fire protection to a uniform

{% raw %}
Expand All @@ -59,3 +60,58 @@ class CfgWeapons {
};
```
{% endraw %}

### 3.2 Custom scream sounds

{% raw %}
```cpp
class CfgVehicles {
class CAManBase;
class yourManClass: CAManBase {
ace_fire_screamSounds = {
"sound_name" // Name of sound(s) in CfgSounds
};
};
};
```
{% endraw %}

## 4. Scripting

### 4.1 Setting/Adding Custom Screaming Sounds

`ace_fire_fnc_addScreamSounds`

```sqf
* Adds custom fire scream sounds for a unit class.
*
* Arguments:
* 0: Unit class <STRING>
* 1: Array of CfgSounds classes <ARRAY of STRING>
* 2: Append to existing sounds array <BOOL> (default: true)
* - true : Passed sounds will be added to unit's existing sounds
* - false: Passed sounds will replace unit's existing sounds
*
* Return Value:
* Succeeded <BOOL>
*
* Example:
* [typeOf player, ["sound1", "sound2"]] call ace_fire_fnc_addScreamSounds
```

### 4.1 Getting Screaming Sounds

`ace_fire_fnc_getScreamSounds`

```sqf
* Returns a list of scream sounds that a unit will play when on fire.
*
* Arguments:
* 0: Unit <OBJECT or STRING>
*
* Return Value:
* Scream sounds <ARRAY of STRINGs>
*
* Example:
* player call ace_fire_fnc_getScreamSounds
```