UE3 - UT3 Playing a sound caused by weapon damage

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

CVROY

New Member
Mar 8, 2003
202
0
0
I have made a custom impact hammer and would like it to play a sound only when the person hit with it dies from it, not because they took damage from it.

Here is my class:
Code:
class UTDmgType_WGSImpactHammer extends UTDamageType
	abstract;


/** Return the DeathCameraEffect that will be played on the instigator that was caused by this damagetype and the Pawn type (e.g. robot) */
simulated static function class<UTEmitCameraEffect> GetDeathCameraEffectInstigator( UTPawn UTP )
{
		// robots need to splatter oil instead of blood
		if( ( UTP != none ) && ( ClassIsChildOf( UTP.GetFamilyInfo(), class'UTFamilyInfo_Liandri' ) == TRUE ) )
		{
			return class'UTEmitCameraEffect_OilSplatter';
		}
		else
		{
			return default.DeathCameraEffectInstigator;
		}
}

defaultproperties
{
//   GibPerterbation=0.500000
   GibPerterbation=0.550000
   DamageWeaponClass=Class'WGSweps_a2v.UTWeap_WGSImpactHammer'
   DamageWeaponFireMode=2
   DeathCameraEffectInstigator=Class'UTGame.UTEmitCameraEffect_BloodSplatter'
   DamageCameraAnim=CameraAnim'Camera_FX.ImpactHammer.C_WP_ImpactHammer_Primary_Fire_GetHit_Shake'
   KillStatsName="KILLS_IMPACTHAMMER"
   DeathStatsName="DEATHS_IMPACTHAMMER"
   SuicideStatsName="SUICIDES_IMPACTHAMMER"
   RewardCount=10
   RewardAnnouncementSwitch=5
   RewardEvent="REWARD_JACKHAMMER"
   CustomTauntIndex=5
   DeathString="`o was hammered by `k."
   FemaleSuicide="`o pounded herself."
   MaleSuicide="`o pounded himself."
   bAlwaysGibs=True
   KDamageImpulse=10000.000000
   VehicleDamageScaling=1.000000
   Name="Default__UTDmgType_WGSImpactHammer"
   ObjectArchetype=UTDamageType'UTGame.Default__UTDamageType'
}

I don't know how to call a sound in UT3 in this type of class when the person dies :(

Anyone know?
 
Last edited:

Surfa

New Member
Apr 1, 2008
1
0
0
The sound files are not defined in that class they are in the actual weapon class.
Code:
//============================
// New weap
//============================

class UTWeap_Newweapon extends UTWeap_ImpactHammer
defaultproperties 
{
 WeaponFireSnd(0)=SoundCue'A_Weapon_ImpactHammer.ImpactHammer.A_Weapon_ImpactHammer_AltFire_Cue'  //change theese sounds
 WeaponFireSnd(1)=SoundCue'A_Weapon_ImpactHammer.ImpactHammer.A_Weapon_ImpactHammer_AltImpact_Cue'

}

then create a mutator to replace you new weapon with the impact hammer.

Code:
//========================
//Spawn Mutator
//========================
class SpawnMutator extends UTMutator;

function InitMutator(string Options, out string ErrorMessage)
{
if (UTGame(WorldInfo.Game) != None)
{
UTGame(WorldInfo.Game).DefaultInventory[0] = class'SpawnMutator.UTWeap_Newweapon';
}

Super.InitMutator(Options, ErrorMessage);
}

function bool CheckReplacement(Actor Other)
{
if (Other.IsA('UTWeap_ImpactHammer') && !Other.IsA('UTWeap_Newweapon'))
{
ReplaceWith(Other, "UTWeap_Newweapon");
}

return true;
}

DefaultProperties
{
}
but you might want to change the names of the classes to suitable names.
 
Last edited:

CVROY

New Member
Mar 8, 2003
202
0
0
All my custom weapons work and do get replaced as they should. What I am trying to do is when I gib someone with the impact hammer I made I want a specific sound played when they die only not when they take damage from it... it has to kill them for this sound event to take place.
 

CVROY

New Member
Mar 8, 2003
202
0
0
why would I do that if it's a function of the weapon, would it not go into one of the weapon classes?
 

Jrubzjeknf

Registered Coder
Mar 12, 2004
1,276
0
36
36
The Netherlands
Ah nm, I misread your first post. But now I don't really get your problem. :p What's different from making a sound play in that class? If you can't play the sound in the UTDamageType because its abstract, you can call the PlaySound() function on the given UTPawn object.

So in your case:

Code:
simulated static function class<UTEmitCameraEffect> GetDeathCameraEffectInstigator( UTPawn UTP )
{
  UTP.PlaySound(WickedGameSound);

  return Super.GetDeathCameraEffectInstigator(UTP);
}
 

