UnrealShare
Class BabyCow

source: e:\games\UnrealTournament\UnrealShare\Classes\BabyCow.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Pawn
         |
         +--UnrealShare.ScriptedPawn
            |
            +--UnrealShare.Cow
               |
               +--UnrealShare.BabyCow
Direct Known Subclasses:None

class BabyCow
extends UnrealShare.Cow

//============================================================================= // BabyCow. // Don't add to world directly. Rather, set bHasBaby of an adult cow. //=============================================================================
Variables
 Cow mom

States
Grazing

Function Summary
 void FollowMom()
 void PlayRunning()
 void PlayWalking()


State Grazing Function Summary
 void PickDestination()
 void Bump(Actor Other)
 void TakeDamage(int Damage, Pawn instigatedBy, Vector hitlocation, Vector momentum, name damageType)



Source Code


00001	//=============================================================================
00002	// BabyCow.
00003	// Don't add to world directly.  Rather, set bHasBaby of an adult cow.
00004	//=============================================================================
00005	class BabyCow extends Cow;
00006	
00007	var Cow mom;
00008	
00009	function PlayRunning()
00010	{
00011		LoopAnim('Run', -1.5/GroundSpeed,,0.3);
00012	}
00013	
00014	function PlayWalking()
00015	{
00016		LoopAnim('Walk', -2.0/GroundSpeed,,0.3);
00017	}
00018	
00019	function FollowMom()
00020	{
00021		Disable('AnimEnd');
00022		GotoState('Grazing', 'Wander');
00023	}
00024					
00025	
00026	state Grazing
00027	{
00028		
00029		function TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation, 
00030							Vector momentum, name damageType)
00031		{
00032			Mom.Help(self);
00033			Global.TakeDamage(Damage, instigatedBy, hitlocation, momentum, damageType);
00034			if ( health <= 0 )
00035				return;
00036			if ( NextState == 'TakeHit' )
00037				{
00038				NextState = 'Attacking'; 
00039				NextLabel = 'Begin';
00040				GotoState('TakeHit'); 
00041				}
00042			else
00043				GotoState('Attacking');
00044		}
00045	
00046		function Bump(actor Other)
00047		{
00048			if ( (Pawn(Other)!= None) && (Cow(Other) == None) && (MoveTimer < 0) )
00049				GotoState('Grazing', 'Wander');	
00050			else if ( (Normal(Destination - Location) Dot Normal(Other.Location - Location)) > 0.8 )
00051				MoveTimer = -1.0;
00052			Disable('Bump');
00053		}
00054		
00055		function PickDestination()
00056		{
00057			if ( Mom == None )
00058				Super.PickDestination();
00059			if ( !LineOfSightTo(mom) )
00060			{
00061				MoveTarget = FindPathToward(mom);
00062				if ( MoveTarget != None )
00063				{
00064					Destination = MoveTarget.Location;
00065					return;
00066				}
00067			}		
00068			if (ScaryGuy != None)
00069				Destination = mom.Destination - 2 * mom.CollisionRadius * Normal(ScaryGuy.Location - mom.Destination);
00070			else
00071				Destination = mom.Destination;
00072		}
00073	
00074	Begin:
00075		//log(class$" Grazing");
00076	
00077	Wander: 
00078		if (!bForage)
00079			Goto('Graze');
00080		PickDestination();
00081		TweenToWalking(0.2);
00082		FinishAnim();
00083		PlayWalking();
00084		
00085	Moving:
00086		Enable('HitWall');
00087		Enable('Bump');
00088		MoveTo(Destination, 0.4);
00089		Acceleration = vect(0,0,0);
00090	Graze:
00091		Enable('AnimEnd');
00092		NextAnim = '';
00093		TweenToPatrolStop(0.2);
00094		Sleep(4);
00095		Disable('AnimEnd');
00096		FinishAnim();
00097		Goto('Wander');
00098	
00099	ContinueWander:
00100		FinishAnim();
00101		PlayWalking();
00102		Goto('Wander');
00103	
00104	Turn:
00105		PlayTurning();
00106		TurnToward(Mom);
00107		Goto('Graze');	
00108	}
00109	
00110	defaultproperties
00111	{
00112	     Health=40
00113	     DrawScale=0.500000
00114	     CollisionRadius=24.000000
00115	     CollisionHeight=16.000000
00116	     Mass=70.000000
00117	}

End Source Code