Deathshead Corporal

Joined: 18 Feb 2005 Posts: 87
|
Posted: Mon Apr 11, 2005 3:33 am Post subject: [Tutorial] Random Death Messages |
|
|
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:
Directly underneath. Save and compile.
There you go
-Deathshead _________________ Myspace
VampireFreaks
Music4Life
Wolfing Time |
|