Botpack
Class SkaarjBot

source: e:\games\UnrealTournament\Botpack\Classes\SkaarjBot.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Pawn
         |
         +--Botpack.Bot
            |
            +--Botpack.SkaarjBot
Direct Known Subclasses:None

class SkaarjBot
extends Botpack.Bot

//============================================================================= // SkaarjBot. //=============================================================================
States
FallingState

Function Summary
 void ForceMeshToExist()
 void PlayChallenge()
 void PlayCrawling()
 void PlayDodge(bool bDuckLeft)
     
//-----------------------------------------------------------------------------
// Animation functions
 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()
 void PlayWaiting()
 void PlayWalking()
 void PlayWeaponSwitch(Weapon NewWeapon)
 
simulated
RunStep()
 void TweenToRunning(float tweentime)
 void TweenToSwimming(float tweentime)
 void TweenToWaiting(float tweentime)
 void TweenToWalking(float tweentime)
 
simulated
WalkStep()


State FallingState Function Summary
 void Landed(vector HitNormal)



Source Code


00001	//=============================================================================
00002	// SkaarjBot.
00003	//=============================================================================
00004	class SkaarjBot extends Bot;
00005	
00006	function ForceMeshToExist()
00007	{
00008		Spawn(class'SkaarjTrooper');
00009	}
00010	
00011	simulated function WalkStep()
00012	{
00013		local sound step;
00014		local float decision;
00015		
00016		if ( FootRegion.Zone.bWaterZone )
00017			PlaySound(sound 'LSplash', SLOT_Interact, 1, false, 1000.0, 1.0);
00018	}
00019	
00020	simulated function RunStep()
00021	{
00022		local sound step;
00023		local float decision;
00024	
00025		if ( FootRegion.Zone.bWaterZone )
00026		{
00027			PlaySound(sound 'LSplash', SLOT_Interact, 1, false, 1000.0, 1.0);
00028			return;
00029		}
00030	
00031		PlaySound(Footstep1, SLOT_Interact, 0.7, false, 800.0, 1.0);
00032	}
00033	
00034	//-----------------------------------------------------------------------------
00035	// Animation functions
00036	
00037	function PlayDodge(bool bDuckLeft)
00038	{
00039		bCanDuck = false;
00040		Velocity.Z = 200;
00041		if ( bDuckLeft )
00042			PlayAnim('LeftDodge', 1.35, 0.06);
00043		else 
00044			PlayAnim('RightDodge', 1.35, 0.06);
00045	}
00046			
00047	function PlayTurning()
00048	{
00049		BaseEyeHeight = Default.BaseEyeHeight;
00050		PlayAnim('Turn', 0.3, 0.3);
00051	}
00052	
00053	function TweenToWalking(float tweentime)
00054	{
00055		if ( Physics == PHYS_Swimming )
00056		{
00057			if ( (vector(Rotation) Dot Acceleration) > 0 )
00058				TweenToSwimming(tweentime);
00059			else
00060				TweenToWaiting(tweentime);
00061		}
00062	
00063		BaseEyeHeight = Default.BaseEyeHeight;
00064		if (Weapon == None)
00065			TweenAnim('Walk', tweentime);
00066		else if ( Weapon.bPointing || (CarriedDecoration != None) ) 
00067			TweenAnim('WalkFire', tweentime);
00068		else
00069			TweenAnim('Walk', tweentime);
00070	}
00071	
00072	function TweenToRunning(float tweentime)
00073	{
00074		if ( Physics == PHYS_Swimming )
00075		{
00076			if ( (vector(Rotation) Dot Acceleration) > 0 )
00077				TweenToSwimming(tweentime);
00078			else
00079				TweenToWaiting(tweentime);
00080		}
00081	
00082		BaseEyeHeight = Default.BaseEyeHeight;
00083		if (bIsWalking)
00084			TweenToWalking(0.1);
00085		else if ( (Weapon != None) && Weapon.bPointing )
00086			TweenAnim('JogFire', tweentime);
00087		else
00088			TweenAnim('Jog', tweentime);
00089	}
00090	
00091	function PlayWalking()
00092	{
00093		if ( Physics == PHYS_Swimming )
00094		{
00095			if ( (vector(Rotation) Dot Acceleration) > 0 )
00096				PlaySwimming();
00097			else
00098				PlayWaiting();
00099			return;
00100		}
00101	
00102		BaseEyeHeight = Default.BaseEyeHeight;
00103		if (Weapon == None)
00104			LoopAnim('Walk');
00105		else if ( Weapon.bPointing || (CarriedDecoration != None) ) 
00106			LoopAnim('WalkFire');
00107		else
00108			LoopAnim('Walk');
00109	}
00110	
00111	function PlayRunning()
00112	{
00113		if ( Physics == PHYS_Swimming )
00114		{
00115			if ( (vector(Rotation) Dot Acceleration) > 0 )
00116				PlaySwimming();
00117			else
00118				PlayWaiting();
00119			return;
00120		}
00121	
00122		BaseEyeHeight = Default.BaseEyeHeight;
00123		if (Weapon == None)
00124			LoopAnim('Jog');
00125		else if ( Weapon.bPointing ) 
00126			LoopAnim('JogFire');
00127		else
00128			LoopAnim('Jog');
00129	}
00130	
00131	function PlayRising()
00132	{
00133		BaseEyeHeight = 0.4 * Default.BaseEyeHeight;
00134		PlayAnim('Getup', 0.7, 0.1);
00135	}
00136	
00137	function PlayFeignDeath()
00138	{
00139		BaseEyeHeight = 0;
00140		PlayAnim('Death2',0.7);
00141	}
00142	
00143	function PlayDying(name DamageType, vector HitLoc)
00144	{
00145		local vector X,Y,Z, HitVec, HitVec2D;
00146		local float dotp;
00147	
00148		BaseEyeHeight = Default.BaseEyeHeight;
00149		PlayDyingSound();
00150				
00151		if ( FRand() < 0.15 )
00152		{
00153			PlayAnim('Death',0.7,0.1);
00154			return;
00155		}
00156	
00157		// check for big hit
00158		if ( (Velocity.Z > 250) && (FRand() < 0.7) )
00159		{
00160			PlayAnim('Death2', 0.7, 0.1);
00161			return;
00162		}
00163	
00164		// check for head hit
00165		if ( ((DamageType == 'Decapitated') || (HitLoc.Z - Location.Z > 0.6 * CollisionHeight))
00166			 && !Level.Game.bVeryLowGore )
00167		{
00168			DamageType = 'Decapitated';
00169			PlayAnim('Death', 0.7, 0.1);
00170			return;
00171		}
00172	
00173		
00174		if ( FRand() < 0.15)
00175		{
00176			PlayAnim('Death3', 0.7, 0.1);
00177			return;
00178		}
00179	
00180		GetAxes(Rotation,X,Y,Z);
00181		X.Z = 0;
00182		HitVec = Normal(HitLoc - Location);
00183		HitVec2D= HitVec;
00184		HitVec2D.Z = 0;
00185		dotp = HitVec2D dot X;
00186		
00187		if (Abs(dotp) > 0.71) //then hit in front or back
00188			PlayAnim('Death3', 0.7, 0.1);
00189		else
00190		{
00191			dotp = HitVec dot Y;
00192			if (dotp > 0.0)
00193				PlayAnim('Death', 0.7, 0.1);
00194			else
00195				PlayAnim('Death4', 0.7, 0.1);
00196		}
00197	}
00198	
00199	function PlayGutHit(float tweentime)
00200	{
00201		if ( AnimSequence == 'GutHit' )
00202		{
00203			if (FRand() < 0.5)
00204				TweenAnim('LeftHit', tweentime);
00205			else
00206				TweenAnim('RightHit', tweentime);
00207		}
00208		else
00209			TweenAnim('GutHit', tweentime);
00210	}
00211	
00212	function PlayHeadHit(float tweentime)
00213	{
00214		if ( AnimSequence == 'HeadHit' )
00215			TweenAnim('GutHit', tweentime);
00216		else
00217			TweenAnim('HeadHit', tweentime);
00218	}
00219	
00220	function PlayLeftHit(float tweentime)
00221	{
00222		if ( AnimSequence == 'LeftHit' )
00223			TweenAnim('GutHit', tweentime);
00224		else
00225			TweenAnim('LeftHit', tweentime);
00226	}
00227	
00228	function PlayRightHit(float tweentime)
00229	{
00230		if ( AnimSequence == 'RightHit' )
00231			TweenAnim('GutHit', tweentime);
00232		else
00233			TweenAnim('RightHit', tweentime);
00234	}
00235		
00236	function PlayLanded(float impactVel)
00237		{	
00238			impactVel = impactVel/JumpZ;
00239			impactVel = 0.1 * impactVel * impactVel;
00240			BaseEyeHeight = Default.BaseEyeHeight;
00241	
00242			if ( Role == ROLE_Authority )
00243			{
00244				if ( impactVel > 0.17 )
00245					PlaySound(LandGrunt, SLOT_Talk, FMin(5, 5 * impactVel),false,1200,FRand()*0.4+0.8);
00246				if ( !FootRegion.Zone.bWaterZone && (impactVel > 0.01) )
00247					PlaySound(Land, SLOT_Interact, FClamp(4.5 * impactVel,0.5,6), false, 1000, 1.0);
00248			}
00249	
00250			if ( (GetAnimGroup(AnimSequence) == 'Dodge') && IsAnimating() )
00251				return;
00252			if ( (impactVel > 0.06) || (GetAnimGroup(AnimSequence) == 'Jumping') )
00253				TweenAnim('Land', 0.12);
00254			else if ( !IsAnimating() )
00255			{
00256				if ( GetAnimGroup(AnimSequence) == 'TakeHit' )
00257					AnimEnd();
00258				else
00259					TweenAnim('Land', 0.12);
00260			}
00261		}
00262		
00263	function PlayInAir()
00264	{
00265		BaseEyeHeight =  Default.BaseEyeHeight;
00266		TweenAnim('InAir', 0.4);
00267	}
00268	
00269	function PlayDuck()
00270	{
00271		BaseEyeHeight = 0;
00272		TweenAnim('Duck', 0.25);
00273	}
00274	
00275	function PlayCrawling()
00276	{
00277		BaseEyeHeight = 0;
00278		LoopAnim('DuckWalk');
00279	}
00280	
00281	function TweenToWaiting(float tweentime)
00282	{
00283		if( Physics==PHYS_Swimming )
00284		{
00285			BaseEyeHeight = 0.7 * Default.BaseEyeHeight;
00286			TweenAnim('Swim', tweentime);
00287		}
00288		else
00289		{
00290			BaseEyeHeight = Default.BaseEyeHeight;
00291			TweenAnim('Firing', tweentime);
00292		}
00293	}
00294		
00295	function PlayWaiting()
00296	{
00297		local name newAnim;
00298	
00299		if( Physics==PHYS_Swimming )
00300		{
00301			BaseEyeHeight = 0.7 * Default.BaseEyeHeight;
00302			LoopAnim('Swim');
00303		}
00304		else
00305		{	
00306			BaseEyeHeight = Default.BaseEyeHeight;
00307			if ( (Weapon != None) && Weapon.bPointing )
00308				TweenAnim('Firing', 0.3);
00309			else
00310			{
00311				if ( FRand() < 0.2 )
00312					newAnim = 'Breath';
00313				else
00314					newAnim = 'Breath2';
00315				
00316				if ( AnimSequence == newAnim )
00317					LoopAnim(newAnim, 0.3 + 0.7 * FRand());
00318				else
00319					PlayAnim(newAnim, 0.3 + 0.7 * FRand(), 0.25);
00320			}
00321		}
00322	}	
00323	
00324	function PlayFiring()
00325	{
00326		// switch animation sequence mid-stream if needed
00327		if (AnimSequence == 'Jog')
00328			AnimSequence = 'JogFire';
00329		else if (AnimSequence == 'Walk')
00330			AnimSequence = 'WalkFire';
00331		else if ( AnimSequence == 'InAir' )
00332			TweenAnim('JogFire', 0.03);
00333		else if ( (GetAnimGroup(AnimSequence) != 'Attack')
00334				&& (GetAnimGroup(AnimSequence) != 'MovingAttack') 
00335				&& (GetAnimGroup(AnimSequence) != 'Dodge')
00336				&& (AnimSequence != 'Swim') )
00337			TweenAnim('Firing', 0.02);
00338	}
00339		
00340	function PlayChallenge()
00341	{
00342		local float decision;
00343	
00344		decision = FRand();
00345		if ( decision < 0.6 )
00346			TweenToWaiting(0.1);
00347		else
00348			PlayAnim('Button1');
00349	}	
00350	
00351	function PlayWeaponSwitch(Weapon NewWeapon)
00352	{
00353	}
00354	
00355	function PlaySwimming()
00356	{
00357		BaseEyeHeight = 0.7 * Default.BaseEyeHeight;
00358		LoopAnim('Swim');
00359	}
00360	
00361	function TweenToSwimming(float tweentime)
00362	{
00363		BaseEyeHeight = 0.7 * Default.BaseEyeHeight;
00364		TweenAnim('Swim',tweentime);
00365	}
00366	
00367	state FallingState
00368	{
00369	ignores Bump, Hitwall, HearNoise, WarnTarget;
00370	
00371		function Landed(vector HitNormal)
00372		{
00373			local float landVol;
00374	
00375			if ( GetAnimGroup(AnimSequence) == 'Dodge' )
00376			{
00377				if (Velocity.Z <= -1100)
00378				{
00379					if ( (Velocity.Z < -2000) && (ReducedDamageType != 'All') )
00380					{
00381						health = -1000; //make sure gibs
00382						Died(None, 'Fell', Location);
00383					}
00384					else if ( Role == ROLE_Authority )
00385						TakeDamage(-0.15 * (Velocity.Z + 1050), None, Location, vect(0,0,0), 'Fell');
00386				}
00387				landVol = Velocity.Z/JumpZ;
00388				landVol = 0.008 * Mass * landVol * landVol;
00389				if ( !FootRegion.Zone.bWaterZone )
00390					PlaySound(Land, SLOT_Interact, FMin(20, landVol));
00391				GotoState('FallingState', 'FinishDodge');
00392			}
00393			else
00394				Super.Landed(HitNormal);
00395		}
00396	
00397	FinishDodge:
00398		FinishAnim();
00399		bCanDuck = true;
00400		Goto('Done');
00401	}
00402	
00403	defaultproperties
00404	{
00405	     CarcassType=Class'UnrealI.TrooperCarcass'
00406	     drown=Sound'UnrealI.Skaarj.SKPDrown1'
00407	     breathagain=Sound'UnrealI.Skaarj.SKPGasp1'
00408	     Footstep1=Sound'UnrealShare.Cow.walkC'
00409	     Footstep2=Sound'UnrealShare.Cow.walkC'
00410	     Footstep3=Sound'UnrealShare.Cow.walkC'
00411	     HitSound3=Sound'UnrealI.Skaarj.SKPInjur3'
00412	     HitSound4=Sound'UnrealI.Skaarj.SKPInjur4'
00413	     Deaths(0)=Sound'UnrealI.Skaarj.SKPDeath1'
00414	     Deaths(1)=Sound'UnrealI.Skaarj.SKPDeath2'
00415	     Deaths(2)=Sound'UnrealI.Skaarj.SKPDeath3'
00416	     Deaths(3)=Sound'UnrealI.Skaarj.SKPDeath3'
00417	     Deaths(4)=Sound'UnrealI.Skaarj.SKPDeath2'
00418	     Deaths(5)=Sound'UnrealI.Skaarj.SKPDeath1'
00419	     GaspSound=Sound'UnrealI.Skaarj.SKPGasp1'
00420	     UWHit1=Sound'UnrealShare.Male.MUWHit1'
00421	     UWHit2=Sound'UnrealShare.Male.MUWHit2'
00422	     LandGrunt=Sound'UnrealI.Skaarj.Land1SK'
00423	     JumpSound=Sound'UnrealI.Skaarj.SKPJump1'
00424	     VoicePackMetaClass="BotPack.VoiceMale"
00425	     JumpZ=360.000000
00426	     BaseEyeHeight=30.000000
00427	     EyeHeight=30.000000
00428	     Health=120
00429	     HitSound1=Sound'UnrealI.Skaarj.SKPInjur1'
00430	     HitSound2=Sound'UnrealI.Skaarj.SKPInjur2'
00431	     Die=Sound'UnrealI.Skaarj.SKPDeath1'
00432	     Skin=Texture'UnrealI.Skins.sktrooper1'
00433	     Mesh=LodMesh'UnrealI.sktrooper'
00434	     CollisionRadius=32.000000
00435	     CollisionHeight=42.000000
00436	     Mass=120.000000
00437	     Buoyancy=118.800003
00438	}

End Source Code