home *** CD-ROM | disk | FTP | other *** search
/ Quake 'em / QUAKEEM.BIN / quake / programs / multiqc / client.qc < prev    next >
Encoding:
Text File  |  1996-08-02  |  37.6 KB  |  1,539 lines

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