UnrealShare
Class Nali

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

class Nali
extends UnrealShare.ScriptedPawn

//============================================================================= // Nali. //=============================================================================
Variables
 Weapon Tool
 bool bCringing
 bool bFading
 bool bGesture
 bool bHasWandered
 bool bNeverBow

States
Wandering, Roaming, FadeOut, Guarding, AlarmPaused, TriggerAlarm, Retreating

Function Summary
 bool AdjustHitLocation(out vector, vector TraceDir)
 eAttitude AttitudeToCreature(Pawn Other)
 eAttitude AttitudeWithFear()
     
/* AttitudeWithFear()
may fear other, unless near home
*/
 void Killed(Pawn Killer, Pawn Other, name damageType)
 void PlayBigDeath(name DamageType)
 void PlayCombatMove()
 void PlayDive()
 void PlayDying(name DamageType, vector HitLoc)
 void PlayFearSound()
 void PlayGutDeath(name DamageType)
 void PlayHeadDeath(name DamageType)
 void PlayLanded(float impactVel)
 void PlayLeftDeath(name DamageType)
 void PlayMeleeAttack()
 void PlayPatrolStop()
 void PlayRangedAttack()
 void PlayRetreating()
 void PlayRightDeath(name DamageType)
 void PlayRunning()
 void PlaySwimming()
 void PlayThreatening()
 void PlayTurning()
 void PlayVictoryDance()
 void PlayWaiting()
 void PlayWaitingAmbush()
 void PlayWalking()
 void PostBeginPlay()
 void SpeakPrayer()
 void Step()
 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 damageAttitudeTo(Pawn Other)


State Wandering Function Summary
 void PickDestination()


State Roaming Function Summary
 void PickDestination()


State FadeOut Function Summary
 void EndState()
 void BeginState()
 void Tick(float DeltaTime)
 void TakeDamage(int Damage, Pawn instigatedBy, Vector hitlocation, Vector momentum, name damageType)


State Guarding Function Summary
 void PlayPatrolStop()


State AlarmPaused Function Summary
 void BeginState()
 void PlayWaitAround()
 void PlayWaiting()


State TriggerAlarm Function Summary
 void Bump(Actor Other)


State Retreating Function Summary
 void EndState()
 void BeginState()
 void ChangeDestination()
 void PickDestination()
 void Bump(Actor Other)
 void ReachedHome()
 void SetFall()
 void SeePlayer(Actor SeenPlayer)
 void EnemyNotVisible()



Source Code


