UnrealShare
Class Skaarj

source: e:\games\UnrealTournament\UnrealShare\Classes\Skaarj.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Pawn
         |
         +--UnrealShare.ScriptedPawn
            |
            +--UnrealShare.Skaarj
Direct Known Subclasses:SkaarjTrooper, SkaarjWarrior

class Skaarj
extends UnrealShare.ScriptedPawn

//============================================================================= // Skaarj. //=============================================================================
Variables
 bool AttackSuccess
 bool bButtonPusher
 bool bFakeDeath
 var() byte
 name phrase

States
RangedAttack, Hunting, FallingState, TakeHit

Function Summary
 eAttitude AttitudeToCreature(Pawn Other)
     
//=========================================================================================
 void ClawDamageTarget()
 void PlayAcquisitionSound()
 void PlayBigDeath(name DamageType)
 void PlayCock()
 void PlayDive()
 void PlayFearSound()
 void PlayGutDeath(name DamageType)
 void PlayHeadDeath(name DamageType)
 void PlayInAir()
 void PlayLanded(float impactVel)
 void PlayLeftDeath(name DamageType)
 void PlayMeleeAttack()
 void PlayOutOfWater()
 void PlayRangedAttack()
 void PlayRightDeath(name DamageType)
 void PlayRoamingSound()
 void PlaySwimming()
 void PlayTakeHit(float tweentime, vector HitLoc, int damage)
 void PlayTakeHitSound(int Damage, name damageType, int Mult)
 void PlayThreateningSound()
 void PlayTurning()
 void PlayWaiting()
 void PlayWaitingAmbush()
 void PlayWalking()
 void PreBeginPlay()
 void PreSetMovement()
     
/* PreSetMovement()
*/
 void PushButtons()
 void RunStep()
 void SetMovementPhysics()
 void Speak()
 void SpeakOrderTo(ScriptedPawn TeamMember)
 void SpeakTo(ScriptedPawn Other)
 void SpeechTimer()
     
//=========================================================================================
// Speech
 void SpinDamageTarget()
 void TweenToFalling()
 void TweenToFighter(float tweentime)
 void TweenToPatrolStop(float tweentime)
 void TweenToRunning(float tweentime)
 void TweenToSwimming(float tweentime)
 void TweenToWaiting(float tweentime)
 void TweenToWalking(float tweentime)
 void WalkStep()
 void ZoneChange(ZoneInfo newZone)


State RangedAttack Function Summary
 void PlayRangedAttack()
 void LungeDamageTarget()
 void Bump(Actor Other)


State Hunting Function Summary
 void EndState()
 void BeginState()


State FallingState Function Summary
 void PlayTakeHit(float tweentime, vector HitLoc, int damage)
 void Landed(vector HitNormal)


State TakeHit Function Summary
 void BeginState()
 void PlayTakeHit(float tweentime, vector HitLoc, int damage)
 void Landed(vector HitNormal)



Source Code


