UnrealShare
Class BioGel

source: e:\games\UnrealTournament\UnrealShare\Classes\BioGel.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Projectile
         |
         +--UnrealShare.BioGel
Direct Known Subclasses:BarrelSludge, BigBioGel, BioDrop

class BioGel
extends Engine.Projectile

//============================================================================= // BioGel. //=============================================================================
Variables
 float BaseOffset
 vector SurfaceNormal
 bool bCheckedSurface
 bool bOnGround
 int numBio
 float wallTime

States
OnSurface, Exploding, Flying

Function Summary
 void PostBeginPlay()
 
simulated
SetWall(vector HitNormal, Actor Wall)
 void TakeDamage(int NDamage, Pawn instigatedBy, Vector hitlocation, vector momentum, name damageType)
 void Timer()


State OnSurface Function Summary
 void BeginState()
 void Timer()
 void ProcessTouch(Actor Other, vector HitLocation)


State Exploding Function Summary
 void BeginState()


State Flying Function Summary
 void BeginState()
 void Timer()
 void ProcessTouch(Actor Other, vector HitLocation)



Source Code


00001	//=============================================================================
00002	// BioGel.
00003	//=============================================================================
00004	class BioGel extends Projectile;
00005	
00006	#exec MESH IMPORT MESH=BioRGel ANIVFILE=MODELS\nGel_a.3D DATAFILE=MODELS\nGel_d.3D X=0 Y=0 Z=0
00007	#exec MESH ORIGIN MESH=BioRGel X=-45 Y=0 Z=0 YAW=0 PITCH=-64 ROLL=0
00008	
00009	#exec MESH SEQUENCE MESH=BioRGel SEQ=All     STARTFRAME=0   NUMFRAMES=56
00010	#exec MESH SEQUENCE MESH=BioRGel SEQ=Flying  STARTFRAME=0   NUMFRAMES=13
00011	#exec MESH SEQUENCE MESH=BioRGel SEQ=Still   STARTFRAME=13  NUMFRAMES=1
00012	#exec MESH SEQUENCE MESH=BioRGel SEQ=Hit     STARTFRAME=14  NUMFRAMES=10
00013	#exec MESH SEQUENCE MESH=BioRGel SEQ=Drip    STARTFRAME=24  NUMFRAMES=13
00014	#exec MESH SEQUENCE MESH=BioRGel SEQ=Slide   STARTFRAME=37  NUMFRAMES=7
00015	#exec MESH SEQUENCE MESH=BioRGel SEQ=Shrivel STARTFRAME=44  NUMFRAMES=12
00016	
00017	#exec TEXTURE IMPORT NAME=Jflare FILE=MODELS\flare.PCX
00018	#exec MESHMAP SCALE MESHMAP=BioRGel X=0.05 Y=0.05 Z=0.1
00019	#exec MESHMAP SETTEXTURE MESHMAP=BioRGel NUM=1 TEXTURE=Jflare
00020	
00021	#exec MESH NOTIFY MESH=BioRGel SEQ=Drip TIME=0.6 FUNCTION=DropDrip
00022	
00023	#exec AUDIO IMPORT FILE="sounds\general\explg02.wav" NAME="Explg02" GROUP="General"
00024	#exec AUDIO IMPORT FILE="..\Unreali\Sounds\BRifle\GelHit1.WAV" NAME="GelHit" GROUP="BioRifle"
00025	
00026	var vector SurfaceNormal;	
00027	var bool bOnGround;
00028	var bool bCheckedSurface;
00029	var int numBio;
00030	var float wallTime;
00031	var float BaseOffset;
00032	
00033	function PostBeginPlay()
00034	{
00035		SetTimer(3.0, false);
00036		Super.PostbeginPlay();
00037	}
00038		
00039	function Timer()
00040	{
00041		local GreenGelPuff f;
00042	
00043		f = spawn(class'GreenGelPuff',,,Location + SurfaceNormal*8); 
00044		f.DrawScale = DrawScale*2.0;
00045		f.numBlobs = numBio;
00046		if ( numBio > 0 )
00047			f.SurfaceNormal = SurfaceNormal;	
00048		PlaySound (MiscSound,,3.0*DrawScale);	
00049		if ( (Mover(Base) != None) && Mover(Base).bDamageTriggered )
00050			Base.TakeDamage( Damage, instigator, Location, MomentumTransfer * Normal(Velocity), '');
00051		
00052		HurtRadius(damage * Drawscale, DrawScale * 120, 'corroded', MomentumTransfer * Drawscale, Location);
00053		Destroy();	
00054	}
00055		
00056	simulated function SetWall(vector HitNormal, Actor Wall)
00057	{
00058		local vector TraceNorm, TraceLoc, Extent;
00059		local actor HitActor;
00060		local rotator RandRot;
00061	
00062		SurfaceNormal = HitNormal;
00063		RandRot = rotator(HitNormal);
00064		RandRot.Roll += 32768;
00065		SetRotation(RandRot);	
00066		if ( Mover(Wall) != None )
00067			SetBase(Wall);
00068	}
00069	
00070	singular function TakeDamage( int NDamage, Pawn instigatedBy, Vector hitlocation, 
00071							vector momentum, name damageType )
00072	{
00073		if ( damageType == 'Corroded' )
00074			numBio = 3;
00075		GoToState('Exploding');
00076	}
00077	
00078	auto state Flying
00079	{
00080		function ProcessTouch (Actor Other, vector HitLocation) 
00081		{ 
00082			if ( Pawn(Other)!=Instigator || bOnGround) 
00083				Global.Timer(); 
00084		}
00085	
00086		simulated function HitWall( vector HitNormal, actor Wall )
00087		{
00088			SetPhysics(PHYS_None);		
00089			MakeNoise(0.3);	
00090			bOnGround = True;
00091			PlaySound(ImpactSound);
00092			SetWall(HitNormal, Wall);
00093			PlayAnim('Hit');
00094			GoToState('OnSurface');
00095		}
00096	
00097	
00098		simulated function ZoneChange( Zoneinfo NewZone )
00099		{
00100			local waterring w;
00101			
00102			if (!NewZone.bWaterZone) Return;
00103		
00104			if (!bOnGround) 
00105			{
00106				w = Spawn(class'WaterRing',,,,rot(16384,0,0));
00107				w.DrawScale = 0.1;
00108			}
00109			bOnGround = True;
00110			Velocity=0.1*Velocity;
00111		}
00112	
00113		function Timer()
00114		{
00115			GotoState('Exploding');	
00116		}
00117	
00118		function BeginState()
00119		{	
00120			if ( Role == ROLE_Authority )
00121			{
00122				Velocity = Vector(Rotation) * Speed;
00123				Velocity.z += 120;
00124				if( Region.zone.bWaterZone )
00125					Velocity=Velocity*0.7;
00126			}
00127			if ( Level.NetMode != NM_DedicatedServer )
00128				RandSpin(100000);
00129			LoopAnim('Flying',0.4);
00130			bOnGround=False;
00131			PlaySound(SpawnSound);
00132		}
00133	}
00134	
00135	state Exploding
00136	{
00137		ignores Touch, TakeDamage;
00138	
00139		function BeginState()
00140		{
00141			SetTimer(0.1+FRand()*0.2, False);
00142		}
00143	}
00144	
00145	state OnSurface
00146	{
00147		function ProcessTouch (Actor Other, vector HitLocation)
00148		{
00149			GotoState('Exploding');
00150		}
00151	
00152		simulated function CheckSurface()
00153		{
00154			local float DotProduct;
00155	
00156			DotProduct = SurfaceNormal dot vect(0,0,-1);
00157			If( DotProduct > 0.7 )
00158				PlayAnim('Drip',0.1);
00159			else if (DotProduct > -0.5) 
00160				PlayAnim('Slide',0.2);
00161		}
00162	
00163		function Timer()
00164		{
00165			if ( Mover(Base) != None )
00166			{
00167				WallTime -= 0.2;
00168				if ( WallTime < 0.15 )
00169					Global.Timer();
00170				else if ( VSize(Location - Base.Location) > BaseOffset + 4 )
00171					Global.Timer();
00172			}
00173			else
00174				Global.Timer();
00175		}
00176	
00177		function BeginState()
00178		{
00179			wallTime = DrawScale*3+1;
00180			
00181			if ( Mover(Base) != None )
00182			{
00183				BaseOffset = VSize(Location - Base.Location);
00184				SetTimer(0.2, true);
00185			}
00186			else 
00187				SetTimer(wallTime, false);
00188		}
00189	
00190		simulated function AnimEnd()
00191		{
00192			if ( !bCheckedSurface && (DrawScale > 1.0) )
00193				CheckSurface();
00194	
00195			bCheckedSurface = true;
00196		}
00197	}
00198	
00199	defaultproperties
00200	{
00201	     numBio=7
00202	     speed=800.000000
00203	     MaxSpeed=1500.000000
00204	     Damage=40.000000
00205	     MomentumTransfer=20000
00206	     ImpactSound=Sound'UnrealShare.BioRifle.GelHit'
00207	     MiscSound=Sound'UnrealShare.General.Explg02'
00208	     bNetTemporary=False
00209	     Physics=PHYS_Falling
00210	     RemoteRole=ROLE_SimulatedProxy
00211	     LifeSpan=12.000000
00212	     AnimSequence=Flying
00213	     Mesh=LodMesh'UnrealShare.BioRGel'
00214	     bUnlit=True
00215	     CollisionRadius=2.000000
00216	     CollisionHeight=2.000000
00217	     bProjTarget=True
00218	     LightType=LT_Steady
00219	     LightEffect=LE_NonIncidence
00220	     LightBrightness=70
00221	     LightHue=91
00222	     LightRadius=3
00223	     bBounce=True
00224	     Buoyancy=170.000000
00225	}

End Source Code