## Engine
Class Controller

source: C:\XIII\Engine\Classes\Controller.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Controller

Direct Known Subclasses:AIController, PlayerController, CineController2

class Controller
extends Engine.Actor

    //=============================================================================
    // Controller, the base class of players or AI.
    //
    // Controllers are non-physical actors that can be attached to a pawn to control
    // its actions.  PlayerControllers are used by human players to control pawns, while
    // AIControFllers implement the artificial intelligence for the pawns they control.
    // Controllers take control of a pawn using their Possess() method, and relinquish
    // control of the pawn by calling UnPossess().
    //
    // Controllers receive notifications for many of the events occuring for the Pawn they
    // are controlling.  This gives the controller the opportunity to implement the behavior
    // in response to this event, intercepting the event and superceding the Pawn's default
    // behavior.
    //
    // This is a built-in Unreal class and it shouldn't be modified.
    //=============================================================================

Variables
`vector` | `AdjustLoc` Timer3 loops (else is one-shot).
`float` | `GroundPitchTime` class of pawn to spawn (for players)
`Actor` | `MoveTarget` set by movement natives
`float` | `MoveTimer` skill, scaled by game difficulty (add difficulty to this value)
`Actor` | `NextMoveTarget` set by movement natives
`float` | `OldMessageTime` to limit frequency of voice messages
`Pawn` | `Pawn`
`class` | `PawnClass` class of pawn to spawn (for players)
`PlayerReplicationInfo` | `PlayerReplicationInfo` total distance for current route
`class` | `PlayerReplicationInfoClass` total distance for current route
`Actor` | `RouteCache[16]` to limit frequency of voice messages
`float` | `RouteDist` total distance for current route
`Actor` | `RouteGoal` final destination for current route
`float` | `Skill` skill, scaled by game difficulty (add difficulty to this value)
`NavigationPoint` | `StartSpot` where player started the match
`ViewY,` | `ViewZ` Viewrotation encoding for PHYS_Spider
`byte` | `VoicePitch` for speech
`string` | `VoiceType` for speech
`bool` | `bAdjusting` used for alternating LineOfSight traces
`bool` | `bDisableEventSeeDeadPawn` if true, the event SeeDeadPawn() is not called, whatever the state the controller is in
`bool` | `bDisableEventSeeMonster` if true, the event SeeMonster() is not called, whatever the state the controller is in
`bool` | `bLOSflag` used for alternating LineOfSight traces
`bool` | `bTacticalDir` used during movement between pathnodes
`bool` | `bTimer3Loop` Timer3 loops (else is one-shot).
`input` | `byte` Timer3 loops (else is one-shot).
`NavigationPoint` | `home` set when begin play, used for retreating and attitude checks
`Controller` | `nextController` chained Controller list

States
GameEnded, Dead

Function Summary
`void` | `AddController()`
`rotator` | `AdjustAim(Ammunition FiredAmmunition, vector projStart, int aimerror)`
    /* AdjustAim()
    AIController version does adjustment for non-controlled pawns.
    PlayerController version does the adjustment for player aiming help.
    Only adjusts aiming at pawns
    allows more error in Z direction (full as defined by AutoAim - only half that difference for XY)
    CHANGENOTE: This function change is related to the Weapon code updates
    */
`float` | `AdjustDesireFor(Pickup P)`
`void` | `AdjustView(float DeltaTime)`
    /* AdjustView()
    by default, check and see if pawn still needs to update eye height
    (only if some playercontroller still has pawn as its viewtarget)
    Overridden in playercontroller
    */
`eAttitude` | `AttitudeTo(Pawn Other)`
`void` | `BotVoiceMessage(name messagetype, byte MessageID, Controller Sender)`
`bool` | `CanSee(Pawn Other)`
    /* CanSee() similar to line of sight, but also takes into account Pawn's peripheral vision
    */
`void` | `ChangedWeapon()`
`bool` | `CheckFutureSight(float DeltaTime)`
`void` | `ClearPaths()`
`void` | `ClientGameEnded()`
`void` | `ClientSetLocation(vector NewLocation, rotator NewRotation)`
    /* ClientSetLocation()
    replicated function to set location and rotation.  Allows server to force new location for
    teleports, etc.
    */
`void` | `ClientSetRotation(rotator NewRotation)`
    /* ClientSetRotation()
    replicated function to set rotation.  Allows server to force new rotation.
    */
`void` | `ClientVoiceMessage(PlayerReplicationInfo Sender, PlayerReplicationInfo Recipient, name messagetype, byte messageID)`
`void` | `DisplayDebug(Canvas Canvas, out float, out float)`
    /* DisplayDebug()
    list important controller attributes on canvas
    */
`vector` | `EAdjustJump(float BaseZ, float XYSpeed)`
`void` | `EndClimbLadder()`
`void` | `FearThisSpot(Actor ASpot)`
    //***************************************************************
    // AI related
`Actor` | `FindBestInventoryPath(out float, bool bPredictRespawns)`
`Actor` | `FindPathTo(vector aPoint, optional bool)`
    //Navigation functions - return the next path toward the goal
