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

Gameplay.MPRabbitFlag


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
class MPRabbitFlag extends MPCarryable;
var() int	timerInterval			"The number of seconds that pass between scoring of points for the flag carrier";
var() int	pointsPerInterval		"The number of points awarded each interval";

var(Stats) class<Stat>	timeHeldStat		"The stat that is used to track longest time held";
var(Stats) class<Stat>	rabidRabbitStat		"The stat awarded when the rabbit kills a chaser";

var int timeHeld;
var TeamInfo oldTeam;
var TeamInfo enemyTeam;

function registerStats(StatTracker tracker)
{
	local ModeInfo mode;

	Super.registerStats(tracker);
	tracker.registerStat(timeHeldStat);
	tracker.registerStat(rabidRabbitStat);

	mode = ModeInfo(Level.Game);

	if (mode != None && rabidRabbitStat != None)
	{
		mode.registerPlayerKillListener(self);
	}
}

function onPickedUp(Character c)
{
	if (c == None)
		return;

	// Put the carrier on a new, temporary enemy team
	enemyTeam = spawn(c.team().Class);
	oldTeam = c.team();
	c.setTeam(enemyTeam);

	// Start a scoring timer here
	SetTimer(timerInterval, true);
}

function onDropped(Controller c)
{
	// Put dropping player back on old team
	enemyTeam.destroy();
	if (c.Pawn != None)
	{
		Character(c.Pawn).setTeam(oldTeam);
	}
	else
		TribesReplicationInfo(c.PlayerReplicationInfo).team = oldTeam;

	// Stop scoring timer
	SetTimer(0, false);
	timeHeld = 0;
}

function onPlayerKilled(Controller Killer, Controller Target)
{
	Super.onPlayerKilled(Killer, Target);

	if (Killer == carrierController && rabidRabbitStat != None)
		awardStat(rabidRabbitStat, Character(Killer.Pawn), Target);
}

state Held
{
	function Timer()
	{
		timeHeld += timerInterval;

		// Track time held
		if (timeHeldStat != None && timeHeld > TribesReplicationInfo(carrierController.PlayerReplicationInfo).getStatData(timeHeldStat).amount)
			ModeInfo(Level.Game).Tracker.setStat(carrierController, timeHeldStat, timeHeld);

		scoreIndividual(carrier, pointsPerInterval);
	}
}

defaultproperties
{
	CollisionRadius			= 45
	CollisionHeight			= 100
	returnTime				= 30
	elasticity				= 0.05	

	timerInterval			= 1
	pointsPerInterval		= 1
}

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