Engine
Class Spectator

source: c:\runehov\Engine\Classes\Spectator.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Pawn
         |
         +--Engine.PlayerPawn
            |
            +--Engine.Spectator
Direct Known Subclasses:MessagingSpectator

class Spectator
extends Engine.PlayerPawn

//============================================================================= // Spectator. //=============================================================================
Variables
 bool bChaseCam


Function Summary
 void AltFire(optional float)
     
// The player wants to alternate-fire.
 void BehindView(Bool B)
 void CallForHelp()
 void CameraIn()
 void CameraOut()
 void ChangeTeam(int N)
 void ClientReStart()
 
simulated
Debug(Canvas canvas, int mode)
 void Fire(optional float)
 void Fly()
 void Grab()
 void InitPlayerReplicationInfo()
 bool JointDamaged(int Damage, Pawn instigatedBy, Vector hitlocation, Vector momentum, name damageType, int joint)
     
//=================================================================================
 void NextItem()
 void PlayerTimeOut()
 void Possess()
     
// This pawn was possessed by a player.
 void PrevItem()
 void RestartLevel()
     
//=============================================================================
// functions.
 void Say(string S)
     
// Send a message to all players.
 void ServerChangeSkin(int SkinIndex)
 void Suicide()
 void SwitchWeapon(byte F)
     
// The player wants to switch to weapon group numer I.
 void Taunt()
 void Walk()



Source Code


