(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:


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:


==== 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");
              Msg_Printf ("Player resigns from life");
      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;

Then inside the died function, look for:


gamestate.weapon = -1;        // take away weapon

And add:


DeathMessages ();

Directly underneath. Save and compile.

There you go

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

Posts : 402
Join date : 2015-10-02
Age : 21

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

Back to top Go down

Back to top

- Similar topics

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