UnrealI
Class Pupae

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

class Pupae
extends UnrealShare.ScriptedPawn

//============================================================================= // Pupae. //=============================================================================
Variables
 byte BiteDamage
           Basic damage done by bite.
 byte LungeDamage
           Basic damage done by bite.

States
Waiting, StartUp, MeleeAttack

Function Summary
 eAttitude AttitudeToCreature(Pawn Other)
 void JumpOffPawn()
 void PlayChallenge()
 void PlayDying(name DamageType, vector HitLocation)
 void PlayMeleeAttack()
 void PlayPatrolStop()
 void PlayRunning()
 void PlayTakeHit(float tweentime, vector HitLoc, int damage)
 void PlayThreatening()
 void PlayTurning()
 void PlayVictoryDance()
 void PlayWaiting()
 void PlayWaitingAmbush()
 void PlayWalking()
 void PostBeginPlay()
     
//-----------------------------------------------------------------------------
// Pupae functions.
 void SetMovementPhysics()
 void TweenToFighter(float tweentime)
 void TweenToPatrolStop(float tweentime)
 void TweenToRunning(float tweentime)
 void TweenToWaiting(float tweentime)
 void TweenToWalking(float tweentime)


State Waiting Function Summary


State StartUp Function Summary
 void SetMovementPhysics()


State MeleeAttack Function Summary
 void Bump(Actor Other)



Source Code


