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

Gameplay.MPCapturePoint


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
class MPCapturePoint extends MPActor;

var() int						teamCaptureScore			"The number of points an attacker scores for his team when the carryable is captured";
var() editcombotype(enumCapturables) 
	  Name						homeCapturableLabel			"Label of a carryable of the capture point's team that must be in a home state in order for the team to score on capture";
var() Vector					homeCapturableOffset		"How much the carryable is offset from the capture point";

var() class<MPCapturable>		capturableClass;
var(LocalMessage) class<Engine.Localmessage> CapturePointMessageClass "The class used for playing effects and displaying messages";

var MPCapturable				homeCapturable;
var Array<MPCapturable>			enemyCapturables;

var float lastCaptureAttemptTime;

// Stats

// PostBeginPlay
simulated function PostBeginPlay()
{
	local MPCapturable a;

	Super.PostBeginPlay();

	if (Level.NetMode != NM_Client)
	{
		if (homeCapturableLabel != '')
		{
			homeCapturable = MPCapturable(findByLabel(class'MPCapturable', homeCapturableLabel));
			if (homeCapturable == None)
			{
				LOG(Label$": could not find the specified home capturable");
			}
			else
			{
				// Ensure the homeCapturable is precisely positioned on the stand
				setHomeCapturableLocation();

				// Cross-reference it
				homeCapturable.homeCapturePoint = self;
			}
		}
		else
			Log("Warning:  capture point "$self$" doesn't have a homeCapturable");

		ForEach DynamicActors(class'MPCapturable', a)
		{
			// A capturable is considered "enemy" to the capture point if it's on a different team,
			// or if the capturable is neutral, or if the capture point is neutral
			if (a != None && (a.team() != team() || a.team() == None || team() == None))
			{
				enemyCapturables[enemyCapturables.Length] = a;
			}
		}
	}
}

function setHomeCapturableLocation()
{
	homeCapturable.homeLocation = Location + homeCapturableOffset;
	homeCapturable.returnToHome();
}

// Bump
function touch(Actor Other)
{
	local int i;
	local MPCapturable c;

	// an actor bumped into us - check all the enemy capturables to see if that actor is holding one of them
	for (i = 0; i < enemyCapturables.Length; i++)
	{
		c = enemyCapturables[i];

		if (!c.IsInState('Held'))
		{
			continue;
		}

		// Can only capture if carrier is on the capture point's team or if the capture point is neutral
		if (c.carrier == Other && ((c.carrier.team() == team()) || (team() == None)))
		{
			// can only capture when home capturable is returned
			if (homeCapturable != None && !homeCapturable.bHome)
			{
				if (Level.TimeSeconds - lastCaptureAttemptTime > 2)
				{
					lastCaptureAttemptTime = Level.TimeSeconds;
					c.carrier.ReceiveLocalizedMessage( CapturePointMessageClass, 1 );
				}
				continue;
			}

			if (CapturePointMessageClass != None)
				Level.Game.BroadcastLocalized(self, CapturePointMessageClass, 0, c.carrier.team(), c.team());

			if (SecondaryMessageClass != None)
				Level.Game.BroadcastLocalized(self, SecondaryMessageClass, 3, c.carrier.playerReplicationInfo);

			scoreCapture(c.carrier);
			c.onCapture(c.carrier);
		}
	}
}

// scoreCapture
function scoreCapture(Character instigator)
{
	// If this stand has a team, score according to that team
	if (team() != None)
		scoreTeam(teamCaptureScore);
	// Otherwise, score according to the carrier's team
	else
		scoreTeam(teamCaptureScore, instigator.team());
}

function onHomeCapturableReturned()
{
	local Character c;

	// Check for anyone standing at the capture point when the home capturable returns
	ForEach TouchingActors(class'Character', c)
	{
		Touch(c);
	}
}

// enumCapturables
function enumCapturables(Engine.LevelInfo l, out Array<Name> a)
{
	local MPCapturable f;

	ForEach DynamicActors(class'MPCapturable', f)
	{
		if (f.isA(capturableClass.Name) && f.team() == team())
			a[a.Length] = f.Label;
	}
}


defaultproperties
{
	DrawType				= DT_StaticMesh
	StaticMesh				= StaticMesh'Editor_res.TexPropCube'
	bCollideActors			= true
	bCollideWorld			= true
//	bBlockActors			= true
	bMovable				= false
	bNeedLifetimeEffectEvents	= true
	bProjTarget				= false


	CollisionRadius			= 200
	CollisionHeight			= 200

	teamCaptureScore		= 1
	homeCapturableOffset	= (X=0,Y=0,Z=125)

	capturableClass			= class'MPCapturable'
	CapturePointMessageClass = class'MPCapturePointMessages'
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: ne 5.9.2004 15:53:18.000 - Creation time: st 23.5.2018 00:10:45.825 - Created with UnCodeX