00001	//=============================================================================
00002	// Spectator.
00003	//=============================================================================
00004	class Spectator extends PlayerPawn;
00005	
00006	var bool bChaseCam;
00007	
00008	
00009	replication
00010	{
00011		// Things the server should send to the client.
00012		reliable if( bNetOwner && Role==ROLE_Authority )
00013			bChaseCam;
00014	}
00015	
00016	
00017	function InitPlayerReplicationInfo()
00018	{
00019		Super.InitPlayerReplicationInfo();
00020		PlayerReplicationInfo.bIsSpectator = true;
00021	}
00022	
00023	event FootZoneChange(ZoneInfo newFootZone)
00024	{
00025	}
00026		
00027	event HeadZoneChange(ZoneInfo newHeadZone)
00028	{
00029	}
00030	
00031	event PainTimer()
00032	{
00033	}
00034	
00035	event PostRender( canvas Canvas )
00036	{
00037		Super.PostRender(Canvas);
00038	/*	if (bDebug==1)
00039		{
00040			if ( myDebugHud != None )
00041				myDebugHud.PostRender(Canvas);
00042			else if ( Viewport(Player) != None )
00043				myDebugHud = spawn(class'Engine.DebugHUD', self);
00044		}
00045	
00046		// Draw scoreboard (if active)
00047		if ( bShowScores )
00048		{
00049			if ( (Scoring == None) && (ScoringType != None) )
00050				Scoring = Spawn(ScoringType, self);
00051			if ( Scoring != None )
00052			{ 
00053				Scoring.ShowScores(Canvas);
00054			}
00055		}
00056	*/
00057		if (ViewTarget==None)
00058			bBehindView = false;
00059		else
00060			bBehindView = bChaseCam;
00061	}
00062	
00063	exec function Walk()
00064	{	
00065	}
00066	
00067	exec function BehindView( Bool B )
00068	{	// In this function, the bool B is ignored, so that this function acts as a toggle
00069		bChaseCam = !bChaseCam;
00070	}
00071	
00072	exec function CameraIn()
00073	{
00074		bChaseCam = false;
00075	}
00076	
00077	exec function CameraOut()
00078	{
00079		bChaseCam = true;
00080	}
00081	
00082	function ChangeTeam( int N )
00083	{
00084		Level.Game.ChangeTeam(self, N);
00085	}
00086	
00087	exec function Taunt()
00088	{
00089	}
00090	
00091	exec function CallForHelp()
00092	{
00093	}
00094	
00095	exec function Suicide()
00096	{
00097	}
00098	
00099	exec function Fly()
00100	{
00101		UnderWaterTime = -1;	
00102		SetCollision(false, false, false);
00103		bCollideWorld = true;
00104		GotoState('CheatFlying');
00105	
00106		ClientRestart();
00107	}
00108	
00109	function ServerChangeSkin( int SkinIndex )
00110	{
00111	}
00112	
00113	function ClientReStart()
00114	{
00115		//log("client restart");
00116		Velocity = vect(0,0,0);
00117		Acceleration = vect(0,0,0);
00118		BaseEyeHeight = Default.BaseEyeHeight;
00119		EyeHeight = BaseEyeHeight;
00120		
00121		GotoState('CheatFlying');
00122	}
00123	
00124	function PlayerTimeOut()
00125	{
00126		if (Health > 0)
00127			Died(None, 'dropped', Location);
00128	}
00129	
00130	exec function Grab()
00131	{
00132	}
00133	
00134	// Send a message to all players.
00135	exec function Say( string S )
00136	{
00137		if ( Len(S) > 63 )
00138			S = Left(S,63);
00139		if ( !Level.Game.bMuteSpectators )
00140			BroadcastMessage( PlayerReplicationInfo.PlayerName$":"$S, true );
00141	}
00142	
00143	//=============================================================================
00144	// functions.
00145	
00146	exec function RestartLevel()
00147	{
00148	}
00149	
00150	// This pawn was possessed by a player.
00151	function Possess()
00152	{
00153		bIsPlayer = true;
00154		DodgeClickTime = FMin(0.3, DodgeClickTime);
00155		EyeHeight = BaseEyeHeight;
00156		NetPriority = 2;
00157		Weapon = None;
00158		Inventory = None;
00159		Fly();
00160	}
00161	
00162	
00163	//=============================================================================
00164	// Inventory-related input notifications.
00165	
00166	// The player wants to switch to weapon group numer I.
00167	exec function SwitchWeapon (byte F )
00168	{
00169	}
00170	
00171	exec function NextItem()
00172	{
00173	}
00174	
00175	exec function PrevItem()
00176	{
00177	}
00178	
00179	exec function Fire( optional float F )
00180	{
00181		bBehindView = bChaseCam;
00182		if (Level.NetMode != NM_Client)
00183			ViewPlayerNum(-1);
00184		if ( ViewTarget == None )
00185			bBehindView = false;
00186	}
00187	
00188	// The player wants to alternate-fire.
00189	exec function AltFire( optional float F )
00190	{
00191		bBehindView = false;
00192		if (Level.NetMode != NM_Client)
00193		{
00194			Viewtarget = None;
00195			ClientMessage(ViewingFrom@OwnCamera, 'Event', true);
00196		}
00197	}
00198	
00199	//=================================================================================
00200	
00201	function bool JointDamaged( int Damage, Pawn instigatedBy, Vector hitlocation, 
00202							Vector momentum, name damageType, int joint)
00203	{
00204		return true;
00205	}
00206	
00207	simulated function Debug(Canvas canvas, int mode)
00208	{
00209		Super.Debug(canvas, mode);
00210	
00211		Canvas.DrawText("RunePlayer:");
00212		Canvas.CurY -= 8;
00213		Canvas.DrawText(" bChaseCam:" @ bChaseCam);
00214		Canvas.CurY -= 8;
00215	}
00216	
00217	defaultproperties
00218	{
00219	     bChaseCam=True
00220	     AirSpeed=400.000000
00221	     Visibility=0
00222	     AttitudeToPlayer=ATTITUDE_Friendly
00223	     MenuName="Spectator"
00224	     bHidden=True
00225	     bCollideActors=False
00226	     bCollideWorld=False
00227	     bBlockActors=False
00228	     bBlockPlayers=False
00229	     bProjTarget=False
00230	}

End Source Code