UnrealShare
Class UnrealIPlayer

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

class UnrealIPlayer
extends Engine.PlayerPawn

//============================================================================= // UnrealIPlayer. //=============================================================================
Variables
 class VoiceType


Function Summary
 void ClientPlayTakeHit(float tweentime, vector HitLoc, int Damage, bool bServerGuessWeapon)
 void Gasp()
 
simulated
PlayBeepSound()
 void PlayDeathHit(float Damage, vector HitLocation, name damageType, vector Momentum)
 void PlayDyingSound()
     
//-----------------------------------------------------------------------------
// Sound functions
 
simulated
PlayFootStep()
 void PlayHit(float Damage, vector HitLocation, name damageType, vector Momentum)
 void PlayTakeHitSound(int damage, name damageType, int Mult)
 void SetMultiSkin(Actor SkinActor, string SkinName, string FaceName, byte TeamNum)
 void ShowLoadMenu()
 void Summon(string ClassName)



Source Code


00001	//=============================================================================
00002	// UnrealIPlayer.
00003	//=============================================================================
00004	class UnrealIPlayer extends PlayerPawn
00005		config(user)
00006		abstract;
00007	
00008	#exec AUDIO IMPORT FILE="Sounds\Generic\land1.WAV" NAME="Land1" GROUP="Generic"
00009	#exec AUDIO IMPORT FILE="Sounds\Generic\lsplash.WAV" NAME="LSplash" GROUP="Generic"
00010	#exec AUDIO IMPORT FILE="Sounds\Generic\Say3A.WAV" NAME="Beep" GROUP="Generic"
00011	
00012	var(Sounds) sound 	drown;
00013	var(Sounds) sound	breathagain;
00014	var(Sounds) sound	Footstep1;
00015	var(Sounds) sound	Footstep2;
00016	var(Sounds) sound	Footstep3;
00017	var(Sounds) sound	HitSound3;
00018	var(Sounds) sound	HitSound4;
00019	var(Sounds) sound	Die2;
00020	var(Sounds) sound	Die3;
00021	var(Sounds) sound	Die4;
00022	var(Sounds) sound	GaspSound;
00023	var(Sounds) sound	UWHit1;
00024	var(Sounds) sound	UWHit2;
00025	var(Sounds) sound	LandGrunt;
00026	
00027	var class<VoicePack> VoiceType;
00028	
00029	replication
00030	{
00031		// Functions server can call.
00032		unreliable if( Role==ROLE_Authority )
00033			ClientPlayTakeHit;
00034	}
00035	
00036	event Possess()
00037	{
00038		local UnrealMeshMenu M;
00039	
00040		Super.Possess();
00041	
00042		if ( Level.Netmode == NM_Client )
00043		{
00044			M = spawn(class'UnrealMeshMenu');
00045			M.LoadAllMeshes();
00046			M.Destroy();
00047		}
00048	}
00049	
00050	simulated function PlayBeepSound()
00051	{
00052		PlaySound(sound'Beep',SLOT_Interface, 2.0);
00053	}
00054	
00055	exec event ShowUpgradeMenu()
00056	{
00057		bSpecialMenu = true;
00058		SpecialMenu = class'UpgradeMenu';
00059		ShowMenu();
00060	}
00061	
00062	exec function ShowLoadMenu()
00063	{
00064		bSpecialMenu = true;
00065		SpecialMenu = class'UnrealLoadMenu';
00066		ShowMenu();
00067	}
00068	
00069	exec function Summon( string ClassName )
00070	{
00071		local class<actor> NewClass;
00072		if( !bAdmin && (Level.Netmode != NM_Standalone) )
00073			return;
00074		if( instr(ClassName,".")==-1 )
00075			ClassName = "UnrealI." $ ClassName;
00076		Super.Summon( ClassName );
00077	}
00078	
00079	simulated function PlayFootStep()
00080	{
00081		local sound step;
00082		local float decision;
00083	
00084		if ( !bIsWalking && (Level.Game != None) && (Level.Game.Difficulty > 1) && ((Weapon == None) || !Weapon.bPointing) )
00085			MakeNoise(0.05 * Level.Game.Difficulty);
00086		if ( FootRegion.Zone.bWaterZone )
00087		{
00088			PlaySound(WaterStep, SLOT_Interact, 1, false, 1000.0, 1.0);
00089			return;
00090		}
00091	
00092		decision = FRand();
00093		if ( decision < 0.34 )
00094			step = Footstep1;
00095		else if (decision < 0.67 )
00096			step = Footstep2;
00097		else
00098			step = Footstep3;
00099	
00100		if ( bIsWalking )
00101			PlaySound(step, SLOT_Interact, 0.5, false, 400.0, 1.0);
00102		else 
00103			PlaySound(step, SLOT_Interact, 2, false, 800.0, 1.0);
00104	}
00105	
00106	function PlayHit(float Damage, vector HitLocation, name damageType, vector Momentum)
00107	{
00108		local float rnd;
00109		local Bubble1 bub;
00110		local bool bServerGuessWeapon;
00111		local class<DamageType> DamageClass;
00112		local vector BloodOffset;
00113	
00114		if ( (Damage <= 0) && (ReducedDamageType != 'All') )
00115			return;
00116	
00117		//DamageClass = class(damageType);
00118		if ( ReducedDamageType != 'All' ) //spawn some blood
00119		{
00120			if (damageType == 'Drowned')
00121			{
00122				bub = spawn(class 'Bubble1',,, Location 
00123					+ 0.7 * CollisionRadius * vector(ViewRotation) + 0.3 * EyeHeight * vect(0,0,1));
00124				if (bub != None)
00125					bub.DrawScale = FRand()*0.06+0.04; 
00126			}
00127			else if ( (damageType != 'Burned') && (damageType != 'Corroded') 
00128						&& (damageType != 'Fell') )
00129			{
00130				BloodOffset = 0.2 * CollisionRadius * Normal(HitLocation - Location);
00131				BloodOffset.Z = BloodOffset.Z * 0.5;
00132				if ( (Level.Game != None) && Level.Game.bVeryLowGore )
00133					spawn(class 'BloodBurst',self,,hitLocation + BloodOffset, rotator(BloodOffset));
00134				else
00135					spawn(class 'BloodSpray',self,,hitLocation + BloodOffset, rotator(BloodOffset));
00136			}
00137		}	
00138	
00139		rnd = FClamp(Damage, 20, 60);
00140		if ( damageType == 'Burned' )
00141			ClientFlash( -0.009375 * rnd, rnd * vect(16.41, 11.719, 4.6875));
00142		else if ( damageType == 'corroded' )
00143			ClientFlash( -0.01171875 * rnd, rnd * vect(9.375, 14.0625, 4.6875));
00144		else if ( damageType == 'Drowned' )
00145			ClientFlash(-0.390, vect(312.5,468.75,468.75));
00146		else 
00147			ClientFlash( -0.019 * rnd, rnd * vect(26.5, 4.5, 4.5));
00148	
00149		ShakeView(0.15 + 0.005 * Damage, Damage * 30, 0.3 * Damage); 
00150		PlayTakeHitSound(Damage, damageType, 1);
00151		bServerGuessWeapon = ( ((Weapon != None) && Weapon.bPointing) || (GetAnimGroup(AnimSequence) == 'Dodge') );
00152		ClientPlayTakeHit(0.1, hitLocation, Damage, bServerGuessWeapon ); 
00153		if ( !bServerGuessWeapon 
00154			&& ((Level.NetMode == NM_DedicatedServer) || (Level.NetMode == NM_ListenServer)) )
00155		{
00156			Enable('AnimEnd');
00157			BaseEyeHeight = Default.BaseEyeHeight;
00158			bAnimTransition = true;
00159			PlayTakeHit(0.1, hitLocation, Damage);
00160		}
00161	}
00162	
00163	function PlayDeathHit(float Damage, vector HitLocation, name damageType, vector Momentum)
00164	{
00165		local Bubble1 bub;
00166	
00167		if ( Region.Zone.bDestructive && (Region.Zone.ExitActor != None) )
00168			Spawn(Region.Zone.ExitActor);
00169		if (HeadRegion.Zone.bWaterZone)
00170		{
00171			bub = spawn(class 'Bubble1',,, Location 
00172				+ 0.3 * CollisionRadius * vector(Rotation) + 0.8 * EyeHeight * vect(0,0,1));
00173			if (bub != None)
00174				bub.DrawScale = FRand()*0.08+0.03; 
00175			bub = spawn(class 'Bubble1',,, Location 
00176				+ 0.2 * CollisionRadius * VRand() + 0.7 * EyeHeight * vect(0,0,1));
00177			if (bub != None)
00178				bub.DrawScale = FRand()*0.08+0.03; 
00179			bub = spawn(class 'Bubble1',,, Location 
00180				+ 0.3 * CollisionRadius * VRand() + 0.6 * EyeHeight * vect(0,0,1));
00181			if (bub != None)
00182				bub.DrawScale = FRand()*0.08+0.03; 
00183		}
00184	
00185		if ( (damageType != 'Drowned') && (damageType != 'Corroded') )
00186			spawn(class 'BloodSpray',self,'', hitLocation);
00187	}
00188	
00189	//-----------------------------------------------------------------------------
00190	// Sound functions
00191	
00192	function PlayDyingSound()
00193	{
00194		local float rnd;
00195	
00196		if ( HeadRegion.Zone.bWaterZone )
00197		{
00198			if ( FRand() < 0.5 )
00199				PlaySound(UWHit1, SLOT_Pain,,,,Frand()*0.2+0.9);
00200			else
00201				PlaySound(UWHit2, SLOT_Pain,,,,Frand()*0.2+0.9);
00202			return;
00203		}
00204	
00205		rnd = FRand();
00206		if (rnd < 0.25)
00207			PlaySound(Die, SLOT_Talk);
00208		else if (rnd < 0.5)
00209			PlaySound(Die2, SLOT_Talk);
00210		else if (rnd < 0.75)
00211			PlaySound(Die3, SLOT_Talk);
00212		else 
00213			PlaySound(Die4, SLOT_Talk);
00214	}
00215	
00216	function PlayTakeHitSound(int damage, name damageType, int Mult)
00217	{
00218		if ( Level.TimeSeconds - LastPainSound < 0.3 )
00219			return;
00220		LastPainSound = Level.TimeSeconds;
00221	
00222		if ( HeadRegion.Zone.bWaterZone )
00223		{
00224			if ( damageType == 'Drowned' )
00225				PlaySound(drown, SLOT_Pain, 1.5);
00226			else if ( FRand() < 0.5 )
00227				PlaySound(UWHit1, SLOT_Pain,2.0,,,Frand()*0.15+0.9);
00228			else
00229				PlaySound(UWHit2, SLOT_Pain,2.0,,,Frand()*0.15+0.9);
00230			return;
00231		}
00232		damage *= FRand();
00233	
00234		if (damage < 8) 
00235			PlaySound(HitSound1, SLOT_Pain,2.0,,,Frand()*0.15+0.9);
00236		else if (damage < 25)
00237		{
00238			if (FRand() < 0.5) PlaySound(HitSound2, SLOT_Pain,2.0,,,Frand()*0.15+0.9);			
00239			else PlaySound(HitSound3, SLOT_Pain,2.0,,,Frand()*0.15+0.9);
00240		}
00241		else
00242			PlaySound(HitSound4, SLOT_Pain,2.0,,,Frand()*0.15+0.9);			
00243	}
00244	
00245	function ClientPlayTakeHit(float tweentime, vector HitLoc, int Damage, bool bServerGuessWeapon)
00246	{
00247		if ( bServerGuessWeapon && ((GetAnimGroup(AnimSequence) == 'Dodge') || ((Weapon != None) && Weapon.bPointing)) )
00248			return;
00249		Enable('AnimEnd');
00250		bAnimTransition = true;
00251		BaseEyeHeight = Default.BaseEyeHeight;
00252		PlayTakeHit(tweentime, HitLoc, Damage);
00253	}	
00254	
00255	function Gasp()
00256	{
00257		if ( Role != ROLE_Authority )
00258			return;
00259		if ( PainTime < 2 )
00260			PlaySound(GaspSound, SLOT_Talk, 2.0);
00261		else
00262			PlaySound(BreathAgain, SLOT_Talk, 2.0);
00263	}
00264	
00265	static function SetMultiSkin( Actor SkinActor, string SkinName, string FaceName, byte TeamNum )
00266	{
00267		local Texture NewSkin;
00268		local string MeshName;
00269		local int i;
00270		local string TeamColor[4];
00271	
00272		TeamColor[0]="Red";
00273	    TeamColor[1]="Blue";
00274	    TeamColor[2]="Green";
00275	    TeamColor[3]="Gold";
00276	
00277	
00278		MeshName = SkinActor.GetItemName(string(SkinActor.Mesh));
00279	
00280		if( InStr(SkinName, ".") == -1 )
00281			SkinName = MeshName$"Skins."$SkinName;
00282	
00283		if(TeamNum >=0 && TeamNum <= 3)
00284			NewSkin = texture(DynamicLoadObject(MeshName$"Skins.T_"$TeamColor[TeamNum], class'Texture'));
00285		else if( Left(SkinName, Len(MeshName)) ~= MeshName )
00286			NewSkin = texture(DynamicLoadObject(SkinName, class'Texture'));
00287	
00288		// Set skin
00289		if ( NewSkin != None )
00290			SkinActor.Skin = NewSkin;
00291	}
00292	
00293	defaultproperties
00294	{
00295	     bSinglePlayer=True
00296	     bCanStrafe=True
00297	     MeleeRange=50.000000
00298	     GroundSpeed=400.000000
00299	     AirSpeed=400.000000
00300	     AccelRate=2048.000000
00301	     UnderWaterTime=20.000000
00302	     Intelligence=BRAINS_HUMAN
00303	     Land=Sound'UnrealShare.Generic.Land1'
00304	     WaterStep=Sound'UnrealShare.Generic.LSplash'
00305	     AnimSequence=WalkSm
00306	     DrawType=DT_Mesh
00307	     LightBrightness=70
00308	     LightHue=40
00309	     LightSaturation=128
00310	     LightRadius=6
00311	     RotationRate=(Pitch=3072,Yaw=65000,Roll=2048)
00312	}

End Source Code