I'm a doctor, not a mechanic

Legacy:XTra KrazzY/KActorSound

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
Actor >> KActor >> KActorSound

This custom class adds Sounds and Dynamic Volumes to KActors.

You can modify the code but explain it first with double slashes (//)[edit]

Intro[edit]

Hello... I'm XTra KrazzY and I found out that KActors never make any sounds, even if you try and configure them in the "KActor" impactsounds...

It took me a couple of minutes to realize that it was hidden in the xPawn Ragdoll impact sounds code. So I took it a bit further and it took me a couple of HOURS to finish and compile my newlyborn invention: Dynamic Volume.

When a KActor hits something it makes a strong sound... even if the impactVel's (a vector that controlls the impact velocity) vector size was small, so I decided to make a new code that will also control the volume based on the impact velocity.

Disclaimer[edit]

You may use my code as you wish.

Code[edit]

//=========================================
// Dynamic Volume Kactors 
// (C) Copyrights to XTra Krazzy 2004
//=========================================
class KActorSound extends KActor;
 
var(KActorSounds) array<sound>   	HitImpactSounds;
var(KActorSounds) float			HitImpactSoundInterval;
var transient float			HitLastSoundTime;
 
var string HitOverride;
 
//You can change the volume values...
event KImpact(actor other, vector pos, vector impactVel, vector impactNorm)
{
 
    local int numSounds, soundNum;
    local float impactVelSize;
 
	numSounds = HitImpactSounds.Length;
 
    //log("Impact Velocity :"$VSize(impactVel));
 
    impactVelSize = VSize(impactVel);
 
    //log("the var: "$impactvelsize);
 
    if(numSounds > 0 && Level.TimeSeconds > HitLastSoundTime + HitImpactSoundInterval)
	{
		soundNum = Rand(numSounds);
		//Log("Play Sound:"$soundNum);
        if(impactVelSize > 0 && impactVelSize < 100)
        {
        PlaySound(HitImpactSounds[soundNum], SLOT_Pain, 0.5);
        }
        if(impactVelSize >= 100 && impactvelsize < 300)
        {
        PlaySound(HitImpactSounds[soundNum], SLOT_Pain, 1);
        }
        if(impactVelSize >= 300 && impactVelSize < 600)
        {
        PlaySound(HitImpactSounds[soundNum], SLOT_Pain, 2.5);
        }
        if(impactVelSize >= 600 && impactVelSize < 1000)
        {
        PlaySound(HitImpactSounds[soundNum], SLOT_Pain, 5);
        }
        if(impactVelSize >= 1000 && impactVelSize < 3000)
        {
        PlaySound(HitImpactSounds[soundNum], SLOT_Pain, 10);
        }
        if(impactVelSize >= 3000)
        {
        PlaySound(HitImpactSounds[soundNum], SLOT_Pain, 20);
        }
		HitLastSoundTime = Level.TimeSeconds;
	}
}
 
defaultproperties
{
 
    Begin Object Class=KarmaParams Name=KarmaParams0
 
        KStartEnabled=True
        KImpactThreshold=0
        bHighDetailOnly=False
        bKAllowRotate=True
        KFriction=0.2
        KRestitution=0.5
        KMass=0.5
        bClientOnly=False
        Name="KarmaParams0"
 
    End Object
    KParams=KarmaParams'KarmaParams0'
 
 
}

Comments?[edit]

Right here:

XTra KrazzY it sux, can't believe i made this piece of cr*p that long ago...