home *** CD-ROM | disk | FTP | other *** search
/ Quake 'em / QUAKEEM.BIN / quake / programs / das_dm10 / client.qc next >
Encoding:
Text File  |  1996-08-13  |  38.2 KB  |  1,621 lines

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