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

XGame.BloodRites


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
//==============================================================================
// Single Player Challenge Game code
// A blood rite challenge is a challenge against an whole team. The prize is a
// exchange of team mates.
//
// Written by Michiel Hendriks
// (c) 2003, Epic Games, Inc. All Rights Reserved
//==============================================================================

class BloodRites extends ChallengeGame;

/** menu to display when we lost out team mate */
var string UntradeMenu;
/** The trade menu */
var string TradeMenu;
/** entry fee multiplicator of the bot's price */
var float ChalFeeMultiply;

/**
	We have two special events: TRADE and UNTRADE
	Both have the arguments <teamname> <playername>
	In case of TRADE you get a player to add to your team, unless your team is
	already full, then you have to remove one firts.
	UNTRADE will just give you the message that a team mate has been removed
	from your team.
*/
static function HandleSpecialEvent(UT2K4GameProfile GP, array<string> SpecialEvent, out array<TriString> GUIPages)
{
	local class<UT2K4TeamRoster> ETI;
	local array<string> NewTeamRoster;
	local int i;

	if (SpecialEvent[0] == "TRADE")
	{
		GUIPages.length = GUIPages.length+1;
		GUIPages[GUIPages.length-1].GUIPage = default.TradeMenu;
		GUIPages[GUIPages.length-1].Param1 = SpecialEvent[1];
		GUIPages[GUIPages.length-1].Param2 = SpecialEvent[2];

		// remove the player from that team
		if (!GP.GetAltTeamRoster(SpecialEvent[1], NewTeamRoster))
		{
			ETI = class<UT2K4TeamRoster>(DynamicLoadObject(SpecialEvent[1], class'Class'));
			if (ETI != none) NewTeamRoster = ETI.default.RosterNames;
			else Warn("Some Nali cow ate the enemy team class");
		}
		for (i = 0; i < NewTeamRoster.length; i++)
		{
			if (NewTeamRoster[i] ~= SpecialEvent[2])
			{
				NewTeamRoster.remove(i, 1);
				break;
			}
		}
		GP.SetAltTeamRoster(SpecialEvent[1], NewTeamRoster);
		// update bot stats
		i = GP.GetBotPosition(SpecialEvent[2]);
		if (i > -1)
		{
			GP.BotStats[i].Health = 100;
			GP.BotStats[i].TeamId = -1;
			// refund entry fee
			GP.Balance += GP.BotStats[i].Price*default.ChalFeeMultiply;
		}
	}
	else if (SpecialEvent[0] == "UNTRADE")
	{
		GUIPages.length = GUIPages.length+1;
		GUIPages[GUIPages.length-1].GUIPage = default.UnTradeMenu;
		GUIPages[GUIPages.length-1].Param1 = SpecialEvent[1];
		GUIPages[GUIPages.length-1].Param2 = SpecialEvent[2];
		// remove the player from our team
		GP.ReleaseTeammate(SpecialEvent[2]);
		// add it to the enemy team
		if (!GP.GetAltTeamRoster(SpecialEvent[1], NewTeamRoster))
		{
			ETI = class<UT2K4TeamRoster>(DynamicLoadObject(SpecialEvent[1], class'Class'));
			if (ETI != none) NewTeamRoster = ETI.default.RosterNames;
			else Warn("Some Nali cow ate the enemy team class");
		}
		if (NewTeamRoster.length == 0)
		{
			NewTeamRoster.length = NewTeamRoster.length+1;
			NewTeamRoster[NewTeamRoster.length-1] = SpecialEvent[2];
			// update bot stats
			i = GP.GetBotPosition(SpecialEvent[2]);
			if (i > -1)
			{
				GP.BotStats[i].Health = 100;
				GP.BotStats[i].TeamId = GP.GetTeamPosition(SpecialEvent[1]);
			}
		}
		GP.SetAltTeamRoster(SpecialEvent[1], NewTeamRoster);
	}
}

/** when we where challenged the SpecialEvent logic goes the other way around */
static function PostRegisterGame(UT2K4GameProfile GP, GameInfo currentGame, PlayerReplicationInfo PRI)
{
	// do the switch
	if (GP.bGotChallenged)
	{
		if (!GP.bWonMatch) GP.SpecialEvent $= ";"$GP.ChallengeInfo.SpecialEvent;
		else {
			// remove the UNTRADE
			GP.SpecialEvent = repl(GP.SpecialEvent, GP.ChallengeInfo.SpecialEvent, "");
		}
	}
}

static function AddHistoryRecord(UT2K4GameProfile GP, int offset, GameInfo Game, PlayerReplicationInfo PRI, UT2K4MatchInfo MI)
{
	super.AddHistoryRecord(GP, offset, game, PRI, MI);

}

static function bool canChallenge(optional UT2K4GameProfile GP)
{
	if (GP == none) return true;
	return GP.completedLadder(GP.UT2K4GameLadder.default.LID_TDM);
}

static function bool payTeamMates(UT2K4GameProfile GP)
{
	return ! GP.bGotChallenged;
}

static function StartChallenge(UT2K4GameProfile GP, LevelInfo myLevel)
{
	GP.SpecialEvent = "";
	if (GP.bGotChallenged) GP.SpecialEvent = GP.ChallengeInfo.SpecialEvent; // so you can't chicken out
	GP.bIsChallenge = true;
	GP.Balance -= GP.ChallengeInfo.EntryFee;
	GP.ChallengeGameClass = default.class;
	GP.StartNewMatch ( -1, myLevel );
}

defaultproperties
{
	ChallengeName="Bloodrites"
	ChallengeDescription="Challenge an enemy team for one for their team mates."
	ChallengeMenu="GUI2K4.UT2K4SP_CGBloodRites"
	TradeMenu="GUI2K4.UT2K4SP_CGBRTrade"
	UntradeMenu="GUI2K4.UT2K4SP_CGBRUntrade"
	ChalFeeMultiply=3
}

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