home *** CD-ROM | disk | FTP | other *** search
/ CD Shareware Magazine 1997 January / CD_shareware_1-97.iso / DOS / JUEGOS / DM_STATS.ZIP / SOURCE / CLIENT.QC next >
Encoding:
Text File  |  1996-09-09  |  39.3 KB  |  1,698 lines

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