home *** CD-ROM | disk | FTP | other *** search
/ Qu-ake / Qu-ake.iso / qu_ke / patches / 006 / CLIENT.QC < prev    next >
Encoding:
Text File  |  1996-10-19  |  35.6 KB  |  1,507 lines

  1.  
  2. // prototypes
  3. void () W_WeaponFrame;
  4. void() W_SetCurrentAmmo;
  5. void() player_pain;
  6. void() player_stand1;
  7. void (vector org) spawn_tfog;
  8. void (vector org, entity death_owner) spawn_tdeath;
  9.  
  10. float    modelindex_eyes, modelindex_player;
  11.  
  12. /*
  13. =============================================================================
  14.  
  15.                 LEVEL CHANGING / INTERMISSION
  16.  
  17. =============================================================================
  18. */
  19.  
  20. float    intermission_running;
  21. float    intermission_exittime;
  22.  
  23. /*QUAKED info_intermission (1 0.5 0.5) (-16 -16 -16) (16 16 16)
  24. This is the camera point for the intermission.
  25. Use mangle instead of angle, so you can set pitch or roll as well as yaw.  'pitch roll yaw'
  26. */
  27. void() info_intermission =
  28. {
  29. };
  30.  
  31.  
  32.  
  33. void() SetChangeParms =
  34. {
  35.     if (self.health <= 0)
  36.     {
  37.         SetNewParms ();
  38.         return;
  39.     }
  40.  
  41. // remove items
  42.     self.items = self.items - (self.items &
  43.     (IT_KEY1 | IT_KEY2 | IT_INVISIBILITY | IT_INVULNERABILITY | IT_SUIT | IT_QUAD) );
  44.  
  45. // cap super health
  46.  
  47.     if (self.health > 100)
  48.         self.health = 100;
  49.     if (self.health < 50)
  50.         self.health = 50;
  51.  
  52.     parm1 = self.items;
  53.     parm2 = self.health;
  54.     parm3 = self.armorvalue;
  55.  
  56.     if (self.ammo_shells < 25)
  57.       parm4 = 25;
  58.     else
  59.         parm4 = self.ammo_shells;
  60.     parm5 = self.ammo_nails;
  61.     parm6 = self.ammo_rockets;
  62.     parm7 = self.ammo_cells;
  63.  
  64.     parm8 = self.weapon;
  65.     parm9 = self.armortype * 100;
  66.  
  67.     // ### chase cam ###
  68.     // holds current state of cam and targeter between levels
  69.     if( ! deathmatch && ! coop )
  70.         parm16 = self.speed;
  71.  
  72.  
  73. };
  74.  
  75. void() SetNewParms =
  76. {
  77.     parm1 = IT_SHOTGUN | IT_AXE;
  78.     parm2 = 100;
  79.     parm3 = 0;
  80.     parm4 = 25;
  81.     parm5 = 0;
  82.     parm6 = 0;
  83.     parm7 = 0;
  84.     parm8 = 1;
  85.     parm9 = 0;
  86.  
  87.     // ### chase cam ###
  88.     // state of cam and targeter held in player.speed
  89.     if( ! deathmatch && ! coop )
  90.         parm16 = 0;
  91.  
  92.  
  93. };
  94.  
  95. void() DecodeLevelParms =
  96. {
  97.     if (serverflags)
  98.     {
  99.         if (world.model == "maps/start.bsp")
  100.             SetNewParms ();        // take away all stuff on starting new episode
  101.     }
  102.  
  103.     self.items = parm1;
  104.     self.health = parm2;
  105.     self.armorvalue = parm3;
  106.     self.ammo_shells = parm4;
  107.     self.ammo_nails = parm5;
  108.     self.ammo_rockets = parm6;
  109.     self.ammo_cells = parm7;
  110.     self.weapon = parm8;
  111.     self.armortype = parm9 * 0.01;
  112.  
  113.    // ### chase cam ###
  114.    // state of cam and targeter held in player.speed
  115.    if( ! deathmatch && ! coop )
  116.       self.speed = parm16;
  117.  
  118. };
  119.  
  120. /*
  121. ============
  122. FindIntermission
  123.  
  124. Returns the entity to view from
  125. ============
  126. */
  127. entity() FindIntermission =
  128. {
  129.     local    entity spot;
  130.     local    float cyc;
  131.  
  132. // look for info_intermission first
  133.     spot = find (world, classname, "info_intermission");
  134.     if (spot)
  135.     {    // pick a random one
  136.         cyc = random() * 4;
  137.         while (cyc > 1)
  138.         {
  139.             spot = find (spot, classname, "info_intermission");
  140.             if (!spot)
  141.                 spot = find (spot, classname, "info_intermission");
  142.             cyc = cyc - 1;
  143.         }
  144.         return spot;
  145.     }
  146.  
  147. // then look for the start position
  148.     spot = find (world, classname, "info_player_start");
  149.     if (spot)
  150.         return spot;
  151.     
  152. // testinfo_player_start is only found in regioned levels
  153.     spot = find (world, classname, "testplayerstart");
  154.     if (spot)
  155.         return spot;
  156.     
  157.     objerror ("FindIntermission: no spot");
  158. };
  159.  
  160.  
  161. string nextmap;
  162. void() GotoNextMap =
  163. {
  164.     if (cvar("samelevel"))    // if samelevel is set, stay on same level
  165.         changelevel (mapname);
  166.     else
  167.         changelevel (nextmap);
  168. };
  169.  
  170.  
  171. void() ExitIntermission =
  172. {
  173. // skip any text in deathmatch
  174.     if (deathmatch)
  175.     {
  176.         GotoNextMap ();
  177.         return;
  178.     }
  179.     
  180.     intermission_exittime = time + 1;
  181.     intermission_running = intermission_running + 1;
  182.  
  183. //
  184. // run some text if at the end of an episode
  185. //
  186.     if (intermission_running == 2)
  187.     {
  188.         if (world.model == "maps/e1m7.bsp")
  189.         {
  190.             WriteByte (MSG_ALL, SVC_CDTRACK);
  191.             WriteByte (MSG_ALL, 2);
  192.             WriteByte (MSG_ALL, 3);
  193.             if (!cvar("registered"))
  194.             {
  195.                 WriteByte (MSG_ALL, SVC_FINALE);
  196.                 WriteString (MSG_ALL, "As the corpse of the monstrous entity\nChthon sinks back into the lava whence\nit rose, you grip the Rune of Earth\nMagic tightly. Now that you have\nconquered the Dimension of the Doomed,\nrealm of Earth Magic, you are ready to\ncomplete your task in the other three\nhaunted lands of Quake. Or are you? If\nyou don't register Quake, you'll never\nknow what awaits you in the Realm of\nBlack Magic, the Netherworld, and the\nElder World!");
  197.             }
  198.             else
  199.             {
  200.                 WriteByte (MSG_ALL, SVC_FINALE);
  201.                 WriteString (MSG_ALL, "As the corpse of the monstrous entity\nChthon sinks back into the lava whence\nit rose, you grip the Rune of Earth\nMagic tightly. Now that you have\nconquered the Dimension of the Doomed,\nrealm of Earth Magic, you are ready to\ncomplete your task. A Rune of magic\npower lies at the end of each haunted\nland of Quake. Go forth, seek the\ntotality of the four Runes!");
  202.             }
  203.             return;
  204.         }
  205.         else if (world.model == "maps/e2m6.bsp")
  206.         {
  207.             WriteByte (MSG_ALL, SVC_CDTRACK);
  208.             WriteByte (MSG_ALL, 2);
  209.             WriteByte (MSG_ALL, 3);
  210.  
  211.             WriteByte (MSG_ALL, SVC_FINALE);
  212.             WriteString (MSG_ALL, "The Rune of Black Magic throbs evilly in\nyour hand and whispers dark thoughts\ninto your brain. You learn the inmost\nlore of the Hell-Mother; Shub-Niggurath!\nYou now know that she is behind all the\nterrible plotting which has led to so\nmuch death and horror. But she is not\ninviolate! Armed with this Rune, you\nrealize that once all four Runes are\ncombined, the gate to Shub-Niggurath's\nPit will open, and you can face the\nWitch-Goddess herself in her frightful\notherworld cathedral.");
  213.             return;
  214.         }
  215.         else if (world.model == "maps/e3m6.bsp")
  216.         {
  217.             WriteByte (MSG_ALL, SVC_CDTRACK);
  218.             WriteByte (MSG_ALL, 2);
  219.             WriteByte (MSG_ALL, 3);
  220.  
  221.             WriteByte (MSG_ALL, SVC_FINALE);
  222.             WriteString (MSG_ALL, "The charred viscera of diabolic horrors\nbubble viscously as you seize the Rune\nof Hell Magic. Its heat scorches your\nhand, and its terrible secrets blight\nyour mind. Gathering the shreds of your\ncourage, you shake the devil's shackles\nfrom your soul, and become ever more\nhard and determined to destroy the\nhideous creatures whose mere existence\nthreatens the souls and psyches of all\nthe population of Earth.");
  223.             return;
  224.         }
  225.         else if (world.model == "maps/e4m7.bsp")
  226.         {
  227.             WriteByte (MSG_ALL, SVC_CDTRACK);
  228.             WriteByte (MSG_ALL, 2);
  229.             WriteByte (MSG_ALL, 3);
  230.  
  231.             WriteByte (MSG_ALL, SVC_FINALE);
  232.             WriteString (MSG_ALL, "Despite the awful might of the Elder\nWorld, you have achieved the Rune of\nElder Magic, capstone of all types of\narcane wisdom. Beyond good and evil,\nbeyond life and death, the Rune\npulsates, heavy with import. Patient and\npotent, the Elder Being Shub-Niggurath\nweaves her dire plans to clear off all\nlife from the Earth, and bring her own\nfoul offspring to our world! For all the\ndwellers in these nightmare dimensions\nare her descendants! Once all Runes of\nmagic power are united, the energy\nbehind them will blast open the Gateway\nto Shub-Niggurath, and you can travel\nthere to foil the Hell-Mother's plots\nin person.");
  233.             return;
  234.         }
  235.  
  236.         GotoNextMap();
  237.     }
  238.     
  239.     if (intermission_running == 3)
  240.     {
  241.         if (!cvar("registered"))
  242.         {    // shareware episode has been completed, go to sell screen
  243.             WriteByte (MSG_ALL, SVC_SELLSCREEN);
  244.             return;
  245.         }
  246.         
  247.         if ( (serverflags&15) == 15)
  248.         {
  249.             WriteByte (MSG_ALL, SVC_FINALE);
  250.             WriteString (MSG_ALL, "Now, you have all four Runes. You sense\ntremendous invisible forces moving to\nunseal ancient barriers. Shub-Niggurath\nhad hoped to use the Runes Herself to\nclear off the Earth, but now instead,\nyou will use them to enter her home and\nconfront her as an avatar of avenging\nEarth-life. If you defeat her, you will\nbe remembered forever as the savior of\nthe planet. If she conquers, it will be\nas if you had never been born.");
  251.             return;
  252.         }
  253.         
  254.     }
  255.  
  256.     GotoNextMap();
  257. };
  258.  
  259. /*
  260. ============
  261. IntermissionThink
  262.  
  263. When the player presses attack or jump, change to the next level
  264. ============
  265. */
  266. void() IntermissionThink =
  267. {
  268.     if (time < intermission_exittime)
  269.         return;
  270.  
  271.     if (!self.button0 && !self.button1 && !self.button2)
  272.         return;
  273.     
  274.     ExitIntermission ();
  275. };
  276.  
  277. void() execute_changelevel =
  278. {
  279.     local entity    pos;
  280.  
  281.     intermission_running = 1;
  282.     
  283. // enforce a wait time before allowing changelevel
  284.     if (deathmatch)
  285.         intermission_exittime = time + 5;
  286.     else
  287.         intermission_exittime = time + 2;
  288.  
  289.     WriteByte (MSG_ALL, SVC_CDTRACK);
  290.     WriteByte (MSG_ALL, 3);
  291.     WriteByte (MSG_ALL, 3);
  292.     
  293.     pos = FindIntermission ();
  294.  
  295.     other = find (world, classname, "player");
  296.     while (other != world)
  297.     {
  298.         other.view_ofs = '0 0 0';
  299.         other.angles = other.v_angle = pos.mangle;
  300.         other.fixangle = TRUE;        // turn this way immediately
  301.         other.nextthink = time + 0.5;
  302.         other.takedamage = DAMAGE_NO;
  303.         other.solid = SOLID_NOT;
  304.         other.movetype = MOVETYPE_NONE;
  305.         other.modelindex = 0;
  306.         setorigin (other, pos.origin);
  307.         other = find (other, classname, "player");
  308.     }    
  309.  
  310.     WriteByte (MSG_ALL, SVC_INTERMISSION);
  311. };
  312.  
  313.  
  314. void() changelevel_touch =
  315. {
  316.     local entity    pos;
  317.  
  318.     if (other.classname != "player")
  319.         return;
  320.  
  321.     if ((cvar("noexit") == 1) || ((cvar("noexit") == 2) && (mapname != "start")))
  322.     {
  323.         T_Damage (other, self, self, 50000);
  324.         return;
  325.     }
  326.  
  327.     if (coop || deathmatch)
  328.     {
  329.         bprint (other.netname);
  330.         bprint (" exited the level\n");
  331.     }
  332.     
  333.     nextmap = self.map;
  334.  
  335.     SUB_UseTargets ();
  336.  
  337.     if ( (self.spawnflags & 1) && (deathmatch == 0) )
  338.     {    // NO_INTERMISSION
  339.         GotoNextMap();
  340.         return;
  341.     }
  342.     
  343.     self.touch = SUB_Null;
  344.  
  345. // we can't move people right now, because touch functions are called
  346. // in the middle of C movement code, so set a think time to do it
  347.     self.think = execute_changelevel;
  348.     self.nextthink = time + 0.1;
  349. };
  350.  
  351. /*QUAKED trigger_changelevel (0.5 0.5 0.5) ? NO_INTERMISSION
  352. When the player touches this, he gets sent to the map listed in the "map" variable.  Unless the NO_INTERMISSION flag is set, the view will go to the info_intermission spot and display stats.
  353. */
  354. void() trigger_changelevel =
  355. {
  356.     if (!self.map)
  357.         objerror ("chagnelevel trigger doesn't have map");
  358.     
  359.     InitTrigger ();
  360.     self.touch = changelevel_touch;
  361. };
  362.  
  363.  
  364. /*
  365. =============================================================================
  366.  
  367.                 PLAYER GAME EDGE FUNCTIONS
  368.  
  369. =============================================================================
  370. */
  371.  
  372. void() set_suicide_frame;
  373.  
  374. // called by ClientKill and DeadThink
  375. void() respawn =
  376. {
  377.     if (coop)
  378.     {
  379.         // make a copy of the dead body for appearances sake
  380.         CopyToBodyQue (self);
  381.         // get the spawn parms as they were at level start
  382.         setspawnparms (self);
  383.         // respawn        
  384.         PutClientInServer ();
  385.     }
  386.     else if (deathmatch)
  387.     {
  388.         // make a copy of the dead body for appearances sake
  389.         CopyToBodyQue (self);
  390.         // set default spawn parms
  391.         SetNewParms ();
  392.         // respawn        
  393.         PutClientInServer ();
  394.     }
  395.     else
  396.     {    // restart the entire server
  397.         localcmd ("restart\n");
  398.     }
  399. };
  400.  
  401.  
  402. /*
  403. ============
  404. ClientKill
  405.  
  406. Player entered the suicide command
  407. ============
  408. */
  409. void() ClientKill =
  410. {
  411.     bprint (self.netname);
  412.     bprint (" suicides\n");
  413.     set_suicide_frame ();
  414.     self.modelindex = modelindex_player;
  415.     self.frags = self.frags - 2;    // extra penalty
  416.     respawn ();
  417. };
  418.  
  419. float(vector v) CheckSpawnPoint =
  420. {
  421.     return FALSE;
  422. };
  423.  
  424. /*
  425. ============
  426. SelectSpawnPoint
  427.  
  428. Returns the entity to spawn at
  429. ============
  430. */
  431. entity() SelectSpawnPoint =
  432. {
  433.     local    entity spot;
  434.     local    entity thing;
  435.     local    float  pcount;
  436.     
  437. // testinfo_player_start is only found in regioned levels
  438.     spot = find (world, classname, "testplayerstart");
  439.     if (spot)
  440.         return spot;
  441.         
  442. // choose a info_player_deathmatch point
  443.     if (coop)
  444.     {
  445.         lastspawn = find(lastspawn, classname, "info_player_coop");
  446.         if (lastspawn == world)
  447.             lastspawn = find (lastspawn, classname, "info_player_start");
  448.         if (lastspawn != world)
  449.             return lastspawn;
  450.     }
  451.     else if (deathmatch)
  452.     {
  453.         spot = lastspawn;
  454.         while (1)
  455.         {
  456.             spot = find(spot, classname, "info_player_deathmatch");
  457.             if (spot != world)
  458.             {
  459.                 if (spot == lastspawn)
  460.                     return lastspawn;
  461.                 pcount = 0;
  462.                 thing = findradius(spot.origin, 32);
  463.                 while(thing)
  464.                 {
  465.                     if (thing.classname == "player")
  466.                         pcount = pcount + 1;
  467.                     thing = thing.chain;
  468.                 }
  469.                 if (pcount == 0)
  470.                 {
  471.                     lastspawn = spot;
  472.                     return spot;
  473.                 }
  474.             }
  475.         }
  476.     }
  477.  
  478.     if (serverflags)
  479.     {    // return with a rune to start
  480.         spot = find (world, classname, "info_player_start2");
  481.         if (spot)
  482.             return spot;
  483.     }
  484.     
  485.     spot = find (world, classname, "info_player_start");
  486.     if (!spot)
  487.         error ("PutClientInServer: no info_player_start on level");
  488.     
  489.     return spot;
  490. };
  491.  
  492. /*
  493. ===========
  494. PutClientInServer
  495.  
  496. called each time a player is spawned
  497. ============
  498. */
  499. void() DecodeLevelParms;
  500. void() PlayerDie;
  501.  
  502. // ### chase cam mod ###
  503. void() Chase_cam_level_start;
  504.  
  505.  
  506. void() PutClientInServer =
  507. {
  508.     local    entity spot;
  509.  
  510.     spot = SelectSpawnPoint ();
  511.  
  512.     self.classname = "player";
  513.     self.health = 100;
  514.     self.takedamage = DAMAGE_AIM;
  515.     self.solid = SOLID_SLIDEBOX;
  516.     self.movetype = MOVETYPE_WALK;
  517.     self.show_hostile = 0;
  518.     self.max_health = 100;
  519.     self.flags = FL_CLIENT;
  520.     self.air_finished = time + 12;
  521.     self.dmg = 2;           // initial water damage
  522.     self.super_damage_finished = 0;
  523.     self.radsuit_finished = 0;
  524.     self.invisible_finished = 0;
  525.     self.invincible_finished = 0;
  526.     self.effects = 0;
  527.     self.invincible_time = 0;
  528.  
  529.     DecodeLevelParms ();
  530.     
  531.     W_SetCurrentAmmo ();
  532.  
  533.     self.attack_finished = time;
  534.     self.th_pain = player_pain;
  535.     self.th_die = PlayerDie;
  536.     
  537.     self.deadflag = DEAD_NO;
  538. // paustime is set by teleporters to keep the player from moving a while
  539.     self.pausetime = 0;
  540.     
  541. //    spot = SelectSpawnPoint ();
  542.  
  543.     self.origin = spot.origin + '0 0 1';
  544.     self.angles = spot.angles;
  545.     self.fixangle = TRUE;        // turn this way immediately
  546.  
  547. // oh, this is a hack!
  548.     setmodel (self, "progs/eyes.mdl");
  549.     modelindex_eyes = self.modelindex;
  550.  
  551.     setmodel (self, "progs/player.mdl");
  552.     modelindex_player = self.modelindex;
  553.  
  554.     setsize (self, VEC_HULL_MIN, VEC_HULL_MAX);
  555.     
  556.     self.view_ofs = '0 0 22';
  557.  
  558.     player_stand1 ();
  559.     
  560.     if (deathmatch || coop)
  561.     {
  562.         makevectors(self.angles);
  563.         spawn_tfog (self.origin + v_forward*20);
  564.     }
  565.  
  566.     spawn_tdeath (self.origin, self);
  567.  
  568.    // ### chase cam mod ###
  569.    // reset view and targeter according to what was set in parm16
  570.    if( ! deathmatch && ! coop )
  571.       Chase_cam_level_start();
  572.  
  573. // *************************************************************************
  574. // **                                          **
  575. // ** M U L T I S K I N  1.1  (start)                                     **
  576. // **                                      **
  577. // *************************************************************************
  578.  
  579.     if (self.skin == 0) centerprint(self, "Mr. Quake himself!"); else
  580.     if (self.skin == 1) centerprint(self, "No time to play with yourself here!"); else
  581.     if (self.skin == 2) centerprint(self, "You're one pretty toad!"); else
  582.     if (self.skin == 3) centerprint(self, "Wow Stormtrooper, you're though!"); else
  583.     if (self.skin == 4) centerprint(self, "Hi Max, looking yellow/blue today!"); else
  584.     if (self.skin == 5) centerprint(self, "You are back!"); else
  585.     if (self.skin == 6) centerprint(self, "Judge Dredd! Let's restore some order!"); else
  586.     if (self.skin == 7) centerprint(self, "Camo! Can't see you, where are you!"); else
  587.     if (self.skin == 8) centerprint(self, "Okay Captain Picard, make it so!"); else
  588.     if (self.skin == 9) centerprint(self, "Whizz whizz.. Wizzard!"); else
  589.     if (self.skin == 10) centerprint(self,"I'm the Predator, you're the prey!"); else
  590.     if (self.skin == 11) centerprint(self,"Welcome Skeleton, looking good!"); else
  591.     if (self.skin == 12) centerprint(self,"Wan-Fu, whoever you are :)"); else
  592.     if (self.skin == 13) centerprint(self,"Oh no, it's Henry Rollins!"); else
  593.     if (self.skin == 14) centerprint(self,"Ooh no, it's She.. eh.. He-Man"); else
  594.     if (self.skin == 15) centerprint(self,"If it isn't Boba, go get Han Solo!"); else
  595.     if (self.skin == 16) centerprint(self,"It's SUPERMAN!"); else
  596.     if (self.skin == 17) centerprint(self,"Protect the innocent, uphold your law"); else
  597.     if (self.skin == 18) centerprint(self,"Why is that symbol on your suit?");
  598.  
  599. // *************************************************************************
  600. // **                                          **
  601. // ** M U L T I S K I N  1.1  (end)                                       **
  602. // **                                      **
  603. // *************************************************************************
  604.  
  605.  
  606. };
  607.  
  608.  
  609. /*
  610. =============================================================================
  611.  
  612.                 QUAKED FUNCTIONS
  613.  
  614. =============================================================================
  615. */
  616.  
  617.  
  618. /*QUAKED info_player_start (1 0 0) (-16 -16 -24) (16 16 24)
  619. The normal starting point for a level.
  620. */
  621. void() info_player_start =
  622. {
  623. };
  624.  
  625.  
  626. /*QUAKED info_player_start2 (1 0 0) (-16 -16 -24) (16 16 24)
  627. Only used on start map for the return point from an episode.
  628. */
  629. void() info_player_start2 =
  630. {
  631. };
  632.  
  633.  
  634. /*
  635. saved out by quaked in region mode
  636. */
  637. void() testplayerstart =
  638. {
  639. };
  640.  
  641. /*QUAKED info_player_deathmatch (1 0 1) (-16 -16 -24) (16 16 24)
  642. potential spawning position for deathmatch games
  643. */
  644. void() info_player_deathmatch =
  645. {
  646. };
  647.  
  648. /*QUAKED info_player_coop (1 0 1) (-16 -16 -24) (16 16 24)
  649. potential spawning position for coop games
  650. */
  651. void() info_player_coop =
  652. {
  653. };
  654.  
  655. /*
  656. ===============================================================================
  657.  
  658. RULES
  659.  
  660. ===============================================================================
  661. */
  662.  
  663. /*
  664. go to the next level for deathmatch
  665. only called if a time or frag limit has expired
  666. */
  667. void() NextLevel =
  668. {
  669.     local entity o;
  670.  
  671.     if (mapname == "start")
  672.     {
  673.         if (!cvar("registered"))
  674.         {
  675.             mapname = "e1m1";
  676.         }
  677.         else if (!(serverflags & 1))
  678.         {
  679.             mapname = "e1m1";
  680.             serverflags = serverflags | 1;
  681.         }
  682.         else if (!(serverflags & 2))
  683.         {
  684.             mapname = "e2m1";
  685.             serverflags = serverflags | 2;
  686.         }
  687.         else if (!(serverflags & 4))
  688.         {
  689.             mapname = "e3m1";
  690.             serverflags = serverflags | 4;
  691.         }
  692.         else if (!(serverflags & 8))
  693.         {
  694.             mapname = "e4m1";
  695.             serverflags = serverflags - 7;
  696.         }
  697.  
  698.         o = spawn();
  699.         o.map = mapname;
  700.     }
  701.     else
  702.     {
  703.         // find a trigger changelevel
  704.         o = find(world, classname, "trigger_changelevel");
  705.  
  706.         // go back to start if no trigger_changelevel
  707.         if (!o)
  708.         {
  709.             mapname = "start";
  710.             o = spawn();
  711.             o.map = mapname;
  712.         }
  713.     }
  714.  
  715.     nextmap = o.map;
  716.     gameover = TRUE;
  717.     
  718.     if (o.nextthink < time)
  719.     {
  720.         o.think = execute_changelevel;
  721.         o.nextthink = time + 0.1;
  722.     }
  723. };
  724.  
  725. /*
  726. ============
  727. CheckRules
  728.  
  729. Exit deathmatch games upon conditions
  730. ============
  731. */
  732. void() CheckRules =
  733. {
  734.     local    float        timelimit;
  735.     local    float        fraglimit;
  736.     
  737.     if (gameover)    // someone else quit the game already
  738.         return;
  739.         
  740.     timelimit = cvar("timelimit") * 60;
  741.     fraglimit = cvar("fraglimit");
  742.     
  743.     if (timelimit && time >= timelimit)
  744.     {
  745.         NextLevel ();
  746.         return;
  747.     }
  748.     
  749.     if (fraglimit && self.frags >= fraglimit)
  750.     {
  751.         NextLevel ();
  752.         return;
  753.     }    
  754. };
  755.  
  756. //============================================================================
  757.  
  758. void() PlayerDeathThink =
  759. {
  760.     local entity    old_self;
  761.     local float        forward;
  762.  
  763.     if ((self.flags & FL_ONGROUND))
  764.     {
  765.         forward = vlen (self.velocity);
  766.         forward = forward - 20;
  767.         if (forward <= 0)
  768.             self.velocity = '0 0 0';
  769.         else    
  770.             self.velocity = forward * normalize(self.velocity);
  771.     }
  772.  
  773. // wait for all buttons released
  774.     if (self.deadflag == DEAD_DEAD)
  775.     {
  776.         if (self.button2 || self.button1 || self.button0)
  777.             return;
  778.         self.deadflag = DEAD_RESPAWNABLE;
  779.         return;
  780.     }
  781.  
  782. // wait for any button down
  783.     if (!self.button2 && !self.button1 && !self.button0)
  784.         return;
  785.  
  786.     self.button0 = 0;
  787.     self.button1 = 0;
  788.     self.button2 = 0;
  789.     respawn();
  790. };
  791.  
  792.  
  793. void() PlayerJump =
  794. {
  795.     local vector start, end;
  796.     
  797.     if (self.flags & FL_WATERJUMP)
  798.         return;
  799.     
  800.     if (self.waterlevel >= 2)
  801.     {
  802.         if (self.watertype == CONTENT_WATER)
  803.             self.velocity_z = 100;
  804.         else if (self.watertype == CONTENT_SLIME)
  805.             self.velocity_z = 80;
  806.         else
  807.             self.velocity_z = 50;
  808.  
  809. // play swiming sound
  810.         if (self.swim_flag < time)
  811.         {
  812.             self.swim_flag = time + 1;
  813.             if (random() < 0.5)
  814.                 sound (self, CHAN_BODY, "misc/water1.wav", 1, ATTN_NORM);
  815.             else
  816.                 sound (self, CHAN_BODY, "misc/water2.wav", 1, ATTN_NORM);
  817.         }
  818.  
  819.         return;
  820.     }
  821.  
  822.     if (!(self.flags & FL_ONGROUND))
  823.         return;
  824.  
  825.     if ( !(self.flags & FL_JUMPRELEASED) )
  826.         return;        // don't pogo stick
  827.  
  828.     self.flags = self.flags - (self.flags & FL_JUMPRELEASED);
  829.  
  830.     self.flags = self.flags - FL_ONGROUND;    // don't stairwalk
  831.     
  832.     self.button2 = 0;
  833. // player jumping sound
  834.     sound (self, CHAN_BODY, "player/plyrjmp8.wav", 1, ATTN_NORM);
  835.     self.velocity_z = self.velocity_z + 270;
  836. };
  837.  
  838.  
  839. /*
  840. ===========
  841. WaterMove
  842.  
  843. ============
  844. */
  845. .float    dmgtime;
  846.  
  847. void() WaterMove =
  848. {
  849. //dprint (ftos(self.waterlevel));
  850.     if (self.movetype == MOVETYPE_NOCLIP)
  851.         return;
  852.     if (self.health < 0)
  853.         return;
  854.  
  855.     if (self.waterlevel != 3)
  856.     {
  857.         if (self.air_finished < time)
  858.             sound (self, CHAN_VOICE, "player/gasp2.wav", 1, ATTN_NORM);
  859.         else if (self.air_finished < time + 9)
  860.             sound (self, CHAN_VOICE, "player/gasp1.wav", 1, ATTN_NORM);
  861.         self.air_finished = time + 12;
  862.         self.dmg = 2;
  863.     }
  864.     else if (self.air_finished < time)
  865.     {    // drown!
  866.         if (self.pain_finished < time)
  867.         {
  868.             self.dmg = self.dmg + 2;
  869.             if (self.dmg > 15)
  870.                 self.dmg = 10;
  871.             T_Damage (self, world, world, self.dmg);
  872.             self.pain_finished = time + 1;
  873.         }
  874.     }
  875.     
  876.     if (!self.waterlevel)
  877.     {
  878.         if (self.flags & FL_INWATER)
  879.         {    
  880.             // play leave water sound
  881.             sound (self, CHAN_BODY, "misc/outwater.wav", 1, ATTN_NORM);
  882.             self.flags = self.flags - FL_INWATER;
  883.         }
  884.         return;
  885.     }
  886.  
  887.     if (self.watertype == CONTENT_LAVA)
  888.     {    // do damage
  889.         if (self.dmgtime < time)
  890.         {
  891.             if (self.radsuit_finished > time)
  892.                 self.dmgtime = time + 1;
  893.             else
  894.                 self.dmgtime = time + 0.2;
  895.  
  896.             T_Damage (self, world, world, 10*self.waterlevel);
  897.         }
  898.     }
  899.     else if (self.watertype == CONTENT_SLIME)
  900.     {    // do damage
  901.         if (self.dmgtime < time && self.radsuit_finished < time)
  902.         {
  903.             self.dmgtime = time + 1;
  904.             T_Damage (self, world, world, 4*self.waterlevel);
  905.         }
  906.     }
  907.     
  908.     if ( !(self.flags & FL_INWATER) )
  909.     {    
  910.  
  911. // player enter water sound
  912.  
  913.         if (self.watertype == CONTENT_LAVA)
  914.             sound (self, CHAN_BODY, "player/inlava.wav", 1, ATTN_NORM);
  915.         if (self.watertype == CONTENT_WATER)
  916.             sound (self, CHAN_BODY, "player/inh2o.wav", 1, ATTN_NORM);
  917.         if (self.watertype == CONTENT_SLIME)
  918.             sound (self, CHAN_BODY, "player/slimbrn2.wav", 1, ATTN_NORM);
  919.  
  920.         self.flags = self.flags + FL_INWATER;
  921.         self.dmgtime = 0;
  922.     }
  923.     
  924.     if (! (self.flags & FL_WATERJUMP) )
  925.         self.velocity = self.velocity - 0.8*self.waterlevel*frametime*self.velocity;
  926. };
  927.  
  928. void() CheckWaterJump =
  929. {
  930.     local vector start, end;
  931.  
  932. // check for a jump-out-of-water
  933.     makevectors (self.angles);
  934.     start = self.origin;
  935.     start_z = start_z + 8; 
  936.     v_forward_z = 0;
  937.     normalize(v_forward);
  938.     end = start + v_forward*24;
  939.     traceline (start, end, TRUE, self);
  940.     if (trace_fraction < 1)
  941.     {    // solid at waist
  942.         start_z = start_z + self.maxs_z - 8;
  943.         end = start + v_forward*24;
  944.         self.movedir = trace_plane_normal * -50;
  945.         traceline (start, end, TRUE, self);
  946.         if (trace_fraction == 1)
  947.         {    // open at eye level
  948.             self.flags = self.flags | FL_WATERJUMP;
  949.             self.velocity_z = 225;
  950.             self.flags = self.flags - (self.flags & FL_JUMPRELEASED);
  951.             self.teleport_time = time + 2;    // safety net
  952.             return;
  953.         }
  954.     }
  955. };
  956.  
  957.  
  958. /*
  959. ================
  960. PlayerPreThink
  961.  
  962. Called every frame before physics are run
  963. ================
  964. */
  965. void() PlayerPreThink =
  966. {
  967.     local    float    mspeed, aspeed;
  968.     local    float    r;
  969.  
  970.     if (intermission_running)
  971.     {
  972.         IntermissionThink ();    // otherwise a button could be missed between
  973.         return;                    // the think tics
  974.     }
  975.  
  976.     if (self.view_ofs == '0 0 0')
  977.         return;        // intermission or finale
  978.  
  979.     makevectors (self.v_angle);        // is this still used
  980.  
  981.     CheckRules ();
  982.     WaterMove ();
  983.  
  984.     if (self.waterlevel == 2)
  985.         CheckWaterJump ();
  986.  
  987.     if (self.deadflag >= DEAD_DEAD)
  988.     {
  989.         PlayerDeathThink ();
  990.         return;
  991.     }
  992.     
  993.     if (self.deadflag == DEAD_DYING)
  994.         return;    // dying, so do nothing
  995.  
  996.     if (self.button2)
  997.     {
  998.         PlayerJump ();
  999.     }
  1000.     else
  1001.         self.flags = self.flags | FL_JUMPRELEASED;
  1002.  
  1003. // teleporters can force a non-moving pause time    
  1004.     if (time < self.pausetime)
  1005.         self.velocity = '0 0 0';
  1006.  
  1007.     if(time > self.attack_finished && self.currentammo == 0 && self.weapon != IT_AXE)
  1008.     {
  1009.         self.weapon = W_BestWeapon ();
  1010.         W_SetCurrentAmmo ();
  1011.     }
  1012. };
  1013.     
  1014. /*
  1015. ================
  1016. CheckPowerups
  1017.  
  1018. Check for turning off powerups
  1019. ================
  1020. */
  1021. void() CheckPowerups =
  1022. {
  1023.     if (self.health <= 0)
  1024.         return;
  1025.  
  1026. // invisibility
  1027.     if (self.invisible_finished)
  1028.     {
  1029. // sound and screen flash when items starts to run out
  1030.         if (self.invisible_sound < time)
  1031.         {
  1032.             sound (self, CHAN_AUTO, "items/inv3.wav", 0.5, ATTN_IDLE);
  1033.             self.invisible_sound = time + ((random() * 3) + 1);
  1034.         }
  1035.  
  1036.  
  1037.         if (self.invisible_finished < time + 3)
  1038.         {
  1039.             if (self.invisible_time == 1)
  1040.             {
  1041.                 sprint (self, "Ring of Shadows magic is fading\n");
  1042.                 stuffcmd (self, "bf\n");
  1043.                 sound (self, CHAN_AUTO, "items/inv2.wav", 1, ATTN_NORM);
  1044.                 self.invisible_time = time + 1;
  1045.             }
  1046.             
  1047.             if (self.invisible_time < time)
  1048.             {
  1049.                 self.invisible_time = time + 1;
  1050.                 stuffcmd (self, "bf\n");
  1051.             }
  1052.         }
  1053.  
  1054.         if (self.invisible_finished < time)
  1055.         {    // just stopped
  1056.             self.items = self.items - IT_INVISIBILITY;
  1057.             self.invisible_finished = 0;
  1058.             self.invisible_time = 0;
  1059.         }
  1060.         
  1061.     // use the eyes
  1062.         self.frame = 0;
  1063.         self.modelindex = modelindex_eyes;
  1064.     }
  1065.     else
  1066.         self.modelindex = modelindex_player;    // don't use eyes
  1067.  
  1068. // invincibility
  1069.     if (self.invincible_finished)
  1070.     {
  1071. // sound and screen flash when items starts to run out
  1072.         if (self.invincible_finished < time + 3)
  1073.         {
  1074.             if (self.invincible_time == 1)
  1075.             {
  1076.                 sprint (self, "Protection is almost burned out\n");
  1077.                 stuffcmd (self, "bf\n");
  1078.                 sound (self, CHAN_AUTO, "items/protect2.wav", 1, ATTN_NORM);
  1079.                 self.invincible_time = time + 1;
  1080.             }
  1081.             
  1082.             if (self.invincible_time < time)
  1083.             {
  1084.                 self.invincible_time = time + 1;
  1085.                 stuffcmd (self, "bf\n");
  1086.             }
  1087.         }
  1088.         
  1089.         if (self.invincible_finished < time)
  1090.         {    // just stopped
  1091.             self.items = self.items - IT_INVULNERABILITY;
  1092.             self.invincible_time = 0;
  1093.             self.invincible_finished = 0;
  1094.         }
  1095.         if (self.invincible_finished > time)
  1096.             self.effects = self.effects | EF_DIMLIGHT;
  1097.         else
  1098.             self.effects = self.effects - (self.effects & EF_DIMLIGHT);
  1099.     }
  1100.  
  1101. // super damage
  1102.     if (self.super_damage_finished)
  1103.     {
  1104.  
  1105. // sound and screen flash when items starts to run out
  1106.  
  1107.         if (self.super_damage_finished < time + 3)
  1108.         {
  1109.             if (self.super_time == 1)
  1110.             {
  1111.                 sprint (self, "Quad Damage is wearing off\n");
  1112.                 stuffcmd (self, "bf\n");
  1113.                 sound (self, CHAN_AUTO, "items/damage2.wav", 1, ATTN_NORM);
  1114.                 self.super_time = time + 1;
  1115.             }      
  1116.             
  1117.             if (self.super_time < time)
  1118.             {
  1119.                 self.super_time = time + 1;
  1120.                 stuffcmd (self, "bf\n");
  1121.             }
  1122.         }
  1123.  
  1124.         if (self.super_damage_finished < time)
  1125.         {    // just stopped
  1126.             self.items = self.items - IT_QUAD;
  1127.             self.super_damage_finished = 0;
  1128.             self.super_time = 0;
  1129.         }
  1130.         if (self.super_damage_finished > time)
  1131.             self.effects = self.effects | EF_DIMLIGHT;
  1132.         else
  1133.             self.effects = self.effects - (self.effects & EF_DIMLIGHT);
  1134.     }    
  1135.  
  1136. // suit    
  1137.     if (self.radsuit_finished)
  1138.     {
  1139.         self.air_finished = time + 12;        // don't drown
  1140.  
  1141. // sound and screen flash when items starts to run out
  1142.         if (self.radsuit_finished < time + 3)
  1143.         {
  1144.             if (self.rad_time == 1)
  1145.             {
  1146.                 sprint (self, "Air supply in Biosuit expiring\n");
  1147.                 stuffcmd (self, "bf\n");
  1148.                 sound (self, CHAN_AUTO, "items/suit2.wav", 1, ATTN_NORM);
  1149.                 self.rad_time = time + 1;
  1150.             }
  1151.             
  1152.             if (self.rad_time < time)
  1153.             {
  1154.                 self.rad_time = time + 1;
  1155.                 stuffcmd (self, "bf\n");
  1156.             }
  1157.         }
  1158.  
  1159.         if (self.radsuit_finished < time)
  1160.         {    // just stopped
  1161.             self.items = self.items - IT_SUIT;
  1162.             self.rad_time = 0;
  1163.             self.radsuit_finished = 0;
  1164.         }
  1165.     }    
  1166.  
  1167. };
  1168.  
  1169.  
  1170. /*
  1171. ================
  1172. PlayerPostThink
  1173.  
  1174. Called every frame after physics are run
  1175. ================
  1176. */
  1177. void() PlayerPostThink =
  1178. {
  1179.     local    float    mspeed, aspeed;
  1180.     local    float    r;
  1181.  
  1182.     if (self.view_ofs == '0 0 0')
  1183.         return;        // intermission or finale
  1184.     if (self.deadflag)
  1185.         return;
  1186.         
  1187. // do weapon stuff
  1188.  
  1189.     W_WeaponFrame ();
  1190.  
  1191. // check to see if player landed and play landing sound    
  1192.     if ((self.jump_flag < -300) && (self.flags & FL_ONGROUND) && (self.health > 0))
  1193.     {
  1194.         if (self.watertype == CONTENT_WATER)
  1195.             sound (self, CHAN_BODY, "player/h2ojump.wav", 1, ATTN_NORM);
  1196.         else if (self.jump_flag < -650)
  1197.         {
  1198.             T_Damage (self, world, world, 5); 
  1199.             sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  1200.             self.deathtype = "falling";
  1201.         }
  1202.         else
  1203.             sound (self, CHAN_VOICE, "player/land.wav", 1, ATTN_NORM);
  1204.  
  1205.         self.jump_flag = 0;
  1206.     }
  1207.  
  1208.     if (!(self.flags & FL_ONGROUND))
  1209.         self.jump_flag = self.velocity_z;
  1210.  
  1211.     CheckPowerups ();
  1212. };
  1213.  
  1214.  
  1215. /*
  1216. ===========
  1217. ClientConnect
  1218.  
  1219. called when a player connects to a server
  1220. ============
  1221. */
  1222. void() ClientConnect =
  1223. {
  1224.     bprint (self.netname);
  1225.     bprint (" entered the game\n");
  1226.     
  1227. // a client connecting during an intermission can cause problems
  1228.     if (intermission_running)
  1229.         ExitIntermission ();
  1230. };
  1231.  
  1232.  
  1233. /*
  1234. ===========
  1235. ClientDisconnect
  1236.  
  1237. called when a player disconnects from a server
  1238. ============
  1239. */
  1240. void() ClientDisconnect =
  1241. {
  1242.     if (gameover)
  1243.         return;
  1244.     // if the level end trigger has been activated, just return
  1245.     // since they aren't *really* leaving
  1246.  
  1247.     // let everyone else know
  1248.     bprint (self.netname);
  1249.     bprint (" left the game with ");
  1250.     bprint (ftos(self.frags));
  1251.     bprint (" frags\n");
  1252.     sound (self, CHAN_BODY, "player/tornoff2.wav", 1, ATTN_NONE);
  1253.     set_suicide_frame ();
  1254. };
  1255.  
  1256. /*
  1257. ===========
  1258. ClientObituary
  1259.  
  1260. called when a player dies
  1261. ============
  1262. */
  1263. void(entity targ, entity attacker) ClientObituary =
  1264. {
  1265.     local    float rnum;
  1266.     local    string deathstring, deathstring2;
  1267.     rnum = random();
  1268.  
  1269.     if (targ.classname == "player")
  1270.     {
  1271.         if (attacker.classname == "teledeath")
  1272.         {
  1273.             bprint (targ.netname);
  1274.             bprint (" was telefragged by ");
  1275.             bprint (attacker.owner.netname);
  1276.             bprint ("\n");
  1277.  
  1278.             attacker.owner.frags = attacker.owner.frags + 1;
  1279.             return;
  1280.         }
  1281.  
  1282.         if (attacker.classname == "teledeath2")
  1283.         {
  1284.             bprint ("Satan's power deflects ");
  1285.             bprint (targ.netname);
  1286.             bprint ("'s telefrag\n");
  1287.  
  1288.             targ.frags = targ.frags - 1;
  1289.             return;
  1290.         }
  1291.  
  1292.         if (attacker.classname == "player")
  1293.         {
  1294.             if (targ == attacker)
  1295.             {
  1296.                 // killed self
  1297.                 attacker.frags = attacker.frags - 1;
  1298.                 bprint (targ.netname);
  1299.                 
  1300.                 if (targ.weapon == 64 && targ.waterlevel > 1)
  1301.                 {
  1302.                     bprint (" discharges into the water.\n");
  1303.                     return;
  1304.                 }
  1305.                 if (targ.weapon == IT_GRENADE_LAUNCHER)
  1306.                     bprint (" tries to put the pin back in\n");
  1307.                 else
  1308.                     bprint (" becomes bored with life\n");
  1309.                 return;
  1310.             }
  1311.             else if ( (teamplay == 2) && (targ.team > 0)&&(targ.team == attacker.team) )
  1312.             {
  1313.                 if (rnum < 0.25)
  1314.                     deathstring = " mows down a teammate\n";
  1315.                 else if (rnum < 0.50)
  1316.                     deathstring = " checks his glasses\n";
  1317.                 else if (rnum < 0.75)
  1318.                     deathstring = " gets a frag for the other team\n";
  1319.                 else
  1320.                     deathstring = " loses another friend\n";
  1321.                 bprint (attacker.netname);
  1322.                 bprint (deathstring);
  1323.                 attacker.frags = attacker.frags - 1;
  1324.                 return;
  1325.             }
  1326.             else
  1327.             {
  1328.                 attacker.frags = attacker.frags + 1;
  1329.  
  1330.                 rnum = attacker.weapon;
  1331.                 if (rnum == IT_AXE)
  1332.                 {
  1333.                     deathstring = " was ax-murdered by ";
  1334.                     deathstring2 = "\n";
  1335.                 }
  1336.                 if (rnum == IT_SHOTGUN)
  1337.                 {
  1338.                     deathstring = " chewed on ";
  1339.                     deathstring2 = "'s boomstick\n";
  1340.                 }
  1341.                 if (rnum == IT_SUPER_SHOTGUN)
  1342.                 {
  1343.                     deathstring = " ate 2 loads of ";
  1344.                     deathstring2 = "'s buckshot\n";
  1345.                 }
  1346.                 if (rnum == IT_NAILGUN)
  1347.                 {
  1348.                     deathstring = " was nailed by ";
  1349.                     deathstring2 = "\n";
  1350.                 }
  1351.                 if (rnum == IT_SUPER_NAILGUN)
  1352.                 {
  1353.                     deathstring = " was punctured by ";
  1354.                     deathstring2 = "\n";
  1355.                 }
  1356.                 if (rnum == IT_GRENADE_LAUNCHER)
  1357.                 {
  1358.                     deathstring = " eats ";
  1359.                     deathstring2 = "'s pineapple\n";
  1360.                     if (targ.health < -40)
  1361.                     {
  1362.                         deathstring = " was gibbed by ";
  1363.                         deathstring2 = "'s grenade\n";
  1364.                     }
  1365.                 }
  1366.                 if (rnum == IT_ROCKET_LAUNCHER)
  1367.                 {
  1368.                     deathstring = " rides ";
  1369.                     deathstring2 = "'s rocket\n";
  1370.                     if (targ.health < -40)
  1371.                     {
  1372.                         deathstring = " was gibbed by ";
  1373.                         deathstring2 = "'s rocket\n" ;
  1374.                     }
  1375.                 }
  1376.                 if (rnum == IT_LIGHTNING)
  1377.                 {
  1378.                     deathstring = " accepts ";
  1379.                     if (attacker.waterlevel > 1)
  1380.                         deathstring2 = "'s discharge\n";
  1381.                     else
  1382.                         deathstring2 = "'s shaft\n";
  1383.                 }
  1384.                 bprint (targ.netname);
  1385.                 bprint (deathstring);
  1386.                 bprint (attacker.netname);
  1387.                 bprint (deathstring2);
  1388.             }
  1389.             return;
  1390.         }
  1391.         else
  1392.         {
  1393.             targ.frags = targ.frags - 1;
  1394.             bprint (targ.netname);
  1395.  
  1396.             // killed by a montser?
  1397.             if (attacker.flags & FL_MONSTER)
  1398.             {
  1399.                 if (attacker.classname == "monster_army")
  1400.                     bprint (" was shot by a Grunt\n");
  1401.                 if (attacker.classname == "monster_demon1")
  1402.                     bprint (" was eviscerated by a Fiend\n");
  1403.                 if (attacker.classname == "monster_dog")
  1404.                     bprint (" was mauled by a Rottweiler\n");
  1405.                 if (attacker.classname == "monster_dragon")
  1406.                     bprint (" was fried by a Dragon\n");
  1407.                 if (attacker.classname == "monster_enforcer")
  1408.                     bprint (" was blasted by an Enforcer\n");
  1409.                 if (attacker.classname == "monster_fish")
  1410.                     bprint (" was fed to the Rotfish\n");
  1411.                 if (attacker.classname == "monster_hell_knight")
  1412.                     bprint (" was slain by a Death Knight\n");
  1413.                 if (attacker.classname == "monster_knight")
  1414.                     bprint (" was slashed by a Knight\n");
  1415.                 if (attacker.classname == "monster_ogre")
  1416.                     bprint (" was destroyed by an Ogre\n");
  1417.                 if (attacker.classname == "monster_oldone")
  1418.                     bprint (" became one with Shub-Niggurath\n");
  1419.                 if (attacker.classname == "monster_shalrath")
  1420.                     bprint (" was exploded by a Vore\n");
  1421.                 if (attacker.classname == "monster_shambler")
  1422.                     bprint (" was smashed by a Shambler\n");
  1423.                 if (attacker.classname == "monster_tarbaby")
  1424.                     bprint (" was slimed by a Spawn\n");
  1425.                 if (attacker.classname == "monster_vomit")
  1426.                     bprint (" was vomited on by a Vomitus\n");
  1427.                 if (attacker.classname == "monster_wizard")
  1428.                     bprint (" was scragged by a Scrag\n");
  1429.                 if (attacker.classname == "monster_zombie")
  1430.                     bprint (" joins the Zombies\n");
  1431.  
  1432.                 return;
  1433.             }
  1434.  
  1435.             // tricks and traps
  1436.             if (attacker.classname == "explo_box")
  1437.             {
  1438.                 bprint (" blew up\n");
  1439.                 return;
  1440.             }
  1441.             if (attacker.solid == SOLID_BSP && attacker != world)
  1442.             {    
  1443.                 bprint (" was squished\n");
  1444.                 return;
  1445.             }
  1446.             if (attacker.classname == "trap_shooter" || attacker.classname == "trap_spikeshooter")
  1447.             {
  1448.                 bprint (" was spiked\n");
  1449.                 return;
  1450.             }
  1451.             if (attacker.classname == "fireball")
  1452.             {
  1453.                 bprint (" ate a lavaball\n");
  1454.                 return;
  1455.             }
  1456.             if (attacker.classname == "trigger_changelevel")
  1457.             {
  1458.                 bprint (" tried to leave\n");
  1459.                 return;
  1460.             }
  1461.  
  1462.             // in-water deaths
  1463.             rnum = targ.watertype;
  1464.             if (rnum == -3)
  1465.             {
  1466.                 if (random() < 0.5)
  1467.                     bprint (" sleeps with the fishes\n");
  1468.                 else
  1469.                     bprint (" sucks it down\n");
  1470.                 return;
  1471.             }
  1472.             else if (rnum == -4)
  1473.             {
  1474.                 if (random() < 0.5)
  1475.                     bprint (" gulped a load of slime\n");
  1476.                 else
  1477.                     bprint (" can't exist on slime alone\n");
  1478.                 return;
  1479.             }
  1480.             else if (rnum == -5)
  1481.             {
  1482.                 if (targ.health < -15)
  1483.                 {
  1484.                     bprint (" burst into flames\n");
  1485.                     return;
  1486.                 }
  1487.                 if (random() < 0.5)
  1488.                     bprint (" turned into hot slag\n");
  1489.                 else
  1490.                     bprint (" visits the Volcano God\n");
  1491.                 return;
  1492.             }
  1493.  
  1494.             // fell to their death?
  1495.             if (targ.deathtype == "falling")
  1496.             {
  1497.                 targ.deathtype = "";
  1498.                 bprint (" fell to his death\n");
  1499.                 return;
  1500.             }
  1501.  
  1502.             // hell if I know; he's just dead!!!
  1503.             bprint (" died\n");
  1504.         }
  1505.     }
  1506. };
  1507.