UnrealShare
Class SparkBit

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

class SparkBit
extends Engine.Effects

//============================================================================= // SparkBit. //=============================================================================
Variables
 float BurnTime
 float InitialBrightness
 float PassedTime

States
Burning
State Burning Function Summary



Source Code


00001	//=============================================================================
00002	// SparkBit.
00003	//=============================================================================
00004	class SparkBit extends Effects;
00005	
00006	#exec MESH IMPORT MESH=bolt1 ANIVFILE=MODELS\bolt1_a.3D DATAFILE=MODELS\bolt1_d.3D X=0 Y=0 Z=0
00007	#exec MESH ORIGIN MESH=bolt1 X=0 Y=0 Z=-0 YAW=64
00008	#exec MESH SEQUENCE MESH=bolt1 SEQ=All    STARTFRAME=0   NUMFRAMES=1
00009	#exec MESH SEQUENCE MESH=bolt1 SEQ=Still  STARTFRAME=0   NUMFRAMES=1
00010	#exec TEXTURE IMPORT NAME=Jmisc1 FILE=MODELS\misc.PCX 
00011	#exec MESHMAP SCALE MESHMAP=bolt1 X=0.05 Y=0.05 Z=0.1
00012	#exec MESHMAP SETTEXTURE MESHMAP=bolt1 NUM=1 TEXTURE=Jmisc1
00013	
00014	// Owner (spawner) specifies the velocity of the SparkBit (implicitly in
00015	// Actor properties), the length of time it can burn for, and the initial 
00016	// brightness of the spark.  MZM
00017	
00018	var float BurnTime;
00019	var float InitialBrightness;
00020	var float PassedTime;
00021	
00022	auto state Burning
00023	{
00024		simulated function Timer() 
00025		{
00026			// The Spark should lose its brightness as it
00027			// burns away, but not linearly - the main brightness
00028			// decays in quadratic fashion but the actual brightness
00029			// is also randomly tweaked to give the appearance of
00030			// non-uniform burning.  The object also gives off
00031			// its own light.
00032			//
00033			local float tempBrightness;
00034	
00035			BurnTime -= 0.15;
00036			if ( BurnTime < 0 )
00037			{
00038				Destroy();
00039				return;
00040			}
00041	
00042			PassedTime += 0.15;
00043			tempBrightness = InitialBrightness*(1-
00044	 					    ((PassedTime*(1-0.1+0.2*FRand()))/BurnTime) **2);
00045			tempBrightness = FClamp (tempBrightness, 0, 1);
00046			
00047			LightBrightness = tempBrightness * 90;
00048			AmbientGlow     = tempBrightness * 240;
00049	
00050		}
00051	
00052		simulated function HitWall (vector HitNormal, actor Wall) 
00053		{
00054			// When surface is hit, the spark appears to become
00055			// brighter, losing size, but still bounces off (losing half its speed).
00056			//
00057			InitialBrightness *= 1.5;
00058			DrawScale         /= 1.5;
00059			Velocity = 0.5*(-(Velocity dot HitNormal)*HitNormal*2 + Velocity);
00060			if ( (HitNormal.Z > 0.7) && (VSize(Velocity) < 50) )
00061				bBounce = false;
00062		}
00063		
00064		simulated function ZoneChange (ZoneInfo NewZone) 
00065		{
00066			// Spark dies if it hits the water.
00067			//
00068			if (NewZone.bWaterZone) Destroy();
00069		}
00070	
00071		simulated function BeginState()
00072		{
00073			SetTimer(0.15, true);
00074			BurnTime = FMax(BurnTime, 0.1);
00075		}
00076	}
00077	
00078	defaultproperties
00079	{
00080	     BurnTime=0.100000
00081	     bNetOptional=True
00082	     Physics=PHYS_Falling
00083	     RemoteRole=ROLE_SimulatedProxy
00084	     DrawType=DT_Mesh
00085	     Texture=None
00086	     DrawScale=0.300000
00087	     AmbientGlow=123
00088	     bUnlit=True
00089	     CollisionRadius=1.000000
00090	     CollisionHeight=1.000000
00091	     bCollideActors=True
00092	     bCollideWorld=True
00093	     LightType=LT_Steady
00094	     LightBrightness=130
00095	     LightHue=120
00096	     LightSaturation=200
00097	     LightRadius=1
00098	     bBounce=True
00099	}

End Source Code