00001	//=============================================================================
00002	// Nali.
00003	//=============================================================================
00004	class Nali extends ScriptedPawn;
00005	
00006	#exec MESH IMPORT MESH=Nali1 ANIVFILE=MODELS\nali_a.3D DATAFILE=MODELS\nali_d.3D X=0 Y=0 Z=0 ZEROTEX=1
00007	#exec MESH ORIGIN MESH=Nali1 X=00 Y=-130 Z=30 YAW=64 ROLL=-64
00008	
00009	#exec MESH SEQUENCE MESH=nali1 SEQ=All      STARTFRAME=0   NUMFRAMES=397
00010	#exec MESH SEQUENCE MESH=nali1 SEQ=Backup   STARTFRAME=0   NUMFRAMES=10  RATE=15
00011	#exec MESH SEQUENCE MESH=nali1 SEQ=Bowing   STARTFRAME=10  NUMFRAMES=20  RATE=15 Group=Ducking
00012	#exec MESH SEQUENCE MESH=nali1 SEQ=Breath   STARTFRAME=30  NUMFRAMES=8   RATE=6
00013	#exec MESH SEQUENCE MESH=nali1 SEQ=Cough    STARTFRAME=38  NUMFRAMES=25  RATE=15
00014	#exec MESH SEQUENCE MESH=nali1 SEQ=Landed   STARTFRAME=68  NUMFRAMES=1
00015	#exec MESH SEQUENCE MESH=nali1 SEQ=Cringe   STARTFRAME=63  NUMFRAMES=15  RATE=15 Group=Ducking
00016	#exec MESH SEQUENCE MESH=nali1 SEQ=Dead     STARTFRAME=78  NUMFRAMES=38  RATE=15
00017	#exec MESH SEQUENCE MESH=nali1 SEQ=Dead2    STARTFRAME=116 NUMFRAMES=16  RATE=15
00018	#exec MESH SEQUENCE MESH=nali1 SEQ=Dead3    STARTFRAME=132 NUMFRAMES=13  RATE=15
00019	#exec MESH SEQUENCE MESH=nali1 SEQ=Dead4    STARTFRAME=145 NUMFRAMES=21  RATE=15
00020	#exec MESH SEQUENCE MESH=nali1 SEQ=Follow   STARTFRAME=166 NUMFRAMES=23  RATE=15
00021	#exec MESH SEQUENCE MESH=nali1 SEQ=GetDown  STARTFRAME=189 NUMFRAMES=5   RATE=15
00022	#exec MESH SEQUENCE MESH=nali1 SEQ=GetUp    STARTFRAME=194 NUMFRAMES=8   RATE=15
00023	#exec MESH SEQUENCE MESH=nali1 SEQ=levitate STARTFRAME=202 NUMFRAMES=6  RATE=6
00024	#exec MESH SEQUENCE MESH=nali1 SEQ=pray     STARTFRAME=208 NUMFRAMES=8   RATE=6
00025	#exec MESH SEQUENCE MESH=nali1 SEQ=spell    STARTFRAME=216 NUMFRAMES=28  RATE=15
00026	#exec MESH SEQUENCE MESH=nali1 SEQ=Sweat    STARTFRAME=244 NUMFRAMES=18  RATE=15
00027	#exec MESH SEQUENCE MESH=nali1 SEQ=walk     STARTFRAME=262 NUMFRAMES=20  RATE=15
00028	#exec MESH SEQUENCE MESH=nali1 SEQ=GutHit   STARTFRAME=282 NUMFRAMES=1
00029	#exec MESH SEQUENCE MESH=nali1 SEQ=AimDown  STARTFRAME=283 NUMFRAMES=1
00030	#exec MESH SEQUENCE MESH=nali1 SEQ=AimUp    STARTFRAME=284 NUMFRAMES=1
00031	#exec MESH SEQUENCE MESH=nali1 SEQ=Bow2     STARTFRAME=285 NUMFRAMES=28  RATE=15
00032	#exec MESH SEQUENCE MESH=nali1 SEQ=HeadHit  STARTFRAME=313 NUMFRAMES=1
00033	#exec MESH SEQUENCE MESH=nali1 SEQ=LeftHit  STARTFRAME=314 NUMFRAMES=1
00034	#exec MESH SEQUENCE MESH=nali1 SEQ=RightHit STARTFRAME=315 NUMFRAMES=1
00035	#exec MESH SEQUENCE MESH=nali1 SEQ=Run      STARTFRAME=316 NUMFRAMES=10  RATE=15
00036	#exec MESH SEQUENCE MESH=nali1 SEQ=RunFire  STARTFRAME=326 NUMFRAMES=10  RATE=15
00037	#exec MESH SEQUENCE MESH=nali1 SEQ=StilFire STARTFRAME=336 NUMFRAMES=1
00038	#exec MESH SEQUENCE MESH=nali1 SEQ=WalkFire STARTFRAME=337 NUMFRAMES=20  RATE=15
00039	#exec MESH SEQUENCE MESH=nali1 SEQ=WalkTool STARTFRAME=357 NUMFRAMES=20  RATE=15
00040	#exec MESH SEQUENCE MESH=nali1 SEQ=Drowning STARTFRAME=377 NUMFRAMES=20  RATE=15
00041	
00042	#exec MESH SEQUENCE MESH=nali1 SEQ=fighter STARTFRAME=0   NUMFRAMES=1
00043	
00044	#exec TEXTURE IMPORT NAME=JNali1 FILE=MODELS\nali.PCX GROUP=Skins 
00045	#exec MESHMAP SCALE MESHMAP=nali1 X=0.069 Y=0.069 Z=0.138
00046	#exec MESHMAP SETTEXTURE MESHMAP=nali1 NUM=0 TEXTURE=Jnali1
00047	
00048	#exec MESH NOTIFY MESH=Nali1 SEQ=Dead TIME=0.46 FUNCTION=LandThump
00049	#exec MESH NOTIFY MESH=Nali1 SEQ=Dead2 TIME=0.64 FUNCTION=LandThump
00050	#exec MESH NOTIFY MESH=Nali1 SEQ=Dead3 TIME=0.84 FUNCTION=LandThump
00051	#exec MESH NOTIFY MESH=Nali1 SEQ=Dead4 TIME=0.51 FUNCTION=LandThump
00052	#exec MESH NOTIFY MESH=Nali1 SEQ=Backup TIME=0.25 FUNCTION=Step
00053	#exec MESH NOTIFY MESH=Nali1 SEQ=Backup TIME=0.75 FUNCTION=Step
00054	#exec MESH NOTIFY MESH=Nali1 SEQ=Walk   TIME=0.25 FUNCTION=Step
00055	#exec MESH NOTIFY MESH=Nali1 SEQ=Walk   TIME=0.75 FUNCTION=Step
00056	
00057	#exec AUDIO IMPORT FILE="Sounds\Nali\syl1.WAV" NAME="syl1n" GROUP="Nali"
00058	#exec AUDIO IMPORT FILE="Sounds\Nali\syl2.WAV" NAME="syl2n" GROUP="Nali"
00059	#exec AUDIO IMPORT FILE="Sounds\Nali\syl3.WAV" NAME="syl3n" GROUP="Nali"
00060	#exec AUDIO IMPORT FILE="Sounds\Nali\syl4.WAV" NAME="syl4n" GROUP="Nali"
00061	#exec AUDIO IMPORT FILE="Sounds\Nali\syl5.WAV" NAME="syl5n" GROUP="Nali"
00062	#exec AUDIO IMPORT FILE="Sounds\Nali\syl6.WAV" NAME="syl6n" GROUP="Nali"
00063	#exec AUDIO IMPORT FILE="Sounds\Nali\follow1c.WAV" NAME="follow1n" GROUP="Nali"
00064	#exec AUDIO IMPORT FILE="Sounds\Nali\injur1a.WAV" NAME="injur1n" GROUP="Nali"
00065	#exec AUDIO IMPORT FILE="Sounds\Nali\injur2a.WAV" NAME="injur2n" GROUP="Nali"
00066	#exec AUDIO IMPORT FILE="Sounds\Nali\contct1a.WAV" NAME="contct1n" GROUP="Nali"
00067	#exec AUDIO IMPORT FILE="Sounds\Nali\contct3a.WAV" NAME="contct3n" GROUP="Nali"
00068	#exec AUDIO IMPORT FILE="Sounds\Nali\fear1a.WAV" NAME="fear1n" GROUP="Nali"
00069	#exec AUDIO IMPORT FILE="Sounds\Nali\breath2na.WAV" NAME="breath1n" GROUP="Nali"
00070	#exec AUDIO IMPORT FILE="Sounds\Nali\death1na.WAV" NAME="death1n" GROUP="Nali"
00071	#exec AUDIO IMPORT FILE="Sounds\Nali\death2a.WAV" NAME="death2n" GROUP="Nali"
00072	#exec AUDIO IMPORT FILE="Sounds\Nali\bowing1a.WAV" NAME="bowing1n" GROUP="Nali"
00073	#exec AUDIO IMPORT FILE="Sounds\Nali\cringe2a.WAV" NAME="cringe2n" GROUP="Nali"
00074	#exec AUDIO IMPORT FILE="Sounds\Nali\backup2a.WAV" NAME="backup2n" GROUP="Nali"
00075	#exec AUDIO IMPORT FILE="Sounds\Nali\cough1na.WAV" NAME="cough1n" GROUP="Nali"
00076	#exec AUDIO IMPORT FILE="Sounds\Nali\sweat1na.WAV" NAME="sweat1n" GROUP="Nali"
00077	#exec AUDIO IMPORT FILE="Sounds\Nali\levitF1.WAV" NAME="pray1n" GROUP="Nali"
00078	#exec AUDIO IMPORT FILE="Sounds\Cow\walknc.WAV" NAME="walkC" GROUP="Cow"
00079	#exec AUDIO IMPORT FILE="Sounds\Generic\teleprt27.WAV" NAME="Teleport1" GROUP="Generic"
00080	
00081	//====================================================================
00082	// Nali Variables
00083	
00084	var() bool bNeverBow;
00085	var bool bCringing;
00086	var bool bGesture;
00087	var bool bFading;
00088	var bool bHasWandered;
00089	var(Sounds) sound syllable1;
00090	var(Sounds) sound syllable2;
00091	var(Sounds) sound syllable3;
00092	var(Sounds) sound syllable4;
00093	var(Sounds) sound syllable5;
00094	var(Sounds) sound syllable6;
00095	var(Sounds) sound urgefollow;
00096	var(Sounds) sound cringe;
00097	var(Sounds) sound cough;
00098	var(Sounds) sound sweat;
00099	var(Sounds) sound bowing;
00100	var(Sounds) sound backup;
00101	var(Sounds) sound pray;
00102	var(Sounds) sound breath;
00103	var() Weapon Tool;
00104	
00105	function PostBeginPlay()
00106	{
00107		Super.PostBeginPlay();
00108		bCanSpeak = true;
00109		if ( Orders == 'Ambushing' )
00110			AnimSequence = 'Levitate';
00111	}
00112	
00113	function SpeakPrayer()
00114	{
00115		PlaySound(Pray);
00116	}
00117	
00118	
00119	function PlayFearSound()
00120	{
00121		if ( (Threaten != None) && (FRand() < 0.4) )
00122		{
00123			PlaySound(Threaten, SLOT_Talk,, true); 
00124			return;
00125		}
00126		if (Fear != None)
00127			PlaySound(Fear, SLOT_Talk,, true); 
00128	}
00129	
00130	function bool AdjustHitLocation(out vector HitLocation, vector TraceDir)
00131	{
00132		local float adjZ, maxZ;
00133	
00134		TraceDir = Normal(TraceDir);
00135		HitLocation = HitLocation + 0.5 * CollisionRadius * TraceDir;
00136	
00137		if ( (GetAnimGroup(AnimSequence) == 'Ducking') && (AnimFrame > -0.03) )
00138		{
00139			if ( AnimSequence == 'Bowing' )
00140				maxZ = Location.Z - 0.2 * CollisionHeight;
00141			else
00142				maxZ = Location.Z + 0.25 * CollisionHeight;
00143			if ( HitLocation.Z > maxZ )
00144			{
00145				if ( TraceDir.Z >= 0 )
00146					return false;
00147				adjZ = (maxZ - HitLocation.Z)/TraceDir.Z;
00148				HitLocation.Z = maxZ;
00149				HitLocation.X = HitLocation.X + TraceDir.X * adjZ;
00150				HitLocation.Y = HitLocation.Y + TraceDir.Y * adjZ;
00151				if ( VSize(HitLocation - Location) > CollisionRadius )	
00152					return false;
00153			}
00154		}
00155		return true;
00156	}
00157	
00158	function Killed(pawn Killer, pawn Other, name damageType)
00159	{
00160		if ( (Nali(Other) != None) && Killer.bIsPlayer )
00161			AttitudeToPlayer = ATTITUDE_Fear;
00162		Super.Killed(Killer, Other, damageType);
00163	}
00164	
00165	/* AttitudeWithFear()
00166	may fear other, unless near home
00167	*/
00168	
00169	function eAttitude AttitudeWithFear()
00170	{
00171		return ATTITUDE_Fear;
00172	}
00173	
00174	function damageAttitudeTo(pawn Other)
00175	{
00176		local eAttitude OldAttitude;
00177		
00178		if ( (Other == Self) || (Other == None) || (FlockPawn(Other) != None) )
00179			return;
00180		if( Other.bIsPlayer ) //change attitude to player
00181			AttitudeToPlayer = ATTITUDE_Fear;
00182		else if ( ScriptedPawn(Other) == None )
00183			Hated = Other;
00184		SetEnemy(Other);				
00185	}
00186	
00187	function eAttitude AttitudeToCreature(Pawn Other)
00188	{
00189		if ( Other.IsA('Nali') )
00190			return ATTITUDE_Friendly;
00191		else if ( Other.IsA('ScriptedPawn') && !Other.IsA('Cow') )
00192			return ATTITUDE_Fear;
00193		else
00194			return ATTITUDE_Ignore;
00195	}
00196	
00197	function Step()
00198	{
00199		PlaySound(sound'WalkC', SLOT_Interact,0.5,,500);
00200	}	
00201	
00202	function PlayWaiting()
00203	{
00204		local float decision;
00205		local float animspeed;
00206	
00207		if (Region.Zone.bWaterZone)
00208		{
00209			PlaySwimming();
00210			return;
00211		}
00212		
00213		animspeed = 0.4 + 0.6 * FRand(); 
00214		decision = FRand();
00215		if ( AnimSequence == 'Breath' )
00216		{
00217			if (!bQuiet && (decision < 0.12) )
00218			{
00219				PlaySound(Cough,Slot_Talk,1.0,,800);
00220				LoopAnim('Cough', 0.85);
00221				return;
00222			}
00223			else if (decision < 0.24)
00224			{
00225				PlaySound(Sweat,Slot_Talk,0.3,,300);
00226				LoopAnim('Sweat', animspeed);
00227				return;
00228			}
00229			else if (!bQuiet && (decision < 0.34) )
00230			{
00231				PlayAnim('Pray', animspeed, 0.3);
00232				return;
00233			}
00234		}
00235		else if ( AnimSequence == 'Pray' )
00236		{
00237			if (decision < 0.3)
00238				PlayAnim('Breath', animspeed, 0.3);
00239			else
00240			{
00241				SpeakPrayer();
00242				PlayAnim('Pray', animspeed);
00243			}
00244			return;
00245		}
00246	 	
00247		PlaySound(Breath,SLOT_Talk,0.5,true,500,animspeed * 1.5);
00248	 	LoopAnim('Breath', animspeed);
00249	}
00250	
00251	function PlayPatrolStop()
00252	{
00253		PlayWaiting();
00254	}
00255	
00256	function PlayWaitingAmbush()
00257	{
00258		if (Region.Zone.bWaterZone)
00259		{
00260			PlaySwimming();
00261			return;
00262		}
00263		
00264		LoopAnim('Levitate', 0.4 + 0.3 * FRand());
00265	}
00266	
00267	function PlayDive()
00268	{
00269		TweenToSwimming(0.2);
00270	}
00271	
00272	function TweenToFighter(float tweentime)
00273	{
00274		if (Region.Zone.bWaterZone)
00275			TweenToSwimming(tweentime);
00276		else if (AnimSequence == 'Bowing')
00277			PlayAnim('GetUp', 0.4, 0.15);
00278		else
00279			TweenAnim('Fighter', tweentime);
00280	}
00281	
00282	function TweenToRunning(float tweentime)
00283	{
00284		if (Region.Zone.bWaterZone)
00285			TweenToSwimming(tweentime);
00286		else if ( ((AnimSequence != 'Run') && (AnimSequence != 'RunFire')) || !bAnimLoop)
00287		{
00288			if (AnimSequence == 'Bowing')
00289				PlayAnim('GetUp', 0.4, 0.15);
00290			else
00291				TweenAnim('Run', tweentime);
00292		}
00293	}
00294	
00295	function TweenToWalking(float tweentime)
00296	{
00297		if (Region.Zone.bWaterZone)
00298			TweenToSwimming(tweentime);
00299		else if (AnimSequence == 'Bowing')
00300			PlayAnim('GetUp', 0.4, 0.15);
00301		else if ( Weapon != None )
00302			TweenAnim('WalkTool', tweentime);
00303		else
00304			TweenAnim('Walk', tweentime);
00305	}
00306	
00307	function TweenToWaiting(float tweentime)
00308	{
00309		if (Region.Zone.bWaterZone)
00310			TweenToSwimming(tweentime);
00311		else if (AnimSequence == 'Bowing')
00312			PlayAnim('GetUp', 0.4, 0.15);
00313		else
00314			TweenAnim('Breath', tweentime);
00315	}
00316	
00317	function TweenToPatrolStop(float tweentime)
00318	{
00319		if (Region.Zone.bWaterZone)
00320			TweenToSwimming(tweentime);
00321		else if (AnimSequence == 'Bowing')
00322			PlayAnim('GetUp', 0.4, 0.15);
00323		else if ( IsInState('Guarding')) 
00324			TweenAnim('Pray', tweentime);
00325		else
00326			TweenAnim('Breath', tweentime);
00327	}
00328	
00329	function PlayRunning()
00330	{
00331		if (Region.Zone.bWaterZone)
00332		{
00333			PlaySwimming();
00334			return;
00335		}
00336		LoopAnim('Run', -1.0/GroundSpeed,,0.4);
00337	}
00338	
00339	function PlayCombatMove()
00340	{
00341		if (Region.Zone.bWaterZone)
00342		{
00343			PlaySwimming();
00344			return;
00345		}
00346		LoopAnim('Walk', -1.3/GroundSpeed,,0.4);
00347	}
00348	
00349	function PlayWalking()
00350	{
00351		if (Region.Zone.bWaterZone)
00352		{
00353			PlaySwimming();
00354			return;
00355		}
00356		if ( Weapon != None )
00357			LoopAnim('WalkTool', -3/GroundSpeed,,0.4);
00358		else
00359			LoopAnim('Walk', -3/GroundSpeed,,0.4);
00360	}
00361	
00362	function PlayThreatening()
00363	{
00364		if (Region.Zone.bWaterZone)
00365		{
00366			PlaySwimming();
00367			return;
00368		}
00369		Acceleration = vect(0,0,0);
00370		if (AnimSequence == 'Backup')
00371		{
00372			PlaySound(Cringe, SLOT_Talk);
00373			LoopAnim('Cringe', 0.4 + 0.7 * FRand(), 0.4);
00374		}
00375		else if (AnimSequence == 'Cringe')
00376		{
00377			if ( FRand() < 0.6 )
00378				PlaySound(Cringe, SLOT_Talk);
00379			LoopAnim('Cringe', 0.4 + 0.7 * FRand());
00380		}
00381		else if (AnimSequence == 'Bowing')
00382		{
00383			PlaySound(Bowing, SLOT_Talk);
00384			LoopAnim('Bowing', 0.4 + 0.7 * FRand());
00385		}
00386		else if (FRand() < 0.4)
00387			LoopAnim('Bowing', 0.4 + 0.7 * FRand(), 0.5);		
00388		else 
00389			PlayRetreating();
00390	}
00391	
00392	function PlayRetreating()
00393	{
00394		if (Region.Zone.bWaterZone)
00395		{
00396			PlaySwimming();
00397			return;
00398		}
00399		bAvoidLedges = true;
00400		PlaySound(Backup, SLOT_Talk);
00401		DesiredRotation = Rotator(Enemy.Location - Location);
00402		DesiredSpeed = WalkingSpeed;
00403		Acceleration = AccelRate * Normal(Location - Enemy.Location);
00404		LoopAnim('Backup');
00405	} 
00406	
00407	function PlayTurning()
00408	{
00409		TweenAnim('Walk', 0.3);
00410	}
00411	
00412	function PlayDying(name DamageType, vector HitLoc)
00413	{
00414		//first check for head hit
00415		if ( ((DamageType == 'Decapitated') || (HitLoc.Z - Location.Z > 0.5 * CollisionHeight))
00416			 && !Level.Game.bVeryLowGore )
00417		{
00418			PlayHeadDeath(DamageType);
00419			return;
00420		}
00421		Super.PlayDying(DamageType, HitLoc);
00422	}
00423	
00424	function PlayHeadDeath(name DamageType)
00425	{
00426		local carcass carc;
00427	
00428		carc = Spawn(class 'CreatureChunks',,, Location + CollisionHeight * vect(0,0,0.8), Rotation + rot(3000,0,16384) );
00429		if (carc != None)
00430		{
00431			carc.Mesh = mesh'NaliHead';
00432			carc.Initfor(self);
00433			carc.Velocity = Velocity + VSize(Velocity) * VRand();
00434			carc.Velocity.Z = FMax(carc.Velocity.Z, Velocity.Z);
00435		}
00436		PlaySound(sound'Death2n', SLOT_Talk, 4 * TransientSoundVolume);
00437		PlayAnim('Dead3',0.5, 0.1);
00438	}
00439	
00440	function PlayBigDeath(name DamageType)
00441	{
00442		PlaySound(Die, SLOT_Talk, 4 * TransientSoundVolume);
00443		PlayAnim('Dead4',0.7, 0.1);
00444	}
00445	
00446	function PlayLeftDeath(name DamageType)
00447	{
00448		PlaySound(sound'Death2n', SLOT_Talk, 4 * TransientSoundVolume);
00449		PlayAnim('Dead',0.7, 0.1);
00450	}
00451	
00452	function PlayRightDeath(name DamageType)
00453	{
00454		PlaySound(Die, SLOT_Talk, 4 * TransientSoundVolume);
00455		PlayAnim('Dead2',0.7, 0.1);
00456	}
00457	
00458	function PlayGutDeath(name DamageType)
00459	{
00460		PlaySound(Die, SLOT_Talk, 4 * TransientSoundVolume);
00461		if ( FRand() < 0.5 )
00462			PlayAnim('Dead2',0.7, 0.1);
00463		else
00464			PlayAnim('Dead',0.7, 0.1);
00465	}
00466	
00467	function PlayLanded(float impactVel)
00468	{
00469		TweenAnim('Landed', 0.1);
00470	}
00471	
00472	function PlayVictoryDance()
00473	{
00474		PlaySound(Sweat, SLOT_Talk);
00475		PlayAnim('Sweat', 1.0, 0.1);
00476	}
00477	
00478	function PlayMeleeAttack()
00479	{
00480		if (Region.Zone.bWaterZone)
00481		{
00482			PlaySwimming();
00483			return;
00484		}
00485		PlayThreatening();
00486	}
00487	
00488	function PlayRangedAttack()
00489	{
00490		if (Region.Zone.bWaterZone)
00491		{
00492			PlaySwimming();
00493			return;
00494		}
00495		PlayThreatening();
00496	}
00497	
00498	function PlaySwimming()
00499	{
00500		Acceleration = WaterSpeed * VRand();
00501		Velocity = Acceleration;
00502		SetPhysics(PHYS_Falling);
00503		LoopAnim('Drowning', 0.5 + 0.9 * FRand());
00504	}
00505	
00506	function TweenToSwimming(float TweenTime)
00507	{
00508		TweenAnim('Drowning', TweenTime);
00509	}
00510	
00511	state Retreating
00512	{
00513		ignores HearNoise, Bump, AnimEnd;
00514	
00515		function EnemyNotVisible()
00516		{
00517			bCringing = False;
00518			Disable('EnemyNotVisible');
00519			Enable('SeePlayer');
00520		}
00521	
00522		function SeePlayer(actor SeenPlayer)
00523		{
00524			MakeNoise(1.0);
00525			Enable('EnemyNotVisible');
00526			Disable('SeePlayer');
00527		}
00528	
00529		function SetFall()
00530		{
00531			NextState = 'Retreating'; 
00532			NextLabel = 'Moving';
00533			NextAnim = AnimSequence;
00534			GotoState('FallingState'); 
00535		}
00536	
00537		function ReachedHome()
00538		{
00539			if (LineOfSightTo(Enemy))
00540			{
00541				if (Homebase(home) != None)
00542				{
00543					MoveTarget = None;
00544					health = Min(default.health, health+10);
00545					MakeNoise(1.0);
00546				}
00547				else
00548					ChangeDestination();
00549			}
00550			else
00551			{
00552				health = Min(default.health, health+5);
00553				GotoState('FadeOut');
00554			}	
00555		}
00556	
00557		function Bump(actor Other)
00558		{
00559			local vector VelDir, OtherDir;
00560			//log(Other.class$" bumped "$class);
00561			if (Pawn(Other) != None)
00562			{
00563				if ( (Enemy == Other) || SetEnemy(Pawn(Other)) )
00564				{
00565					bReadyToAttack = True; //can melee right away
00566					LastSeenPos = Enemy.Location;
00567					GotoState('Attacking');
00568					return;
00569				}
00570			}
00571			setTimer(1.0, false);
00572			VelDir = Normal(Velocity);
00573			VelDir.Z = 0;
00574			OtherDir = Normal(Other.Location - Location);
00575			OtherDir.Z = 0;
00576			if ( (VelDir Dot OtherDir) > 0.9 )
00577			{
00578				VelDir.X = Velocity.Y;
00579				VelDir.Y = -1 * Velocity.X;
00580				VelDir.Z = Velocity.Z;
00581				Velocity = VelDir;
00582			}
00583			Disable('Bump');
00584		}
00585		
00586		function PickDestination()
00587		{
00588			//log("find retreat destination");
00589			if (HomeBase(Home) == None)
00590				Home = FindRandomDest(); //find temporary home
00591		}
00592	
00593		function ChangeDestination()
00594		{
00595			local actor oldTarget;
00596			local Actor path;
00597			
00598			oldTarget = Home;
00599			PickDestination();
00600			if ( (Home == oldTarget) || (Home == None) )
00601				MoveTarget = None;
00602			else
00603			{
00604				path = FindPathToward(Home);
00605				if (path == None)
00606					MoveTarget = None;
00607				else 
00608				{
00609					MoveTarget = path;
00610					Destination = path.Location;
00611				}
00612			}
00613		}
00614		
00615		Function BeginState()
00616		{
00617			bReadyToAttack = true;
00618			Disable('SeePlayer');
00619		}
00620	
00621		function EndState()
00622		{
00623			bAvoidLedges = false;
00624			GroundSpeed = Default.GroundSpeed;
00625			Super.EndState();
00626		}
00627	
00628	Begin:
00629		if (Region.Zone.bWaterZone)
00630		{
00631			TweenToSwimming(0.12);
00632			Goto('Drowning');
00633		}
00634		bCringing = !bNeverBow;
00635		Target = None;
00636		TweenAnim('Backup',0.2);
00637		FinishAnim();
00638		
00639	RunAway:
00640		WaitForLanding();
00641		if ( Enemy == None )
00642			GotoState('Attacking');
00643		if (Region.Zone.bWaterZone)
00644		{
00645			TweenToSwimming(0.2);
00646			Goto('Drowning');
00647		}
00648		if (Home == None)
00649			PickDestination();
00650		bCringing = (bCringing && !bNeverBow && (FRand() < 0.8) && (VSize(Location - Enemy.Location) < 600) );
00651		if (Home == None)
00652			MoveTarget = None;
00653		else
00654		{
00655			PickNextSpot();
00656			if ( (MoveTarget != None) && (((MoveTarget.Location - Location) Dot (Enemy.Location - Location)) > 0)
00657				&& LineOfSightTo(Enemy) )
00658			{
00659				MoveTarget = None;
00660				if ( (Home == None) || !Home.IsA('HomeBase') )
00661					Home = None;
00662			}				
00663		}	
00664	Moving:
00665		if (Region.Zone.bWaterZone)
00666		{
00667			TweenToSwimming(0.12);
00668			Goto('Drowning');
00669		}
00670		If (MoveTarget == None)
00671		{
00672			GroundSpeed = Default.GroundSpeed;
00673			TweenAnim('Backup', 0.1);
00674			FinishAnim();
00675			PlayRetreating();
00676			Goto('Cringe');
00677		}
00678		bAvoidLedges = false;
00679		if (bCringing)
00680		{
00681			TweenAnim('Backup', 0.1);
00682			FinishAnim();
00683			if ( Enemy == None )
00684				GotoState('Attacking');
00685			GroundSpeed = GroundSpeed * WalkingSpeed;
00686			LoopAnim('Backup', -1.0/GroundSpeed,,0.4);
00687			Target = MoveTarget;
00688			StrafeFacing(MoveTarget.Location, Enemy);
00689			MoveTarget = Target;
00690	Cringe:
00691			FinishAnim();
00692			Acceleration = vect(0,0,0);
00693			if (FRand() < 0.4)
00694			{
00695				PlayAnim('Cringe', 0.4 + 0.6 * FRand(), 0.4);
00696				if ( FRand() < 0.6 )
00697					PlaySound(Cringe, SLOT_Talk);
00698	KeepCringeing:
00699				FinishAnim();
00700				PlayAnim('Cringe', 0.4 + 0.6 * FRand());
00701				FinishAnim();
00702				If (FRand() < 0.15)
00703				{
00704					PlayAnim('Cringe', 0.4 + 0.6 * FRand());
00705					Goto('KeepCringeing');
00706				}
00707			}
00708			else if (FRand() < 0.6)
00709			{
00710				PlayAnim('GetDown', 0.5, 0.3);
00711	KeepBowing:
00712				FinishAnim();
00713				PlayAnim('Bowing', 0.3 + 0.7 * FRand(), 0.1);
00714				FinishAnim();
00715				If (FRand() < 0.25)
00716				{
00717					PlayAnim('Bowing', 0.3 + 0.7 * FRand());
00718					Goto('KeepBowing');
00719				}
00720				PlayAnim('GetUp', 0.5);
00721			}
00722			FinishAnim(); 
00723			if ( AnimSequence != 'Backup' )
00724			{
00725				TweenAnim('Backup',0.3);
00726				FinishAnim();
00727			}
00728		}
00729		else
00730		{
00731			GroundSpeed = Default.GroundSpeed;
00732			if ( ((AnimSequence != 'Run') && (AnimSequence != 'RunFire')) || !bAnimLoop )
00733			{
00734				TweenToRunning(0.1);
00735				FinishAnim();
00736				LoopAnim('Run', -1.0/GroundSpeed,,0.5);
00737			}
00738			MoveToward(MoveTarget); 
00739		}
00740	
00741		Goto('RunAway');
00742	
00743	TakeHit:
00744		Goto('Moving');
00745	
00746	Drowning:
00747		FinishAnim();
00748		PlaySwimming();
00749	}
00750	
00751	
00752	state TriggerAlarm
00753	{
00754		ignores HearNoise, SeePlayer;
00755	
00756		function Bump(actor Other)
00757		{
00758			local vector VelDir, OtherDir;
00759			local float speed;
00760	
00761			if ( (Pawn(Other) != None) && Pawn(Other).bIsPlayer 
00762				&& (AttitudeToPlayer == ATTITUDE_Friendly) )
00763				return;
00764	
00765			Super.Bump(Other);
00766		}
00767	}
00768	
00769	state AlarmPaused
00770	{
00771		ignores HearNoise, Bump;
00772	
00773		function PlayWaiting()
00774		{
00775			if ( !bGesture || (FRand() < 0.3) ) //pick first waiting animation
00776			{
00777				bGesture = true;
00778				PlaySound(UrgeFollow, SLOT_Talk);
00779				NextAnim = 'Follow';
00780	 			LoopAnim(NextAnim, 0.4 + 0.6 * FRand());
00781			}
00782			else 
00783				Global.PlayWaiting();
00784		}
00785	
00786		function PlayWaitAround()
00787		{
00788			if ( (AnimSequence == 'Bowing') || (AnimSequence == 'GetDown') )
00789				PlayAnim('Bowing', 0.75, 0.1);
00790			else
00791				PlayAnim('GetDown', 0.7, 0.25);
00792		}
00793	
00794		function BeginState()
00795		{
00796			bGesture = false;
00797			Super.BeginState();
00798		}
00799	}
00800	
00801	state Guarding
00802	{
00803		function PlayPatrolStop()
00804		{
00805			local float decision;
00806			local float animspeed;
00807			animspeed = 0.2 + 0.6 * FRand(); 
00808			decision = FRand();
00809	
00810			if ( AnimSequence == 'Breath' )
00811			{
00812				if (!bQuiet && (decision < 0.12) )
00813				{
00814					PlaySound(Cough,Slot_Talk,1.0,,800);
00815					LoopAnim('Cough', 0.85);
00816					return;
00817				}
00818				else if (decision < 0.24)
00819				{
00820					PlaySound(Sweat,Slot_Talk,0.3,,300);
00821					LoopAnim('Sweat', animspeed);
00822					return;
00823				}
00824				else if (!bQuiet && (decision < 0.65) )
00825				{
00826					PlayAnim('Pray', animspeed, 0.3);
00827					return;
00828				}
00829				else if ( decision < 0.8 )
00830				{
00831					PlayAnim('GetDown', 0.4, 0.1);
00832					return;
00833				}
00834			}
00835			else if ( AnimSequence == 'Pray' )
00836			{
00837				if (decision < 0.2)
00838					PlayAnim('Breath', animspeed, 0.3);
00839				else if ( decision < 0.35 )
00840					PlayAnim('GetDown', 0.4, 0.1);
00841				else
00842				{
00843					SpeakPrayer();
00844					PlayAnim('Pray', animspeed);
00845				}
00846				return;
00847			}
00848			else if ( AnimSequence == 'GetDown')
00849			{
00850				PlaySound(Bowing, SLOT_Talk);
00851				LoopAnim('Bowing', animspeed, 0.1);
00852				return;
00853			}
00854			else if ( AnimSequence == 'GetUp' )
00855				PlayAnim('Pray', animspeed, 0.1);
00856			else if ( AnimSequence == 'Bowing' )
00857			{
00858				if ( decision < 0.15 )
00859					PlayAnim('GetUp', 0.4);
00860				else
00861				{
00862					PlaySound(Bowing, SLOT_Talk);
00863					LoopAnim('Bowing', animspeed);
00864				}
00865				return;
00866			}		 	
00867			PlaySound(Breath,SLOT_Talk,0.5,true,500,animspeed * 1.5);
00868	 		LoopAnim('Breath', animspeed);
00869		}
00870	}
00871	
00872	state FadeOut
00873	{
00874		ignores HitWall, EnemyNotVisible, HearNoise, SeePlayer;
00875	
00876		function TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation, 
00877								Vector momentum, name damageType)
00878		{
00879			Global.TakeDamage(Damage, instigatedBy, hitlocation, momentum, damageType);
00880			if ( health <= 0 )
00881				return;
00882			if (NextState == 'TakeHit')
00883			{
00884				NextState = 'Attacking'; 
00885				NextLabel = 'Begin';
00886				GotoState('TakeHit'); 
00887			}
00888			else if ( Enemy != None )
00889				GotoState('Attacking');
00890		}
00891	
00892		function Tick(float DeltaTime)
00893		{
00894			local int NewFatness; 
00895	
00896			if ( !bFading )
00897			{
00898				NewFatness = fatness + 50 * DeltaTime;
00899				bFading = ( NewFatness > 160 );
00900			}
00901			else if ( Style == STY_Translucent )
00902			{
00903				ScaleGlow -= 3 * DeltaTime;
00904				if ( ScaleGlow < 0.3 )
00905				{
00906					PlaySound(sound'Teleport1',, 2.0);
00907					Destroy();
00908				}
00909				return;
00910			}
00911			else
00912			{
00913				NewFatness = fatness - 100 * DeltaTime;
00914				if ( NewFatness < 80 )
00915				{
00916					bUnlit = true;
00917					ScaleGlow = 2.0;
00918					Style = STY_Translucent;
00919				}
00920			}
00921	
00922			fatness = Clamp(NewFatness, 0, 255);
00923		}
00924	
00925		function BeginState()
00926		{
00927			bFading = false;
00928			Disable('Tick');
00929		}
00930	
00931		function EndState()
00932		{
00933			bUnlit = false;
00934			Style = STY_Normal;
00935			ScaleGlow = 1.0;
00936			fatness = Default.fatness;
00937		}
00938	
00939	Begin:
00940		Acceleration = Vect(0,0,0);
00941		if ( NearWall(100) )
00942		{
00943			PlayTurning();
00944			TurnTo(Focus);
00945		}
00946		PlayAnim('Levitate', 0.3, 1.0);
00947		FinishAnim();
00948		PlayAnim('Levitate', 0.3);
00949		FinishAnim();
00950		LoopAnim('Levitate', 0.3);
00951		Enable('Tick');
00952	}
00953	
00954	state Roaming
00955	{
00956		ignores EnemyNotVisible;
00957	
00958		function PickDestination()
00959		{
00960			if ( bHasWandered && (FRand() < 0.1) )
00961				GotoState('FadeOut');
00962			else
00963				Super.PickDestination();
00964			bHasWandered = true;
00965		}
00966	}
00967	
00968	state Wandering
00969	{
00970		ignores EnemyNotVisible;
00971	
00972		function PickDestination()
00973		{
00974			if ( bHasWandered && (FRand() < 0.1) )
00975				GotoState('FadeOut');
00976			else
00977				Super.PickDestination();
00978			bHasWandered = true;
00979		}
00980	}
00981	
00982	defaultproperties
00983	{
00984	     syllable1=Sound'UnrealShare.Nali.syl1n'
00985	     syllable2=Sound'UnrealShare.Nali.syl2n'
00986	     syllable3=Sound'UnrealShare.Nali.syl3n'
00987	     syllable4=Sound'UnrealShare.Nali.syl4n'
00988	     syllable5=Sound'UnrealShare.Nali.syl5n'
00989	     syllable6=Sound'UnrealShare.Nali.syl6n'
00990	     urgefollow=Sound'UnrealShare.Nali.follow1n'
00991	     Cringe=Sound'UnrealShare.Nali.cringe2n'
00992	     Cough=Sound'UnrealShare.Nali.cough1n'
00993	     Sweat=Sound'UnrealShare.Nali.sweat1n'
00994	     Bowing=Sound'UnrealShare.Nali.bowing1n'
00995	     Backup=Sound'UnrealShare.Nali.backup2n'
00996	     pray=Sound'UnrealShare.Nali.pray1n'
00997	     Breath=Sound'UnrealShare.Nali.breath1n'
00998	     CarcassType=Class'UnrealShare.NaliCarcass'
00999	     TimeBetweenAttacks=0.500000
01000	     Aggressiveness=-10.000000
01001	     RefireRate=0.500000
01002	     bHasRangedAttack=True
01003	     bIsWuss=True
01004	     Acquire=Sound'UnrealShare.Nali.contct1n'
01005	     Fear=Sound'UnrealShare.Nali.fear1n'
01006	     Roam=Sound'UnrealShare.Nali.breath1n'
01007	     Threaten=Sound'UnrealShare.Nali.contct3n'
01008	     MeleeRange=40.000000
01009	     GroundSpeed=300.000000
01010	     WaterSpeed=100.000000
01011	     AccelRate=900.000000
01012	     JumpZ=-1.000000
01013	     SightRadius=1500.000000
01014	     Health=40
01015	     UnderWaterTime=6.000000
01016	     AttitudeToPlayer=ATTITUDE_Friendly
01017	     Intelligence=BRAINS_HUMAN
01018	     HitSound1=Sound'UnrealShare.Nali.injur1n'
01019	     HitSound2=Sound'UnrealShare.Nali.injur2n'
01020	     Die=Sound'UnrealShare.Nali.death1n'
01021	     DrawType=DT_Mesh
01022	     Mesh=LodMesh'UnrealShare.Nali1'
01023	     CollisionRadius=24.000000
01024	     CollisionHeight=48.000000
01025	     Buoyancy=95.000000
01026	     RotationRate=(Pitch=2048,Yaw=40000,Roll=0)
01027	}

End Source Code