DAZZLE'S UPGRADE PACK

If you haven't already done so, upgrade your game by downloading Dazzle's all-in-one upgrade pack. It comes with everything you need for today's servers. Does your blue bar freeze when joining servers? Do you lag in games? Do you get an annoying siren in Phobik's Servers? This is what you need. CLICK HERE TO DOWNLOAD.

Complete control over scoring and kill messages

Modding questions, answers, help.....

Moderators: Warfare, Moderator, Admin

DJ Wings
Need Major Repair
Need Major Repair
Posts: 895
Joined: Thu Dec 28, 2006 9:01 am
Location: Places... Places.

Complete control over scoring and kill messages

Post by DJ Wings »

This script changes the scoring process so that a random message pops up each time, instead of "Blah has been eliminated by blah!" every time. The point-awarding process has been changed just a bit to give you more control over it, and some of the defaults have changed. Now, teamkillers lose points instead of their victims, and while being killed won't lose you points, diving and suicide (in indie BM) will, so no more killing yourself to get a fresh tank for free. Of course, you can change all this if you don't like it.
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);

}
Never really gone, never really part of the game.
Mr Phobik
Site Mechanic
Site Mechanic
Posts: 283
Joined: Wed Apr 30, 2008 2:35 pm
Location: Toronto, CANADA

Re: Complete control over scoring and kill messages

Post by Mr Phobik »

^^ You make a new .cs file and add the exec(); in the main.cs...Read..He Clearly said that..
And Cool, thanks :thumbup:
Image
User avatar
TMG Leader
Veteran Light
Veteran Light
Posts: 962
Joined: Mon Jun 25, 2007 10:31 am
Location: In my refrigerator....

Re: Complete control over scoring and kill messages

Post by TMG Leader »

Thats helpful, could u help me with my question?
http://forums.planetthinktanks2.com/Thi ... f=4&t=3692
First to fall, last man standing.

Who is online

Users browsing this forum: Amazon [Bot], ClaudeBot [Bot] and 17 guests