Author Topic: Random Pain/Death Sounds on PlayerType  (Read 2015 times)

Is it possible for a playertype to play a random sound when getting hit or when they die?

I'm looking at how the Repeater Gun on RTB has random sounds on projectile collision and i would like to implement the same system for    PainSound & DeathSound on a playertype.

Yes, it is completely possible.

You need to put serverPlay3D(SOUND, POSITION); into the parent function, of the desired script.
See http://forum.blockland.us/index.php?topic=133471.0 for onProjectileHit. And also see http://forum.blockland.us/index.php?topic=199151.0 for onDeath.

To add/register a sound..
Code: [Select]
datablock AudioProfile(blahSound)
{
   filename    = "./blah.wav";
   description = AudioClose3d;
   preload = true;
};

My Example..

Code: [Select]
function GameConnection::OnDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc)
{
       serverPlay3D(blahSound, %client.player.getPosition());
       parent::OnDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc)
}

Please also note, that they need to be in packages.
« Last Edit: December 01, 2012, 04:55:53 AM by Honorabl3 »



But what's the function for when a player is hurt and shall play owch sound?

But what's the function for when a player is hurt and shall play owch sound?
Player::playPain

« Last Edit: December 01, 2012, 05:00:35 AM by Honorabl3 »

So in order for the player to play a random death sound out of 5 sounds, it should look something like this?



Code: [Select]
function GameConnection::OnDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc)
{
Parent::OnDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc);
%random = getRandom(1,5);
switch(%random)
{
case 1:
serverplay3d(Death1SFX,%client);
case 2:
serverplay3d(Death2SFX,%client);
case 3:
serverplay3d(Death3SFX,%client);
case 4:
serverplay3d(Death4SFX,%client);
case 5:
serverplay3d(Death5SFX,%client);
default:
echo("Error on PlayerType");
}
}

I recommend using player::playDeathCry.

So in order for the player to play a random death sound out of 5 sounds, it should look something like this?



Code: [Select]
...

  • You should use a package.
  • You're trying to use the gameConnection ID as the position of the sound.

now i need to know if and how i can have a playertype play a sound when a fellow teammate dies near them and when they kill a apposing team member.

i would like them to share a 10-30 sec delay so that it won't get to annoying.
« Last Edit: December 12, 2012, 12:33:06 PM by Digit2049 »

now i need to know if and how i can have a playertype play a sound when a fellow teammate dies near them and when the kill a apposing team member.

i would like them to share a 10-30 sec delay so that it won't get to annoying.

Package onDeath.