`Actor` | `FindPathToward(Actor anActor, optional bool)`
`NavigationPoint` | `FindRandomDest(optional bool)`
`void` | `FinishRotation()`
`void` | `FireWeaponAt(Actor A)`
`int` | `GetFacingDirection()`
    /* GetFacingDirection()
    returns direction faced relative to movement dir

    0 = forward
    16384 = right
    32768 = back
    49152 = left
    */
`void` | `HandlePickup(Pickup pick)`
    {
    	return vect(0,0,0);
    }
    */
`void` | `InitPlayerReplicationInfo()`
`bool` | `LineOfSightTo(Actor Other)`
    /* LineOfSightTo() returns true if any of several points of Other is visible
      (origin, top, bottom)
    */
`void` | `MoveTo(vector NewDestination, optional Actor, optional float)`
    // Latent Movement.
    //Note that MoveTo sets the actor's Destination, and MoveToward sets the
    //actor's MoveTarget.  Actor will rotate towards destination unless the optional ViewFocus is specified.
`void` | `MoveToward(Actor NewTarget, optional Actor, optional float, optional Actor)`
`void` | `MoverFinished()`
`void` | `NotifyAddInventory(Inventory NewItem)`
    // notifications called by pawn in script
`void` | `NotifyFiring()`
    // Notification called by weapon to inform pawn controller.
`void` | `NotifyKilled(Controller Killer, Controller Killed, Pawn Other)`
`void` | `PawnDied()`
    /* PawnDied()
     unpossess a pawn (because pawn was killed)
     */
`Actor` | `PickAnyTarget(out float, out float, vector FireDir, vector projStart)`
`Pawn` | `PickTarget(out float, out float, vector FireDir, vector projStart, optional int)`
    // Pick best pawn target
`bool` | `PickWallAdjust(vector HitNormal)`
    /* PickWallAdjust()
    Check if could jump up over obstruction (only if there is a knee height obstruction)
    If so, start jump, and return current destination
    Else, try to step around - return a destination 90 degrees right or left depending on traces
    out and floor checks
    */
`void` | `Possess(Pawn aPawn)`
    /* AIHearSound()
    Called when AI controlled pawn would hear a sound.  Default AI implementation uses MakeNoise()
    interface for hearing appropriate sounds instead
    */
`void` | `ReceiveWarning(Pawn shooter, float projSpeed, vector FireDir)`
    /* ReceiveWarning()  *** CHANGENOTE: RENAMED (WAS WARNTARGET())***
     AI controlled creatures may duck
     if not falling, and projectile time is long enough
     often pick opposite to current direction (relative to shooter axis)
    */
`void` | `RemoveController()`
`void` | `Reset()`
    /* Reset()
    reset actor to initial state
    */
`void` | `Restart()`
`void` | `SendMessage(PlayerReplicationInfo Recipient, name MessageType, byte MessageID, float Wait, name BroadcastType)`
    //------------------------------------------------------------------------------
    // Speech related
`void` | `SendVoiceMessage(PlayerReplicationInfo Sender, PlayerReplicationInfo Recipient, name messagetype, byte messageID, name broadcasttype)`
`void` | `ServerReStartPlayer()`
`void` | `SetFall()`
`void` | `SetTimer3(float NewTimerRate, bool bLoop)`
    // Causes Timer3() events every NewTimerRate seconds.
`void` | `ShakeView(float shaketime, float RollMag, vector OffsetMag, float RollRate, vector OffsetRate, float OffsetTime)`
    // for advanced tactics
`void` | `StopFiring()`
`void` | `StopWaiting()`
    // Force end to sleep
`void` | `SwitchToBestWeapon()`
    /* CHANGENOTE: Changes in this function related to the Weapon code updates
    */
`void` | `UnderLift(Mover M)`
`void` | `WaitForLanding()`
    /* WaitForLanding()
    latent function returns when pawn is on ground (no longer falling)
    */
`void` | `WaitForMover(Mover M)`
`bool` | `WantsSmoothedView()`
    {
    	return ( ((Pawn.Physics==PHYS_Walking) || (Pawn.Physics==PHYS_Spider)) && !Pawn.bJustLanded );
    }*/
`bool` | `WantsSmoothedView()`
    {
    	return ( ((Pawn.Physics==PHYS_Walking) || (Pawn.Physics==PHYS_Spider)) && !Pawn.bJustLanded );
    }*/
