home *** CD-ROM | disk | FTP | other *** search
/ Superpower (Alt) / SUPERPOWER.iso / q / patch / mbq091 / client.qc < prev    next >
Encoding:
Text File  |  1996-09-04  |  41.1 KB  |  1,626 lines

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