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

Gameplay.MPPersonalStatMessage


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
//
// Base personal message class
//
class MPPersonalStatMessage extends MPPersonalMessage;

var array<string> personalMessages;
var localized string offenseStr, defenseStr, styleStr;

static function string GetPersonalString(
	out EMessageType messageType,
	optional int Switch,
	optional Core.Object Related1, 
	optional Core.Object Related2,
	optional Core.Object OptionalObject,
	optional String OptionalString
	)
{
	local class<Stat> s;
	local PlayerReplicationInfo PRI;
	local int amount;

	// Expect Related1 to be a stat (required)
	// Expect Related2 to be a target PRI (optional)
	s = class<Stat>(Related1);
	if (s == None)
		return "";

	if (Related2 != None)
		PRI = PlayerReplicationInfo(Related2);

	// If an amount wasn't explicitly sent, assume 1
	amount = int(OptionalString);
	if (amount <= 0)
	{
		amount = 1;
	}

	// Check if it's a penalty
	if (s.default.offensePointsPerStat < 0 || s.default.defensePointsPerStat < 0 || s.default.stylePointsPerStat < 0)
		messageType = MessageType_StatPenalty;
	// Otherwise set messagetype depending on stat level
	else if (s.default.logLevel <= 1)
		messageType = MessageType_StatHigh;
	else if (s.default.logLevel == 2)
		messageType = MessageType_StatMedium;
	else
		messageType = MessageType_StatLow;

	//Log("MPPersonalStatMessage set messageType to "$messageType$" due to logLevel "$s.default.logLevel$" for stat "$s);

	if (Switch == 0)
	{
		if (PRI == None)
			return s.default.personalMessage @ createScoreString(s, amount);
		else
			return replaceStr(s.default.personalmessage, PRI.PlayerName) @ createScoreString(s, amount);
	}

	// A custom message has been defined
	if (default.personalMessages.Length < Switch)
		return "";

	if (PRI == None)
		return default.personalMessages[Switch] @ createScoreString(s, amount);
	else
		return replaceStr(default.personalMessages[Switch], PRI.PlayerName) @ createScoreString(s, amount);

	return "";
}

static function string createScoreString(class<Stat> s, int amount)
{
	local string str;
	local array<string> strList;
	local int i;
	local string operatorString;

	if (s.default.offensePointsPerStat < 0 || s.default.defensePointsPerStat < 0 || s.default.stylePointsPerStat < 0)
		operatorString = "";
	else
		operatorString = "+";


	if (s.default.offensePointsPerStat != 0)
	{
		strList[strList.Length] = operatorString $ s.default.offensePointsPerStat*amount @ default.offenseStr;
	}

	if (s.default.defensePointsPerStat != 0)
	{
		strList[strList.Length] = operatorString $ s.default.defensePointsPerStat*amount @ default.defenseStr;
	}

	if (s.default.stylePointsPerStat != 0)
	{
		strList[strList.Length] = operatorString $ s.default.stylePointsPerStat*amount @ default.styleStr;
	}

	str = "(";

	// Append all but the last string using comma separators
	for (i=0; i<strList.Length - 1; i++)
	{
		str = str $ strList[i] $ ", ";
	}

	// Append the last string with a bracket on the end
	str = str $ strList[i] $ ")";

	return str;
}

defaultproperties
{
	personalMessages(0)="This index is reserved for a personal message stored in a Stat."

	offenseStr = "Offense"
	defenseStr = "Defense"
	styleStr   = "Style"
}

// You killed Kaka (+1 Offense)
// You midair'd Kaka (+1 Style)
// You protected your Generator (+1 Defense)
// You teamkilled Kaka (-1 Offense)
// Kaka teamkilled you
// You returned the flag with good timing (+3 Defense)

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