UnrealShare
Class Slith

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

class Slith
extends UnrealShare.ScriptedPawn

//============================================================================= // Slith. //=============================================================================
Variables
 byte ClawDamage
           Basic damage done by Claw/punch.
 bool bFirstAttack
           Basic damage done by Claw/punch.

States
MeleeAttack

Function Summary
 eAttitude AttitudeToCreature(Pawn Other)
 bool CanFireAtEnemy()
 void ClawDamageTarget()
 void JumpOutOfWater(vector jumpDir)
 void PlayAcquisitionSound()
 void PlayChallenge()
 void PlayDive()
 void PlayDying(name DamageType, vector HitLocation)
 void PlayInAir()
 void PlayLanded(float impactVel)
 void PlayMeleeAttack()
 void PlayMovingAttack()
 void PlayOutOfWater()
 void PlayPatrolStop()
 void PlayRangedAttack()
 void PlayRunning()
 void PlayTakeHit(float tweentime, vector HitLoc, int Damage)
 void PlayThreatening()
 void PlayTurning()
 void PlayVictoryDance()
 void PlayWaiting()
 void PlayWaitingAmbush()
 void PlayWalking()
 void PreSetMovement()
     
/* PreSetMovement()
default for walking creature.  Re-implement in subclass
for swimming/flying capability
*/
 void SetFall()
 void SetMovementPhysics()
 void ShootTarget()
 void TweenToFalling()
 void TweenToFighter(float tweentime)
 void TweenToPatrolStop(float tweentime)
 void TweenToRunning(float tweentime)
 void TweenToWaiting(float tweentime)
 void TweenToWalking(float tweentime)


State MeleeAttack Function Summary
 void EndState()
 void BeginState()
 void PlayMeleeAttack()



Source Code


