RuneI
Class DealieFish

source: c:\runehov\RuneI\Classes\DealieFish.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Pawn
         |
         +--RuneI.FlockPawn
            |
            +--RuneI.DealieFish
Direct Known Subclasses:None

class DealieFish
extends RuneI.FlockPawn

//============================================================================= // DealieFish. // Do not add directly - rather add DealieFishSchools to the world //=============================================================================
Variables
 float AirTime
 Actor Glow
 vector OldSchoolDestination
 DealieFishSchool School
 vector SchoolOffset
 bool bGlowing

States
Dying, Flopping, Swimming

Function Summary
 void Died(Pawn Killer, name damageType, vector HitLocation)
 void FootZoneChange(ZoneInfo newFootZone)
 bool JointDamaged(int Damage, Pawn instigatedBy, Vector hitlocation, Vector momentum, name damageType, int joint)
 void Landed(vector HitNormal, Actor HitActor)
 Texture PainSkin(int BodyPart)
 void PostBeginPlay()
 void PreSetMovement()
 void ZoneChange(ZoneInfo NewZone)


State Dying Function Summary
 void Timer()
 void Landed(vector HitNormal, Actor HitActor)


State Flopping Function Summary
 void BeginState()
 void AnimEnd()
 void Timer()
 void Landed(vector HitNormal, Actor HitActor)


State Swimming Function Summary
 void Touch(Actor Other)
     
