Class NKillsMessage extends LocalMessage;

var localized string KillString,KillsString;
var localized float MessageShowTime;
var bool bDamageMessage;

static final function string GetNameOf( class<Monster> M )
{
	if( Len(M.Default.MenuName)==0 )
		return string(M.Name);
	return M.Default.MenuName;
}

static function string GetString(
    optional int Switch,
    optional PlayerReplicationInfo RelatedPRI_1,
    optional PlayerReplicationInfo RelatedPRI_2,
    optional Object OptionalObject
    )
{
	if( RelatedPRI_1==None )
		return "+"$(Switch+1)@GetNameOf(Class<Monster>(OptionalObject))@Eval(Switch==0,Default.KillString,Default.KillsString);
	return RelatedPRI_1.PlayerName@"+"$(Switch+1)@GetNameOf(Class<Monster>(OptionalObject))@Eval(Switch==0,Default.KillString,Default.KillsString);
}

static function ClientReceive(
    PlayerController P,
    optional int Sw,
    optional PlayerReplicationInfo RelatedPRI_1,
    optional PlayerReplicationInfo RelatedPRI_2,
    optional Object OptionalObject
    )
{
	local HudBase H;
	local byte i;

	if( Class<Monster>(OptionalObject)==None || HudBase(P.myHud)==None || (!Default.bDamageMessage && RelatedPRI_1==None && Sw==1) )
		return;
	H = HudBase(P.myHud);
	if( HudKillingFloor(H)!=None )
		HudKillingFloor(H).bTallySpecimenKills = false;
	for( i=0; i<8; ++i )
	{
		if( H.LocalMessages[i].Message==Default.Class && H.LocalMessages[i].OptionalObject==OptionalObject && H.LocalMessages[i].RelatedPRI==RelatedPRI_1 )
		{
			if( Default.bDamageMessage )
				H.LocalMessages[i].Switch+=Sw;
			else ++H.LocalMessages[i].Switch;
			H.LocalMessages[i].DrawColor = GetColor(H.LocalMessages[i].Switch);
			H.LocalMessages[i].LifeTime = Default.MessageShowTime;
			H.LocalMessages[i].EndOfLife = Default.MessageShowTime + P.Level.TimeSeconds;
			H.LocalMessages[i].StringMessage = GetString(H.LocalMessages[i].Switch,RelatedPRI_1,,OptionalObject);
			return;
		}
	}
	if( !Default.bDamageMessage )
		Sw = 0;
	if ( H!=None )
		H.LocalizedMessage(Default.Class,Sw,RelatedPRI_1,,OptionalObject);
}

static function float GetLifeTime(int Switch)
{
	return default.MessageShowTime;
}

// Fade color: Green (0-3 frags) > Yellow (4-7 frags) > Red (8-12 frags) > Dark Red (13+ frags).
static function color GetColor(
	optional int Switch,
	optional PlayerReplicationInfo RelatedPRI_1,
	optional PlayerReplicationInfo RelatedPRI_2
	)
{
	local color C;

	C.A = 255;
	if( Switch<10 )
	{
		C.G = Clamp(500-Switch*50,0,255);
		C.R = Clamp(0+Switch*50,0,255);
	}
	else C.R = Max(505-Switch*25,150);
	return C;
}

defaultproperties
{
     KillString="kill"
     KillsString="kills"
     MessageShowTime=5.000000
     bIsConsoleMessage=False
     bFadeMessage=True
     DrawColor=(B=0,G=0,R=150)
     DrawPivot=DP_UpperLeft
     StackMode=SM_Down
     PosX=0.020000
     PosY=0.200000
     FontSize=-1
}
