//=============================================================================
// High jump destination
//
// For testing purposes, do not modify or redistribute
// Have suggestions? Contact me.
// caco_fff@hotmail.com - Higor at UT99.org
//=============================================================================
class Botz_JumpNode expands Botz_NavigBase;

var NavigationPoint NearestFlat;
var MasterGasterFer MasterG;

#exec TEXTURE IMPORT NAME=BWP_Goal FILE=..\CompileData\BWP_Goal.bmp FLAGS=2

//Called after botZ decides this is the path to take
function bool PostPathEvaluate( botz other)
{
	if ( !other.PointReachable(Location) )
	{
		if ( other.bCanTranslocate )
			Other.TranslocateToTarget(self);
		else
			Other.HighJump(self);
		return true;
	}
	return false;
}

function EPathMode IsCandidateTo( Botz_NavigBase Other)
{
	local EPathMode eResult;

	if ( Other.IsA('Botz_JumpNode') )
		return PM_None;

	eResult = Super.IsCandidateTo(Other);
	if ( eResult > 0 )
	{
		if ( (abs(Normal( Location - Other.Location).Z) < 0.17) || (VSize(Location - Other.Location) < 50) )  //Flat point or very close
		{
			if ( (NearestFlat == none) || (VSize(NearestFlat.Location - Location) > VSize(Location - Other.Location)) )
			{
				NearestFlat = Other;
				return PM_None; //Do not path, leave for end
			}
		}
		else if ( Normal( Other.Location - Location).Z < -0.3 ) //Low points
		{
			if ( UpstreamPaths[14] != -1 || Paths[14] != -1 ) //Leave room for the flat Node
				return PM_None;
			return eResult;
		}
	}
	return PM_None;
}

function EPathMode OtherIsCandidate( NavigationPoint Nav)
{
	local EPathMode eResult;

	if ( Nav.IsA('Teleporter') )
		return PM_None;
	eResult = Super.OtherIsCandidate(Nav);
	if ( eResult > 0 )
	{
		if ( (abs(Normal( Location - Nav.Location).Z) < 0.17) || (VSize(Location - Nav.Location) < 50) ) //Flat point or very close
		{
			if ( (NearestFlat == none) || (VSize(NearestFlat.Location - Location) > VSize(Location - Nav.Location)) )
			{
				NearestFlat = Nav;
				return PM_None; //Do not path, leave for end
			}
		}
		else if ( Normal( Nav.Location - Location).Z < -0.3 ) //Low points
		{
			if ( UpstreamPaths[14] != -1 || Paths[14] != -1 ) //Leave room for the flat Node
				return PM_None;
			return eResult;
		}
	}
	return PM_None;
}

//Add force flag when i'm the once connecting
event AddPathHere( NavigationPoint Start, NavigationPoint End, bool bForce)
{
	if ( !bForce && Start == self )
		bForce = true;
	Super.AddPathHere( Start, End, bForce);
}

event FinishedPathing();

event int SpecialCost(Pawn Seeker)
{
	local Bot B;
	local Botz A;

	if ( (Seeker.JumpZ > MaxDistance*1.5) || Region.Zone.ZoneGravity.Z > -650 ) //Dynamic condition
		return 100;

	if ( Seeker.GetPropertyText("bCanTranslocate") ~= "True" )
		return 150;

	return 100000000;
}

defaultproperties
{
	FriendlyName="Big jump destination"
	MaxDistance=480
	Texture=Texture'FerBotz.BWP_Goal'
	bSpecialCost=true
	bPushSave=True
}