00001	//=============================================================================
00002	// Slith.
00003	//=============================================================================
00004	class Slith extends ScriptedPawn;
00005	
00006	#exec MESH IMPORT MESH=Slith1 ANIVFILE=MODELS\slith_a.3D DATAFILE=MODELS\slith_d.3D ZEROTEX=1 LODSTYLE=2
00007	#exec MESH ORIGIN MESH=Slith1 X=0 Y=60 Z=50 YAW=64 ROLL=-64
00008	
00009	#exec MESH SEQUENCE MESH=slith1 SEQ=All       STARTFRAME=0   NUMFRAMES=230
00010	#exec MESH SEQUENCE MESH=slith1 SEQ=BREATH    STARTFRAME=0   NUMFRAMES=6	RATE=6
00011	#exec MESH SEQUENCE MESH=slith1 SEQ=CHARGEUP  STARTFRAME=6   NUMFRAMES=13	RATE=15
00012	#exec MESH SEQUENCE MESH=slith1 SEQ=WFighter  STARTFRAME=19  NUMFRAMES=1
00013	#exec MESH SEQUENCE MESH=slith1 SEQ=CLAW1     STARTFRAME=19  NUMFRAMES=11			Group=Attack
00014	#exec MESH SEQUENCE MESH=slith1 SEQ=CLAW2     STARTFRAME=30  NUMFRAMES=11			Group=Attack
00015	#exec MESH SEQUENCE MESH=slith1 SEQ=DEAD1     STARTFRAME=41  NUMFRAMES=13	RATE=15
00016	#exec MESH SEQUENCE MESH=slith1 SEQ=DEAD2     STARTFRAME=54  NUMFRAMES=21	RATE=15
00017	#exec MESH SEQUENCE MESH=slith1 SEQ=LTakeHit  STARTFRAME=41  NUMFRAMES=1
00018	#exec MESH SEQUENCE MESH=slith1 SEQ=WTakeHit  STARTFRAME=54  NUMFRAMES=1
00019	#exec MESH SEQUENCE MESH=slith1 SEQ=DIVE      STARTFRAME=75  NUMFRAMES=16	RATE=15
00020	#exec MESH SEQUENCE MESH=slith1 SEQ=Falling   STARTFRAME=83  NUMFRAMES=1
00021	#exec MESH SEQUENCE MESH=slith1 SEQ=LFighter  STARTFRAME=91  NUMFRAMES=1
00022	#exec MESH SEQUENCE MESH=slith1 SEQ=PUNCH     STARTFRAME=91  NUMFRAMES=15	RATE=15 Group=Attack
00023	#exec MESH SEQUENCE MESH=slith1 SEQ=SCRATCH   STARTFRAME=106 NUMFRAMES=20	RATE=15
00024	#exec MESH SEQUENCE MESH=slith1 SEQ=SHOOT1    STARTFRAME=126 NUMFRAMES=13	RATE=15 Group=MovingAttack
00025	#exec MESH SEQUENCE MESH=slith1 SEQ=SHOOT2    STARTFRAME=139 NUMFRAMES=13	RATE=15 Group=MovingAttack
00026	#exec MESH SEQUENCE MESH=slith1 SEQ=SLASH     STARTFRAME=152 NUMFRAMES=15	RATE=15 Group=Attack
00027	#exec MESH SEQUENCE MESH=slith1 SEQ=SLICK     STARTFRAME=167 NUMFRAMES=15	RATE=15
00028	#exec MESH SEQUENCE MESH=slith1 SEQ=SLITHER   STARTFRAME=182 NUMFRAMES=15	RATE=15
00029	#exec MESH SEQUENCE MESH=slith1 SEQ=SURFACE   STARTFRAME=197 NUMFRAMES=18	RATE=15
00030	#exec MESH SEQUENCE MESH=slith1 SEQ=SWIM      STARTFRAME=215 NUMFRAMES=15	RATE=15
00031	
00032	#exec TEXTURE IMPORT NAME=JSlith1 FILE=MODELS\slith.PCX GROUP=Skins 
00033	#exec MESHMAP SCALE MESHMAP=slith1 X=0.12 Y=0.12 Z=0.24
00034	#exec MESHMAP SETTEXTURE MESHMAP=slith1 NUM=0 TEXTURE=Jslith1
00035	
00036	#exec MESH NOTIFY MESH=slith1 SEQ=Claw1 TIME=0.81 FUNCTION=ClawDamageTarget
00037	#exec MESH NOTIFY MESH=slith1 SEQ=Claw2 TIME=0.81 FUNCTION=ClawDamageTarget
00038	#exec MESH NOTIFY MESH=slith1 SEQ=Punch TIME=0.5 FUNCTION=ClawDamageTarget
00039	#exec MESH NOTIFY MESH=slith1 SEQ=Slash TIME=0.5 FUNCTION=ClawDamageTarget
00040	#exec MESH NOTIFY MESH=slith1 SEQ=Shoot1 TIME=0.3 FUNCTION=ShootTarget
00041	#exec MESH NOTIFY MESH=slith1 SEQ=Shoot2 TIME=0.3 FUNCTION=ShootTarget
00042	#exec MESH NOTIFY MESH=slith1 SEQ=Dead1 TIME=0.61 FUNCTION=LandThump
00043	
00044	#exec AUDIO IMPORT FILE="Sounds\Slith\amb1sl.WAV" NAME="amb1sl" GROUP="Slith"
00045	#exec AUDIO IMPORT FILE="Sounds\Slith\injur1sl.WAV" NAME="injur1sl" GROUP="Slith"
00046	#exec AUDIO IMPORT FILE="Sounds\Slith\injur2sl.WAV" NAME="injur2sl" GROUP="Slith"
00047	#exec AUDIO IMPORT FILE="Sounds\Slith\yell1sl.WAV" NAME="yell1sl" GROUP="Slith"
00048	#exec AUDIO IMPORT FILE="Sounds\Slith\yell2sl.WAV" NAME="yell2sl" GROUP="Slith"
00049	#exec AUDIO IMPORT FILE="Sounds\Slith\yell3sl.WAV" NAME="yell3sl" GROUP="Slith"
00050	#exec AUDIO IMPORT FILE="Sounds\Slith\yell4sl.WAV" NAME="yell4sl" GROUP="Slith"
00051	#exec AUDIO IMPORT FILE="Sounds\Slith\roam1sl.WAV" NAME="roam1sl" GROUP="Slith"
00052	#exec AUDIO IMPORT FILE="Sounds\Slith\dieL1sl.WAV" NAME="deathLsl" GROUP="Slith"
00053	#exec AUDIO IMPORT FILE="Sounds\Slith\dieW1sl.WAV" NAME="deathWsl" GROUP="Slith"
00054	#exec AUDIO IMPORT FILE="Sounds\Slith\surf1sl.WAV" NAME="surf1sl" GROUP="Slith"
00055	#exec AUDIO IMPORT FILE="Sounds\Slith\dive2a.WAV" NAME="dive2sl" GROUP="Slith"
00056	#exec AUDIO IMPORT FILE="Sounds\Slith\swim1sl.WAV" NAME="swim1sl" GROUP="Slith"
00057	#exec AUDIO IMPORT FILE="Sounds\Slith\scratch1sl.WAV" NAME="scratch1sl" GROUP="Slith"
00058	#exec AUDIO IMPORT FILE="Sounds\Slith\slithr1sl.WAV" NAME="slithr1sl" GROUP="Slith"
00059	
00060	//FIXME - not using Charge1sl 
00061	//-----------------------------------------------------------------------------
00062	// Slith variables.
00063	
00064	// Attack damage.
00065	var() byte ClawDamage;	// Basic damage done by Claw/punch.
00066	var bool bFirstAttack;
00067	
00068	var(Sounds) sound die2;
00069	var(Sounds) sound slick;
00070	var(Sounds) sound slash;
00071	var(Sounds) sound slice;
00072	var(Sounds) sound slither;
00073	var(Sounds) sound swim;
00074	var(Sounds) sound dive;
00075	var(Sounds) sound surface;
00076	var(Sounds) sound scratch;
00077	var(Sounds) sound charge;
00078	
00079	//-----------------------------------------------------------------------------
00080	// Slith functions.
00081	
00082	/* PreSetMovement()
00083	default for walking creature.  Re-implement in subclass
00084	for swimming/flying capability
00085	*/
00086	function PreSetMovement()
00087	{
00088		MaxDesiredSpeed = 0.79 + 0.07 * skill;
00089		bCanJump = true;
00090		bCanWalk = true;
00091		bCanSwim = true;
00092		bCanFly = false;
00093		MinHitWall = -0.6;
00094		if (Intelligence > BRAINS_Reptile)
00095			bCanOpenDoors = true;
00096		if (Intelligence == BRAINS_Human)
00097			bCanDoSpecial = true;
00098	}
00099	
00100	function eAttitude AttitudeToCreature(Pawn Other)
00101	{
00102		if ( Other.IsA('Slith') )
00103			return ATTITUDE_Friendly;
00104		else if ( Other.IsA('Nali') )
00105			return ATTITUDE_Hate;
00106		else
00107			return ATTITUDE_Ignore;
00108	}
00109	
00110	function SetMovementPhysics()
00111	{
00112		if (Region.Zone.bWaterZone && (Physics != PHYS_Swimming) )
00113			SetPhysics(PHYS_Swimming);
00114		else if (Physics != PHYS_Walking)
00115			SetPhysics(PHYS_Walking); 
00116	}
00117	
00118	function JumpOutOfWater(vector jumpDir)
00119	{
00120		Falling();
00121		Velocity = jumpDir * WaterSpeed;
00122		Acceleration = jumpDir * AccelRate;
00123		velocity.Z = 460; //set here so physics uses this for remainder of tick
00124		PlayOutOfWater();
00125		bUpAndOut = true;
00126	}
00127	
00128	function SetFall()
00129		{
00130			if (Enemy != None)
00131			{
00132				NextState = 'Attacking'; //default
00133				NextLabel = 'Begin';
00134				NextAnim = 'LFighter';
00135				GotoState('FallingState');
00136			}
00137		}
00138	
00139	function PlayAcquisitionSound()
00140	{
00141		if ( FRand() < 0.5 )
00142			PlaySound(Acquire, SLOT_Talk);
00143		else
00144			PlaySound(sound'yell3sl', SLOT_Talk); 
00145	}
00146	
00147	function PlayWaiting()
00148	{
00149		local float decision;
00150	
00151		if (Region.Zone.bWaterZone)
00152		{
00153			LoopAnim('Swim', 0.2  + 0.3 * FRand());
00154			return;
00155		}
00156		
00157		decision = FRand();
00158	
00159		if (decision < 0.8)
00160			LoopAnim('Breath', 0.2 + 0.6 * FRand());
00161		else if (decision < 0.9)
00162		{
00163			PlaySound(Slick, SLOT_Interact);
00164			LoopAnim('Slick', 0.4 + 0.6 * FRand());
00165		}
00166		else
00167		{
00168			PlaySound(Scratch, SLOT_Interact);
00169			LoopAnim('Scratch', 0.4 + 0.6 * FRand());
00170		}
00171	}
00172	
00173	function PlayPatrolStop()
00174	{
00175		PlayWaiting();
00176	}
00177	
00178	function PlayWaitingAmbush()
00179	{
00180		PlayWaiting();
00181	}
00182	
00183	function PlayChallenge()
00184	{
00185		TweenToFighter(0.1);
00186	}
00187	
00188	function TweenToFighter(float tweentime)
00189	{
00190		if (Region.Zone.bWaterZone)
00191			TweenAnim('WFighter', tweentime);
00192		else
00193			TweenAnim('LFighter', tweentime);
00194	}
00195	
00196	function TweenToRunning(float tweentime)
00197	{
00198		if (Region.Zone.bWaterZone)
00199		{
00200			if ( (AnimSequence == 'Shoot2') && IsAnimating() )
00201				return;
00202			if ( (AnimSequence != 'Swim') || !bAnimLoop )
00203				TweenAnim('Swim', tweentime);
00204		}
00205		else
00206		{
00207			if ( (AnimSequence == 'Shoot1') && IsAnimating() )
00208				return;
00209			if ( (AnimSequence != 'Slither') || !bAnimLoop )
00210				TweenAnim('Slither', tweentime);
00211		}
00212	}
00213	
00214	function TweenToWalking(float tweentime)
00215	{
00216		if (Region.Zone.bWaterZone)
00217		{
00218			if ( (AnimSequence != 'Swim') || !bAnimLoop )
00219				TweenAnim('Swim', tweentime);
00220		}
00221		else
00222		{
00223			if ( (AnimSequence != 'Slither') || !bAnimLoop )
00224				TweenAnim('Slither', tweentime);
00225		}
00226	}
00227	
00228	function TweenToWaiting(float tweentime)
00229	{
00230		if (Region.Zone.bWaterZone)
00231			TweenAnim('Swim', tweentime);
00232		else
00233			TweenAnim('Breath', tweentime);
00234	}
00235	
00236	function TweenToPatrolStop(float tweentime)
00237	{
00238		TweenToWaiting(tweentime);
00239	}
00240	
00241	function PlayRunning()
00242	{
00243		if (Region.Zone.bWaterZone)
00244		{
00245			PlaySound(Swim, SLOT_Interact);
00246			LoopAnim('Swim', -1.0/WaterSpeed,, 0.4);
00247		}
00248		else
00249		{
00250			PlaySound(Slither, SLOT_Interact);
00251			LoopAnim('Slither', -1.1/GroundSpeed,, 0.4);
00252		}
00253	}
00254	
00255	function PlayWalking()
00256	{
00257		if (Region.Zone.bWaterZone)
00258		{
00259			PlaySound(Swim, SLOT_Interact);
00260			LoopAnim('Swim', -1.0/WaterSpeed,, 0.4);
00261		}
00262		else
00263		{
00264			PlaySound(Slither, SLOT_Interact);
00265			LoopAnim('Slither', -1.3/GroundSpeed,, 0.4);
00266		}
00267	}
00268	
00269	function PlayThreatening()
00270	{
00271		local float decision;
00272		decision = FRand();
00273	
00274		if (decision < 0.8)
00275		{
00276			PlayWaiting();
00277			return;
00278		}
00279		NextAnim = '';
00280				
00281		if (Region.Zone.bWaterZone)
00282			TweenAnim('WFighter', 0.25);
00283		else
00284			TweenAnim('LFighter', 0.25);
00285	}
00286	
00287	function PlayTurning()
00288	{
00289		if (Region.Zone.bWaterZone)
00290			TweenAnim('Swim', 0.35);
00291		else
00292			TweenAnim('Slither', 0.35);
00293	}
00294	
00295	function PlayDying(name DamageType, vector HitLocation)
00296	{
00297		if (Region.Zone.bWaterZone)
00298		{
00299			PlaySound(Die2, SLOT_Talk, 4 * TransientSoundVolume);
00300			PlayAnim('Dead2', 0.7, 0.1);
00301		}
00302		else
00303		{
00304			PlaySound(Die, SLOT_Talk, 4 * TransientSoundVolume);
00305			PlayAnim('Dead1', 0.7, 0.1);
00306		}
00307	}
00308	
00309	function PlayTakeHit(float tweentime, vector HitLoc, int Damage)
00310	{
00311		if (Region.Zone.bWaterZone)
00312			TweenAnim('WTakeHit', tweentime);
00313		else
00314			TweenAnim('LTakeHit', tweentime);
00315	}
00316	
00317	function PlayOutOfWater()
00318	{
00319		PlayAnim('Surface',,0.1);
00320	}
00321	
00322	function PlayDive()
00323	{
00324		PlayAnim('Dive',,0.1);
00325	}
00326	
00327	function TweenToFalling()
00328	{
00329		TweenAnim('Falling', 0.4);
00330	}
00331	
00332	function PlayInAir()
00333	{
00334		TweenAnim('Falling', 0.4);
00335	}
00336	
00337	function PlayLanded(float impactVel)
00338	{
00339		TweenAnim('Slither', 0.25);
00340	}
00341	
00342	
00343	function PlayVictoryDance()
00344	{
00345		PlayAnim('ChargeUp', 0.3, 0.1);
00346		PlaySound(Charge, SLOT_Interact);		
00347	}
00348		
00349	function ClawDamageTarget()
00350	{
00351		MeleeDamageTarget(ClawDamage, (ClawDamage * 1000.0 * Normal(Target.Location - Location)));
00352	}
00353		
00354	function PlayMeleeAttack()
00355	{
00356		local float decision;
00357		
00358		decision = FRand();
00359		Acceleration = AccelRate * Normal(Target.Location - Location);
00360		//log("Start Melee Attack");
00361		if ( Region.Zone.bWaterZone )
00362		{
00363			if (AnimSequence == 'Claw1')
00364				decision += 0.17;
00365			else if (AnimSequence == 'Claw2')
00366				decision -= 0.17; 
00367	
00368			if (decision < 0.5)
00369				PlayAnim('Claw1');
00370			else
00371				PlayAnim('Claw2');
00372		}
00373		else
00374		{
00375			if (AnimSequence == 'Punch')
00376				decision += 0.17;
00377			else if (AnimSequence == 'Slash')
00378				decision -= 0.17; 
00379			if (decision < 0.5)
00380			{
00381				PlayAnim('Punch');
00382	 		}
00383			else
00384			{
00385		 		PlayAnim('Slash'); 
00386		 	}
00387	 	}	
00388	 }
00389	
00390	
00391	function bool CanFireAtEnemy()
00392	{
00393		local vector HitLocation, HitNormal, EnemyDir, projStart;
00394		local actor HitActor;
00395		local float EnemyDist;
00396	
00397		EnemyDir = Enemy.Location - Location + Enemy.CollisionHeight * vect(0,0,0.8);	
00398		EnemyDist = VSize(EnemyDir);
00399		if (EnemyDist > 750) //FIXME - what is right number?
00400			return false;
00401		
00402		EnemyDir = EnemyDir/EnemyDist;	
00403		projStart = Location + 0.8 * CollisionRadius * EnemyDir + 0.8 * CollisionHeight * vect(0,0,1);
00404		HitActor = Trace(HitLocation, HitNormal, 
00405					projStart + (MeleeRange + Enemy.CollisionRadius) * EnemyDir,
00406					projStart, false, vect(6,6,4) );
00407	
00408		return (HitActor == None);
00409	}
00410	
00411	function ShootTarget()
00412	{
00413		FireProjectile( vect(1, 0, 0.8), 900);
00414	}
00415	
00416	function PlayRangedAttack()
00417	{
00418		if (Region.Zone.bWaterZone)
00419			PlayAnim('Shoot2');
00420		else
00421			PlayAnim('Shoot1');
00422	}
00423	
00424	function PlayMovingAttack()
00425	{
00426		PlayRangedAttack();
00427	}
00428	
00429	state MeleeAttack
00430	{
00431	ignores SeePlayer, HearNoise, Bump;
00432	
00433		function PlayMeleeAttack()
00434		{
00435			if ( Region.Zone.bWaterZone && !bFirstAttack && (FRand() > 0.4 + 0.17 * skill) )
00436			{
00437				PlayAnim('Swim');
00438				Acceleration = AccelRate * Normal(Location - Enemy.Location + 0.9 * VRand());
00439			}	
00440			else
00441				Global.PlayMeleeAttack();
00442			bFirstAttack = false;	 
00443		}
00444	
00445		function BeginState()
00446		{
00447			Super.BeginState();
00448			bCanStrafe = True;
00449			bFirstAttack = True;
00450		}
00451	
00452		function EndState()
00453		{
00454			Super.EndState();
00455			bCanStrafe = false;
00456		}
00457	}
00458	
00459	defaultproperties
00460	{
00461	     ClawDamage=25
00462	     Die2=Sound'UnrealShare.Slith.deathWsl'
00463	     SLASH=Sound'UnrealShare.Slith.yell4sl'
00464	     SLITHER=Sound'UnrealShare.Slith.slithr1sl'
00465	     Swim=Sound'UnrealShare.Slith.swim1sl'
00466	     DIVE=Sound'UnrealShare.Slith.dive2sl'
00467	     Surface=Sound'UnrealShare.Slith.surf1sl'
00468	     SCRATCH=Sound'UnrealShare.Slith.scratch1sl'
00469	     CarcassType=Class'UnrealShare.SlithCarcass'
00470	     TimeBetweenAttacks=1.200000
00471	     Aggressiveness=0.700000
00472	     RefireRate=0.400000
00473	     WalkingSpeed=0.300000
00474	     bHasRangedAttack=True
00475	     bMovingRangedAttack=True
00476	     RangedProjectile=Class'UnrealShare.SlithProjectile'
00477	     ProjectileSpeed=750.000000
00478	     Acquire=Sound'UnrealShare.Slith.yell1sl'
00479	     Fear=Sound'UnrealShare.Slith.yell3sl'
00480	     Roam=Sound'UnrealShare.Slith.roam1sl'
00481	     Threaten=Sound'UnrealShare.Slith.yell2sl'
00482	     MeleeRange=50.000000
00483	     GroundSpeed=250.000000
00484	     WaterSpeed=280.000000
00485	     AccelRate=850.000000
00486	     JumpZ=120.000000
00487	     Visibility=150
00488	     SightRadius=2000.000000
00489	     Health=210
00490	     ReducedDamageType=Corroded
00491	     ReducedDamagePct=1.000000
00492	     UnderWaterTime=-1.000000
00493	     HitSound1=Sound'UnrealShare.Slith.injur1sl'
00494	     HitSound2=Sound'UnrealShare.Slith.injur2sl'
00495	     Die=Sound'UnrealShare.Slith.deathLsl'
00496	     CombatStyle=0.850000
00497	     AmbientSound=Sound'UnrealShare.Slith.amb1sl'
00498	     DrawType=DT_Mesh
00499	     Mesh=LodMesh'UnrealShare.Slith1'
00500	     CollisionRadius=48.000000
00501	     CollisionHeight=44.000000
00502	     Mass=200.000000
00503	     Buoyancy=200.000000
00504	     RotationRate=(Pitch=3072,Yaw=40000,Roll=6000)
00505	}

End Source Code