Engine
Class LiftCenter

source: e:\games\UnrealTournament\Engine\Classes\LiftCenter.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.NavigationPoint
         |
         +--Engine.LiftCenter
Direct Known Subclasses:JumpSpot, PainPath, TranslocDest

class LiftCenter
extends Engine.NavigationPoint

//============================================================================= // LiftCenter. //=============================================================================
Variables
 float LastTriggerTime
 vector LiftOffset
           added threshold for Z difference between pawn and lift (for lifts which are at the end of a ramp or stairs)
 name LiftTag
 name LiftTrigger
 float MaxDist2D
           added threshold for Z difference between pawn and lift (for lifts which are at the end of a ramp or stairs)
 float MaxZDiffAdd
           added threshold for Z difference between pawn and lift (for lifts which are at the end of a ramp or stairs)
 Trigger RecommendedTrigger


Function Summary
 void PostBeginPlay()
 Actor SpecialHandling(Pawn Other)
     
/* SpecialHandling is called by the navigation code when the next path has been found.  
It gives that path an opportunity to modify the result based on any special considerations
*/



Source Code


00001	//=============================================================================
00002	// LiftCenter.
00003	//=============================================================================
00004	class LiftCenter extends NavigationPoint
00005		native;
00006	
00007	var() name LiftTag;
00008	var	 mover MyLift;
00009	var() name LiftTrigger;
00010	var trigger RecommendedTrigger;
00011	var float LastTriggerTime;
00012	var() float MaxZDiffAdd;  //added threshold for Z difference between pawn and lift (for lifts which are at the end of a ramp or stairs)
00013	var() float MaxDist2D;
00014	var vector LiftOffset;
00015	
00016	function PostBeginPlay()
00017	{
00018		if ( LiftTag != '' )
00019			ForEach AllActors(class'Mover', MyLift, LiftTag )
00020			{
00021				MyLift.myMarker = self;
00022				SetBase(MyLift);
00023				LiftOffset = Location - MyLift.Location;
00024				if ( MyLift.InitialState == 'BumpOpenTimed' )
00025					log("Warning: "$MyLift$" is BumpOpenTimed.  Bots don't understand this well - use StandOpenTimed instead!");
00026				break;
00027			}
00028		// log(self$" attached to "$MyLift);
00029		if ( LiftTrigger != '' )
00030			ForEach AllActors(class'Trigger', RecommendedTrigger, LiftTrigger )
00031				break;
00032		Super.PostBeginPlay();
00033	}
00034	
00035	/* SpecialHandling is called by the navigation code when the next path has been found.  
00036	It gives that path an opportunity to modify the result based on any special considerations
00037	*/
00038	
00039	function Actor SpecialHandling(Pawn Other)
00040	{
00041		local float dist2d;
00042		local NavigationPoint N, Exit;
00043	
00044		if ( MyLift == None )
00045			return self;
00046		if ( Other.base == MyLift )
00047		{
00048			if ( (RecommendedTrigger != None) 
00049			&& (myLift.SavedTrigger == None)
00050			&& (Level.TimeSeconds - LastTriggerTime > 5) )
00051			{
00052				Other.SpecialGoal = RecommendedTrigger;
00053				LastTriggerTime = Level.TimeSeconds;
00054				return RecommendedTrigger;
00055			}
00056	
00057			return self;
00058		}
00059	
00060		if ( (LiftExit(Other.MoveTarget) != None) 
00061			&& (LiftExit(Other.MoveTarget).RecommendedTrigger != None)
00062			&& (LiftExit(Other.MoveTarget).LiftTag == LiftTag)
00063			&& (Level.TimeSeconds - LiftExit(Other.MoveTarget).LastTriggerTime > 5)
00064			&& (MyLift.SavedTrigger == None)
00065			&& (Abs(Other.Location.X - Other.MoveTarget.Location.X) < Other.CollisionRadius)
00066			&& (Abs(Other.Location.Y - Other.MoveTarget.Location.Y) < Other.CollisionRadius)
00067			&& (Abs(Other.Location.Z - Other.MoveTarget.Location.Z) < Other.CollisionHeight) )
00068		{
00069			LiftExit(Other.MoveTarget).LastTriggerTime = Level.TimeSeconds;
00070			Other.SpecialGoal = LiftExit(Other.MoveTarget).RecommendedTrigger;
00071			return LiftExit(Other.MoveTarget).RecommendedTrigger;
00072		}
00073	
00074		SetLocation(MyLift.Location + LiftOffset);
00075		SetBase(MyLift);
00076		dist2d = square(Location.X - Other.Location.X) + square(Location.Y - Other.Location.Y);
00077		if ( (Location.Z - CollisionHeight - MaxZDiffAdd < Other.Location.Z - Other.CollisionHeight + Other.MaxStepHeight)
00078			&& (Location.Z - CollisionHeight > Other.Location.Z - Other.CollisionHeight - 1200)
00079			&& ( dist2D < MaxDist2D * MaxDist2D) )
00080		{
00081			return self;
00082		}
00083	
00084		if ( MyLift.BumpType == BT_PlayerBump && !Other.bIsPlayer )
00085			return None;
00086		Other.SpecialGoal = None;
00087			
00088		// make sure Other is at valid lift exit
00089		if ( LiftExit(Other.MoveTarget) == None )
00090		{
00091			for ( N=Level.NavigationPointList; N!=None; N=N.NextNavigationPoint )
00092				if ( N.IsA('LiftExit') && (LiftExit(N).LiftTag == LiftTag) 
00093					&& (Abs(Other.Location.X - N.Location.X) < Other.CollisionRadius)
00094					&& (Abs(Other.Location.Y - N.Location.Y) < Other.CollisionRadius)
00095					&& (Abs(Other.Location.Z - N.Location.Z) < Other.CollisionHeight) )
00096				{
00097					Exit = N;
00098					break;
00099				}
00100			if ( Exit == None )
00101				return self;
00102		}
00103	
00104		MyLift.HandleDoor(Other);
00105		MyLift.RecommendedTrigger = None;
00106	
00107		if ( (Other.SpecialGoal == MyLift) || (Other.SpecialGoal == None) )
00108			Other.SpecialGoal = self;
00109	
00110		return Other.SpecialGoal;
00111	}
00112	
00113	defaultproperties
00114	{
00115	     MaxDist2D=400.000000
00116	     ExtraCost=400
00117	     bStatic=False
00118	     bNoDelete=True
00119	     RemoteRole=ROLE_None
00120	}

End Source Code