UnrealShare
Class Human

source: e:\games\UnrealTournament\UnrealShare\Classes\Human.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Pawn
         |
         +--Engine.PlayerPawn
            |
            +--UnrealShare.UnrealIPlayer
               |
               +--UnrealShare.Human
Direct Known Subclasses:Female, Male

class Human
extends UnrealShare.UnrealIPlayer

//============================================================================= // Human. //=============================================================================

Function Summary
 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 PlayRecoil(float Rate)
 void PlayRightHit(float tweentime)
 void PlayRising()
 void PlayRunning()
 void PlaySwimming()
 void PlayTurning()
     
//-----------------------------------------------------------------------------
// Animation functions
 void PlayWaiting()
 void PlayWalking()
 void PlayWeaponSwitch(Weapon NewWeapon)
 void TweenToRunning(float tweentime)
 void TweenToSwimming(float tweentime)
 void TweenToWaiting(float tweentime)
 void TweenToWalking(float tweentime)



Source Code


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

End Source Code