(Old code tutorial) Random Death Messages from Wolf Planet forum

Go down

(Old code tutorial) Random Death Messages from Wolf Planet forum

Post by Officer-M. John (Admin) on Sat Mar 26, 2016 8:35 pm

Hi all. I have once again developed a tutorial to show everyone. When you die, it gives a random number, then shows the corresponding message. There are also messages specific to certain enemies.

Let's begin. This code requires the ingame messages variation tutorial.

Open WL_GAME.C . Add the following two lines in the Global Variables section:

Code:

objtype      *LastAttacker;
void DeathMessages (void);

LastAttacker checks what enemy killed you, and DeathMessages is the routine that gives the random message. Now scroll down, and add this routine above the Died Function:

Code:

/*==
==== DeathMessages ();
==== By Deathshead
====
==== Checks for the
==== LastAttacker, then
==== display a random
==== random message
==*/

void DeathMessages (void)
{
  switch (rand()%7)
  {
      case 0:
      if (LastAttacker->obclass==guardobj)
              Msg_Printf ("Player gunned down by Guard");
          else if (LastAttacker->obclass==dogobj)
              Msg_Printf ("Player bit off more than he could chew");
          else if (LastAttacker->obclass==ssobj)
              Msg_Printf ("Player pumped full of lead");
          else if (LastAttacker->obclass==officerobj)
              Msg_Printf ("Player met an untimely end");
          else if (LastAttacker->obclass==mutantobj)
          Msg_Printf ("Player couldn't take the pressure");
          else
              Msg_Printf ("Player resigns from life");
          break;
      case 1:
          Msg_Printf ("Player became bored with life"); break;
      case 2:
          Msg_Printf ("Player bit the dust"); break;
      case 3:
          Msg_Printf ("Player likes the taste of blood"); break;
      case 4:
          Msg_Printf ("Player gave up"); break;
      case 5:
          Msg_Printf ("Player forgot to dodge"); break;
      case 6:
          Msg_Printf ("Player forgot not to die"); break;
  }
  IN_ClearKeysDown();
}

Then inside the died function, look for:

Code:

gamestate.weapon = -1;        // take away weapon
  SD_PlaySound (PLAYERDEATHSND);

And add:

Code:

DeathMessages ();

Directly underneath. Save and compile.

There you go
-Deathshead

Writte by Deathshead on Mon Apr 11, 2005 3:33 am
avatar
Officer-M. John (Admin)
Admin

Posts : 377
Join date : 2015-10-02
Age : 20

View user profile http://wolf3dfanboys.usersboard.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum