UnrealShare
Class HumanBot

source: e:\games\UnrealTournament\UnrealShare\Classes\HumanBot.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Pawn
         |
         +--UnrealShare.Bots
            |
            +--UnrealShare.HumanBot
Direct Known Subclasses:FemaleBot, MaleBot

class HumanBot
extends UnrealShare.Bots

//============================================================================= // HumanBot. //=============================================================================

Function Summary
 void PlayChallenge()
 void PlayCrawling()
 void PlayDuck()
 void PlayDying(name DamageType, vector HitLoc)
 void PlayFeignDeath()
 void PlayFiring()
 void PlayGutHit(float tweentime)
 void PlayHeadHit(float tweentime)
 void PlayInAir()
 void PlayLanded(float impactVel)
 void PlayLeftHit(float tweentime)
 void PlayRightHit(float tweentime)
 void PlayRising()
 void PlayRunning()
 void PlaySwimming()
 void PlayTurning()
     
//-----------------------------------------------------------------------------
// Animation functions
 void PlayWaiting()
 void PlayWalking()
 void PlayWeaponSwitch(Weapon NewWeapon)
 void TweenToFighter(float tweentime)
 void TweenToRunning(float tweentime)
 void TweenToSwimming(float tweentime)
 void TweenToWaiting(float tweentime)
 void TweenToWalking(float tweentime)



Source Code


00001	//=============================================================================
00002	// HumanBot.
00003	//=============================================================================
00004	class HumanBot extends Bots
00005		abstract;
00006	
00007	#exec AUDIO IMPORT FILE="Sounds\female\stone02.WAV" NAME="stwalk1" GROUP="Female"
00008	#exec AUDIO IMPORT FILE="Sounds\female\stone04.WAV" NAME="stwalk2" GROUP="Female"
00009	#exec AUDIO IMPORT FILE="Sounds\female\stone05.WAV" NAME="stwalk3" GROUP="Female"
00010	
00011	//-----------------------------------------------------------------------------
00012	// Sound functions 
00013	
00014	
00015	//-----------------------------------------------------------------------------
00016	// Animation functions
00017	
00018	function PlayTurning()
00019	{
00020		BaseEyeHeight = Default.BaseEyeHeight;
00021		if ( (Weapon == None) || (Weapon.Mass < 20) )
00022			PlayAnim('TurnSM', 0.3, 0.3);
00023		else
00024			PlayAnim('TurnLG', 0.3, 0.3);
00025	}
00026	
00027	function TweenToWalking(float tweentime)
00028		{
00029			if ( Physics == PHYS_Swimming )
00030			{
00031				if ( (vector(Rotation) Dot Acceleration) > 0 )
00032					TweenToSwimming(tweentime);
00033				else
00034					TweenToWaiting(tweentime);
00035			}
00036			
00037			BaseEyeHeight = Default.BaseEyeHeight;
00038			if (Weapon == None)
00039				TweenAnim('Walk', tweentime);
00040			else if ( Weapon.bPointing ) 
00041			{
00042				if (Weapon.Mass < 20)
00043					TweenAnim('WalkSMFR', tweentime);
00044				else
00045					TweenAnim('WalkLGFR', tweentime);
00046			}
00047			else
00048			{
00049				if (Weapon.Mass < 20)
00050					TweenAnim('WalkSM', tweentime);
00051				else
00052					TweenAnim('WalkLG', tweentime);
00053			} 
00054		}
00055	
00056	function TweenToRunning(float tweentime)
00057		{
00058			if ( Physics == PHYS_Swimming )
00059			{
00060				if ( (vector(Rotation) Dot Acceleration) > 0 )
00061					TweenToSwimming(tweentime);
00062				else
00063					TweenToWaiting(tweentime);
00064				return;
00065			}
00066	
00067			BaseEyeHeight = Default.BaseEyeHeight;
00068	
00069			if (Weapon == None)
00070				TweenAnim('RunSM', tweentime);
00071			else if ( Weapon.bPointing ) 
00072			{
00073				if (Weapon.Mass < 20)
00074					TweenAnim('RunSMFR', tweentime);
00075				else
00076					TweenAnim('RunLGFR', tweentime);
00077			}
00078			else
00079			{
00080				if (Weapon.Mass < 20)
00081					TweenAnim('RunSM', tweentime);
00082				else
00083					TweenAnim('RunLG', tweentime);
00084			} 
00085		}
00086	
00087	function PlayWalking()
00088		{
00089			if ( Physics == PHYS_Swimming )
00090			{
00091				if ( (vector(Rotation) Dot Acceleration) > 0 )
00092					PlaySwimming();
00093				else
00094					PlayWaiting();
00095				return;
00096			}
00097	
00098			BaseEyeHeight = Default.BaseEyeHeight;
00099			if (Weapon == None)
00100				LoopAnim('Walk');
00101			else if ( Weapon.bPointing ) 
00102			{
00103				if (Weapon.Mass < 20)
00104					LoopAnim('WalkSMFR');
00105				else
00106					LoopAnim('WalkLGFR');
00107			}
00108			else
00109			{
00110				if (Weapon.Mass < 20)
00111					LoopAnim('WalkSM');
00112				else
00113					LoopAnim('WalkLG');
00114			}
00115		}
00116	
00117	
00118	function PlayRunning()
00119		{
00120			if ( Physics == PHYS_Swimming )
00121			{
00122				if ( (vector(Rotation) Dot Acceleration) > 0 )
00123					PlaySwimming();
00124				else
00125					PlayWaiting();
00126				return;
00127			}
00128	
00129			BaseEyeHeight = Default.BaseEyeHeight;
00130			if (Weapon == None)
00131				LoopAnim('RunSM');
00132			else if ( Weapon.bPointing ) 
00133			{
00134				if (Weapon.Mass < 20)
00135					LoopAnim('RunSMFR');
00136				else
00137					LoopAnim('RunLGFR');
00138			}
00139			else
00140			{
00141				if (Weapon.Mass < 20)
00142					LoopAnim('RunSM');
00143				else
00144					LoopAnim('RunLG');
00145			}
00146		}
00147	
00148	function PlayRising()
00149	{
00150		BaseEyeHeight = 0.4 * Default.BaseEyeHeight;
00151		TweenAnim('DuckWlkS', 0.7);
00152	}
00153	
00154	function PlayFeignDeath()
00155	{
00156		local float decision;
00157	
00158		BaseEyeHeight = 0;
00159		if ( decision < 0.33 )
00160			TweenAnim('DeathEnd', 0.5);
00161		else if ( decision < 0.67 )
00162			TweenAnim('DeathEnd2', 0.5);
00163		else 
00164			TweenAnim('DeathEnd3', 0.5);
00165	}
00166	
00167	function PlayDying(name DamageType, vector HitLoc)
00168	{
00169		local vector X,Y,Z, HitVec, HitVec2D;
00170		local float dotp;
00171		local carcass carc;
00172	
00173		BaseEyeHeight = Default.BaseEyeHeight;
00174		PlayDyingSound();
00175				
00176		if ( FRand() < 0.15 )
00177		{
00178			PlayAnim('Dead3',0.7,0.1);
00179			return;
00180		}
00181	
00182		// check for big hit
00183		if ( (Velocity.Z > 250) && (FRand() < 0.7) )
00184		{
00185			PlayAnim('Dead2', 0.7, 0.1);
00186			return;
00187		}
00188	
00189		// check for head hit
00190		if ( ((DamageType == 'Decapitated') || (HitLoc.Z - Location.Z > 0.6 * CollisionHeight))
00191			 && !Level.Game.bVeryLowGore )
00192		{
00193			DamageType = 'Decapitated';
00194			if ( Level.NetMode != NM_Client )
00195			{
00196				carc = Spawn(class 'FemaleHead',,, Location + CollisionHeight * vect(0,0,0.8), Rotation + rot(3000,0,16384) );
00197				if (carc != None)
00198				{
00199					carc.Initfor(self);
00200					carc.Velocity = Velocity + VSize(Velocity) * VRand();
00201					carc.Velocity.Z = FMax(carc.Velocity.Z, Velocity.Z);
00202				}
00203			}
00204			PlayAnim('Dead6', 0.7, 0.1);
00205			return;
00206		}
00207	
00208		
00209		if ( FRand() < 0.15)
00210		{
00211			PlayAnim('Dead1', 0.7, 0.1);
00212			return;
00213		}
00214	
00215		GetAxes(Rotation,X,Y,Z);
00216		X.Z = 0;
00217		HitVec = Normal(HitLoc - Location);
00218		HitVec2D= HitVec;
00219		HitVec2D.Z = 0;
00220		dotp = HitVec2D dot X;
00221		
00222		if (Abs(dotp) > 0.71) //then hit in front or back
00223			PlayAnim('Dead4', 0.7, 0.1);
00224		else
00225		{
00226			dotp = HitVec dot Y;
00227			if ( (dotp > 0.0) && !Level.Game.bVeryLowGore )
00228			{
00229				PlayAnim('Dead7', 0.7, 0.1);
00230				carc = Spawn(class 'Arm1');
00231				if (carc != None)
00232				{
00233					carc.Initfor(self);
00234					carc.Velocity = Velocity + VSize(Velocity) * VRand();
00235					carc.Velocity.Z = FMax(carc.Velocity.Z, Velocity.Z);
00236				}
00237			}
00238			else
00239				PlayAnim('Dead5', 0.7, 0.1);
00240		}
00241	}
00242	
00243	function PlayGutHit(float tweentime)
00244	{
00245		if ( (AnimSequence == 'GutHit') || (AnimSequence == 'Dead2') )
00246		{
00247			if (FRand() < 0.5)
00248				TweenAnim('LeftHit', tweentime);
00249			else
00250				TweenAnim('RightHit', tweentime);
00251		}
00252		else if ( FRand() < 0.6 )
00253			TweenAnim('GutHit', tweentime);
00254		else
00255			TweenAnim('Dead2', tweentime);
00256	
00257	}
00258	
00259	function PlayHeadHit(float tweentime)
00260	{
00261		if ( (AnimSequence == 'HeadHit') || (AnimSequence == 'Dead4') )
00262			TweenAnim('GutHit', tweentime);
00263		else if ( FRand() < 0.6 )
00264			TweenAnim('HeadHit', tweentime);
00265		else
00266			TweenAnim('Dead4', tweentime);
00267	}
00268	
00269	function PlayLeftHit(float tweentime)
00270	{
00271		if ( (AnimSequence == 'LeftHit') || (AnimSequence == 'Dead3') )
00272			TweenAnim('GutHit', tweentime);
00273		else if ( FRand() < 0.6 )
00274			TweenAnim('LeftHit', tweentime);
00275		else 
00276			TweenAnim('Dead3', tweentime);
00277	}
00278	
00279	function PlayRightHit(float tweentime)
00280	{
00281		if ( (AnimSequence == 'RightHit') || (AnimSequence == 'Dead5') )
00282			TweenAnim('GutHit', tweentime);
00283		else if ( FRand() < 0.6 )
00284			TweenAnim('RightHit', tweentime);
00285		else
00286			TweenAnim('Dead5', tweentime);
00287	}	
00288		
00289	function PlayLanded(float impactVel)
00290	{	
00291		impactVel = impactVel/JumpZ;
00292		impactVel = 0.1 * impactVel * impactVel;
00293		BaseEyeHeight = Default.BaseEyeHeight;
00294	
00295		if ( impactVel > 0.17 )
00296			PlaySound(LandGrunt, SLOT_Talk, FMin(4, 5 * impactVel),false,1600,FRand()*0.4+0.8);
00297		if ( !FootRegion.Zone.bWaterZone && (impactVel > 0.01) )
00298			PlaySound(Land, SLOT_Interact, FClamp(4 * impactVel,0.2,4.5), false,1600, 1.0);
00299	
00300		if ( (impactVel > 0.06) || (GetAnimGroup(AnimSequence) == 'Jumping') )
00301		{
00302			if ( (Weapon == None) || (Weapon.Mass < 20) )
00303				TweenAnim('LandSMFR', 0.12);
00304			else
00305				TweenAnim('LandLGFR', 0.12);
00306		}
00307		else if ( !IsAnimating() )
00308		{
00309			if ( GetAnimGroup(AnimSequence) == 'TakeHit' )
00310				AnimEnd();
00311			else 
00312			{
00313				if ( (Weapon == None) || (Weapon.Mass < 20) )
00314					TweenAnim('LandSMFR', 0.12);
00315				else
00316					TweenAnim('LandLGFR', 0.12);
00317			}
00318		}
00319	}
00320		
00321	function PlayInAir()
00322	{
00323		BaseEyeHeight =  0.7 * Default.BaseEyeHeight;
00324		if ( (Weapon == None) || (Weapon.Mass < 20) )
00325			TweenAnim('JumpSMFR', 0.8);
00326		else
00327			TweenAnim('JumpLGFR', 0.8); 
00328	}
00329	
00330	function PlayDuck()
00331	{
00332		BaseEyeHeight = 0;
00333		if ( (Weapon == None) || (Weapon.Mass < 20) )
00334			TweenAnim('DuckWlkS', 0.25);
00335		else
00336			TweenAnim('DuckWlkL', 0.25);
00337	}
00338	
00339	function PlayCrawling()
00340	{
00341		//log("Play duck");
00342		BaseEyeHeight = 0;
00343		if ( (Weapon == None) || (Weapon.Mass < 20) )
00344			LoopAnim('DuckWlkS');
00345		else
00346			LoopAnim('DuckWlkL');
00347	}
00348	
00349	function TweenToWaiting(float tweentime)
00350	{
00351		if ( Physics == PHYS_Swimming )
00352		{
00353			BaseEyeHeight = 0.7 * Default.BaseEyeHeight;
00354			if ( (Weapon == None) || (Weapon.Mass < 20) )
00355				TweenAnim('TreadSM', tweentime);
00356			else
00357				TweenAnim('TreadLG', tweentime);
00358		}
00359		else
00360		{
00361			BaseEyeHeight = Default.BaseEyeHeight;
00362			if ( Enemy != None )
00363				ViewRotation = Rotator(Enemy.Location - Location);
00364			else
00365				ViewRotation.Pitch = 0;
00366			ViewRotation.Pitch = ViewRotation.Pitch & 65535;
00367			If ( (ViewRotation.Pitch > RotationRate.Pitch) 
00368				&& (ViewRotation.Pitch < 65536 - RotationRate.Pitch) )
00369			{
00370				If (ViewRotation.Pitch < 32768) 
00371				{
00372					if ( (Weapon == None) || (Weapon.Mass < 20) )
00373						TweenAnim('AimUpSm', 0.3);
00374					else
00375						TweenAnim('AimUpLg', 0.3);
00376				}
00377				else
00378				{
00379					if ( (Weapon == None) || (Weapon.Mass < 20) )
00380						TweenAnim('AimDnSm', 0.3);
00381					else
00382						TweenAnim('AimDnLg', 0.3);
00383				}
00384			}
00385			else if ( (Weapon == None) || (Weapon.Mass < 20) )
00386				TweenAnim('StillSMFR', tweentime);
00387			else
00388				TweenAnim('StillFRRP', tweentime);
00389		}
00390	}
00391	
00392	function TweenToFighter(float tweentime)
00393	{
00394		TweenToWaiting(tweentime);
00395	}
00396		
00397	function PlayChallenge()
00398	{
00399		local float decision;
00400	
00401		decision = FRand();
00402		if ( decision < 0.6 )
00403			TweenToWaiting(0.1);
00404		else
00405			PlayAnim('Taunt1');
00406	}	
00407		
00408	function PlayWaiting()
00409	{
00410		local name newAnim;
00411	
00412		if ( Physics == PHYS_Swimming )
00413		{
00414			BaseEyeHeight = 0.7 * Default.BaseEyeHeight;
00415			if ( (Weapon == None) || (Weapon.Mass < 20) )
00416				LoopAnim('TreadSM');
00417			else
00418				LoopAnim('TreadLG');
00419		}
00420		else
00421		{	
00422			BaseEyeHeight = Default.BaseEyeHeight;
00423			if ( (Weapon != None) && Weapon.bPointing )
00424			{
00425				if ( Weapon.Mass < 20 )
00426					TweenAnim('StillSMFR', 0.3);
00427				else
00428					TweenAnim('StillFRRP', 0.3);
00429			}
00430			else
00431			{
00432				if ( FRand() < 0.1 )
00433				{
00434					if ( (Weapon == None) || (Weapon.Mass < 20) )
00435						PlayAnim('CockGun', 0.5 + 0.5 * FRand(), 0.3);
00436					else
00437						PlayAnim('CockGunL', 0.5 + 0.5 * FRand(), 0.3);
00438				}
00439				else
00440				{
00441					if ( (Weapon == None) || (Weapon.Mass < 20) )
00442					{
00443						if ( Health > 50 )
00444							newAnim = 'Breath1';
00445						else
00446							newAnim = 'Breath2';
00447					}
00448					else
00449					{
00450						if ( Health > 50 )
00451							newAnim = 'Breath1L';
00452						else
00453							newAnim = 'Breath2L';
00454					}
00455									
00456					if ( AnimSequence == newAnim )
00457						LoopAnim(newAnim, 0.3 + 0.7 * FRand());
00458					else
00459						PlayAnim(newAnim, 0.3 + 0.7 * FRand(), 0.25);
00460				}
00461			}
00462		}
00463	}	
00464		
00465	function PlayFiring()
00466	{
00467		// switch animation sequence mid-stream if needed
00468		if (AnimSequence == 'RunLG')
00469			AnimSequence = 'RunLGFR';
00470		else if (AnimSequence == 'RunSM')
00471			AnimSequence = 'RunSMFR';
00472		else if (AnimSequence == 'WalkLG')
00473			AnimSequence = 'WalkLGFR';
00474		else if (AnimSequence == 'WalkSM')
00475			AnimSequence = 'WalkSMFR';
00476		else if ( AnimSequence == 'JumpSMFR' )
00477			TweenAnim('JumpSMFR', 0.03);
00478		else if ( AnimSequence == 'JumpLGFR' )
00479			TweenAnim('JumpLGFR', 0.03);
00480		else if ( (GetAnimGroup(AnimSequence) == 'Waiting') || (GetAnimGroup(AnimSequence) == 'Gesture') 
00481			&& (AnimSequence != 'TreadLG') && (AnimSequence != 'TreadSM') )
00482		{
00483			if ( Weapon.Mass < 20 )
00484				TweenAnim('StillSMFR', 0.02);
00485			else
00486				TweenAnim('StillFRRP', 0.02);
00487		}
00488	}
00489	
00490	function PlayWeaponSwitch(Weapon NewWeapon)
00491	{
00492		if ( (Weapon == None) || (Weapon.Mass < 20) )
00493		{
00494			if ( (NewWeapon != None) && (NewWeapon.Mass > 20) )
00495			{
00496				if ( (AnimSequence == 'RunSM') || (AnimSequence == 'RunSMFR') )
00497					AnimSequence = 'RunLG';
00498				else if ( (AnimSequence == 'WalkSM') || (AnimSequence == 'WalkSMFR') )
00499					AnimSequence = 'WalkLG';	
00500			 	else if ( AnimSequence == 'JumpSMFR' )
00501			 		AnimSequence = 'JumpLGFR';
00502				else if ( AnimSequence == 'DuckWlkL' )
00503					AnimSequence = 'DuckWlkS';
00504			 	else if ( AnimSequence == 'StillSMFR' )
00505			 		AnimSequence = 'StillFRRP';
00506				else if ( AnimSequence == 'AimDnSm' )
00507					AnimSequence = 'AimDnLg';
00508				else if ( AnimSequence == 'AimUpSm' )
00509					AnimSequence = 'AimUpLg';
00510			 }	
00511		}
00512		else if ( (NewWeapon == None) || (NewWeapon.Mass < 20) )
00513		{		
00514			if ( (AnimSequence == 'RunLG') || (AnimSequence == 'RunLGFR') )
00515				AnimSequence = 'RunSM';
00516			else if ( (AnimSequence == 'WalkLG') || (AnimSequence == 'WalkLGFR') )
00517				AnimSequence = 'WalkSM';
00518		 	else if ( AnimSequence == 'JumpLGFR' )
00519		 		AnimSequence = 'JumpSMFR';
00520			else if ( AnimSequence == 'DuckWlkS' )
00521				AnimSequence = 'DuckWlkL';
00522		 	else if (AnimSequence == 'StillFRRP')
00523		 		AnimSequence = 'StillSMFR';
00524			else if ( AnimSequence == 'AimDnLg' )
00525				AnimSequence = 'AimDnSm';
00526			else if ( AnimSequence == 'AimUpLg' )
00527				AnimSequence = 'AimUpSm';
00528		}
00529	}
00530	
00531	function PlaySwimming()
00532	{
00533		BaseEyeHeight = 0.7 * Default.BaseEyeHeight;
00534		if ((Weapon == None) || (Weapon.Mass < 20) )
00535			LoopAnim('SwimSM');
00536		else
00537			LoopAnim('SwimLG');
00538	}
00539	
00540	function TweenToSwimming(float tweentime)
00541	{
00542		BaseEyeHeight = 0.7 * Default.BaseEyeHeight;
00543		if ((Weapon == None) || (Weapon.Mass < 20) )
00544			TweenAnim('SwimSM',tweentime);
00545		else
00546			TweenAnim('SwimLG',tweentime);
00547	}
00548	
00549	defaultproperties
00550	{
00551	     Footstep1=Sound'UnrealShare.Female.stwalk1'
00552	     Footstep2=Sound'UnrealShare.Female.stwalk2'
00553	     Footstep3=Sound'UnrealShare.Female.stwalk3'
00554	     bIsHuman=True
00555	     EyeHeight=23.000000
00556	     CollisionRadius=17.000000
00557	     CollisionHeight=39.000000
00558	     Buoyancy=99.000000
00559	}

End Source Code