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