CVROY

New Member
Mar 8, 2003
202
0
0
SWEEEEET! Will try this later tonight when I get home from work.

Thanks for the suggestion and I'll post my results :)
 

CVROY

New Member
Mar 8, 2003
202
0
0
I apologize for the very late response, just been very busy with work :(

Here is my code now:
Code:
var soundcue WickedGameSound;

/** Return the DeathCameraEffect that will be played on the instigator that was caused by this damagetype and the Pawn type (e.g. robot) */
simulated static function class<UTEmitCameraEffect> GetDeathCameraEffectInstigator( UTPawn UTP )
{
		// robots need to splatter oil instead of blood
		if( ( UTP != none ) && ( ClassIsChildOf( UTP.GetFamilyInfo(), class'UTFamilyInfo_Liandri' ) == TRUE ) )
		{
			return class'UTEmitCameraEffect_OilSplatter';
		}
		else
		{
			return default.DeathCameraEffectInstigator;
		}

  UTP.PlaySound(WickedGameSound);

  return Super.GetDeathCameraEffectInstigator(UTP);

}

defaultproperties
{
WickedGameSound=SoundCue'WGSweps_5b_snds.gurgle'

Here is the error I get on compile:
Code:
Warning/Error Summary
---------------------
C:\Program Files (x86)\Unreal Tournament 3\Development\Src\WGSweps_5b\Classes\UTDmgType_WGSImpactHammer.uc(19) : Error, You can only access default values of variables here

Failure - 1 error(s), 0 warning(s)

the line (19) error is referring to this: UTP.PlaySound(WickedGameSound);
 
Last edited:

CVROY

New Member
Mar 8, 2003
202
0
0
I think it gets the error because WickedGameSound is not a default in utpawn (utp)

Lastly, I would like this sound to play for the victim and killer... is it possible? Maybe I should use an ambient sound.
 
Last edited:

Jrubzjeknf

Registered Coder
Mar 12, 2004
1,276
0
36
36
The Netherlands
Code:
UTP.PlaySound(WickedGameSound);

You can only access the default values of variables in static function. Use this instead:

Code:
UTP.PlaySound(default.WickedGameSound);
 

CVROY

New Member
Mar 8, 2003
202
0
0
Weeeeeeeeeeeeeeeeeeeee!!! That works :)

I had to change the code layout to this and the sound is audible... the way I had it above did not work.

Code:
var soundcue WickedGameSound;

/** Return the DeathCameraEffect that will be played on the instigator that was caused by this damagetype and the Pawn type (e.g. robot) */
simulated static function class<UTEmitCameraEffect> GetDeathCameraEffectInstigator( UTPawn UTP )
{
		// robots need to splatter oil instead of blood
		if( ( UTP != none ) && ( ClassIsChildOf( UTP.GetFamilyInfo(), class'UTFamilyInfo_Liandri' ) == TRUE ) )
		{
		          UTP.PlaySound(default.WickedGameSound);
			return class'UTEmitCameraEffect_OilSplatter';
		}
		else
		{
	        	UTP.PlaySound(default.WickedGameSound);
			return default.DeathCameraEffectInstigator;
		}
}

defaultproperties
{
   WickedGameSound=SoundCue'WGSweps_5b_snds.gurgleCue'

The killer hears the sound no problems, when you are killed by it (the victim) you do not hear the blood gurgle. Is there a way to make the victim hear it as well.


Thank you so much BTW for helping with this, I have been having trouble as I am not good at making new code, but kind of understand it if I see it and can use it at that point.
 
Last edited:

CVROY

New Member
Mar 8, 2003
202
0
0
should I change it to an ambient sound? Would that allow both parties to hear it?
 

CVROY

New Member
Mar 8, 2003
202
0
0
Here is what I use, works like a charm, now the victims hear the blood curdling and metal smashing sounds too :)

Code:
/** Return the Sound that will be played on the victim by this damagetype and the Pawn type (e.g. robot) */
simulated static function class<UTEmitCameraEffect> GetDeathCameraEffectVictim( UTPawn UTP )
{
		// robots need to splatter oil instead of blood
		if( ( UTP != none ) && ( ClassIsChildOf( UTP.GetFamilyInfo(), class'UTFamilyInfo_Liandri' ) == TRUE ) )
		{
                    UTP.PlaySound(default.RobotBreak);
		}
		else
		{
 	            UTP.PlaySound(default.BloodGurgle);
		}
}

Thanks agian Jrubzjeknf.
 
Last edited:

eblade

New Member
Jan 29, 2006
113
0
0
Personally, I'd have overridden whatever function actually causes damage in the weapon/weaponfire/whatever, and after that is done, check to see if the hit pawn is still alive, and play from there.. but.. w/e D: