Engine
Class NavigationPoint

source: c:\runehov\Engine\Classes\NavigationPoint.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.NavigationPoint
Direct Known Subclasses:AmbushPoint, AutoLink, ButtonMarker, HomeBase, InventorySpot, LiftCenter, LiftExit, PathNode, PatrolPoint, PlayerStart, Teleporter, TriggerMarker, WarpZoneMarker, ScriptPoint, SarkBallStart

class NavigationPoint
extends Engine.Actor

//============================================================================= // NavigationPoint. //=============================================================================
Variables
 int ExtraCost
           added cost to visit this pathnode
 int Paths[16]
           index of reachspecs (used by C++ Navigation code)
 int PrunedPaths[16]
           index of reachspecs (used by C++ Navigation code)
 NavigationPoint VisNoReachPaths[16]
           paths that are visible but not directly reachable
 bool bAutoBuilt
           placed during execution of "PATHS BUILD"
 bool bEndPoint
           used by C++ navigation code
 bool bEndPointOnly
           only used as an endpoint in routing network
 bool bNeverUseStrafing
           shouldn't use bAdvancedTactics going to this point
 bool bOneWayPath
           reachspecs from this path only in the direction the path is facing (180 degrees)
 bool bPlayerOnly
           only players should use this path
 bool bSpecialCost
           if true, navigation code will call SpecialCost function for this navigation point
 bool bTwoWay
           hacked here to fix CTF problems post release (used by Botpack.AlternatePath)
 int bestPathWeight
           paths that are visible but not directly reachable
 int cost
           added cost to visit this pathnode
 NavigationPoint nextNavigationPoint
           paths that are visible but not directly reachable
 NavigationPoint nextOrdered
           paths that are visible but not directly reachable
 name ownerTeam
           creature clan owning this area (area visible from this point)
 NavigationPoint prevOrdered
           paths that are visible but not directly reachable
 NavigationPoint previousPath
           paths that are visible but not directly reachable
 Actor routeCache
           paths that are visible but not directly reachable
 NavigationPoint startPath
           paths that are visible but not directly reachable
 bool taken
           set when a creature is occupying this spot
 int upstreamPaths[16]
           set when a creature is occupying this spot
 int visitedWeight
           paths that are visible but not directly reachable


Function Summary
 
simulated
Debug(Canvas Canvas, int mode)
 void DrawSpec(Canvas Canvas, vector start, vector end, int flags)
 void DrawTextOnLine(Canvas Canvas, vector start, vector end, string text)
 void DrawTube(Canvas Canvas, vector v1, vector v2, int Radius, int Height)
 int NumPaths()
 Actor PathEndPoint(int i)
 void PlayTeleportEffect(Actor Incoming, bool bOut)
 void describeSpec(int iSpec, out Actor, out Actor, out int, out int, out int, out int)



Source Code


00001	//=============================================================================
00002	// NavigationPoint.
00003	//=============================================================================
00004	class NavigationPoint extends Actor
00005		native;
00006	
00007	#exec Texture Import File=Textures\S_Pickup.pcx Name=S_Pickup Mips=Off Flags=2
00008	
00009	#exec Texture Import File=Textures\S_Point.pcx Name=S_Point Mips=Off Flags=2
00010	
00011	
00012	//------------------------------------------------------------------------------
00013	// NavigationPoint variables
00014	var() name ownerTeam;	//creature clan owning this area (area visible from this point)
00015	var bool taken; //set when a creature is occupying this spot
00016	var int upstreamPaths[16];
00017	var int Paths[16]; //index of reachspecs (used by C++ Navigation code)
00018	var int PrunedPaths[16];
00019	var NavigationPoint VisNoReachPaths[16]; //paths that are visible but not directly reachable
00020	var int visitedWeight;
00021	var actor routeCache;
00022	var const int bestPathWeight;
00023	var const NavigationPoint nextNavigationPoint;
00024	var const NavigationPoint nextOrdered;
00025	var const NavigationPoint prevOrdered;
00026	var const NavigationPoint startPath;
00027	var const NavigationPoint previousPath;
00028	var int cost; //added cost to visit this pathnode
00029	var() int ExtraCost;
00030	var() bool bPlayerOnly;	//only players should use this path
00031	
00032	var bool bEndPoint; //used by C++ navigation code
00033	var bool bEndPointOnly; //only used as an endpoint in routing network
00034	var bool bSpecialCost;	//if true, navigation code will call SpecialCost function for this navigation point
00035	var() bool bOneWayPath;	//reachspecs from this path only in the direction the path is facing (180 degrees)
00036	var() bool bNeverUseStrafing; // shouldn't use bAdvancedTactics going to this point
00037	var bool bAutoBuilt;	// placed during execution of "PATHS BUILD"
00038	var bool bTwoWay;	// hacked here to fix CTF problems post release (used by Botpack.AlternatePath)
00039	 
00040	native(519) final function describeSpec(int iSpec, out Actor Start, out Actor End, out int ReachFlags, out int Distance, out int Radius, out int Height); 
00041	event int SpecialCost(Pawn Seeker);
00042	
00043	// Accept an actor that has teleported in.
00044	// used for random spawning and initial placement of creatures
00045	event bool Accept( actor Incoming, actor Source )
00046	{
00047		// Move the actor here.
00048		taken = Incoming.SetLocation( Location + vect (0,0,20));
00049		if (taken)
00050		{
00051			Incoming.Velocity = vect(0,0,0);
00052			Incoming.SetRotation(Rotation);
00053		}
00054		// Play teleport-in effect.
00055		PlayTeleportEffect(Incoming, true);
00056		return taken;
00057	}
00058	
00059	function PlayTeleportEffect(actor Incoming, bool bOut)
00060	{
00061		Level.Game.PlayTeleportEffect(Incoming, bOut, false);
00062	}
00063	
00064	final function int NumPaths()
00065	{
00066		local int count;
00067	
00068		count = 0;
00069		while (Paths[count] != -1)
00070		{
00071			count++;
00072		}
00073		return count;
00074	}
00075	
00076	function actor PathEndPoint(int i)
00077	{
00078		local actor Start,End;
00079		local int flags, dist;
00080		local int Radius, Height;
00081		
00082		if (Paths[i] == -1)
00083			return None;
00084		
00085		DescribeSpec(Paths[i], Start, End, flags, dist, Radius, Height);
00086		
00087		return End;
00088	}
00089	
00090	simulated function Debug(canvas Canvas, int mode)
00091	{
00092		local int i, num,flags,dist,R,G,B,sx,sy;
00093		local actor Start,End;
00094		local bool bNear;
00095		local int Radius, Height;
00096		local Pawn P;
00097		local vector work;
00098	
00099		if (ROLE < ROLE_Authority)	// Nav point info unavailable on clients
00100			return;
00101	
00102		num = NumPaths();
00103	
00104		// Find the player
00105		for( P=Level.PawnList; P!=None; P=P.nextPawn )
00106			if( P.bIsPlayer )
00107				break;
00108	
00109		bNear = (VSize(P.Location - Location) < 500);
00110	
00111		// Show paths
00112		switch(mode)
00113		{
00114			case HUD_ACTOR:			// Normal paths
00115				for (i=0; i<num; i++)
00116				{
00117					if (Paths[i] == -1)
00118						continue;
00119					DescribeSpec(Paths[i], Start, End, flags, dist, radius, height);
00120					if (Start==None || End==None)
00121						continue;
00122					DrawSpec(Canvas, Start.Location, End.Location, flags);
00123					if (bNear)
00124					{
00125						if (Radius < 50 || Height < 50)
00126						{	R = 255;  G = 255;  B =   0;	}
00127						else
00128						{	R =   0;  G = 255;  B =   0;	}
00129						Canvas.SetColor(R,G,B);
00130						DrawTextOnLine(Canvas, start.Location, End.Location, "R="$Radius@"H="$Height);
00131					}
00132				}
00133				break;
00134			case HUD_SKELETON:		// VisNoReach paths
00135				if (bNear)
00136				{
00137					for (i=0; i<num; i++)
00138					{
00139						if (VisNoReachPaths[i] != None)
00140						{
00141							DrawSpec(Canvas, Location, VisNoReachPaths[i].Location, 1);
00142						}
00143					}
00144				}
00145				break;
00146				
00147			case HUD_SKELNAMES:		// Pruned paths
00148				if (bNear)
00149				{
00150					for (i=0; i<num; i++)
00151					{
00152						if (PrunedPaths[i] == -1)
00153							continue;
00154						DescribeSpec(PrunedPaths[i], Start, End, flags, dist, radius, height);
00155						DrawSpec(Canvas, Start.Location, End.Location, flags);
00156					}
00157				}
00158				break;
00159				
00160			case HUD_SKELJOINTS:	// Radii/Height Tubes
00161				if (bNear)
00162				{
00163					for (i=0; i<num; i++)
00164					{
00165						if (Paths[i] == -1)
00166							continue;
00167						DescribeSpec(Paths[i], Start, End, flags, dist, radius, height);
00168						DrawTube(Canvas, Start.Location, End.Location, Radius, Height);
00169						if (Radius < 50 || Height < 50)
00170						{	R = 255;  G = 255;  B =   0;	}
00171						else
00172						{	R =   0;  G = 255;  B =   0;	}
00173						Canvas.SetColor(R,G,B);
00174						DrawTextOnLine(Canvas, start.Location, End.Location, "R="$Radius@"H="$Height);
00175					}
00176				}
00177				break;
00178				
00179			case HUD_SKELAXES:		// End point info
00180				if (bEndPoint)
00181				{
00182					work.X = Location.X + 5;
00183					work.Y = Location.Y + 5;
00184					work.Z = Location.Z + 200;
00185					Canvas.DrawLine3D(Location, work, 255, 255, 0);
00186					Canvas.TransformPoint(work, sx, sy);
00187					Canvas.SetPos(sx,sy);
00188					Canvas.DrawText("bEndPoint");
00189				}
00190				if (bEndPointOnly)
00191				{
00192					work.X = Location.X - 5;
00193					work.Y = Location.Y - 5;
00194					work.Z = Location.Z + 200;
00195					Canvas.DrawLine3D(Location, work, 0, 0, 255);
00196					Canvas.TransformPoint(work, sx, sy);
00197					Canvas.SetPos(sx,sy);
00198					Canvas.DrawText("bEndPointOnly");
00199				}
00200				for (i=0; i<num; i++)
00201				{
00202					if (Paths[i] == -1)
00203						continue;
00204					DescribeSpec(Paths[i], Start, End, flags, dist, radius, height);
00205					DrawSpec(Canvas, Start.Location, End.Location, flags);
00206				}
00207				break;
00208			case HUD_LOD:
00209				if (bNear)
00210				{
00211					if (nextOrdered != None)
00212					{
00213						R = 255;  G =   0;  B = 255;
00214						work = nextOrdered.Location;
00215						Canvas.SetColor(R,G,B);
00216						DrawTextOnLine(Canvas, Location, work, "NextOrdered");
00217						Canvas.DrawLine3D(Location, work, R, G, B);
00218					}
00219		
00220					if (prevOrdered != None)
00221					{
00222						R =   0;  G = 255;  B = 255;
00223						work = prevOrdered.Location;
00224						Canvas.SetColor(R,G,B);
00225						DrawTextOnLine(Canvas, Location, work, "PrevOrdered");
00226						Canvas.DrawLine3D(Location, work, R, G, B);
00227					}
00228				}
00229				break;
00230			case HUD_POV:
00231				if (bNear)
00232				{
00233					if (startPath != None)
00234					{
00235						R = 255;  G = 255;  B =   0;
00236						work = startPath.Location;
00237						Canvas.SetColor(R,G,B);
00238						DrawTextOnLine(Canvas, Location, work, "StartPath");
00239						Canvas.DrawLine3D(Location, work, R, G, B);
00240					}
00241		
00242					if (previousPath != None)
00243					{
00244						R = 255;  G = 255;  B = 255;
00245						work = previousPath.Location;
00246						Canvas.SetColor(R,G,B);
00247						DrawTextOnLine(Canvas, Location, work, "previousPath");
00248						Canvas.DrawLine3D(Location, work, R, G, B);
00249					}
00250				}
00251				break;
00252		}		
00253	}
00254	
00255	function DrawTextOnLine(canvas Canvas, vector start, vector end, string text)
00256	{
00257		local int sx,sy;
00258		Canvas.TransformPoint(Start + ((end-start) * 0.2), sx, sy);
00259		Canvas.SetOrigin(sx,sy);
00260		Canvas.SetPos(0, 0);
00261		Canvas.DrawText(text);
00262	}
00263	
00264	function DrawSpec(canvas Canvas, vector start, vector end, int flags)
00265	{
00266		local int R,G,B;
00267		R = 0;
00268		G = 0;
00269		B = 0;
00270		if ((flags & 1)>0) R = 255; else R = 0;
00271		if ((flags & 2)>0) G = 255; else G = 0;
00272		if ((flags & 4)>0) B = 255; else B = 0;
00273		Canvas.DrawLine3D(Start, End, R, G, B);
00274	}
00275	
00276	function DrawTube(canvas Canvas, vector v1, vector v2, int Radius, int Height)
00277	{
00278		local vector p1, p2, X, Y, Z, tocorner1, tocorner2, tocorner3, tocorner4;
00279		local float R,G,B;
00280		local rotator toend;
00281	
00282		if (Radius < 50 || Height < 50)
00283		{	R = 255;  G = 255;  B =   0;	}
00284		else
00285		{	R =   0;  G = 255;  B =   0;	}
00286	
00287		toend = rotator(v2 - v1);
00288		GetAxes(toend, X, Y, Z);
00289	
00290		tocorner1 =  Y*Radius + Z*Height;
00291		tocorner2 =  Y*Radius - Z*Height;
00292		tocorner3 = -Y*Radius - Z*Height;
00293		tocorner4 = -Y*Radius + Z*Height;
00294	
00295		// Length of box
00296		Canvas.DrawLine3D( v1 + tocorner1, v2 + tocorner1, R, G, B);
00297		Canvas.DrawLine3D( v1 + tocorner2, v2 + tocorner2, R, G, B);
00298		Canvas.DrawLine3D( v1 + tocorner3, v2 + tocorner3, R, G, B);
00299		Canvas.DrawLine3D( v1 + tocorner4, v2 + tocorner4, R, G, B);
00300	
00301		// End cap 1
00302		Canvas.DrawLine3D( v1+tocorner1, v1+tocorner2, R, G, B);
00303		Canvas.DrawLine3D( v1+tocorner2, v1+tocorner3, R, G, B);
00304		Canvas.DrawLine3D( v1+tocorner3, v1+tocorner4, R, G, B);
00305		Canvas.DrawLine3D( v1+tocorner4, v1+tocorner1, R, G, B);
00306	
00307		// End cap 2
00308		Canvas.DrawLine3D( v2+tocorner1, v2+tocorner2, R, G, B);
00309		Canvas.DrawLine3D( v2+tocorner2, v2+tocorner3, R, G, B);
00310		Canvas.DrawLine3D( v2+tocorner3, v2+tocorner4, R, G, B);
00311		Canvas.DrawLine3D( v2+tocorner4, v2+tocorner1, R, G, B);
00312	}
00313	
00314	defaultproperties
00315	{
00316	     upstreamPaths(0)=-1
00317	     upstreamPaths(1)=-1
00318	     upstreamPaths(2)=-1
00319	     upstreamPaths(3)=-1
00320	     upstreamPaths(4)=-1
00321	     upstreamPaths(5)=-1
00322	     upstreamPaths(6)=-1
00323	     upstreamPaths(7)=-1
00324	     upstreamPaths(8)=-1
00325	     upstreamPaths(9)=-1
00326	     upstreamPaths(10)=-1
00327	     upstreamPaths(11)=-1
00328	     upstreamPaths(12)=-1
00329	     upstreamPaths(13)=-1
00330	     upstreamPaths(14)=-1
00331	     upstreamPaths(15)=-1
00332	     Paths(0)=-1
00333	     Paths(1)=-1
00334	     Paths(2)=-1
00335	     Paths(3)=-1
00336	     Paths(4)=-1
00337	     Paths(5)=-1
00338	     Paths(6)=-1
00339	     Paths(7)=-1
00340	     Paths(8)=-1
00341	     Paths(9)=-1
00342	     Paths(10)=-1
00343	     Paths(11)=-1
00344	     Paths(12)=-1
00345	     Paths(13)=-1
00346	     Paths(14)=-1
00347	     Paths(15)=-1
00348	     PrunedPaths(0)=-1
00349	     PrunedPaths(1)=-1
00350	     PrunedPaths(2)=-1
00351	     PrunedPaths(3)=-1
00352	     PrunedPaths(4)=-1
00353	     PrunedPaths(5)=-1
00354	     PrunedPaths(6)=-1
00355	     PrunedPaths(7)=-1
00356	     PrunedPaths(8)=-1
00357	     PrunedPaths(9)=-1
00358	     PrunedPaths(10)=-1
00359	     PrunedPaths(11)=-1
00360	     PrunedPaths(12)=-1
00361	     PrunedPaths(13)=-1
00362	     PrunedPaths(14)=-1
00363	     PrunedPaths(15)=-1
00364	     bStatic=True
00365	     bHidden=True
00366	     bCollideWhenPlacing=True
00367	     SoundVolume=0
00368	     CollisionRadius=23.000000
00369	     CollisionHeight=25.000000
00370	}

End Source Code