I said I'd share so here's what I have (in it's working state!)
I chose to utilise: ExileClient_object_player_event_onHandleDamage (Figured I'd wanted injury sounds for crashing, falling, etc.. that aren't handled by the standard Hit handler, or so it seems!)
ExileClient_object_player_event_onHandleDamage.sqf:
/**
* ExileClient_object_player_event_onHandleDamage
*
* Exile Mod
* exile.majormittens.co.uk
* © 2015 Exile Mod Team
*
* This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
*/
private["_unit","_selectionName","_amountOfDamage","_sourceOfDamage","_typeOfProjectile"];
_unit = _this select 0;
_selectionName = _this select 1;
_amountOfDamage = _this select 2;
_sourceOfDamage = _this select 3;
_typeOfProjectile = _this select 4;
// There's probably a better way of doing this.
if (isNil {_unit getVariable "LastInjuredSound"}) then {
_unit setVariable ["LastInjuredSound", 0];
};
// Push this for use.
_lastHitTime = _unit getVariable "LastInjuredSound";
// If it's the first time triggering, or the last time the sound was played is greater than 0.005 (To avoid sounds being spammed...) then fire.
if (_lastHitTime == 0 || diag_tickTime - _lastHitTime > 0.005) then {
// Set new timer to current tick time.
_unit setVariable ["LastInjuredSound", diag_tickTime];
// Execute script.
[_unit, _sourceOfDamage, _amountOfDamage] execVM "scripts\hooks\survivorHit.sqf";
};
// Return original damage value back out.
_amountOfDamage
In config.cpp:
class CfgExileCustomCode
{
/*
You can overwrite every single file of our code without touching it.
To do that, add the function name you want to overwrite plus the
path to your custom file here. If you wonder how this works, have a
look at our bootstrap/fn_preInit.sqf function.
Simply add the following scheme here:
<Function Name of Exile> = "<New File Name>";
Example:
ExileClient_util_fusRoDah = "myaddon\myfunction.sqf";
*/
// Emergency fixes for 0.9.41
ExileClient_object_player_bambiStateBegin = "ExileClient_object_player_bambiStateBegin.sqf";
// On damage trigger for injury sounds.
ExileClient_object_player_event_onHandleDamage = "ExileClient_object_player_event_onHandleDamage.sqf";
};
scripts/hooks/survivorHit.sqf (This could probably be done without this, but I have another script I'm using, unrelated to this :)):
// For the sake of logic.
_victim = _this select 0;
_shooter = _this select 1;
_damage = _this select 2;
// Don't stack scripts if we are hurting ourself.
if (_victim == _shooter) then {
[_victim, _damage] execVM "scripts\hooks\survivorHitVictim.sqf";
} else {
[_victim, _damage] execVM "scripts\hooks\survivorHitVictim.sqf";
//[_shooter] execVM "scripts\hooks\survivorHitShooter.sqf";
};
survivorHitVictim.sqf:
// Survivor is hit script
// This is the GLOBAL script
// This script is for updating clients
// THE SOUND LOL
// For the sake of logic.
_victim = _this select 0;
_damage = _this select 1;
// Do we exist? Are we alive? Are we in a vehicle?
if (isNull _victim || !alive _victim || vehicle _victim != _victim) exitWith {};
// If we sustain more than 50% damage, we have broken legs in Exile.
if (_damage > 0.5) then {
_victim say ["legBreak", 25];
sleep 0.25;
};
// Array of sounds.
_soundArray = ["hit1", "hit2", "hit3", "hit4", "hit5", "hit6", "hit7", "hit8", "hit9"];
// Select a sound.
_soundToPlay = _soundArray select (floor(random(count _soundArray)));
// Say sound.
_victim say [_soundToPlay, 25];
description.ext:
class CfgSounds
{
sounds[] = {legbreak, hit1, hit2, hit3, hit4, hit5, hit6, hit7, hit8, hit9};
class legbreak
{
name = "legbreak";
sound[] = {\sounds\injuries\legbreak.ogg, 1, 1.0};
titles[] = {};
};
class hit1
{
name = "hit1";
sound[] = {\sounds\injuries\hit1.ogg, 1, 1.0};
titles[] = {};
};
class hit2
{
name = "hit2";
sound[] = {\sounds\injuries\hit2.ogg, 1, 1.0};
titles[] = {};
};
class hit3
{
name = "hit3";
sound[] = {\sounds\injuries\hit3.ogg, 1, 1.0};
titles[] = {};
};
class hit4
{
name = "hit4";
sound[] = {\sounds\injuries\hit4.ogg, 1, 1.0};
titles[] = {};
};
class hit5
{
name = "hit5";
sound[] = {\sounds\injuries\hit5.ogg, 1, 1.0};
titles[] = {};
};
class hit6
{
name = "hit6";
sound[] = {\sounds\injuries\hit6.ogg, 1, 1.0};
titles[] = {};
};
class hit7
{
name = "hit7";
sound[] = {\sounds\injuries\hit7.ogg, 1, 1.0};
titles[] = {};
};
class hit8
{
name = "hit8";
sound[] = {\sounds\injuries\hit8.ogg, 1, 1.0};
titles[] = {};
};
class hit9
{
name = "hit9";
sound[] = {\sounds\injuries\hit9.ogg, 1, 1.0};
titles[] = {};
};
};
That last script still needs a little work. Especially around the legbreak part, considering it should only fire when the user's legs aren't broken, rather than just taking >50% of their health in damage I suppose, but hey, I added that part in just for fun.
And the injury sounds:
http://www.mediafire.com/download/u5b71p5264k6ipe/injuries.rar
Thanks to the both of you assisting me on this