View Full Version: [Tutorial] Random Death Messages

wolfers >>Coding Alliance >>[Tutorial] Random Death Messages


<< Prev | Next >>

Deathshead- 04-10-2005
[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: 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"); 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: gamestate.weapon = -1; // take away weapon SD_PlaySound (PLAYERDEATHSND); And add: DeathMessages (); Directly underneath. Save and compile. There you go -Deathshead

Flamer46- 04-11-2005

Hey very cool deathshead.

Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.