Botpack
Class UT_BioGel

source: e:\games\UnrealTournament\Botpack\Classes\UT_BioGel.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Projectile
         |
         +--Botpack.UT_BioGel
Direct Known Subclasses:BioGlob, BioSplash

class UT_BioGel
extends Engine.Projectile

//============================================================================= // ut_BioGel. //=============================================================================
Variables
 float BaseOffset
 BioFear MyFear
 vector SurfaceNormal
 bool bCheckedSurface
 bool bOnGround
 int numBio
 float wallTime

States
OnSurface, Exploding, Flying

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

End Source Code