Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

UnrealGame.AssaultPath


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
//********************************************************************
// AssaultPath
// used to specify alternate routes for attackers
//
//********************************************************************
class AssaultPath extends NavigationPoint
	placeable;

var		GameObjective	AssociatedObjective;
var		AssaultPath		NextPath;
var()	int				Position;	// specifies relative position in a chain of AssaultPaths with the same PathTag and the same ObjectiveTag
var()	name			ObjectiveTag;
var()	name			PathTag[4];		// paths that fan out from the same first AssaultPath share the same PathTag, more than one path can go through a given assaultpath

var()	bool			bEnabled;
var()	bool			bNoReturn;
var()	bool			bReturnOnly;
var		bool			bFirstPath;
var		bool			bLastPath;
var()	bool			bNoGrouping;	// bots won't wait to reform squads at this assault path
	
var()	float			Priority;	// 0 to 1, higher means heavier weighting when determining whether to use this path

event Trigger( Actor Other, Pawn EventInstigator )
{
	bEnabled = !bEnabled;
}

function ValidatePathTags()
{
	if ( PathTag[0] == '' )
		PathTag[0] = Name;
}

function AddTo(GameObjective O)
{
	local AssaultPath A;
	local int i;

	NextPath = None;
	AssociatedObjective = O;
	if ( O.AlternatePaths == None )
	{
		O.AlternatePaths = self;
		return;
	}
	ValidatePathTags();
	for ( A=O.AlternatePaths; A!=None; A=A.NextPath )
	{
		for ( i=0; i<4; i++ )
			if ( (PathTag[i] != '') && A.HasPathTag(PathTag[i]) )
			{
				if ( A.Position < Position )
				{
					A.bLastPath = false;
					bFirstPath = false;
				}
				else if ( A.Position > Position )
				{
					A.bFirstPath = false;
					bLastPath = false;
				}
			}
		if ( A.NextPath == None )
		{
			A.NextPath = self;
			return;
		}
	}
}

function name PickTag()
{
	local name Result;
	local int i, num;

	ValidatePathTags();
	Result = PathTag[0];

	for ( i=0; i<4; i++ )
		if ( PathTag[i] != 'None' )
		{
			num++;
			if ( FRand() < 1/num )
				Result = PathTag[i];
		}
			
	return Result;
}

function bool HasPathTag(name aPathTag)
{
	local int i;

	ValidatePathTags();
	for ( i=0; i<4; i++ )
		if ( PathTag[i] == aPathTag )
			return true;

	return false;
}

function AssaultPath FindNextPath(name AlternatePathTag)
{
	local AssaultPath A;
	local AssaultPath List[16];
	local int i,num;
	local float sum,r;

	for ( A=AssociatedObjective.AlternatePaths; A!=None; A=A.NextPath )
	{
		if ( A.bEnabled && (A.Position > Position) && !A.bReturnOnly
			&& A.HasPathTag(AlternatePathTag) )
		{
			if ( (List[0] == None) || (A.Position < List[0].Position) )
			{
				for ( i=0; i<num; i++ )
					List[i] = None;
				List[0] = A;
				num = 1;
			}
			else if ( A.Position == List[0].Position )
			{
				List[num] = A;
				num++;
				if ( num > 15 )
					break;
			}
		}
	}
			
	if ( num > 0 )
	{
		for ( i=0; i<num; i++ )
			sum += List[i].Priority;
		r = FRand() * sum;
		sum = 0;
		for ( i=0; i<num; i++ )
		{
			sum += List[i].Priority;
			if ( r <= sum )
				return List[i];
		}
		return List[0];
	}
	return none;
}

function AssaultPath FindPreviousPath(name AlternatePathTag)
{
	local AssaultPath A;
	local AssaultPath List[16];
	local int i,num;
	local float sum,r;

	for ( A=AssociatedObjective.AlternatePaths; A!=None; A=A.NextPath )
	{
		if ( A.bEnabled && (A.Position < Position) && A.HasPathTag(AlternatePathTag) && !A.bNoReturn )
		{
			if ( (List[0] == None) || (A.Position == List[0].Position) )
			{
				List[num] = A;
				num++;
				if ( num > 15 )
					break;
			}
			else if ( A.Position < List[0].Position )
				break;
		}
	}

	if ( num > 0 )
	{
		for ( i=0; i<num; i++ )
			sum += List[i].Priority;
		r = FRand() * sum;
		sum = 0;
		for ( i=0; i<num; i++ )
		{
			sum += List[i].Priority;
			if ( r <= sum )
				return List[i];
		}
		return List[0];
	}
	return none;
}

defaultproperties
{
	bLastPath=true
	bFirstPath=true
	bEnabled=true
	Priority=+1.0
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Di 5.9.2006 22:36:08.000 - Creation time: Do 14.8.2014 09:58:34.270 - Created with UnCodeX