00001	//=============================================================================
00002	// Skaarj.
00003	//=============================================================================
00004	class Skaarj extends ScriptedPawn
00005		abstract;
00006	
00007	#exec AUDIO IMPORT FILE="Sounds\Skaarj\amb1sk.WAV" NAME="amb1sk" GROUP="Skaarj"
00008	#exec AUDIO IMPORT FILE="Sounds\Skaarj\syl07.WAV" NAME="syl07sk" GROUP="Skaarj"
00009	#exec AUDIO IMPORT FILE="Sounds\Skaarj\syl09.WAV" NAME="syl09sk" GROUP="Skaarj"
00010	#exec AUDIO IMPORT FILE="Sounds\Skaarj\syl11.WAV" NAME="syl11sk" GROUP="Skaarj"
00011	#exec AUDIO IMPORT FILE="Sounds\Skaarj\syl12.WAV" NAME="syl12sk" GROUP="Skaarj"
00012	#exec AUDIO IMPORT FILE="Sounds\Skaarj\syl13.WAV" NAME="syl13sk" GROUP="Skaarj"
00013	#exec AUDIO IMPORT FILE="Sounds\Skaarj\syl15.WAV" NAME="syl15sk" GROUP="Skaarj"
00014	#exec AUDIO IMPORT FILE="Sounds\Skaarj\spin1a.WAV" NAME="spin1s" GROUP="Skaarj"
00015	#exec AUDIO IMPORT FILE="Sounds\Skaarj\claw2a.WAV" NAME="claw2s" GROUP="Skaarj"
00016	#exec AUDIO IMPORT FILE="Sounds\Skaarj\clawhit1a.WAV" NAME="clawhit1s" GROUP="Skaarj"
00017	#exec AUDIO IMPORT FILE="Sounds\Skaarj\injur5.WAV" NAME="injur1sk" GROUP="Skaarj"
00018	#exec AUDIO IMPORT FILE="Sounds\Skaarj\injur6.WAV" NAME="injur2sk" GROUP="Skaarj"
00019	#exec AUDIO IMPORT FILE="Sounds\Skaarj\injur7.WAV" NAME="injur3sk" GROUP="Skaarj"
00020	#exec AUDIO IMPORT FILE="Sounds\Skaarj\chalnge1a.WAV" NAME="chalnge1s" GROUP="Skaarj"
00021	#exec AUDIO IMPORT FILE="Sounds\Skaarj\chalnge3a.WAV" NAME="chalnge3s" GROUP="Skaarj"
00022	#exec AUDIO IMPORT FILE="Sounds\Skaarj\death1a.WAV" NAME="death1sk" GROUP="Skaarj"
00023	#exec AUDIO IMPORT FILE="Sounds\Skaarj\death2a.WAV" NAME="death2sk" GROUP="Skaarj"
00024	#exec AUDIO IMPORT FILE="Sounds\Skaarj\roam11.WAV" NAME="roam11s" GROUP="Skaarj"
00025	#exec AUDIO IMPORT FILE="Sounds\Skaarj\lunge1sk.WAV" NAME="lunge1sk" GROUP="Skaarj"
00026	#exec AUDIO IMPORT FILE="Sounds\Skaarj\squat1a.WAV" NAME="squat1sk" GROUP="Skaarj"
00027	#exec AUDIO IMPORT FILE="Sounds\Skaarj\hairflp2a.WAV" NAME="hairflp2sk" GROUP="Skaarj"
00028	#exec AUDIO IMPORT FILE="Sounds\Cow\walknc.WAV" NAME="walkC" GROUP="Cow"
00029	#exec AUDIO IMPORT FILE="Sounds\Gibs\bthump1.WAV" NAME="Thump" GROUP="Gibs"
00030	
00031	//-----------------------------------------------------------------------------
00032	// Skaarj variables.
00033	
00034	// Attack damage.
00035	var() byte
00036		LungeDamage,	// Basic damage done by lunge.
00037		SpinDamage,		// Basic damage done by spin.
00038		ClawDamage;		// Basic damage done by each claw.
00039	
00040	var bool AttackSuccess;
00041	var() bool	bButtonPusher;
00042	var() bool  bFakeDeath;
00043	var(Sounds) sound hitsound3;
00044	var(Sounds) sound hitsound4;
00045	var(Sounds) sound syllable1;
00046	var(Sounds) sound syllable2;
00047	var(Sounds) sound syllable3;
00048	var(Sounds) sound syllable4;
00049	var(Sounds) sound syllable5;
00050	var(Sounds) sound syllable6;
00051	var(Sounds) sound spin;
00052	var(Sounds) sound claw;
00053	var(Sounds) sound slice;
00054	var(Sounds) sound lunge;
00055	var(Sounds) sound hairflip;
00056	var(Sounds) sound Die2;
00057	var(Sounds) sound Footstep;
00058	var(Sounds) sound Footstep2;
00059	
00060	var 	name phrase;
00061	var		byte phrasesyllable;
00062	var		float	voicePitch;
00063	
00064	function PreBeginPlay()
00065	{
00066		Super.PreBeginPlay();
00067		bCanSpeak = true;
00068		voicePitch = Default.voicePitch + 0.6 * Default.voicePitch * FRand();
00069		
00070		if ( CombatStyle == Default.CombatStyle)
00071			CombatStyle = CombatStyle + 0.3 * FRand() - 0.15;
00072	
00073		if ( bFakeDeath )
00074		{
00075			AnimSequence = 'Death2';
00076			AnimFrame = 0.92;
00077			SimAnim.X = 9200;
00078		}
00079		if ( skill > 2 )
00080			ProjectileSpeed *= 1.1;
00081	}
00082	
00083	function RunStep()
00084	{
00085		if (FRand() < 0.6)
00086			PlaySound(FootStep, SLOT_Interact,0.8,,900);
00087		else
00088			PlaySound(FootStep2, SLOT_Interact,0.8,,900);
00089	}
00090	
00091	function WalkStep()
00092	{
00093		if (FRand() < 0.6)
00094			PlaySound(FootStep, SLOT_Interact,0.2,,500);
00095		else
00096			PlaySound(FootStep2, SLOT_Interact,0.2,,500);
00097	}
00098	
00099	function ZoneChange(ZoneInfo newZone)
00100	{
00101		bCanSwim = newZone.bWaterZone; //only when it must
00102			
00103		if ( newZone.bWaterZone )
00104			CombatStyle = 1.0; //always charges when in the water
00105		else if (Physics == PHYS_Swimming)
00106			CombatStyle = Default.CombatStyle;
00107	
00108		Super.ZoneChange(newZone);
00109	}
00110	
00111	/* PreSetMovement()
00112	*/
00113	function PreSetMovement()
00114	{
00115		MaxDesiredSpeed = 0.7 + 0.1 * skill;
00116		bCanJump = true;
00117		bCanWalk = true;
00118		bCanSwim = false;
00119		bCanFly = false;
00120		MinHitWall = -0.6;
00121		bCanOpenDoors = true;
00122		if ( Intelligence > BRAINS_Mammal )
00123			bCanDoSpecial = true;
00124		bCanDuck = true;
00125	}
00126	
00127	function SetMovementPhysics()
00128	{
00129		if ( Region.Zone.bWaterZone )
00130			SetPhysics(PHYS_Swimming);
00131		else if (Physics != PHYS_Walking)
00132			SetPhysics(PHYS_Walking); 
00133	}
00134	
00135	//=========================================================================================
00136	// Speech
00137	
00138	function SpeechTimer()
00139	{
00140		//last syllable expired.  Decide whether to keep the floor or quit
00141		if (FRand() < 0.3)
00142		{
00143			bIsSpeaking = false;
00144			if (TeamLeader != None)
00145				TeamLeader.bTeamSpeaking = false;
00146		}
00147		else
00148			Speak();
00149	}
00150	
00151	function SpeakOrderTo(ScriptedPawn TeamMember)
00152	{
00153		phrase = '';
00154		if ( !TeamMember.bCanSpeak || (FRand() < 0.5) )
00155			Speak();
00156		else  
00157		{
00158			if (SkaarjWarrior(TeamMember) != None)
00159				SkaarjWarrior(TeamMember).phrase = '';
00160			TeamMember.Speak();
00161		}
00162	}
00163	
00164	function SpeakTo(ScriptedPawn Other)
00165	{
00166		if (Other.bIsSpeaking || ((TeamLeader != None) && TeamLeader.bTeamSpeaking) )
00167			return;
00168		
00169		phrase = '';
00170		Speak();
00171	}
00172	
00173	function Speak()
00174	{
00175		local float decision, inflection, pitch;
00176		
00177		//if (phrase != '')
00178		//	SpeakPhrase();
00179		bIsSpeaking = true;
00180		if ( FRand() < 0.65)
00181		{
00182			inflection = 0.6 + 0.5 * FRand();
00183			pitch = voicePitch + 0.4 * FRand();
00184		}
00185		else
00186		{
00187			inflection = 1.3 + 0.5 * FRand();
00188			pitch = voicePitch + 0.8 * FRand();
00189		}
00190		decision = FRand();
00191		if (TeamLeader != None)	
00192			TeamLeader.bTeamSpeaking = true;
00193		if (decision < 0.167)
00194			PlaySound(Syllable1,SLOT_Talk,inflection,,, pitch);
00195		else if (decision < 0.333)
00196			PlaySound(Syllable2,SLOT_Talk,inflection,,, pitch);
00197		else if (decision < 0.5)
00198			PlaySound(Syllable3,SLOT_Talk,inflection,,, pitch);
00199		else if (decision < 0.667)
00200			PlaySound(Syllable4,SLOT_Talk,inflection,,, pitch);
00201		else if (decision < 0.833)
00202			PlaySound(Syllable5,SLOT_Talk,inflection,,, pitch);
00203		else 
00204			PlaySound(Syllable6,SLOT_Talk,inflection,,, pitch);
00205	
00206		SpeechTime = 0.1 + 0.3 * FRand();
00207	}
00208		
00209	function PlayAcquisitionSound()
00210	{
00211		if ( bCanSpeak && (TeamLeader != None) && !TeamLeader.bTeamSpeaking )
00212		{
00213			phrase = 'Acquisition';
00214			phrasesyllable = 0;
00215			Speak();
00216			return;
00217		} 
00218		Super.PlayAcquisitionSound(); 
00219	}
00220	
00221	function PlayFearSound()
00222	{
00223		if ( bCanSpeak && (TeamLeader != None) && !TeamLeader.bTeamSpeaking )
00224		{
00225			phrase = 'Fear';
00226			phrasesyllable = 0;
00227			Speak();
00228			return;
00229		} 
00230		Super.PlayFearSound();
00231	}
00232	
00233	function PlayRoamingSound()
00234	{
00235		if ( bCanSpeak && (TeamLeader != None) && !TeamLeader.bTeamSpeaking  && (FRand() < 0.5) )
00236		{
00237			phrase = '';
00238			Speak();
00239			return;
00240		} 
00241		Super.PlayRoamingSound();
00242	}
00243	
00244	function PlayThreateningSound()
00245	{
00246		if ( bCanSpeak && (FRand() < 0.6) && ((TeamLeader == None) || !TeamLeader.bTeamSpeaking) )
00247		{
00248			phrase = 'Threaten';
00249			phrasesyllable = 0;
00250			Speak();
00251			return;
00252		} 
00253		Super.PlayThreateningSound();
00254	}
00255	
00256	
00257	//=========================================================================================
00258	function eAttitude AttitudeToCreature(Pawn Other)
00259	{
00260		if ( Other.IsA('Skaarj') )
00261		{
00262			if ( Other.IsA('SkaarjBerserker') )
00263				return ATTITUDE_Ignore;
00264			else
00265				return ATTITUDE_Friendly;
00266		}
00267		else if ( Other.IsA('Pupae') )
00268			return ATTITUDE_Friendly;
00269		else if ( Other.IsA('Nali') )
00270			return ATTITUDE_Hate;
00271		else if ( Other.IsA('WarLord') || Other.IsA('Queen') )
00272			return ATTITUDE_Friendly;
00273		else
00274			return ATTITUDE_Ignore;
00275	}
00276	
00277	function PushButtons()
00278	{
00279		local float decision, animspeed;
00280	
00281		SetAlertness(-0.7);
00282		animspeed = 0.4 + 0.6 * FRand(); 
00283		decision = FRand();
00284		if (decision < 0.2)
00285			LoopAnim('Breath2', animspeed, 1.0);
00286		else if (decision < 0.3)
00287		{
00288			SetAlertness(0.2);
00289			LoopAnim('Breath', animspeed, 1.0);
00290		}
00291		else if (decision < 0.4)
00292			LoopAnim('MButton1', animspeed);
00293		else if (decision < 0.5)
00294			LoopAnim('MButton2', animspeed);
00295		else if (decision < 0.6)
00296			LoopAnim('MButton3', animspeed);
00297		else if (decision < 0.7)
00298			LoopAnim('MButton4', animspeed);
00299		else if (decision < 0.76)
00300			LoopAnim('Button1', animspeed);
00301		else if (decision < 0.82)
00302			LoopAnim('Button2', animspeed);
00303		else if (decision < 0.88)
00304			LoopAnim('Button3', animspeed);
00305		else if (decision < 0.94)
00306			LoopAnim('Button4', animspeed);
00307		else
00308			LoopAnim('Button5', animspeed);
00309		return;
00310	}
00311	
00312	function PlayCock()
00313	{
00314	}
00315	
00316	function PlayWaiting()
00317	{
00318		local float decision;
00319		local float animspeed;
00320	
00321		if (Region.Zone.bWaterZone)
00322		{
00323			PlaySwimming();
00324			return;
00325		}
00326		if ( bFakeDeath )
00327			return;
00328		if ( bButtonPusher )
00329		{
00330			PushButtons();
00331			return;
00332		}
00333	
00334		animspeed = 0.3 + 0.6 * FRand(); //vary speed
00335		decision = FRand();
00336		if (AnimSequence == 'Breath')
00337		{
00338			SetAlertness(0.0);
00339			if (decision < 0.15)
00340			{
00341				PlayAnim('gunfix', AnimSpeed, 0.7);
00342				if ( !bQuiet )
00343					PlaySound(Roam, SLOT_Talk);			
00344			}
00345			else if ( decision < 0.28 )
00346			{
00347				if ( IsA('SkaarjWarrior') )
00348					PlayAnim('Stretch', AnimSpeed);
00349				else
00350					PlayAnim('ShldTest', AnimSpeed);
00351			}
00352			else
00353				LoopAnim('Breath2', AnimSpeed);
00354			return;
00355		}
00356		else if ( AnimSequence == 'Breath2' )
00357		{
00358			if (decision < 0.2)
00359			{
00360				SetAlertness(0.3);
00361				LoopAnim('Breath', 0.2 + 0.5 * FRand());
00362			}
00363			else
00364				LoopAnim('Breath2', AnimSpeed);
00365			return;
00366		}
00367		else if ( AnimSequence == 'gunfix' )
00368		{
00369			SetAlertness(-0.3);
00370			if (decision < 0.25)
00371			{
00372				PlayCock();
00373				LoopAnim('guncheck', animspeed);
00374			}
00375			else if (decision < 0.37)
00376				PlayAnim('headup', animspeed);
00377			else
00378				LoopAnim('gunfix', animspeed);
00379			return;
00380	 	}
00381		else if ( AnimSequence == 'Looking' )
00382		{
00383			if (decision < 0.7)
00384			{
00385				SetAlertness(-0.3);
00386				LoopAnim('gunfix', animspeed);
00387			}
00388			else if (decision < 0.85)
00389			{
00390				SetAlertness(0.0);
00391				PlayAnim('Breath2', AnimSpeed, 0.7);
00392			}
00393			else
00394			{
00395				SetAlertness(0.5);
00396				LoopAnim('Looking', AnimSpeed);
00397			}
00398			return;
00399		}
00400		else if ( AnimSequence == 'Headup' )
00401		{
00402			if (decision < 0.1)
00403			{
00404				SetAlertness(0.0);
00405				PlayAnim('Breath2', AnimSpeed, 0.7);
00406			}
00407			else
00408			{
00409				SetAlertness(0.6);
00410				LoopAnim('Looking', AnimSpeed);
00411				if ( !bQuiet )
00412					PlaySound(Roam, SLOT_Talk);
00413			}
00414			return; 	
00415		}
00416		else if ( AnimSequence == 'guncheck' )
00417		{
00418			SetAlertness(-0.4);
00419			if (decision < 0.87) 
00420				LoopAnim('gunfix', AnimSpeed);
00421			else
00422			{
00423				PlayCock();
00424				LoopAnim('guncheck', AnimSpeed);
00425			}
00426			return;
00427		}
00428		else
00429		{
00430			SetAlertness(-0.3);
00431			PlayAnim('gunfix', animspeed, 0.6);
00432			return;
00433		} 
00434	}
00435	
00436	function PlayWaitingAmbush()
00437	{
00438		if (Region.Zone.bWaterZone)
00439		{
00440			PlaySwimming();
00441			return;
00442		}
00443		if ( bFakeDeath )
00444			return;
00445		if ( bButtonPusher )
00446		{
00447			PushButtons();
00448			return;
00449		}
00450		if (FRand() < 0.8)
00451			LoopAnim('Breath2', 0.3 + 0.6 * FRand());
00452		else
00453			LoopAnim('Breath', 0.3 + 0.6 * FRand());
00454	}
00455	
00456	function PlayDive()
00457	{
00458		TweenToSwimming(0.2);
00459	}
00460	
00461	function TweenToWaiting(float tweentime)
00462	{
00463		if ( bFakeDeath )
00464			return;
00465		if (Region.Zone.bWaterZone)
00466		{
00467			TweenToSwimming(tweentime);
00468			return;
00469		}
00470		TweenAnim('gunfix', tweentime);
00471	}
00472	
00473	function TweenToFighter(float tweentime)
00474	{
00475		bButtonPusher = false;
00476		bFakeDeath = false;
00477		if (Region.Zone.bWaterZone)
00478		{
00479			TweenToSwimming(tweentime);
00480			return;
00481		}
00482		if ( (AnimSequence == 'Death2') && (AnimFrame > 0.8) )
00483		{
00484			SetFall();
00485			GotoState('FallingState', 'RiseUp');
00486		}
00487		else
00488			TweenAnim('Fighter', tweentime);
00489	}
00490	
00491	function TweenToRunning(float tweentime)
00492	{
00493		bButtonPusher = false;
00494		bFakeDeath = false;
00495		if (Region.Zone.bWaterZone)
00496		{
00497			TweenToSwimming(tweentime);
00498			return;
00499		}
00500		if ( (AnimSequence == 'Death2') && (AnimFrame > 0.8) )
00501		{
00502			SetFall();
00503			GotoState('FallingState', 'RiseUp');
00504		}
00505		else if ( ((AnimSequence != 'Jog') && (AnimSequence != 'JogFire')) || !bAnimLoop )
00506			TweenAnim('Jog', tweentime);
00507	}
00508	
00509	function TweenToWalking(float tweentime)
00510	{
00511		if (Region.Zone.bWaterZone)
00512		{
00513			TweenToSwimming(tweentime);
00514			return;
00515		}
00516		TweenAnim('Walk', tweentime);
00517	}
00518	
00519	function TweenToPatrolStop(float tweentime)
00520	{
00521		if ( bFakeDeath )
00522			return;
00523		if (Region.Zone.bWaterZone)
00524		{
00525			TweenToSwimming(tweentime);
00526			return;
00527		}
00528		TweenAnim('Breath', tweentime);
00529	}
00530	
00531	function PlayWalking()
00532	{
00533		if (Region.Zone.bWaterZone)
00534		{
00535			PlaySwimming();
00536			return;
00537		}
00538	
00539		LoopAnim('Walk', 0.88);
00540	}
00541	
00542	function TweenToSwimming(float tweentime)
00543	{
00544		if ( (AnimSequence != 'Swim') || !bAnimLoop )
00545			TweenAnim('Swim', tweentime);
00546	}
00547	
00548	function PlaySwimming()
00549	{
00550		LoopAnim('Swim', -1.0/WaterSpeed,, 0.5); 
00551	}
00552	
00553	function PlayTurning()
00554	{
00555		if (Region.Zone.bWaterZone)
00556		{
00557			PlaySwimming();
00558			return;
00559		}
00560		if ( (AnimSequence == 'Death2') && (AnimFrame > 0.8) )
00561		{
00562			SetFall();
00563			GotoState('FallingState', 'RiseUp');
00564		}
00565		else
00566			TweenAnim('Walk', 0.3);
00567	}
00568	
00569	function PlayBigDeath(name DamageType)
00570	{
00571		if ( FRand() < 0.35 )
00572			PlayAnim('Death',0.7,0.1);
00573		else
00574			PlayAnim('Death2',0.7,0.1);
00575		PlaySound(Die2, SLOT_Talk, 4.5 * TransientSoundVolume);
00576	}
00577	
00578	function PlayHeadDeath(name DamageType)
00579	{
00580		local carcass carc;
00581	
00582		if ( ((DamageType == 'Decapitated') || ((Health < -20) && (FRand() < 0.5)))
00583			 && !Level.Game.bVeryLowGore )
00584		{
00585			carc = Spawn(class 'CreatureChunks',,, Location + CollisionHeight * vect(0,0,0.8), Rotation + rot(3000,0,16384) );
00586			if (carc != None)
00587			{
00588				carc.Mesh = mesh'SkaarjHead';
00589				carc.Initfor(self);
00590				carc.Velocity = Velocity + VSize(Velocity) * VRand();
00591				carc.Velocity.Z = FMax(carc.Velocity.Z, Velocity.Z);
00592			}
00593			PlayAnim('Death5',0.7,0.1);
00594			if ( IsA('SkaarjWarrior') && (Velocity.Z < 120) )
00595			{
00596				Velocity = GroundSpeed * vector(Rotation);
00597				Velocity.Z = 150;
00598			}
00599		}
00600		else if ( FRand() < 0.5 )
00601			PlayAnim('Death',0.7,0.1);
00602		else
00603			PlayAnim('Death4',0.7,0.1);
00604		PlaySound(Die, SLOT_Talk, 4.5 * TransientSoundVolume);
00605	}
00606	
00607	function PlayLeftDeath(name DamageType)
00608	{
00609		if ( FRand() < 0.5 )
00610			PlayAnim('Death',0.7,0.1);
00611		else
00612			PlayAnim('Death4',0.7,0.1);
00613		PlaySound(Die, SLOT_Talk, 4.5 * TransientSoundVolume);
00614	}
00615	
00616	function PlayRightDeath(name DamageType)
00617	{
00618		if ( FRand() < 0.3 )
00619			PlayAnim('Death3',0.7,0.1);
00620		else
00621			PlayAnim('Death4',0.7,0.1);
00622		PlaySound(Die, SLOT_Talk, 4.5 * TransientSoundVolume);
00623	}
00624	
00625	function PlayGutDeath(name DamageType)
00626	{
00627		PlayAnim('Death3',0.7, 0.1);
00628		PlaySound(Die, SLOT_Talk, 4.5 * TransientSoundVolume);
00629	}
00630	
00631	function PlayTakeHitSound(int Damage, name damageType, int Mult)
00632	{
00633		local float decision;
00634	
00635		if ( Level.TimeSeconds - LastPainSound < 0.25 )
00636			return;
00637		LastPainSound = Level.TimeSeconds;
00638	
00639		decision = FRand(); //FIXME - modify based on damage
00640		if (decision < 0.25)
00641			PlaySound(HitSound1, SLOT_Pain, 2.0 * Mult);
00642		else if (decision < 0.5)
00643			PlaySound(HitSound2, SLOT_Pain, 2.0 * Mult);
00644		else if (decision < 0.75)
00645			PlaySound(HitSound3, SLOT_Pain, 2.0 * Mult);
00646		else
00647			PlaySound(HitSound4, SLOT_Pain, 2.0 * Mult); 
00648	}
00649	
00650	function TweenToFalling()
00651	{
00652		if ( FRand() < 0.5 )
00653			TweenAnim('Jog', 0.2);
00654		else
00655			PlayAnim('Jump',0.7,0.1);
00656	}
00657	
00658	function PlayInAir()
00659	{
00660		if ( AnimSequence == 'Jog' )
00661			PlayAnim('Jog', 0.4);
00662		else if ( AnimSequence == 'JogFire' )
00663			PlayAnim('JogFire', 0.4);
00664		else
00665			TweenAnim('InAir',0.4);
00666	}
00667	
00668	function PlayOutOfWater()
00669	{
00670		TweenAnim('Landed', 0.8);
00671	}
00672	
00673	function PlayLanded(float impactVel)
00674	{
00675		if (impactVel > 1.7 * JumpZ)
00676			TweenAnim('Landed',0.1);
00677		else
00678			TweenAnim('Land', 0.1);
00679	}
00680		
00681	function PlayTakeHit(float tweentime, vector HitLoc, int damage)
00682	{
00683		if ( (Velocity.Z > 120) && (Health < 0.4 * Default.Health) && (FRand() < 0.33) )
00684			PlayAnim('Death2',0.7);
00685		else if ( (AnimSequence != 'Spin') && (AnimSequence != 'Lunge') && (AnimSequence != 'Death2') )
00686			Super.PlayTakeHit(tweentime, HitLoc, damage);
00687	}
00688	
00689	function SpinDamageTarget()
00690	{
00691		if (MeleeDamageTarget(SpinDamage, (SpinDamage * 1000 * Normal(Target.Location - Location))) )
00692			PlaySound(slice, SLOT_Interact);		
00693	}
00694	
00695	function ClawDamageTarget()
00696	{
00697		if ( MeleeDamageTarget(ClawDamage, (ClawDamage * 900 * Normal(Target.Location - Location))) )
00698			PlaySound(slice, SLOT_Interact);			
00699	}
00700	
00701		
00702	function PlayMeleeAttack()
00703	{
00704		local int hitdamage;
00705		local float TargetDist, decision;
00706	
00707		decision = FRand();
00708		if (AnimSequence == 'Spin')
00709			decision += 0.2;
00710		else if (AnimSequence == 'Claw')
00711			decision -= 0.2;
00712		AttackSuccess = false;
00713		//log("Start Melee Attack");
00714		if ( Region.Zone.bWaterZone || (decision < 0.5) )
00715		{
00716			Acceleration = AccelRate * Normal(Target.Location - Location);
00717	 		PlayAnim('Spin');
00718			PlaySound(Spin, SLOT_Interact);	 		
00719	 	}
00720		else
00721		{
00722	 		PlayAnim('Claw'); 
00723	 		PlaySound(Claw, SLOT_Interact);
00724	 	}	
00725	 }
00726	
00727	function PlayRangedAttack()
00728	{
00729		PlayAnim('Firing', 1.5); 
00730	}
00731	
00732	state TakeHit 
00733	{
00734	ignores seeplayer, hearnoise, bump, hitwall;
00735	
00736		function Landed(vector HitNormal)
00737		{
00738			local float landVol;
00739	
00740			if ( AnimSequence == 'Death2' )
00741			{
00742				landVol = 0.75 + Velocity.Z * 0.004;
00743				LandVol = Mass * landVol * landVol * 0.01;
00744				PlaySound(sound'thump', SLOT_Interact, landVol);
00745				GotoState('FallingState', 'RiseUp');
00746			}
00747			else
00748				Super.Landed(HitNormal);
00749		}
00750	
00751		function PlayTakeHit(float tweentime, vector HitLoc, int damage)
00752		{
00753			if ( AnimSequence != 'Death2' )
00754				Global.PlayTakeHit(tweentime, HitLoc, damage);
00755		}
00756	
00757		function BeginState()
00758		{
00759			Super.BeginState();
00760			If ( AnimSequence == 'Death2' )
00761				GotoState('FallingState');
00762		}	
00763	}
00764	
00765	state FallingState
00766	{
00767	ignores Bump, Hitwall, HearNoise, WarnTarget;
00768	
00769		function Landed(vector HitNormal)
00770		{
00771			local float landVol;
00772	
00773			if ( AnimSequence == 'Death2' )
00774			{
00775				landVol = 0.75 + Velocity.Z * 0.004;
00776				LandVol = Mass * landVol * landVol * 0.01;
00777				PlaySound(sound'Thump', SLOT_Interact, landVol);
00778				GotoState('FallingState', 'RiseUp');
00779			}
00780			else if ( (AnimSequence == 'LeftDodge') || (AnimSequence == 'RightDodge') )
00781			{
00782				landVol = Velocity.Z/JumpZ;
00783				landVol = 0.008 * Mass * landVol * landVol;
00784				if ( !FootRegion.Zone.bWaterZone )
00785					PlaySound(Land, SLOT_Interact, FMin(20, landVol));
00786				GotoState('FallingState', 'FinishDodge');
00787			}
00788			else
00789				Super.Landed(HitNormal);
00790		}
00791	
00792		function PlayTakeHit(float tweentime, vector HitLoc, int damage)
00793		{
00794			if ( AnimSequence != 'Death2' )
00795				Global.PlayTakeHit(tweentime, HitLoc, damage);
00796		}
00797	
00798	LongFall:
00799		if ( AnimSequence == 'Death2' )
00800		{
00801			Sleep(1.5);
00802			Goto('RiseUp');
00803		}
00804		if ( bCanFly )
00805		{
00806			SetPhysics(PHYS_Flying);
00807			Goto('Done');
00808		}
00809		Sleep(0.7);
00810		TweenToFighter(0.2);
00811		if ( bHasRangedAttack && (Enemy != None) )
00812		{
00813			TurnToward(Enemy);
00814			FinishAnim();
00815			if ( CanFireAtEnemy() )
00816			{
00817				PlayRangedAttack();
00818				FinishAnim();
00819			}
00820			PlayChallenge();
00821			FinishAnim();
00822		}
00823		TweenToFalling();
00824		if ( Velocity.Z > -150 ) //stuck
00825		{
00826			SetPhysics(PHYS_Falling);
00827			if ( Enemy != None )
00828				Velocity = groundspeed * normal(Enemy.Location - Location);
00829			else
00830				Velocity = groundspeed * VRand();
00831	
00832			Velocity.Z = FMax(JumpZ, 250);
00833		}
00834		Goto('LongFall');
00835	RiseUp:
00836		FinishAnim();
00837		bCanDuck = false;
00838		DesiredRotation = Rotation;
00839		Acceleration = vect(0,0,0);
00840		if ( !bFakeDeath )
00841			Sleep(1.0 + 6 * FRand());
00842		PlayAnim('GetUp', 0.7);
00843	FinishDodge:
00844		FinishAnim();
00845		bCanDuck = true;
00846		Goto('Done');
00847	}
00848	
00849	state Hunting
00850	{
00851	ignores EnemyNotVisible; 
00852	
00853		function BeginState()
00854		{
00855			bCanSwim = true;
00856			Super.BeginState();
00857		}
00858	
00859		function EndState()
00860		{
00861			if ( !Region.Zone.bWaterZone )
00862				bCanSwim = false;
00863			Super.EndState();
00864		}
00865	}
00866	
00867	state RangedAttack
00868	{
00869	ignores SeePlayer, HearNoise;
00870		
00871		function Bump (Actor Other)
00872		{
00873			if ( AttackSuccess || (AnimSequence != 'Lunge') )
00874			{
00875				Disable('Bump');
00876				return;
00877			}
00878			else		
00879				LungeDamageTarget();
00880	
00881			if (!AttackSuccess && Pawn(Other) != None) //always add momentum
00882				Pawn(Other).AddVelocity((60000.0 * (Normal(Other.Location - Location)))/Other.Mass);
00883		}
00884		
00885		function LungeDamageTarget()
00886		{
00887			If (MeleeDamageTarget(LungeDamage, (LungeDamage * 2000 * Normal(Target.Location - Location))))
00888			{
00889				AttackSuccess = true;
00890				disable('Bump');
00891				PlaySound(Slice, SLOT_Interact);
00892			}
00893		}
00894		
00895		function PlayRangedAttack()
00896		{
00897			local float dist;
00898			dist = VSize(Target.Location - Location + vect(0,0,1) * (CollisionHeight - Target.CollisionHeight));
00899			if ( (FRand() < 0.7) && (dist < 180 + CollisionRadius + Target.CollisionRadius) && (Region.Zone.bWaterZone || !Target.Region.Zone.bWaterZone) )
00900			{
00901				PlaySound(Lunge, SLOT_Interact);
00902		 		Velocity = 500 * (Target.Location - Location)/dist; //instant acceleration in that direction 
00903		 		Velocity.Z += 1.5 * dist;
00904		 		if (Physics != PHYS_Swimming)
00905		 			SetPhysics(PHYS_Falling);
00906		 		Enable('Bump');
00907		 		PlayAnim('Lunge');
00908		 	}
00909			else
00910			{
00911				Disable('Bump');
00912				PlayAnim('Firing', 1.5); 
00913			}
00914		}
00915	}
00916	
00917	defaultproperties
00918	{
00919	     LungeDamage=30
00920	     SpinDamage=20
00921	     ClawDamage=15
00922	     HitSound3=Sound'UnrealShare.Skaarj.injur3sk'
00923	     HitSound4=Sound'UnrealShare.Skaarj.injur3sk'
00924	     syllable1=Sound'UnrealShare.Skaarj.syl07sk'
00925	     syllable2=Sound'UnrealShare.Skaarj.syl09sk'
00926	     syllable3=Sound'UnrealShare.Skaarj.syl11sk'
00927	     syllable4=Sound'UnrealShare.Skaarj.syl12sk'
00928	     syllable5=Sound'UnrealShare.Skaarj.syl13sk'
00929	     syllable6=Sound'UnrealShare.Skaarj.syl15sk'
00930	     spin=Sound'UnrealShare.Skaarj.spin1s'
00931	     claw=Sound'UnrealShare.Skaarj.claw2s'
00932	     slice=Sound'UnrealShare.Skaarj.clawhit1s'
00933	     lunge=Sound'UnrealShare.Skaarj.lunge1sk'
00934	     hairflip=Sound'UnrealShare.Skaarj.hairflp2sk'
00935	     Die2=Sound'UnrealShare.Skaarj.death2sk'
00936	     footstep=Sound'UnrealShare.Cow.walkC'
00937	     Footstep2=Sound'UnrealShare.Cow.walkC'
00938	     VoicePitch=0.500000
00939	     CarcassType=Class'UnrealShare.SkaarjCarcass'
00940	     Aggressiveness=0.500000
00941	     RefireRate=0.500000
00942	     bHasRangedAttack=True
00943	     bMovingRangedAttack=True
00944	     RangedProjectile=Class'UnrealShare.SkaarjProjectile'
00945	     Acquire=Sound'UnrealShare.Skaarj.chalnge1s'
00946	     Roam=Sound'UnrealShare.Skaarj.roam11s'
00947	     Threaten=Sound'UnrealShare.Skaarj.chalnge3s'
00948	     bCanStrafe=True
00949	     MeleeRange=40.000000
00950	     GroundSpeed=440.000000
00951	     AccelRate=1200.000000
00952	     Health=210
00953	     UnderWaterTime=-1.000000
00954	     Intelligence=BRAINS_HUMAN
00955	     HitSound1=Sound'UnrealShare.Skaarj.injur1sk'
00956	     HitSound2=Sound'UnrealShare.Skaarj.injur2sk'
00957	     Die=Sound'UnrealShare.Skaarj.death1sk'
00958	     CombatStyle=0.650000
00959	     AmbientSound=Sound'UnrealShare.Skaarj.amb1sk'
00960	     DrawType=DT_Mesh
00961	     TransientSoundVolume=3.000000
00962	     CollisionRadius=35.000000
00963	     CollisionHeight=46.000000
00964	     Mass=150.000000
00965	     Buoyancy=150.000000
00966	     RotationRate=(Pitch=3072,Yaw=60000,Roll=2048)
00967	}

End Source Code