`vector` | `WeaponBob(float BobDamping)`
    /*  --> became purely C++ virtual function
`float` | `WeaponPreference(Weapon W)`
`bool` | `WouldReactToNoise(float Loudness, Actor NoiseMaker)`
    //***************************************************************
    // interface used by ScriptedControllers to query pending controllers
`bool` | `WouldReactToSeeing(Pawn Seen)`
`bool` | `actorReachable(Actor anActor)`
`void` | `damageAttitudeTo(Pawn Other, float Damage)`
`bool` | `pointReachable(vector aPoint)`
    //Reachable returns whether direct path from Actor to aPoint is traversable
    //using the current locomotion method

State GameEnded Function Summary
`void` | `BeginState()`

State Dead Function Summary
`void` | `ServerReStartPlayer()`
`void` | `PawnDied()`

Source Code

    00001	//=============================================================================
    00002	// Controller, the base class of players or AI.
    00003	//
    00004	// Controllers are non-physical actors that can be attached to a pawn to control
    00005	// its actions.  PlayerControllers are used by human players to control pawns, while
    00006	// AIControFllers implement the artificial intelligence for the pawns they control.
    00007	// Controllers take control of a pawn using their Possess() method, and relinquish
    00008	// control of the pawn by calling UnPossess().
    00009	//
    00010	// Controllers receive notifications for many of the events occuring for the Pawn they
    00011	// are controlling.  This gives the controller the opportunity to implement the behavior
    00012	// in response to this event, intercepting the event and superceding the Pawn's default
    00013	// behavior.
    00014	//
    00015	// This is a built-in Unreal class and it shouldn't be modified.
    00016	//=============================================================================
    00017	class Controller extends Actor
    00018		native
    00019		nativereplication
    00020		abstract
    00021		noexport;
    00022
    00023	var Pawn Pawn;
    00024
    00025	// Ticked pawn timers
    00026	var		float		SightCounter;		// Used to keep track of when to check player visibility
    00027
    00028	var		float		FovAngle;			// X field of view angle in degrees, usually 90.
    00029	var		globalconfig float Handedness;
    00030	var		bool        bIsPlayer;			// Pawn is a player or a player-bot.
    00031	var		bool        bIsBot;			// Pawn is player-bot.
    00032	var		bool		bGodMode;			// cheat - when true, can't be killed or hurt
    00033
    00034	//AI flags
    00035	var const bool		bLOSflag;			// used for alternating LineOfSight traces
    00036	var		bool		bAdvancedTactics;	// used during movement between pathnodes
    00037	var		bool		bCanOpenDoors;
    00038	var		bool		bCanDoSpecial;
    00039	var const bool		bAdjusting;
    00040	var		bool		bNoTact;
    00041	var     bool		bTacticalDir;		// used during movement between pathnodes
    00042	var		bool		bPreparingMove;		// set true while pawn sets up for a latent move
    00043	var		bool		bControlAnimations;	// take control of animations from pawn (don't let pawn play animations based on notifications)
    00044	var     bool        bDisableEventSeeMonster;    // if true, the event SeeMonster() is not called, whatever the state the controller is in
    00045	var     bool        bDisableEventSeeDeadPawn;   // if true, the event SeeDeadPawn() is not called, whatever the state the controller is in
    00046	var     bool        bTimer3Loop;        // Timer3 loops (else is one-shot).
    00047
    00048	var vector AdjustLoc;
    00049
    00050	// Input buttons.
    00051	var input byte
    00052		bRun, bDuck, bFire, bAltFire;
    00053
    00054	var const	Controller		nextController; // chained Controller list
    00055
    00056	var		float 		Stimulus;			// Strength of stimulus - Set when stimulus happens
    00057	var     float		Skill;				// skill, scaled by game difficulty (add difficulty to this value)
    00058	var		float		TacticalOffset;		// C++ timer used if bAdvancedTactics is true (to call UpdateTactics)
    00059
    00060
    00061	// Navigation AI
    00062	var 	float		MoveTimer;
    00063	var 	Actor		MoveTarget;		// set by movement natives
    00064	var 	Actor		NextMoveTarget;		// set by movement natives
    00065	var		vector	 	Destination;	// set by Movement natives
    00066	var	 	vector		FocalPoint;		// set by Movement natives
    00067	var		Actor		Focus;
    00068
    00069	var		vector		LastSeenPos; 	// enemy position when I last saw enemy (auto updated if EnemyNotVisible() enabled)
    00070	var		vector		LastSeeingPos;	// position where I last saw enemy (auto updated if EnemyNotVisible enabled)
    00071	var		float		LastSeenTime;
    00072	var	 	Pawn    	Enemy;
    00073	var		Actor		Target;
    00074	var		Mover		PendingMover;	// mover pawn is waiting for to complete its move
    00075	var		Actor		GoalList[4];	// used by navigation AI - list of intermediate goals
    00076
    00077	var NavigationPoint home;			// set when begin play, used for retreating and attitude checks
    00078	var	 	float		MinHitWall;		// Minimum HitNormal dot Velocity.Normal to get a HitWall from the physics
    00079
    00080	var byte VoicePitch; //for speech
    00081	var string VoiceType; //for speech
    00082	var float OldMessageTime; //to limit frequency of voice messages
    00083
    00084	// Route Cache for Navigation
    00085	var Actor RouteCache[16];
    00086
    00087	//var ReachSpec CurrentPath; //FAB
    00088	var	transient int		CurrentPath;
    00089
    00090	var Actor	RouteGoal; //final destination for current route
    00091	var float	RouteDist;	// total distance for current route
    00092
    00093	// Execution and timer 3 variables.
    00094	var				float       Timer3Rate;         // Timer event, 0=no timer.
    00095	var		const	float       Timer3Counter;      // Counts up until it reaches TimerRate.
    00096
    00097	// Replication Info
    00098	var() class<PlayerReplicationInfo> PlayerReplicationInfoClass;
    00099	var PlayerReplicationInfo PlayerReplicationInfo;
    00100
    00101	var(AI) enum EAttitude  //order in decreasing importance
    00102	{
    00103		ATTITUDE_Fear,		//will try to run away
    00104		ATTITUDE_Hate,		// will attack enemy
    00105		ATTITUDE_Frenzy,	//will attack anything, indiscriminately
    00106		ATTITUDE_Threaten,	// animations, but no attack
    00107		ATTITUDE_Ignore,
    00108		ATTITUDE_Friendly,
    00109		ATTITUDE_Follow 	//accepts player as leader
    00110	} AttitudeToPlayer;	//determines how creature will react on seeing player (if in human form)
    00111
    00112	var class<Pawn> PawnClass;	// class of pawn to spawn (for players)
    00113
    00114	var float GroundPitchTime;
    00115	var vector ViewX, ViewY, ViewZ;	// Viewrotation encoding for PHYS_Spider
    00116
    00117	var NavigationPoint StartSpot;  // where player started the match
    00118
    00119	replication
    00120	{
    00121		reliable if( bNetDirty && (Role==ROLE_Authority) )
    00122			PlayerReplicationInfo, Pawn;
    00123		reliable if( bNetDirty && (Role== ROLE_Authority) && bNetOwner )
    00124			PawnClass;
    00125
    00126		// Functions the server calls on the client side.
    00127		reliable if( RemoteRole==ROLE_AutonomousProxy )
    00128			ClientGameEnded, ClientDying, ClientSetRotation, ClientSetLocation;
    00129		reliable if ( (!bDemoRecording || (bClientDemoRecording && bClientDemoNetFunc)) && Role == ROLE_Authority )
    00130			ClientVoiceMessage;
    00131
    00132		// Functions the client calls on the server.
    00133		unreliable if( Role<ROLE_Authority )
    00134			SendVoiceMessage;
    00135		reliable if ( Role < ROLE_Authority )
    00136			ServerRestartPlayer;
    00137	}
    00138
    00139	// Latent Movement.
    00140	//Note that MoveTo sets the actor's Destination, and MoveToward sets the
    00141	//actor's MoveTarget.  Actor will rotate towards destination unless the optional ViewFocus is specified.
    00142
    00143	native(500) final latent function MoveTo( vector NewDestination, optional Actor ViewFocus, optional float speed);
    00144	native(502) final latent function MoveToward(actor NewTarget, optional Actor ViewFocus, optional float speed,optional Actor NextTarget);
    00145	native(508) final latent function FinishRotation();
    00146
    00147	// native AI functions
    00148	/* LineOfSightTo() returns true if any of several points of Other is visible
    00149	  (origin, top, bottom)
    00150	*/
    00151	native(514) final function bool LineOfSightTo(actor Other);
    00152
    00153	/* CanSee() similar to line of sight, but also takes into account Pawn's peripheral vision
    00154	*/
    00155	native(533) final function bool CanSee(Pawn Other);
    00156
    00157	//Navigation functions - return the next path toward the goal
    00158	native(518) final function Actor FindPathTo(vector aPoint, optional bool bClearPaths);
    00159	native(517) final function Actor FindPathToward(actor anActor, optional bool bClearPaths);
    00160	native final function Actor FindPathTowardNearest(class<NavigationPoint> GoalClass);
    00161	native(525) final function NavigationPoint FindRandomDest(optional bool bClearPaths);
    00162
    00163	native(522) final function ClearPaths();
    00164	native(523) final function vector EAdjustJump(float BaseZ, float XYSpeed);
    00165
    00166	//Reachable returns whether direct path from Actor to aPoint is traversable
    00167	//using the current locomotion method
    00168	native(521) final function bool pointReachable(vector aPoint);
    00169	native(520) final function bool actorReachable(actor anActor);
    00170
    00171	/* PickWallAdjust()
    00172	Check if could jump up over obstruction (only if there is a knee height obstruction)
    00173	If so, start jump, and return current destination
    00174	Else, try to step around - return a destination 90 degrees right or left depending on traces
    00175	out and floor checks
    00176	*/
    00177	native(526) final function bool PickWallAdjust(vector HitNormal);
    00178
    00179	/* WaitForLanding()
    00180	latent function returns when pawn is on ground (no longer falling)
    00181	*/
    00182	native(527) final latent function WaitForLanding();
    00183
    00184	native(540) final function actor FindBestInventoryPath(out float MinWeight, bool bPredictRespawns);
    00185
    00186	native(529) final function AddController();
    00187	native(530) final function RemoveController();
    00188
    00189	// Pick best pawn target
    00190	native(531) final function pawn PickTarget(out float bestAim, out float bestDist, vector FireDir, vector projStart, optional int TraceType);
    00191	native(534) final function actor PickAnyTarget(out float bestAim, out float bestDist, vector FireDir, vector projStart);
    00192
    00193	// Force end to sleep
    00194	native function StopWaiting();
    00195
    00196	native function EndClimbLadder(); //FAB
    00197
    00198	event MayFall(); //return true if allowed to fall - called by engine when pawn is about to fall
    00199
    00200
    00201	//=============================================================================
    00202	// Timing.
    00203
    00204	// Causes Timer3() events every NewTimerRate seconds.
    00205	native final function SetTimer3( float NewTimerRate, bool bLoop );
    00206
    00207	event Timer3();
    00208
    00209
    00210
    00211	/* DisplayDebug()
    00212	list important controller attributes on canvas
    00213	*/
    00214	function DisplayDebug(Canvas Canvas, out float YL, out float YPos)
    00215	{
    00216		Canvas.DrawText("PAWN "$Pawn);
    00217		YPos += YL;
    00218		Canvas.SetPos(4,YPos);
    00219		if ( Pawn == None )
    00220		{
    00221			Super.DisplayDebug(Canvas,YL,YPos);
    00222			return;
    00223		}
    00224		Canvas.DrawText("CONTROLLER "$GetItemName(string(self)));
    00225		YPos += YL;
    00226		Canvas.SetPos(4,YPos);
    00227
    00228		Canvas.DrawText("     STATE: "$GetStateName()$" Timer: "$TimerCounter$" Enemy "$Enemy, false);
    00229		YPos += YL;
    00230		Canvas.SetPos(4,YPos);
    00231
    00232		if ( PlayerReplicationInfo == None )
    00233			Canvas.DrawText("     NO PLAYERREPLICATIONINFO", false);
    00234		else
    00235			PlayerReplicationInfo.DisplayDebug(Canvas,YL,YPos);
    00236
    00237		YPos += YL;
    00238		Canvas.SetPos(4,YPos);
    00239
} 00240 00241 /* Reset() 00242 reset actor to initial state 00243 */ 00244 function Reset() 00245 { 00246 Super.Reset(); 00247 Enemy = None; 00248 LastSeenTime = 0; 00249 StartSpot = None; 00250 } 00251 00252 /* ClientSetLocation() 00253 replicated function to set location and rotation. Allows server to force new location for 00254 teleports, etc. 00255 */ 00256 function ClientSetLocation( vector NewLocation, rotator NewRotation ) 00257 { 00258 SetRotation(NewRotation); 00259 If ( (Rotation.Pitch > RotationRate.Pitch) 00260 && (Rotation.Pitch < 65536 - RotationRate.Pitch) ) 00261 { 00262 If (Rotation.Pitch < 32768) 00263 NewRotation.Pitch = RotationRate.Pitch; 00264 else 00265 NewRotation.Pitch = 65536 - RotationRate.Pitch; 00266 } 00267 if ( Pawn != None ) 00268 { 00269 NewRotation.Roll = 0; 00270 Pawn.SetRotation( NewRotation ); 00271 Pawn.SetLocation( NewLocation ); 00272 } 00273 } 00274 00275 /* ClientSetRotation() 00276 replicated function to set rotation. Allows server to force new rotation. 00277 */ 00278 function ClientSetRotation( rotator NewRotation ) 00279 { 00280 SetRotation(NewRotation); 00281 if ( Pawn != None ) 00282 { 00283 NewRotation.Pitch = 0; 00284 NewRotation.Roll = 0; 00285 Pawn.SetRotation( NewRotation ); 00286 } 00287 } 00288 00289 function ClientDying(class<DamageType> DamageType, vector HitLocation) 00290 { 00291 if ( Pawn != None ) 00292 { 00293 Pawn.PlayDying(DamageType, HitLocation); 00294 Pawn.GotoState('Dying'); 00295 } 00296 } 00297 00298 /* AIHearSound() 00299 Called when AI controlled pawn would hear a sound. Default AI implementation uses MakeNoise() 00300 interface for hearing appropriate sounds instead 00301 */ 00302 event AIHearSound ( 00303 actor Actor, 00304 int Id, 00305 sound S, 00306 vector SoundLocation, 00307 vector Parameters, 00308 bool bNoFPHack 00309 ); 00310 00311 function Possess(Pawn aPawn) 00312 { 00313 aPawn.PossessedBy(self); 00314 Pawn = aPawn; 00315 if ( PlayerReplicationInfo != None ) 00316 PlayerReplicationInfo.bIsFemale = Pawn.bIsFemale; 00317 // preserve Pawn's rotation initially for placed Pawns 00318 FocalPoint = Pawn.Location + 512*vector(Pawn.Rotation); 00319 Restart(); 00320 } 00321 00322 /* PawnDied() 00323 unpossess a pawn (because pawn was killed) 00324 */ 00325 function PawnDied() 00326 { 00327 if ( Pawn != None ) 00328 { 00329 SetLocation(Pawn.Location); 00330 Pawn.UnPossessed(); 00331 } 00332 Pawn = None; 00333 PendingMover = None; 00334 if ( bIsPlayer ) 00335 GotoState('Dead'); // can respawn 00336 else 00337 Destroy(); 00338 } 00339 00340 function Restart() 00341 { 00342 Enemy = None; 00343 } 00344 00345 event LongFall(); // called when latent function WaitForLanding() doesn't return after 4 seconds 00346 00347 // notifications of pawn events (from C++) 00348 // if return true, then pawn won't get notified 00349 event bool NotifyPhysicsVolumeChange(PhysicsVolume NewVolume); 00350 event bool NotifyHeadVolumeChange(PhysicsVolume NewVolume); 00351 event bool NotifyLanded(vector HitNormal); 00352 event bool NotifyHitWall(vector HitNormal, actor Wall); 00353 event bool NotifyBump(Actor Other); 00354 event NotifyHitMover(vector HitNormal, mover Wall); 00355 00356 // notifications called by pawn in script 00357 function NotifyAddInventory(inventory NewItem); 00358 function NotifyTakeHit(pawn InstigatedBy, vector HitLocation, int Damage, class<DamageType> damageType, vector Momentum) 00359 { 00360 if ( (instigatedBy != None) && (instigatedBy != pawn) ) 00361 damageAttitudeTo(instigatedBy, Damage); 00362 } 00363 00364 // Notification called by weapon to inform pawn controller. 00365 function NotifyFiring(); 00366 00367 function SetFall(); //about to fall 00368 00369 event PreBeginPlay() 00370 { 00371 AddController(); 00372 Super.PreBeginPlay(); 00373 if ( bDeleteMe ) 00374 return; 00375 00376 SightCounter = 0.2 * FRand(); //offset randomly 00377 } 00378 00379 event PostBeginPlay() 00380 { 00381 Super.PostBeginPlay(); 00382 if (bIsPlayer) 00383 { 00384 PlayerReplicationInfo = Spawn(PlayerReplicationInfoClass, Self,,vect(0,0,0),rot(0,0,0)); 00385 InitPlayerReplicationInfo(); 00386 } 00387 } 00388 00389 function InitPlayerReplicationInfo() 00390 { 00391 if (PlayerReplicationInfo.PlayerName == "") 00392 PlayerReplicationInfo.SetPlayerName(class'GameInfo'.Default.DefaultPlayerName); 00393 } 00394 00395 /* --> became purely C++ virtual function 00396 function vector WeaponBob(float BobDamping) 00397 { 00398 return vect(0,0,0); 00399 } 00400 */ 00401 00402 function HandlePickup(Pickup pick) 00403 { 00404 if ( MoveTarget == pick ) 00405 MoveTimer = -1.0; 00406 } 00407 00408 simulated event Destroyed() 00409 { 00410 if ( Role < ROLE_Authority ) 00411 return; 00412 00413 RemoveController(); 00414 00415 if ( bIsPlayer && (Level.Game != None) ) 00416 Level.Game.logout(self); 00417 if ( PlayerReplicationInfo != None ) 00418 PlayerReplicationInfo.Destroy(); 00419 Super.Destroyed(); 00420 } 00421 00422 /* AdjustView() 00423 by default, check and see if pawn still needs to update eye height 00424 (only if some playercontroller still has pawn as its viewtarget) 00425 Overridden in playercontroller 00426 */ 00427 function AdjustView( float DeltaTime ) 00428 { 00429 local Controller C; 00430 00431 for ( C=Level.ControllerList; C!=None; C=C.NextController ) 00432 if ( C.IsA('PlayerController') && (PlayerController(C).ViewTarget == Pawn) ) 00433 return; 00434 00435 Pawn.bUpdateEyeHeight =false; 00436 Pawn.Eyeheight = Pawn.BaseEyeHeight; 00437 } 00438 00439 /*function bool WantsSmoothedView() 00440 { 00441 return ( ((Pawn.Physics==PHYS_Walking) || (Pawn.Physics==PHYS_Spider)) && !Pawn.bJustLanded ); 00442 }*/ 00443 native function bool WantsSmoothedView(); 00444 00445 00446 function ClientGameEnded() 00447 { 00448 GotoState('GameEnded'); 00449 } 00450 00451 simulated event RenderOverlays( canvas Canvas ) 00452 { 00453 if ( Pawn.Weapon != None ) 00454 Pawn.Weapon.RenderOverlays(Canvas); 00455 } 00456 00457 /* GetFacingDirection() 00458 returns direction faced relative to movement dir 00459 00460 0 = forward 00461 16384 = right 00462 32768 = back 00463 49152 = left 00464 */ 00465 function int GetFacingDirection() 00466 { 00467 return 0; 00468 } 00469 00470 //------------------------------------------------------------------------------ 00471 // Speech related 00472 00473 function SendMessage(PlayerReplicationInfo Recipient, name MessageType, byte MessageID, float Wait, name BroadcastType) 00474 { 00475 SendVoiceMessage(PlayerReplicationInfo, Recipient, MessageType, MessageID, BroadcastType); 00476 } 00477 00478 function SendVoiceMessage(PlayerReplicationInfo Sender, PlayerReplicationInfo Recipient, name messagetype, byte messageID, name broadcasttype) 00479 { 00480 local Controller P; 00481 local bool bNoSpeak; 00482 00483 if ( Level.TimeSeconds - OldMessageTime < 2.5 ) 00484 bNoSpeak = true; 00485 else 00486 OldMessageTime = Level.TimeSeconds; 00487 00488 for ( P=Level.ControllerList; P!=None; P=P.NextController ) 00489 { 00490 if ( PlayerController(P) != None ) 00491 { 00492 if ( !bNoSpeak ) 00493 { 00494 if ( (broadcasttype == 'GLOBAL') || !Level.Game.bTeamGame ) 00495 P.ClientVoiceMessage(Sender, Recipient, messagetype, messageID); 00496 else if ( Sender.Team == P.PlayerReplicationInfo.Team ) 00497 P.ClientVoiceMessage(Sender, Recipient, messagetype, messageID); 00498 } 00499 } 00500 else if ( (P.PlayerReplicationInfo == Recipient) || ((messagetype == 'ORDER') && (Recipient == None)) ) 00501 P.BotVoiceMessage(messagetype, messageID, self); 00502 } 00503 } 00504 00505 function ClientVoiceMessage(PlayerReplicationInfo Sender, PlayerReplicationInfo Recipient, name messagetype, byte messageID); 00506 function BotVoiceMessage(name messagetype, byte MessageID, Controller Sender); 00507 00508 //*************************************************************** 00509 // interface used by ScriptedControllers to query pending controllers 00510 00511 function bool WouldReactToNoise( float Loudness, Actor NoiseMaker) 00512 { 00513 return false; 00514 } 00515 00516 function bool WouldReactToSeeing(Pawn Seen) 00517 { 00518 return false; 00519 } 00520 00521 //*************************************************************** 00522 // AI related 00523 00524 function FearThisSpot(Actor ASpot); 00525 event PrepareForMove(NavigationPoint Goal, ReachSpec Path); 00526 function WaitForMover(Mover M); 00527 function MoverFinished(); 00528 function UnderLift(Mover M); 00529 00530 event float Desireability(Pickup P) 00531 { 00532 return P.BotDesireability(Pawn); 00533 } 00534 00535 event HearNoise( float Loudness, Actor NoiseMaker); 00536 event SeePlayer( Pawn Seen ); // called when a player (bIsPlayer==true) pawn is seen 00537 event SeeMonster( Pawn Seen ); // called when a non-player (bIsPlayer==false) pawn is seen and bDisableEventSeeMonster==false 00538 event SeeDeadPawn( Pawn Seen ); // called when a dead pawn (bIsDead==true) is seen and bDisableEventSeeDeadPawn==false 00539 00540 event UpdateTactics(); // for advanced tactics 00541 event EnemyNotVisible(); 00542 00543 function ShakeView( float shaketime, float RollMag, vector OffsetMag, float RollRate, vector OffsetRate, float OffsetTime); 00544 00545 function NotifyKilled(Controller Killer, Controller Killed, pawn Other) 00546 { 00547 if ( Enemy == Other ) 00548 Enemy = None; 00549 } 00550 00551 function damageAttitudeTo(pawn Other, float Damage); 00552 00553 function eAttitude AttitudeTo(Pawn Other) 00554 { 00555 if ( Other.IsPlayerPawn() ) 00556 return AttitudeToPlayer; 00557 else 00558 return ATTITUDE_Ignore; 00559 } 00560 00561 function float AdjustDesireFor(Pickup P); 00562 function FireWeaponAt(Actor A); 00563 00564 function StopFiring() 00565 { 00566 bFire = 0; 00567 bAltFire = 0; 00568 } 00569 00570 function float WeaponPreference(Weapon W); 00571 00572 00573 /* AdjustAim() 00574 AIController version does adjustment for non-controlled pawns. 00575 PlayerController version does the adjustment for player aiming help. 00576 Only adjusts aiming at pawns 00577 allows more error in Z direction (full as defined by AutoAim - only half that difference for XY) 00578 CHANGENOTE: This function change is related to the Weapon code updates 00579 */ 00580 function rotator AdjustAim(Ammunition FiredAmmunition, vector projStart, int aimerror) 00581 { 00582 return Rotation; 00583 } 00584 00585 /* ReceiveWarning() *** CHANGENOTE: RENAMED (WAS WARNTARGET())*** 00586 AI controlled creatures may duck 00587 if not falling, and projectile time is long enough 00588 often pick opposite to current direction (relative to shooter axis) 00589 */ 00590 function ReceiveWarning(Pawn shooter, float projSpeed, vector FireDir) 00591 { 00592 } 00593 00594 /* CHANGENOTE: Changes in this function related to the Weapon code updates 00595 */ 00596 exec function SwitchToBestWeapon() 00597 { 00598 local float rating; 00599 00600 if ( Pawn.Inventory == None ) 00601 return; 00602 00603 StopFiring(); 00604 Pawn.PendingWeapon = Pawn.Inventory.RecommendWeapon(rating); 00605 if ( Pawn.PendingWeapon == Pawn.Weapon ) 00606 Pawn.PendingWeapon = None; 00607 if ( Pawn.PendingWeapon == None ) 00608 return; 00609 00610 if ( Pawn.Weapon == None ) 00611 Pawn.ChangedWeapon(); 00612 00613 if ( Pawn.Weapon != Pawn.PendingWeapon ) 00614 Pawn.Weapon.PutDown(); 00615 } 00616 00617 function bool CheckFutureSight(float DeltaTime) 00618 { 00619 return true; 00620 } 00621 00622 function ChangedWeapon(); 00623 function ServerReStartPlayer() 00624 { 00625 } 00626 00627 // ********************************************** 00628 // Controller States 00629 00630 State Dead 00631 { 00632 ignores SeePlayer, HearNoise, KilledBy; 00633 00634 function PawnDied() {} 00635 00636 function ServerReStartPlayer() 00637 { 00638 //log("calling restartplayer in dying with netmode "$Level.NetMode); 00639 if ( Level.NetMode == NM_Client ) 00640 return; 00641 Level.Game.RestartPlayer(self); 00642 } 00643 } 00644 00645 state GameEnded 00646 { 00647 ignores SeePlayer, HearNoise, KilledBy, NotifyBump, HitWall, NotifyPhysicsVolumeChange, NotifyHeadVolumeChange, Falling, TakeDamage, ReceiveWarning; 00648 00649 function BeginState() 00650 { 00651 if ( Pawn != None ) 00652 { 00653 Pawn.bPhysicsAnimUpdate = false; 00654 Pawn.StopAnimating(); 00655 Pawn.SimAnim.AnimRate = 0; 00656 Pawn.SetCollision(false,false,false); 00657 Pawn.Velocity = vect(0,0,0); 00658 Pawn.SetPhysics(PHYS_None); 00659 Pawn.UnPossessed(); 00660 } 00661 if ( !bIsPlayer ) 00662 Destroy(); 00663 } 00664 } 00665 00666 00667 debugonly simulated function DumpContent(float TimeStamp, int tabulation) 00668 { 00669 local int j; 00670 local string Tab; 00671 00672 for (j=0; j<tabulation; j++) Tab = Tab$" "; 00673 00674 log(Tab$"Controller's dump at "$TimeStamp$":"); 00675 //log(Tab$" SightCounter:"$SightCounter$" FovAngle:"$FovAngle$" Handedness:"$Handedness$" bIsPlayer:"$bIsPlayer$" bGodMode:"$bGodMode); 00676 log(Tab$" SightCounter:"$SightCounter); 00677 //log(Tab$" bLOSflag:"$bLOSflag$" bAdvancedTactics:"$bAdvancedTactics$" bCanOpenDoors:"$bCanOpenDoors$" bCanDoSpecial:"$bCanDoSpecial$" bAdjusting:"$bAdjusting$" bNoTact:"$bNoTact$" bTacticalDir:"$bTacticalDir$" bPreparingMove:"$bPreparingMove$" bControlAnimations:"$bControlAnimations); 00678 //log(Tab$" AdjustLoc:"$AdjustLoc); 00679 //log(Tab$" bRun:"$bRun$" bDuck:"$bDuck$" bFire:"$bFire$" bAltFire:"$bAltFire); 00680 //log(Tab$" nextController:"$nextController); 00681 //log(Tab$" Stimulus:"$Stimulus$" Skill:"$Skill$" TacticalOffset:"$TacticalOffset); 00682 //log(Tab$" MoveTimer:"$MoveTimer$" MoveTarget:"$MoveTarget$" Destination:"$Destination$" FocalPoint:"$FocalPoint$" Focus:"$Focus); 00683 log(Tab$" MoveTimer:"$MoveTimer); 00684 //log(Tab$" LastSeenPos:"$LastSeenPos$" LastSeeingPos:"$LastSeeingPos$" LastSeenTime:"$LastSeenTime$" Enemy:"$Enemy$" Target:"$Target$" PendingMover:"$PendingMover); 00685 //log(Tab$" MinHitWall:"$MinHitWall$" VoicePitch:"$VoicePitch$" VoiceType:"$VoiceType$" OldMessageTime:"$OldMessageTime); 00686 //log(Tab$" AttitudeToPlayer:"$AttitudeToPlayer$" PawnClass:"$PawnClass$" GroundPitchTime:"$GroundPitchTime); 00687 log(Tab$" GroundPitchTime:"$GroundPitchTime); 00688 //log(Tab$" ViewX:"$ViewX$" ViewY:"$ViewY$" ViewZ:"$ViewZ); 00689 //log(Tab$" PlayerReplicationInfoClass:"$PlayerReplicationInfoClass$" PlayerReplicationInfo:"$PlayerReplicationInfo); 00690 00691 if (PlayerReplicationInfo != none) 00692 { 00693 PlayerReplicationInfo.DumpContent(TimeStamp, tabulation+2); 00694 } 00695 else 00696 { 00697 log(Tab$" PlayerReplicationInfo: none"); 00698 } 00699 if (Pawn != none) 00700 { 00701 Pawn.DumpContent(TimeStamp, tabulation+2); 00702 } 00703 else 00704 { 00705 log(Tab$" Pawn: none"); 00706 } 00707 00708 /* 00709 //var Actor RouteCache[16] 00710 //var ReachSpec CurrentPath 00711 //var Actor RouteGoal 00712 //var float RouteDist 00713 //GoalList[4] 00714 00715 //var NavigationPoint home 00716 00717 //var NavigationPoint StartSpot 00718 */ 00719 00720 00721 Super.DumpContent(TimeStamp, tabulation); 00722 } 00723 00724 defaultproperties 00725 { 00726 FovAngle=90.000000 00727 MinHitWall=-1.000000 00728 PlayerReplicationInfoClass=Class'Engine.PlayerReplicationInfo' 00729 AttitudeToPlayer=ATTITUDE_Hate 00730 bHidden=True 00731 bInteractive=False 00732 bHiddenEd=True 00733 }

End Source Code