Put this code in a separate file (adding the exec(); call to it from main.cs of course):
Code: Select all
//-----------------------------------------------------------------------------
// This is where the kill messages go. Here are some nice defaults.
//-----------------------------------------------------------------------------
$Pref::Kill::numMessages = 6;
$Pref::Kill::Messages[0] = " has been keelhauled by ";
$Pref::Kill::Messages[1] = " got popped by ";
$Pref::Kill::Messages[2] = " has been eliminated by ";
$Pref::Kill::Messages[3] = " has been disposed of by ";
$Pref::Kill::Messages[4] = "'s mind was blown by ";
$Pref::Kill::Messages[5] = " has been lobotomized by ";
function TankData::onDestroyed(%db,%this,%killer)
{
if ($Game::SinglePlayer)
{
%db.onSPDestroyed(%this,%killer);
return;
}
if ($Game::TargetRange)
{
%db.onTargetDestroyed(%this,%killer);
return;
}
// need to deal with both ai bots and players as killer's and killee's
%client = %this.client;
%client.deaths++;
// echo("killed tank: " @ %this @ ", client: " @ %client);
// echo("killer tank: " @ %killer @ ", client: " @ %killerClient);
//-----------------------------------------------------------------------------
// This is where the killer's score is adjusted for the kill.
//-----------------------------------------------------------------------------
if (isObject(%killer))
{
%rand = getRandom($pref::Kill::numMessages - 1);
messageAll('MsgClientKilled', %client.nameBase @ $Pref::Kill::Messages[%rand] @ %killer.client.nameBase @ "!");
if ($Game::MissionType $= "Deathmatch")
{
// this is a score...
if ($Game::TeamGame)
{
if (%killer.client.team.getId() != %client.team.getId())
{
// Fair kill.
%killer.incScore(1,1);
}
else
{
// Team killer, lose a point by default.
%killer.incScore(-1,0);
}
}
else
{
if (%killer.client != %client)
// Fair kill outside a team game.
%killer.incScore(1,1);
else
// Self-killed, so he loses a point.
%killer.incScore(-1,0);
}
}
%killer.client.kills++;
}
else
{
messageAll('MsgClientKilled','%1 has been eliminated!',%client.name);
}
//-----------------------------------------------------------------------------
// This is where the killed tank's score is handled.
// By default, nobody loses points for a death, with one exception...
//-----------------------------------------------------------------------------
if ($Game::MissionType $= "Deathmatch")
{
if ($Game::TeamGame)
{
if (isObject(%killer))
{
if (%killer.client.team.getId() == %client.team.getId())
// Killed by a teammate.
%this.incScore(0,0);
else
// Fair kill.
%this.incScore(0,0);
}
else
// Dive, lose point for that.
%this.incScore(-1,-1);
}
else
{
if (%killer.client != %client)
// Fair kill outside a team game.
%killer.incScore(1,1);
else
// Self-killed, but already lost a point.
%killer.incScore(0,0);
}
}
if (!isObject(%client.ai))
{
if ($Game::aiControlMode)
{
%client.player = 0;
%client.schedule(4000,"spawnPlayer");
}
else
commandToClient(%client,'CenterPrint',"Your brain has been seized by the government, press SPACE.", 0, 1 );
}
else
spawnBotPlayer(%client);
}