Legacy:XTra KrazzY/KActorSound: Difference between revisions

From Unreal Wiki, The Unreal Engine Documentation Site
m Grammar/spelling (omg i was so lame)
 
Sweavo (talk | contribs)
No edit summary
 
Line 107: Line 107:
'''XTra KrazzY''' it sux, can't believe i made this piece of cr*p that long ago...
'''XTra KrazzY''' it sux, can't believe i made this piece of cr*p that long ago...


[[Category:Legacy Custom Class|{{PAGENAME}}]]
[[Category:Legacy Custom Class (UT2004)|{{PAGENAME}}]]

Latest revision as of 16:18, 19 November 2007

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 (//)

Intro

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

You may use my code as you wish.

Code

<uscript> //========================================= // 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'


} </uscript>

Comments?

Right here:

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