UnrealShare
Class Flashlight

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

class Flashlight
extends Engine.Pickup

//============================================================================= // flashlight //=============================================================================
Variables
 Vector HitNormal,HitLocation,EndTrace,StartTrace,X,Y,Z,NewHitLocation
 float TimeChange
 FlashLightBeam s

States
DeActivated, Activated
State DeActivated Function Summary


State Activated Function Summary
 void BeginState()
 void Tick(float DeltaTime)
 void endstate()



Source Code


00001	//=============================================================================
00002	// flashlight
00003	//=============================================================================
00004	class Flashlight extends Pickup;
00005	
00006	#exec AUDIO IMPORT FILE="Sounds\Pickups\FSHLITE1.WAV" NAME="FSHLITE1"   GROUP="Pickups"
00007	#exec AUDIO IMPORT FILE="Sounds\Pickups\fshlite2.WAV" NAME="FSHLITE2"   GROUP="Pickups"
00008	 
00009	#exec TEXTURE IMPORT NAME=I_Flashlight FILE=TEXTURES\HUD\i_flash.PCX GROUP="Icons" MIPS=OFF
00010	
00011	#exec MESH IMPORT MESH=Flashl ANIVFILE=MODELS\flashl_a.3D DATAFILE=MODELS\flashl_d.3D X=0 Y=0 Z=0
00012	#exec MESH ORIGIN MESH=Flashl X=0 Y=0 Z=0 YAW=64
00013	#exec MESH SEQUENCE MESH=flashl SEQ=All    STARTFRAME=0  NUMFRAMES=1
00014	#exec MESH SEQUENCE MESH=flashl SEQ=Still  STARTFRAME=0  NUMFRAMES=1
00015	#exec TEXTURE IMPORT NAME=JFlashl1 FILE=MODELS\flashl.PCX GROUP=Skins FLAGS=2
00016	#exec MESHMAP SCALE MESHMAP=Flashl X=0.02 Y=0.02 Z=0.04
00017	#exec MESHMAP SETTEXTURE MESHMAP=flashl NUM=1 TEXTURE=Jflashl1
00018	
00019	var FlashLightBeam s;
00020	var float TimeChange;
00021	var Vector HitNormal,HitLocation,EndTrace,StartTrace,X,Y,Z,NewHitLocation;
00022	
00023	state Activated
00024	{
00025		function endstate()
00026		{
00027			if (s!=None) s.Destroy();
00028			bActive = false;		
00029		}
00030		
00031		function Tick( float DeltaTime )
00032		{
00033			TimeChange += DeltaTime*10;
00034			if (TimeChange > 1) {
00035				if ( s == None )
00036				{
00037					UsedUp();
00038					return;
00039				}		
00040				Charge -= int(TimeChange);
00041				TimeChange = TimeChange - int(TimeChange);
00042			}
00043			
00044			if (s == None) Return;
00045	
00046			if ( Pawn(Owner) == None )
00047			{
00048				s.Destroy();
00049				UsedUp();
00050				return;		
00051			}
00052			if (Charge<-0) {
00053				s.Destroy();
00054				Pawn(Owner).ClientMessage(ExpireMessage);		
00055				UsedUp();		
00056			}
00057			
00058			if (Charge<400) s.LightBrightness=byte(Charge*0.6+10);
00059	
00060			GetAxes(Pawn(Owner).ViewRotation,X,Y,Z);	
00061			EndTrace = Pawn(Owner).Location + 10000* Vector(Pawn(Owner).ViewRotation);
00062			Trace(HitLocation,HitNormal,EndTrace,Pawn(Owner).Location, True);
00063			s.SetLocation(HitLocation-vector(Pawn(Owner).ViewRotation)*64);
00064	//		s.LightRadius = fmin(Vsize(HitLocation-Pawn(Owner).Location)/200,14) + 2.0;
00065		}
00066		
00067		function BeginState()
00068		{
00069			TimeChange = 0;
00070			Owner.PlaySound(ActivateSound);		
00071			GetAxes(Pawn(Owner).ViewRotation,X,Y,Z);	
00072			EndTrace = Pawn(Owner).Location + 10000* Vector(Pawn(Owner).ViewRotation);
00073			Trace(HitLocation,HitNormal,EndTrace,Pawn(Owner).Location+Y*17);
00074			s = Spawn(class'FlashLightBeam',Owner, '', HitLocation+HitNormal*40);
00075			s.LightHue = LightHue;
00076			s.LightRadius = LightRadius;		
00077			if (Charge<400) s.LightBrightness=byte(Charge*0.6+10);	
00078			if (s==None) GoToState('DeActivated');	
00079		}
00080		
00081	Begin:
00082	}
00083	
00084	state DeActivated
00085	{
00086	Begin:
00087		s.Destroy();
00088		Owner.PlaySound(DeActivateSound);
00089	}
00090	
00091	defaultproperties
00092	{
00093	     ExpireMessage="Flashlight batteries have died."
00094	     bActivatable=True
00095	     bDisplayableInv=True
00096	     PickupMessage="You picked up the flashlight"
00097	     RespawnTime=40.000000
00098	     PickupViewMesh=LodMesh'UnrealShare.Flashl'
00099	     Charge=800
00100	     PickupSound=Sound'UnrealShare.Pickups.GenPickSnd'
00101	     ActivateSound=Sound'UnrealShare.Pickups.FSHLITE1'
00102	     DeActivateSound=Sound'UnrealShare.Pickups.FSHLITE2'
00103	     Icon=Texture'UnrealShare.Icons.I_Flashlight'
00104	     RemoteRole=ROLE_DumbProxy
00105	     Mesh=LodMesh'UnrealShare.Flashl'
00106	     AmbientGlow=96
00107	     CollisionRadius=22.000000
00108	     CollisionHeight=4.000000
00109	     LightBrightness=100
00110	     LightHue=33
00111	     LightSaturation=187
00112	     LightRadius=7
00113	}

End Source Code