Terrance

Adding injury sounds

11 posts in this topic

Hey everyone,

Apologies if this has already been asked. I've done some searching around but I couldn't find anything distinct.

I'm the creator of a workshop scenario which utilises the injury sounds from the DayZ mod, you know, the ridiculous "EOW" sounds, in conjunction with the leg breaking sound.

I've managed to hook that via my intro.sqf in my workshop scenario like so:

intro.sqf

// Is server executing code?
if (isServer) then {
	// Loop through playableUnits.
	{
		// Add hook for MPHit event (injuries).
		_x addMPEventHandler ["MPHit", {[_this] execVM "scripts\hooks\survivorHit.sqf";}];
	} forEach playableUnits;
};

description.ext

// Game sounds.
class CfgSounds
{
	// All sounds defined below.
	sounds[] = {hit1};

	class hit1
	{
		name = "hit1";
		sound[] = {\sounds\injuries\hit1.ogg, 1, 1.0};
		titles[] = {};
	};
};

The script that the hook (survivorHit.sqf) calls, survivorHitVictim.sqf:

// Survivor is hit script
// Play sound upon injury.

// For the sake of logic.
_victim = _this select 0;
_sleepTime = _this select 1;

// Do we exist? Are we alive? Are we in a vehicle?
if (isNull _victim || !alive _victim || vehicle _victim != _victim) exitWith {};

// 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];

// Delay so we don't hear rapid pain.
// IF, we are causing self harm.
if (_sleepTime > 0) then {
	sleep _sleepTime;
};

Now this works as-is, both in dedicated & non-dedicated environments for my mission, however, I can't get this to fire in Exile.

There are no script errors, I've chucked a few diag_log's here and there but no bueno :(

If this is something very obvious I apologise, I am rather new to working with Exile, in fact, I only started tinkering with it yesterday.

If more information is required, please let me know and I'd be more than happy to share (also happy to share the entire script when it bloody well works!)

Cheers,

-tez.

Share this post


Link to post
Share on other sites

Do you have a RPT from the server? I don't see any reason why this wouldn't run O.o

Share this post


Link to post
Share on other sites
Advertisement

Hey Taytay :)

I do, but it only references the hook itself being applied itself, the example being:

 

diag_log format ["Hook applied."]

....

{

... insert event handler code here
} forEach playableUnits

 

The 'hook applied' appears in the log, but it appears when I put this within the loop itself, it doesn't appear. Perhaps something to do with the BattlEye filters provided by Exile?

Not sure, just thinking out loud I guess :)

Share this post


Link to post
Share on other sites

@Terrance@Taylor Swift

This hook you are using will work wonderfully in the editor / sp mission.

However with exile I suggest using the Overrides system, placing a new customcode for the ExileClient_object_player_event_onHit.sqf

 

/**
 * ExileClient_object_player_event_onHit
 *
 * Exile Mod
 * www.exilemod.com
 * © 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["_damage"];
_damage = _this select 2;
if !(ExilePlayerInSafezone) then
{
	[_damage * 10] call BIS_fnc_bloodEffect;
	ExileClientPlayerIsInCombat = true;
	ExileClientPlayerLastCombatAt = diag_tickTime;
	true call ExileClient_gui_hud_toggleCombatIcon;
    [] execVM "scripts\hooks\survivorHit.sqf";
};
true

This is theory only, not tested but should get you on the right path

1 person likes this

Share this post


Link to post
Share on other sites

@DirtySanchez

You are an absolute bloody legend mate, thank you so much. I'll take your theory and put it to the test.

If it works, I'll share it here :)

Cheers,

-tez.

Share this post


Link to post
Share on other sites

Apologies, I forgot Exile is already handling onHit. Glad you got it sorted, can I close this now? :)

Share this post


Link to post
Share on other sites

Yep! I'm sure if it's already handled via the Exile onHit I should be able to implement this :)
 

I'll admit, I feel a little stupid now! Is there somewhere these functions are documented, for future reference?

Share this post


Link to post
Share on other sites

I believe the question has been answered to its fullest with a good example to run off of. I say yes to the ole [SOLVED] and close.

Share this post


Link to post
Share on other sites

Funnily enough, the Wiki is being worked on as we speak. All Useful Exile function will be listed :)

 

1 person likes this

Share this post


Link to post
Share on other sites

Great work :)

Thank you both for being so helpful and kind to a newcomer.

I guess if this is to be closed I'll edit my first post with the results when I manage to get some free time on the weekend!

Also, I got to see her live when she came to Melbourne and she was absolutely phenomenal! Offtopic as all hell =)

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.