00001	//=============================================================================
00002	// Pupae.
00003	//=============================================================================
00004	class Pupae extends ScriptedPawn;
00005	
00006	#exec MESH IMPORT MESH=Pupae1 ANIVFILE=MODELS\pupae_a.3D DATAFILE=MODELS\pupae_d.3D X=0 Y=0 Z=0
00007	#exec MESH ORIGIN MESH=Pupae1 X=0 Y=0 Z=-90 YAW=64 PITCH=0 ROLL=-64
00008	
00009	#exec MESH SEQUENCE MESH=pupae1 SEQ=All		 STARTFRAME=0	 NUMFRAMES=171
00010	#exec MESH SEQUENCE MESH=pupae1 SEQ=Bite     STARTFRAME=0    NUMFRAMES=15  RATE=15  Group=Attack
00011	#exec MESH SEQUENCE MESH=pupae1 SEQ=Crawl    STARTFRAME=15   NUMFRAMES=20  RATE=20
00012	#exec MESH SEQUENCE MESH=pupae1 SEQ=Dead     STARTFRAME=35   NUMFRAMES=18  RATE=15
00013	#exec MESH SEQUENCE MESH=pupae1 SEQ=TakeHit  STARTFRAME=36   NUMFRAMES=1
00014	#exec MESH SEQUENCE MESH=pupae1 SEQ=Fighter  STARTFRAME=53   NUMFRAMES=6   RATE=6
00015	#exec MESH SEQUENCE MESH=pupae1 SEQ=Lunge    STARTFRAME=59   NUMFRAMES=15  RATE=15  Group=Attack
00016	#exec MESH SEQUENCE MESH=pupae1 SEQ=Munch    STARTFRAME=74   NUMFRAMES=8   RATE=15
00017	#exec MESH SEQUENCE MESH=pupae1 SEQ=Pick     STARTFRAME=82   NUMFRAMES=10  RATE=15
00018	#exec MESH SEQUENCE MESH=pupae1 SEQ=Stab     STARTFRAME=92   NUMFRAMES=10  RATE=15  Group=Attack
00019	#exec MESH SEQUENCE MESH=pupae1 SEQ=Tear     STARTFRAME=102  NUMFRAMES=28  RATE=15
00020	#exec MESH SEQUENCE MESH=pupae1 SEQ=Dead2    STARTFRAME=130  NUMFRAMES=18  RATE=15
00021	#exec MESH SEQUENCE MESH=pupae1 SEQ=Dead3    STARTFRAME=148  NUMFRAMES=23  RATE=15
00022	
00023	#exec TEXTURE IMPORT NAME=JPupae1 FILE=MODELS\pupae.PCX GROUP=Skins 
00024	#exec MESHMAP SCALE MESHMAP=pupae1 X=0.05 Y=0.05 Z=0.1
00025	#exec MESHMAP SETTEXTURE MESHMAP=pupae1 NUM=1 TEXTURE=Jpupae1
00026	
00027	#exec MESH NOTIFY MESH=Pupae1 SEQ=Dead TIME=0.52 FUNCTION=LandThump
00028	
00029	#exec AUDIO IMPORT FILE="Sounds\Pupae\scuttle1.WAV" NAME="scuttle1pp" GROUP="Pupae"
00030	#exec AUDIO IMPORT FILE="Sounds\Pupae\injur1.WAV" NAME="injur1pp" GROUP="Pupae"
00031	#exec AUDIO IMPORT FILE="Sounds\Pupae\injur2.WAV" NAME="injur2pp" GROUP="Pupae"
00032	#exec AUDIO IMPORT FILE="Sounds\Pupae\roam1.WAV" NAME="roam1pp" GROUP="Pupae"
00033	#exec AUDIO IMPORT FILE="Sounds\Pupae\hiss1.WAV" NAME="hiss1pp" GROUP="Pupae"
00034	#exec AUDIO IMPORT FILE="Sounds\Pupae\hiss2.WAV" NAME="hiss2pp" GROUP="Pupae"
00035	#exec AUDIO IMPORT FILE="Sounds\Pupae\hiss3.WAV" NAME="hiss3pp" GROUP="Pupae"
00036	#exec AUDIO IMPORT FILE="Sounds\Pupae\bite1pp.WAV" NAME="bite1pp" GROUP="Pupae"
00037	#exec AUDIO IMPORT FILE="Sounds\Pupae\tear1b.WAV" NAME="tear1pp" GROUP="Pupae"
00038	#exec AUDIO IMPORT FILE="Sounds\Pupae\munch1pp.WAV" NAME="munch1p" GROUP="Pupae"
00039	#exec AUDIO IMPORT FILE="Sounds\Pupae\death1b.WAV" NAME="death1pp" GROUP="Pupae"
00040	
00041	//-----------------------------------------------------------------------------
00042	// Pupae variables.
00043	
00044	// Attack damage.
00045	var() byte BiteDamage;		// Basic damage done by bite.
00046	var() byte LungeDamage;		// Basic damage done by bite.
00047	var(Sounds) sound bite;
00048	var(Sounds) sound stab;
00049	var(Sounds) sound lunge;
00050	var(Sounds) sound chew;
00051	var(Sounds) sound tear;
00052	 
00053	//-----------------------------------------------------------------------------
00054	// Pupae functions.
00055	
00056	function PostBeginPlay()
00057	{
00058		Super.PostBeginPlay();
00059		MaxDesiredSpeed = 0.7 + 0.1 * skill;
00060	}
00061	
00062	function JumpOffPawn()
00063	{
00064		Super.JumpOffPawn();
00065		PlayAnim('crawl', 1.0, 0.2);
00066	}
00067	
00068	function SetMovementPhysics()
00069	{
00070		SetPhysics(PHYS_Falling); 
00071	}
00072	
00073	function eAttitude AttitudeToCreature(Pawn Other)
00074	{
00075		if ( Other.IsA('Pupae') )
00076			return ATTITUDE_Friendly;
00077		else if ( Other.IsA('Skaarj') )
00078		{
00079			if ( Other.IsA('SkaarjBerserker') )
00080				return ATTITUDE_Ignore;
00081			else
00082				return ATTITUDE_Friendly;
00083		}
00084		else if ( Other.IsA('WarLord') || Other.IsA('Queen') )
00085			return ATTITUDE_Friendly;
00086		else if ( Other.IsA('ScriptedPawn') )
00087			return ATTITUDE_Hate;
00088	}
00089	
00090	function PlayWaiting()
00091		{
00092		local float decision;
00093		local float animspeed;
00094		animspeed = 0.4 + 0.6 * FRand(); 
00095		decision = FRand();
00096		if ( !bool(NextAnim) || (decision < 0.4) ) //pick first waiting animation
00097		{
00098			if ( !bQuiet )
00099				PlaySound(Chew, SLOT_Talk, 0.7,,800);
00100			NextAnim = 'Munch';
00101		}
00102		else if (decision < 0.55)
00103			NextAnim = 'Pick';
00104		else if (decision < 0.7)
00105		{
00106			if ( !bQuiet )
00107				PlaySound(Stab, SLOT_Talk, 0.7,,800);
00108			NextAnim = 'Stab';
00109		}
00110		else if (decision < 0.7)
00111			NextAnim = 'Bite';
00112		else 
00113			NextAnim = 'Tear';
00114			
00115		LoopAnim(NextAnim, animspeed);
00116		}
00117	
00118	function PlayPatrolStop()
00119	{
00120		PlayWaiting();
00121	}
00122	
00123	function PlayWaitingAmbush()
00124	{
00125		PlayWaiting();
00126	}
00127	
00128	function PlayChallenge()
00129	{
00130		if ( FRand() < 0.3 )
00131			PlayWaiting();
00132		else
00133			PlayAnim('Fighter');
00134	}
00135	
00136	function TweenToFighter(float tweentime)
00137	{
00138		TweenAnim('Fighter', tweentime);
00139	}
00140	
00141	function TweenToRunning(float tweentime)
00142	{
00143		if (AnimSequence != 'Crawl' || !bAnimLoop)
00144			TweenAnim('Crawl', tweentime);
00145	}
00146	
00147	function TweenToWalking(float tweentime)
00148	{
00149		TweenAnim('Crawl', tweentime);
00150	}
00151	
00152	function TweenToWaiting(float tweentime)
00153	{
00154		TweenAnim('Munch', tweentime);
00155	}
00156	
00157	function TweenToPatrolStop(float tweentime)
00158	{
00159		TweenAnim('Munch', tweentime);
00160	}
00161	
00162	function PlayRunning()
00163	{
00164		PlaySound(sound'scuttle1pp', SLOT_Interact);
00165		LoopAnim('Crawl', -4.0/GroundSpeed,,0.4);
00166	}
00167	
00168	function PlayWalking()
00169	{
00170		PlaySound(sound'scuttle1pp', SLOT_Interact);
00171		LoopAnim('Crawl', -4.0/GroundSpeed,,0.4);
00172	}
00173	
00174	function PlayThreatening()
00175	{
00176		PlayWaiting();
00177	}
00178	
00179	function PlayTurning()
00180	{
00181		TweenAnim('Crawl', 0.3);
00182	}
00183	
00184	function PlayDying(name DamageType, vector HitLocation)
00185	{
00186		local carcass carc;
00187	
00188		PlaySound(Die, SLOT_Talk, 3.5 * TransientSoundVolume);
00189		if ( FRand() < 0.35 )
00190			PlayAnim('Dead', 0.7, 0.1);
00191		else if ( FRand() < 0.5 )
00192		{
00193			carc = Spawn(class 'CreatureChunks',,, Location + CollisionHeight * vect(0,0,0.8), Rotation + rot(3000,0,16384) );
00194			if (carc != None)
00195			{
00196				carc.Mesh = mesh'PupaeHead';
00197				carc.Initfor(self);
00198				carc.Velocity = Velocity + VSize(Velocity) * VRand();
00199				carc.Velocity.Z = FMax(carc.Velocity.Z, Velocity.Z);
00200			}
00201			PlayAnim('Dead2', 0.7, 0.1);
00202		}
00203		else
00204		{
00205			carc = Spawn(class 'CreatureChunks',,, Location + CollisionHeight * vect(0,0,0.8), Rotation + rot(3000,0,16384) );
00206			if (carc != None)
00207			{
00208				carc.Mesh = mesh'PupaeBody';
00209				carc.Initfor(self);
00210				carc.Velocity = Velocity + VSize(Velocity) * VRand();
00211				carc.Velocity.Z = FMax(carc.Velocity.Z, Velocity.Z);
00212			}
00213			PlayAnim('Dead3', 0.7, 0.1);
00214		}
00215	}
00216	
00217	function PlayTakeHit(float tweentime, vector HitLoc, int damage)
00218	{
00219		PlayAnim('TakeHit');
00220	}
00221	
00222	function PlayVictoryDance()
00223	{
00224		PlayAnim('Stab', 1.0, 0.1);
00225	}
00226	
00227	function PlayMeleeAttack()
00228	{
00229		local float dist, decision;
00230	
00231		decision = FRand();
00232		dist = VSize(Target.Location - Location);
00233		if (dist > CollisionRadius + Target.CollisionRadius + 45)
00234			decision = 0.0;
00235	
00236		if (Physics == PHYS_Falling)
00237			decision = 1.0;
00238		if (Target == None)
00239			decision = 1.0;
00240	
00241		if (decision < 0.15)
00242		{
00243			PlaySound(Lunge, SLOT_Interact);
00244			Enable('Bump');
00245			PlayAnim('Lunge');
00246			Velocity = 450 * Normal(Target.Location + Target.CollisionHeight * vect(0,0,0.75) - Location);
00247			if (dist > CollisionRadius + Target.CollisionRadius + 35)
00248				Velocity.Z += 0.7 * dist;
00249			SetPhysics(PHYS_Falling);
00250		}
00251	  	else
00252	  	{
00253	  		PlaySound(Stab, SLOT_Interact);
00254	  		PlayAnim('Stab');
00255			MeleeRange = 50;
00256			MeleeDamageTarget(BiteDamage, vect(0,0,0));
00257			MeleeRange = Default.MeleeRange;
00258		}  		
00259	}
00260	
00261	state MeleeAttack
00262	{
00263	ignores SeePlayer, HearNoise;
00264	
00265		singular function Bump(actor Other)
00266		{
00267			Disable('Bump');
00268			if ( (Other == Target) && (AnimSequence == 'Lunge') )
00269				if (MeleeDamageTarget(LungeDamage, vect(0,0,0)))
00270				{
00271					if (FRand() < 0.5)
00272						PlaySound(Tear, SLOT_Interact);
00273					else
00274						PlaySound(Bite, SLOT_Interact);
00275				}
00276		}
00277	}		
00278	
00279	auto state StartUp
00280	{
00281		function SetMovementPhysics()
00282		{
00283			SetPhysics(PHYS_None); // don't fall at start
00284		}
00285	}
00286	
00287	
00288	state Waiting
00289	{
00290	TurnFromWall:
00291		if ( NearWall(70) )
00292		{
00293			PlayTurning();
00294			TurnTo(Focus);
00295		}
00296	Begin:
00297		TweenToWaiting(0.4);
00298		bReadyToAttack = false;
00299		if (Physics != PHYS_Falling) 
00300			SetPhysics(PHYS_None);
00301	KeepWaiting:
00302		NextAnim = '';
00303	}
00304	
00305	defaultproperties
00306	{
00307	     BiteDamage=10
00308	     LungeDamage=20
00309	     Bite=Sound'UnrealI.Pupae.bite1pp'
00310	     Stab=Sound'UnrealI.Pupae.hiss1pp'
00311	     lunge=Sound'UnrealI.Pupae.hiss2pp'
00312	     Chew=Sound'UnrealI.Pupae.munch1p'
00313	     Tear=Sound'UnrealI.Pupae.tear1pp'
00314	     CarcassType=Class'UnrealI.PupaeCarcass'
00315	     Aggressiveness=10.000000
00316	     Acquire=Sound'UnrealI.Pupae.hiss2pp'
00317	     Fear=Sound'UnrealI.Pupae.hiss1pp'
00318	     Roam=Sound'UnrealI.Pupae.roam1pp'
00319	     Threaten=Sound'UnrealI.Pupae.hiss3pp'
00320	     bCanStrafe=True
00321	     MeleeRange=280.000000
00322	     GroundSpeed=260.000000
00323	     WaterSpeed=100.000000
00324	     JumpZ=340.000000
00325	     Visibility=100
00326	     SightRadius=3000.000000
00327	     PeripheralVision=-0.400000
00328	     Health=65
00329	     Intelligence=BRAINS_NONE
00330	     HitSound1=Sound'UnrealI.Pupae.injur1pp'
00331	     HitSound2=Sound'UnrealI.Pupae.injur2pp'
00332	     Die=Sound'UnrealI.Pupae.death1pp'
00333	     CombatStyle=1.000000
00334	     DrawType=DT_Mesh
00335	     Mesh=LodMesh'UnrealI.Pupae1'
00336	     CollisionRadius=28.000000
00337	     CollisionHeight=9.000000
00338	     Mass=80.000000
00339	     RotationRate=(Pitch=3072,Yaw=65000,Roll=0)
00340	}

End Source Code