UnrealShare
Class VoiceBox

source: e:\games\UnrealTournament\UnrealShare\Classes\VoiceBox.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Inventory
         |
         +--Engine.Pickup
            |
            +--UnrealShare.VoiceBox
Direct Known Subclasses:None

class VoiceBox
extends Engine.Pickup

//============================================================================= // VoiceBox. //=============================================================================
Variables
 sound BattleSounds[10]
 vector X,Y,Z

States
Playing, Activated
State Playing Function Summary
 void BeginState()
 void Timer()
 void Touch(Actor Other)


State Activated Function Summary
 void HitWall(vector HitNormal, Actor Wall)
     
// Delete from inventory and toss in front of player.



Source Code


00001	//=============================================================================
00002	// VoiceBox.
00003	//=============================================================================
00004	class VoiceBox extends Pickup;
00005	
00006	#exec TEXTURE IMPORT NAME=I_VoiceBox FILE=TEXTURES\HUD\i_voice.PCX GROUP="Icons" MIPS=OFF
00007	
00008	#exec AUDIO IMPORT FILE="Sounds\Pickups\VOICEB1.WAV" NAME="VoiceSnd" GROUP="Pickups"
00009	#exec AUDIO IMPORT FILE="Sounds\automag\shot.WAV" NAME="shot" GROUP="AutoMag"
00010	#exec AUDIO IMPORT FILE="Sounds\stinger\sshot10d.WAV" NAME="StingerFire" GROUP="Stinger"
00011	#exec AUDIO IMPORT FILE="Sounds\flak\shot1.WAV" NAME="shot1" GROUP="flak"
00012	#exec AUDIO IMPORT FILE="Sounds\flak\Explode1.WAV" NAME="Explode1" GROUP="flak"
00013	#exec AUDIO IMPORT FILE="Sounds\flak\expl2.WAV" NAME="expl2" GROUP="flak"
00014	
00015	#exec MESH IMPORT MESH=VoiceBoxMesh ANIVFILE=MODELS\voice_a.3D DATAFILE=MODELS\voice_d.3D X=0 Y=0 Z=0
00016	#exec MESH ORIGIN MESH=VoiceBoxMesh X=0 Y=0 Z=-15 YAW=64
00017	#exec MESH SEQUENCE MESH=VoiceBoxMesh SEQ=All   STARTFRAME=0  NUMFRAMES=10
00018	#exec MESH SEQUENCE MESH=VoiceBoxMesh SEQ=Pulse STARTFRAME=0  NUMFRAMES=10
00019	#exec TEXTURE IMPORT NAME=Ainv1 FILE=MODELS\inv.PCX GROUP="Skins"
00020	#exec MESHMAP SCALE MESHMAP=VoiceBoxMesh X=0.04 Y=0.04 Z=0.08
00021	#exec MESHMAP SETTEXTURE MESHMAP=VoiceBoxMesh NUM=1 TEXTURE=Ainv1
00022	
00023	var vector X,Y,Z;
00024	var() sound BattleSounds[10];	
00025	
00026	state Activated  // Delete from inventory and toss in front of player.
00027	{
00028		function HitWall (vector HitNormal, actor Wall)
00029		{
00030			Velocity = 0.5*(( Velocity dot HitNormal ) * HitNormal * (-2.0) + Velocity);   // Reflect off Wall w/damping
00031		//	PlaySound(Sound 'GrenadeFloor', SLOT_Misc, VSize(Velocity)/1300 );
00032			If (VSize(Velocity) < 20)
00033			{
00034				bBounce = False;
00035				bStasis = false;
00036				SetPhysics(PHYS_None);
00037				GoToState('Playing');
00038			}
00039		}
00040	Begin:
00041		GetAxes(Pawn(Owner).ViewRotation,X,Y,Z);
00042		SetLocation(Pawn(Owner).Location+X*10+Y*8-Z*20);
00043	    Disable('Touch');
00044		bBounce=True;	
00045		Velocity = Owner.Velocity + Vector(Owner.Rotation) * 150.0;
00046		Velocity.z += 240;         
00047		DesiredRotation = RotRand();
00048		RotationRate.Yaw = 20000*FRand() - 10000;
00049		RespawnTime = 0.0; //don't respawn
00050		SetPhysics(PHYS_Falling);
00051		RemoteRole = ROLE_DumbProxy;
00052		BecomePickup();
00053		bCollideWorld = true;
00054		Pawn(Owner).NextItem();
00055		if (Pawn(Owner).SelectedItem == Self) Pawn(Owner).SelectedItem=None;	
00056		Owner.PlaySound(ActivateSound);		
00057		Pawn(Owner).DeleteInventory(Self);	
00058		bStasis=false;
00059	}
00060	
00061	
00062	state Playing
00063	{
00064		function Touch(Actor Other)
00065		{
00066			Super.Touch(Other);
00067		}
00068	
00069		function Timer()
00070		{
00071			local int i;
00072			
00073			MakeNoise(1.0);
00074			for (i=0 ; i<10 ; i++) 
00075				if (FRand()<0.05 && BattleSounds[i]!=None) PlaySound(BattleSounds[i], SLOT_None, FRand()/2+0.5);
00076			Charge--;
00077			if (Charge<=0) {
00078				spawn(class'SpriteBallExplosion',,,Location + vect(0,0,1)*16); 
00079				destroy();
00080			}
00081		}
00082		
00083		function BeginState()
00084		{
00085			bStasis = false;
00086			SetTimer(0.1,True);
00087			LoopAnim('Pulse');
00088		}
00089	}
00090	
00091	defaultproperties
00092	{
00093	     BattleSounds(0)=Sound'UnrealShare.AutoMag.shot'
00094	     BattleSounds(1)=Sound'UnrealShare.flak.expl2'
00095	     BattleSounds(2)=Sound'UnrealShare.AutoMag.shot'
00096	     BattleSounds(3)=Sound'UnrealShare.AutoMag.shot'
00097	     BattleSounds(4)=Sound'UnrealShare.flak.Explode1'
00098	     BattleSounds(5)=Sound'UnrealShare.flak.expl2'
00099	     BattleSounds(6)=Sound'UnrealShare.flak.shot1'
00100	     BattleSounds(7)=Sound'UnrealShare.ASMD.TazerFire'
00101	     BattleSounds(8)=Sound'UnrealShare.Stinger.Ricochet'
00102	     BattleSounds(9)=Sound'UnrealShare.AutoMag.shot'
00103	     bActivatable=True
00104	     bDisplayableInv=True
00105	     PickupMessage="You picked up the Voice Box"
00106	     RespawnTime=30.000000
00107	     PickupViewMesh=LodMesh'UnrealShare.VoiceBoxMesh'
00108	     Charge=100
00109	     PickupSound=Sound'UnrealShare.Pickups.GenPickSnd'
00110	     Icon=Texture'UnrealShare.Icons.I_VoiceBox'
00111	     RemoteRole=ROLE_DumbProxy
00112	     Mesh=LodMesh'UnrealShare.VoiceBoxMesh'
00113	     AmbientGlow=64
00114	     CollisionRadius=18.000000
00115	     CollisionHeight=8.000000
00116	     bCollideWorld=True
00117	}

End Source Code