/*
	
 void PickDestination()
 void Timer()
 void BeginState()



Source Code


00001	//=============================================================================
00002	// DealieFish.
00003	// Do not add directly - rather add DealieFishSchools to the world
00004	//=============================================================================
00005	class DealieFish extends FlockPawn;
00006	
00007	
00008	var float AirTime;
00009	var vector OldSchoolDestination;
00010	var DealieFishSchool School;
00011	var bool bGlowing;
00012	var actor Glow;
00013	
00014	var vector SchoolOffset;
00015	
00016	
00017	function PostBeginPlay()
00018	{
00019		School = DealieFishSchool(Owner); 
00020		Super.PostBeginPlay();
00021		if ( School == None )
00022		{
00023			log("Warning - can't add Dealiefish independently from Dealiefish schools");
00024			destroy();
00025		}
00026		else
00027		{
00028			SchoolOffset.X = -FRand() * School.SchoolRadius;
00029			SchoolOffset.Y = (FRand() - 0.5) * School.SchoolRadius;
00030			SchoolOffset.Z = (FRand() - 0.5) * School.SchoolRadius;
00031		}
00032	}
00033	
00034	function Texture PainSkin(int BodyPart)
00035	{
00036	}
00037	
00038	function bool JointDamaged( int Damage, Pawn instigatedBy, Vector hitlocation, 
00039							Vector momentum, name damageType, int joint)
00040	{
00041		local bool bAlreadyDead;
00042	
00043		bAlreadyDead = (Health <= 0);
00044	
00045		if (Physics == PHYS_None)
00046			SetMovementPhysics();
00047		if (Physics == PHYS_Walking)
00048			momentum.Z = 0.4 * Vsize(momentum);
00049		if ( instigatedBy == self )
00050			momentum *= 0.6;
00051		momentum = momentum/Mass;
00052		AddVelocity( momentum ); 
00053		Health -= Damage;
00054		if ( Health < -20 )
00055		{
00056	//		Spawn(class'Bloodspurt');
00057	//		Destroy();
00058			school.ReplentishOne();
00059			SetPhysics(PHYS_None);
00060			SetCollision(false, false, false);
00061			Destroy();
00062		}
00063		else if ( !bAlreadyDead && (Health < 0) )
00064			Died(instigatedBy, damageType, hitLocation);
00065		return true;
00066	}
00067	
00068	function Landed(vector HitNormal, actor HitActor)
00069	{
00070		local rotator newRotation;
00071	
00072		SetPhysics(PHYS_None);
00073		SetTimer(0.2 + FRand(), false);
00074		newRotation = Rotation;
00075		newRotation.Pitch = 0;
00076		newRotation.Roll = 16384;
00077		SetRotation(newRotation);
00078		GotoState('Flopping');
00079	}
00080	
00081	function PreSetMovement()
00082	{
00083		bCanSwim = true;
00084		if (Region.Zone.bWaterZone)
00085			SetPhysics(PHYS_Swimming);
00086		else
00087			SetPhysics(PHYS_Falling);
00088		MinHitWall = -0.6;
00089	}
00090	
00091	function ZoneChange( ZoneInfo NewZone )
00092	{
00093		local rotator newRotation;
00094		if (NewZone.bWaterZone)
00095		{
00096			if ( !Region.Zone.bWaterZone && (Physics != PHYS_Swimming) )
00097			{
00098				newRotation = Rotation;
00099				newRotation.Roll = 0;
00100				SetRotation(newRotation);
00101				MoveTimer = -1.0;
00102			}
00103			AirTime = 0;
00104			SetPhysics(PHYS_Swimming);
00105			if ( !IsInState('Swimming') ) 
00106				GotoState('Swimming');
00107		}
00108		else if (Physics != PHYS_Falling)
00109		{
00110			MoveTimer = -1;
00111			SetPhysics(PHYS_Falling);
00112		}
00113	}
00114	
00115	function FootZoneChange(ZoneInfo newFootZone)
00116	{
00117		if ( (Level.TimeSeconds - SplashTime > 3) && 
00118		 	!FootRegion.Zone.bWaterZone && newFootZone.bWaterZone )
00119		{
00120			SplashTime = Level.TimeSeconds;
00121	//		PlaySound(sound 'LSplash', SLOT_Interact, 0.4,,500);
00122	//		Spawn(class 'WaterImpact',,,Location - CollisionHeight * vect(0,0,1));
00123		}
00124		
00125		if ( FootRegion.Zone.bPainZone )
00126		{
00127			if ( !newFootZone.bPainZone )
00128				PainTime = -1.0;
00129		}
00130		else if (newFootZone.bPainZone)
00131			PainTime = 0.01;
00132	}
00133	
00134	function Died(pawn Killer, name damageType, vector HitLocation)
00135	{
00136		local rotator newRot;
00137	
00138		newRot = Rotation;
00139		if ( FRand() < 0.5 )
00140			newRot.Roll = 16384;
00141		else 
00142			newRot.Roll = -16384;
00143		SetRotation(newRot);
00144		SetPhysics(PHYS_Falling);
00145		SetCollision(true,false,false);
00146		Buoyancy = 1.05 * mass;
00147		Velocity.Z = FMax(0, Velocity.Z);
00148		AnimRate = 0.0;
00149	
00150		school.FishDied();
00151		RemoteRole = ROLE_DumbProxy;
00152		GotoState('Dying');
00153	}
00154	
00155	Auto State Swimming
00156	{
00157		function BeginState()
00158		{
00159			SetTimer(1, false);
00160		}
00161	
00162		function Timer()
00163		{
00164			if(bGlowing)
00165			{
00166				bGlowing = false;
00167				if(Glow != None)
00168				{
00169					Glow.bHidden = true;
00170					SetTimer(2.5 + FRand(), false);
00171				}
00172			}
00173			else
00174			{
00175				bGlowing = true;
00176				if(Glow == None)
00177				{
00178					Glow = Spawn(Class'DealieLight');
00179					AttachActorToJoint(Glow, JointNamed('head'));
00180				}
00181	
00182				Glow.bHidden = false;
00183				Glow.DrawScale = 0.15 + FRand() * 0.1;			
00184	
00185				SetTimer(0.5 + FRand(), false);
00186			}
00187		}
00188	
00189		function PickDestination()
00190		{
00191			local vector vec;
00192			local rotator rot;
00193			local vector X, Y, Z;
00194	
00195			if(School == None)
00196				return;
00197	
00198			if(School.IsInState('Stasis') && !PlayerCanSeeMe())
00199			{
00200				School.Remove(self);
00201				return;
00202			}
00203	
00204			vec = Normal(School.Location - OldSchoolDestination);
00205			rot = rotator(vec);
00206			OldSchoolDestination = School.Location;
00207	
00208			GetAxes(rot, X, Y, Z);
00209			Destination = School.Location + X * SchoolOffset.X + Y * SchoolOffset.Y + Z * SchoolOffset.Z;
00210					
00211	/*
00212			if ( School.validDest )
00213				OldSchoolDestination = School.Location;
00214			Destination = OldSchoolDestination +
00215				 0.5 * School.schoolradius * ( Normal(Location - School.Location) + VRand());
00216	*/
00217		}
00218	/*
00219		function Touch(Actor Other)
00220		{
00221			if ( Pawn(Other) == School.Enemy )
00222				Other.TakeDamage(2, self, location, vect(0,0,0), 'bitten');
00223		}
00224	*/		
00225	Begin:
00226		Disable('Touch');
00227	//	if (!Region.Zone.bWaterZone)
00228	//		GotoState('Flopping');
00229		SetPhysics(PHYS_Swimming);
00230	Swim:
00231		Enable('HitWall');
00232		LoopAnim('Swim', 0.7 + FRand());
00233	
00234		PickDestination();
00235		MoveTo(Destination);
00236	School:
00237		if(School != None)
00238		{
00239			if((FRand() < 0.85) && (OldSchoolDestination == School.Location) 
00240				&& ((School.Enemy == None) || !School.Enemy.Region.Zone.bWaterZone) 
00241				&& !School.IsInState('SplinePath'))
00242			{
00243				Velocity = vect(0,0,0);
00244				Acceleration = vect(0,0,0);
00245				Sleep(1.5 * FRand()); // was 3.3
00246				Goto('School');
00247			}
00248	
00249			if(!School.IsInState('SplinePath'))
00250			{
00251				Velocity = vect(0,0,0);
00252				Acceleration = vect(0,0,0);
00253				Sleep(0.7 * FRand());
00254			}
00255		}
00256	
00257		Goto('Swim');
00258	}
00259	
00260	State Flopping
00261	{
00262	
00263		function Landed(vector HitNormal, actor HitActor)
00264		{
00265			local rotator newRotation;
00266	
00267			SetPhysics(PHYS_None);
00268			SetTimer(0.3 + 0.3 * AirTime * FRand(), false);
00269			newRotation = Rotation;
00270			newRotation.Pitch = 0;
00271			newRotation.Roll = 16384;
00272			SetRotation(newRotation);
00273		}
00274			
00275		function Timer()
00276		{
00277			AirTime += 1;
00278			if (AirTime > 25 + 20 * FRand())
00279				GotoState('Dying');
00280			else
00281			{
00282				SetPhysics(PHYS_Falling);
00283				Velocity = 200 * VRand();
00284				Velocity.Z = 60 + 160 * FRand();
00285				DesiredRotation.Pitch = Rand(8192) - 4096;
00286				DesiredRotation.Yaw = Rand(65535);
00287			}		
00288		}
00289	
00290		function AnimEnd()
00291		{
00292			PlayAnim('Swim', 0.1 * FRand());
00293		}
00294	
00295		function BeginState()
00296		{
00297			SetPhysics(PHYS_Falling);
00298		}
00299	}
00300	
00301	State Dying
00302	{
00303		ignores zonechange, headzonechange, falling, hitwall;
00304	
00305		function Landed(vector HitNormal, actor HitActor)
00306		{
00307			SetPhysics(PHYS_None);
00308		}	
00309	
00310		function Timer()
00311		{
00312			if ( !PlayerCanSeeMe() )
00313				Destroy();
00314		}
00315	
00316	Begin:
00317		Sleep(12);
00318		SetTimer(4.0, true);
00319	}			
00320			
00321	
00322	simulated function Debug(canvas Canvas, int mode)
00323	{
00324		Canvas.DrawText("Dealie: ");
00325		Canvas.CurY -= 8;
00326		Canvas.DrawText(" SchoolSize: "$School.SchoolSize);
00327		Canvas.CurY -= 8;
00328		Canvas.DrawText(" ActiveFish: "$School.ActiveFish);
00329		Canvas.CurY -= 8;
00330	}
00331	
00332	defaultproperties
00333	{
00334	     bCanStrafe=True
00335	     WaterSpeed=250.000000
00336	     AccelRate=700.000000
00337	     SightRadius=3000.000000
00338	     Health=5
00339	     ReducedDamageType=exploded
00340	     ReducedDamagePct=0.900000
00341	     UnderWaterTime=-1.000000
00342	     DrawType=DT_SkeletalMesh
00343	     DrawScale=2.500000
00344	     LODDistMax=500.000000
00345	     LODCurve=LOD_CURVE_ULTRA_AGGRESSIVE
00346	     bPointLight=True
00347	     TransientSoundRadius=800.000000
00348	     CollisionRadius=8.000000
00349	     CollisionHeight=6.000000
00350	     bCollideActors=False
00351	     bBlockActors=False
00352	     bBlockPlayers=False
00353	     bProjTarget=False
00354	     Buoyancy=5.000000
00355	     RotationRate=(Pitch=8192,Yaw=128000,Roll=16384)
00356	     Skeletal=SkelModel'creatures.dealie'
00357	}

End Source Code