home *** CD-ROM | disk | FTP | other *** search
/ Quake 'em / QUAKEEM.BIN / quake / programs / skarmod3 / client.qc < prev    next >
Encoding:
Text File  |  1996-08-16  |  41.7 KB  |  1,619 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, looking good!"); 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,"It's SUPERMAN!"); else
  555.     if (self.skin == 17) centerprint(self,"Protect the innocent, uphold your law"); else
  556.     if (self.skin == 18) centerprint(self,"Let's go crack some head."); else
  557.     if (self.skin == 19) centerprint(self,"Ah.. the smell of rotten flesh.."); else
  558.     if (self.skin == 20) centerprint(self,"Doh! .. I mean DOOH!"); else
  559.     if (self.skin == 21) centerprint(self,"Do the Mario!"); else
  560.     if (self.skin == 22) centerprint(self,"uhm.. 311 is my number."); else
  561.     if (self.skin == 23) centerprint(self,"Where did I stick that ninja star.."); else
  562.     if (self.skin == 24) centerprint(self,"Deadpool!"); else
  563.     if (self.skin == 25) centerprint(self,"My head feels empty.."); else
  564.     if (self.skin == 26) centerprint(self,"Its.. Spidermn.. uhm.. wtf!"); else
  565.     if (self.skin == 27) centerprint(self,"Ah.. Im getting tired of this.."); else
  566.     if (self.skin == 28) centerprint(self,"They WILL pay!"); else
  567.     if (self.skin == 29) centerprint(self,"Yes master.."); else
  568.     if (self.skin == 30) centerprint(self,"Grr.. NOW IM MAD!!"); else
  569.     if (self.skin == 31) centerprint(self,"Here goes nothing.."); else
  570.     if (self.skin == 32) centerprint(self,"Holy jumpin' jeepers batman!"); else
  571.     if (self.skin == 33) centerprint(self,"(deep breathing sound)"); else
  572.     if (self.skin == 34) centerprint(self,"ogg.. grrrr...rrr.."); else
  573.     if (self.skin == 35) centerprint(self,"Its Flash.. darkflash!"); else
  574.     if (self.skin == 36) centerprint(self,"Now its MY turn to shot that bastard player!"); else
  575.     if (self.skin == 37) centerprint(self,"bzz bzz.. halt!"); else
  576.     if (self.skin == 38) centerprint(self,"Now.. Lets SEE.."); else
  577.     if (self.skin == 39) centerprint(self,"Flash!! AAhhaaaa! .. Flash!"); else
  578.     if (self.skin == 40) centerprint(self,"grumble.. Im getting rusty."); else
  579.     if (self.skin == 41) centerprint(self,"Hehe.. lets chop someone up!"); else
  580.     if (self.skin == 42) centerprint(self,"Grunt.. this sword was getting kinda heavy.."); else
  581.     if (self.skin == 43) centerprint(self,"Im the incredible MoleMan (TM)! You DIG me?"); else
  582.     if (self.skin == 44) centerprint(self,"Ggrr.. where is my chainsaw?"); else
  583.     if (self.skin == 45) centerprint(self,"Hoii!.. swoosh! poof!"); else
  584.     if (self.skin == 46) centerprint(self,"Far out man.. rock the world!"); else
  585.     if (self.skin == 47) centerprint(self,"Quake Spawn!");
  586.  
  587. // *************************************************************************
  588. // **                                          **
  589. // ** M U L T I S K I N  1.1  (end)                                       **
  590. // **                                      **
  591. // *************************************************************************
  592.  
  593.  
  594. };
  595.  
  596.  
  597.  
  598.  
  599. /*
  600. =============================================================================
  601.  
  602.                 QUAKED FUNCTIONS
  603.  
  604. =============================================================================
  605. */
  606.  
  607.  
  608. /*QUAKED info_player_start (1 0 0) (-16 -16 -24) (16 16 24)
  609. The normal starting point for a level.
  610. */
  611. void() info_player_start =
  612. {
  613. };
  614.  
  615.  
  616. /*QUAKED info_player_start2 (1 0 0) (-16 -16 -24) (16 16 24)
  617. Only used on start map for the return point from an episode.
  618. */
  619. void() info_player_start2 =
  620. {
  621. };
  622.  
  623.  
  624. /*
  625. saved out by quaked in region mode
  626. */
  627. void() testplayerstart =
  628. {
  629. };
  630.  
  631. /*QUAKED info_player_deathmatch (1 0 1) (-16 -16 -24) (16 16 24)
  632. potential spawning position for deathmatch games
  633. */
  634. void() info_player_deathmatch =
  635. {
  636. };
  637.  
  638. /*QUAKED info_player_coop (1 0 1) (-16 -16 -24) (16 16 24)
  639. potential spawning position for coop games
  640. */
  641. void() info_player_coop =
  642. {
  643. };
  644.  
  645. /*
  646. ===============================================================================
  647.  
  648. RULES
  649.  
  650. ===============================================================================
  651. */
  652.  
  653. void(entity c) PrintClientScore =
  654. {
  655.     if (c.frags > -10 && c.frags < 0)
  656.         bprint (" ");
  657.     else if (c.frags >= 0)
  658.     {
  659.         if (c.frags < 100)
  660.             bprint (" ");
  661.         if (c.frags < 10)
  662.             bprint (" ");
  663.     }
  664.     bprint (ftos(c.frags));
  665.     bprint (" ");
  666.     bprint (c.netname);
  667.     bprint ("\n");
  668. };
  669.  
  670. void() DumpScore =
  671. {
  672.     local entity    e, sort, walk;
  673.  
  674.     if (world.chain)
  675.         error ("DumpScore: world.chain is set");
  676.  
  677. // build a sorted lis
  678.     e = find(world, classname, "player");
  679.     sort = world;
  680.     while (e)
  681.     {
  682.         if (!sort)
  683.         {
  684.             sort = e;
  685.             e.chain = world;
  686.         }
  687.         else
  688.         {
  689.             if (e.frags > sort.frags)
  690.             {
  691.                 e.chain = sort;
  692.                 sort = e;
  693.             }
  694.             else
  695.             {
  696.                 walk = sort;
  697.                 do
  698.                 {
  699.                     if (!walk.chain)
  700.                     {
  701.                         e.chain = world;
  702.                         walk.chain = e;
  703.                     }
  704.                     else if (walk.chain.frags < e.frags)
  705.                     {
  706.                         e.chain = walk.chain;
  707.                         walk.chain = e;
  708.                     }
  709.                     else
  710.                         walk = walk.chain;
  711.                 } while (walk.chain != e);
  712.             }
  713.         }
  714.         
  715.         e = find(e, classname, "player");
  716.     }
  717.  
  718. // print the list
  719.     
  720.     bprint ("\n");    
  721.     while (sort)
  722.     {
  723.         PrintClientScore (sort);
  724.         sort = sort.chain;
  725.     }
  726.     bprint ("\n");
  727. };
  728.  
  729. /*
  730. go to the next level for deathmatch
  731. */
  732. void() NextLevel =
  733. {
  734.     local entity o;
  735.  
  736. // find a trigger changelevel
  737.     o = find(world, classname, "trigger_changelevel");
  738.     if (!o || mapname == "start")
  739.     {    // go back to same map if no trigger_changelevel
  740.         o = spawn();
  741.         o.map = mapname;
  742.     }
  743.  
  744.     nextmap = o.map;
  745.     
  746.     if (o.nextthink < time)
  747.     {
  748.         o.think = execute_changelevel;
  749.         o.nextthink = time + 0.1;
  750.     }
  751. };
  752.  
  753. /*
  754. ============
  755. CheckRules
  756.  
  757. Exit deathmatch games upon conditions
  758. ============
  759. */
  760. void() CheckRules =
  761. {
  762.     local    float        timelimit;
  763.     local    float        fraglimit;
  764.     
  765.     if (gameover)    // someone else quit the game already
  766.         return;
  767.         
  768.     timelimit = cvar("timelimit") * 60;
  769.     fraglimit = cvar("fraglimit");
  770.     
  771.     if (timelimit && time >= timelimit)
  772.     {
  773. NextLevel ();
  774. /*
  775.         gameover = TRUE;
  776.         bprint ("\n\n\n==============================\n");
  777.         bprint ("game exited after ");
  778.         bprint (ftos(timelimit/60));
  779.         bprint (" minutes\n");
  780.         DumpScore ();
  781.         localcmd ("killserver\n");
  782. */
  783.         return;
  784.     }
  785.     
  786.     if (fraglimit && self.frags >= fraglimit)
  787.     {
  788. NextLevel ();
  789. /*
  790.         gameover = TRUE;
  791.         bprint ("\n\n\n==============================\n");
  792.         bprint ("game exited after ");
  793.         bprint (ftos(self.frags));
  794.         bprint (" frags\n");
  795.         DumpScore ();
  796.         localcmd ("killserver\n");
  797. */
  798.         return;
  799.     }    
  800. };
  801.  
  802. //============================================================================
  803.  
  804. void() PlayerDeathThink =
  805. {
  806.     local entity    old_self;
  807.     local float        forward;
  808.  
  809.     if ((self.flags & FL_ONGROUND))
  810.     {
  811.         forward = vlen (self.velocity);
  812.         forward = forward - 20;
  813.         if (forward <= 0)
  814.             self.velocity = '0 0 0';
  815.         else    
  816.             self.velocity = forward * normalize(self.velocity);
  817.     }
  818.  
  819. // wait for all buttons released
  820.     if (self.deadflag == DEAD_DEAD)
  821.     {
  822.         if (self.button2 || self.button1 || self.button0)
  823.             return;
  824.         self.deadflag = DEAD_RESPAWNABLE;
  825.         return;
  826.     }
  827.  
  828. // wait for any button down
  829.     if (!self.button2 && !self.button1 && !self.button0)
  830.         return;
  831.  
  832.     self.button0 = 0;
  833.     self.button1 = 0;
  834.     self.button2 = 0;
  835.     respawn();
  836. };
  837.  
  838. void() Player_Demon_JumpTouch;
  839.  
  840. void() PlayerJump =
  841. {
  842.     local vector start, end;
  843.     
  844.     if (self.flags & FL_WATERJUMP)
  845.         return;
  846.     
  847.     if (self.waterlevel >= 2)
  848.     {
  849.         if (self.watertype == CONTENT_WATER)
  850.             self.velocity_z = 100;
  851.         else if (self.watertype == CONTENT_SLIME)
  852.             self.velocity_z = 80;
  853.         else
  854.             self.velocity_z = 50;
  855.  
  856. // play swiming sound
  857.         if (self.swim_flag < time)
  858.         {
  859.             self.swim_flag = time + 1;
  860.             if (random() < 0.5)
  861.                 sound (self, CHAN_BODY, "misc/water1.wav", 1, ATTN_NORM);
  862.             else
  863.                 sound (self, CHAN_BODY, "misc/water2.wav", 1, ATTN_NORM);
  864.         }
  865.  
  866.         return;
  867.     }
  868.  
  869.     if (!(self.flags & FL_ONGROUND))
  870.         return;
  871.  
  872.     if ( !(self.flags & FL_JUMPRELEASED) )
  873.         return;        // don't pogo stick
  874.  
  875.     self.flags = self.flags - (self.flags & FL_JUMPRELEASED);
  876.  
  877.     self.flags = self.flags - FL_ONGROUND;    // don't stairwalk
  878.     
  879.     self.button2 = 0;
  880. // player jumping sound
  881.         if (self.invincible_time)
  882.         {
  883.                 makevectors (self.angles);
  884.                 self.origin_z = self.origin_z + 1;
  885.                 self.velocity = v_forward * 800 - '0 0 350';
  886.                 self.velocity_z = self.velocity_z * -1;
  887. //                if (self.flags & FL_ONGROUND)
  888. //                        self.flags = self.flags - FL_ONGROUND;
  889.                 sound (self, CHAN_BODY, "demon/djump.wav", 1, ATTN_NORM);
  890.                 self.touch = Player_Demon_JumpTouch;
  891.                 player_demon_jump();
  892.         }
  893.         else
  894.         {
  895.                 sound (self, CHAN_BODY, "player/plyrjmp8.wav", 1, ATTN_NORM);
  896.                 self.velocity_z = self.velocity_z + 270;
  897.         }
  898. };
  899.  
  900.  
  901. /*
  902. ===========
  903. WaterMove
  904.  
  905. ============
  906. */
  907. .float    dmgtime;
  908.  
  909. void() WaterMove =
  910. {
  911. //dprint (ftos(self.waterlevel));
  912.     if (self.movetype == MOVETYPE_NOCLIP)
  913.         return;
  914.     if (self.health < 0)
  915.         return;
  916.  
  917.     if (self.waterlevel != 3)
  918.     {
  919.         if (self.air_finished < time)
  920.             sound (self, CHAN_VOICE, "player/gasp2.wav", 1, ATTN_NORM);
  921.         else if (self.air_finished < time + 9)
  922.             sound (self, CHAN_VOICE, "player/gasp1.wav", 1, ATTN_NORM);
  923.         self.air_finished = time + 12;
  924.         self.dmg = 2;
  925.     }
  926.     else if (self.air_finished < time)
  927.     {    // drown!
  928.         if (self.pain_finished < time)
  929.         {
  930.             self.dmg = self.dmg + 2;
  931.             if (self.dmg > 15)
  932.                 self.dmg = 10;
  933.             T_Damage (self, world, world, self.dmg);
  934.             self.pain_finished = time + 1;
  935.         }
  936.     }
  937.     
  938.     if (!self.waterlevel)
  939.     {
  940.         if (self.flags & FL_INWATER)
  941.         {    
  942.             // play leave water sound
  943.             sound (self, CHAN_BODY, "misc/outwater.wav", 1, ATTN_NORM);
  944.             self.flags = self.flags - FL_INWATER;
  945.         }
  946.         return;
  947.     }
  948.  
  949.     if (self.watertype == CONTENT_LAVA)
  950.     {    // do damage
  951.         if (self.dmgtime < time)
  952.         {
  953.             if (self.radsuit_finished > time)
  954.                 self.dmgtime = time + 1;
  955.             else
  956.                 self.dmgtime = time + 0.2;
  957.  
  958.             T_Damage (self, world, world, 10*self.waterlevel);
  959.         }
  960.     }
  961.     else if (self.watertype == CONTENT_SLIME)
  962.     {    // do damage
  963.         if (self.dmgtime < time && self.radsuit_finished < time)
  964.         {
  965.             self.dmgtime = time + 1;
  966.             T_Damage (self, world, world, 4*self.waterlevel);
  967.         }
  968.     }
  969.     
  970.     if ( !(self.flags & FL_INWATER) )
  971.     {    
  972.  
  973. // player enter water sound
  974.  
  975.         if (self.watertype == CONTENT_LAVA)
  976.             sound (self, CHAN_BODY, "player/inlava.wav", 1, ATTN_NORM);
  977.         if (self.watertype == CONTENT_WATER)
  978.             sound (self, CHAN_BODY, "player/inh2o.wav", 1, ATTN_NORM);
  979.         if (self.watertype == CONTENT_SLIME)
  980.             sound (self, CHAN_BODY, "player/slimbrn2.wav", 1, ATTN_NORM);
  981.  
  982.         self.flags = self.flags + FL_INWATER;
  983.         self.dmgtime = 0;
  984.     }
  985.     
  986.     if (! (self.flags & FL_WATERJUMP) )
  987.         self.velocity = self.velocity - 0.8*self.waterlevel*frametime*self.velocity;
  988. };
  989.  
  990. void() CheckWaterJump =
  991. {
  992.     local vector start, end;
  993.  
  994. // check for a jump-out-of-water
  995.     makevectors (self.angles);
  996.     start = self.origin;
  997.     start_z = start_z + 8; 
  998.     v_forward_z = 0;
  999.     normalize(v_forward);
  1000.     end = start + v_forward*24;
  1001.     traceline (start, end, TRUE, self);
  1002.     if (trace_fraction < 1)
  1003.     {    // solid at waist
  1004.         start_z = start_z + self.maxs_z - 8;
  1005.         end = start + v_forward*24;
  1006.         self.movedir = trace_plane_normal * -50;
  1007.         traceline (start, end, TRUE, self);
  1008.         if (trace_fraction == 1)
  1009.         {    // open at eye level
  1010.             self.flags = self.flags | FL_WATERJUMP;
  1011.             self.velocity_z = 225;
  1012.             self.flags = self.flags - (self.flags & FL_JUMPRELEASED);
  1013.             self.teleport_time = time + 2;    // safety net
  1014.             return;
  1015.         }
  1016.     }
  1017. };
  1018.  
  1019.  
  1020. /*
  1021. ================
  1022. PlayerPreThink
  1023.  
  1024. Called every frame before physics are run
  1025. ================
  1026. */
  1027. void() PlayerPreThink =
  1028. {
  1029.     local    float    mspeed, aspeed;
  1030.     local    float    r;
  1031.  
  1032.     if (intermission_running)
  1033.     {
  1034.         IntermissionThink ();    // otherwise a button could be missed between
  1035.         return;                    // the think tics
  1036.     }
  1037.  
  1038.     if (self.view_ofs == '0 0 0')
  1039.         return;        // intermission or finale
  1040.  
  1041.     makevectors (self.v_angle);        // is this still used
  1042.  
  1043.     CheckRules ();
  1044.     WaterMove ();
  1045.  
  1046.     if (self.waterlevel == 2)
  1047.         CheckWaterJump ();
  1048.  
  1049.     if (self.deadflag >= DEAD_DEAD)
  1050.     {
  1051.         PlayerDeathThink ();
  1052.         return;
  1053.     }
  1054.     
  1055.     if (self.deadflag == DEAD_DYING)
  1056.         return;    // dying, so do nothing
  1057.  
  1058.     if (self.button2)
  1059.     {
  1060.         PlayerJump ();
  1061.     }
  1062.     else
  1063.         self.flags = self.flags | FL_JUMPRELEASED;
  1064.  
  1065. // teleporters can force a non-moving pause time    
  1066.     if (time < self.pausetime)
  1067.         self.velocity = '0 0 0';
  1068. };
  1069.     
  1070. /*
  1071. ================
  1072. CheckPowerups
  1073.  
  1074. Check for turning off powerups
  1075. ================
  1076. */
  1077. void(vector org, vector vel, float damage) SpawnBlood;
  1078. void() CheckPowerups =
  1079. {
  1080. local   float x,a,b,c;
  1081.  
  1082.     if (self.health <= 0)
  1083.         return;
  1084.  
  1085. // invisibility
  1086.     if (self.invisible_finished)
  1087.     {
  1088. // sound and screen flash when items starts to run out
  1089.         if (self.invisible_sound < time)
  1090.         {
  1091.             sound (self, CHAN_AUTO, "items/inv3.wav", 0.5, ATTN_IDLE);
  1092.             self.invisible_sound = time + ((random() * 3) + 1);
  1093.         }
  1094.  
  1095.  
  1096.                 if (self.invisible_finished < time + 3)
  1097.         {
  1098.             if (self.invisible_time == 1)
  1099.             {
  1100.                 sprint (self, "Ring of Shadows magic is fading\n");
  1101.                 stuffcmd (self, "bf\n");
  1102.                 sound (self, CHAN_AUTO, "items/inv2.wav", 1, ATTN_NORM);
  1103.                 self.invisible_time = time + 1;
  1104.             }
  1105.             
  1106.             if (self.invisible_time < time)
  1107.             {
  1108.                 self.invisible_time = time + 1;
  1109.                 stuffcmd (self, "bf\n");
  1110.             }
  1111.         }
  1112.  
  1113.         if (self.invisible_finished < time)
  1114.         {    // just stopped
  1115.             self.items = self.items - IT_INVISIBILITY;
  1116.             self.invisible_finished = 0;
  1117.             self.invisible_time = 0;
  1118.         }
  1119.         
  1120.     // use the eyes
  1121.         self.frame = 0;
  1122.         self.modelindex = modelindex_eyes;
  1123.     }
  1124.     else
  1125.         self.modelindex = modelindex_player;    // don't use eyes
  1126.  
  1127. // invincibility
  1128.     if (self.invincible_finished)
  1129.     {
  1130. // sound and screen flash when items starts to run out
  1131.         if (self.invincible_finished < time + 3)
  1132.         {
  1133.             if (self.invincible_time == 1)
  1134.             {
  1135.                                 sprint (self, "You feel yourself reverting to humanness.\n");
  1136.                 stuffcmd (self, "bf\n");
  1137.                 sound (self, CHAN_AUTO, "items/protect2.wav", 1, ATTN_NORM);
  1138.                 self.invincible_time = time + 1;
  1139.             }
  1140.             
  1141.             if (self.invincible_time < time)
  1142.             {
  1143.                 self.invincible_time = time + 1;
  1144.                 stuffcmd (self, "bf\n");
  1145.             }
  1146.         }
  1147.         
  1148.         if (self.invincible_finished < time)
  1149.         {    // just stopped
  1150.  
  1151.                 // FIEND -- Turn into a person
  1152.                         self.modelindex = modelindex_player;
  1153.                         W_SetCurrentAmmo();
  1154.  
  1155.                         self.view_ofs = '0 0 22';
  1156.  
  1157.                 // FIEND -- SOUND + GIBS
  1158.                 x = 0;
  1159.                 while (x < 30)      
  1160.                 { 
  1161.                 a=(random()*300 - 150);
  1162.                 b=(random()*300 - 150);
  1163.                 c=(random()*600 - 300);
  1164.                 SpawnMeatSpray (self.origin , a* v_right + b*v_forward);
  1165.                 x = x + 1;
  1166.                 }
  1167.                 ThrowGib("progs/gib1.mdl", -100);
  1168.                 ThrowGib("progs/gib2.mdl", -100);
  1169.                 ThrowGib("progs/gib3.mdl", -100);
  1170.                 ThrowGib("progs/gib1.mdl", -100);
  1171.                 ThrowGib("progs/gib2.mdl", -100);
  1172.                 ThrowGib("progs/gib3.mdl", -100);
  1173.                 sound (other, CHAN_ITEM, "player/udeath.wav", 1, ATTN_NORM);
  1174.  
  1175.             self.items = self.items - IT_INVULNERABILITY;
  1176.             self.invincible_time = 0;
  1177.             self.invincible_finished = 0;
  1178.         }
  1179.  
  1180.                 self.modelindex = modelindex_demon;
  1181.     }
  1182.  
  1183. // super damage
  1184.     if (self.super_damage_finished)
  1185.     {
  1186.  
  1187. // sound and screen flash when items starts to run out
  1188.  
  1189.         if (self.super_damage_finished < time + 3)
  1190.         {
  1191.             if (self.super_time == 1)
  1192.             {
  1193.                 sprint (self, "Quad Damage is wearing off\n");
  1194.                 stuffcmd (self, "bf\n");
  1195.                 sound (self, CHAN_AUTO, "items/damage2.wav", 1, ATTN_NORM);
  1196.                 self.super_time = time + 1;
  1197.             }      
  1198.             
  1199.             if (self.super_time < time)
  1200.             {
  1201.                 self.super_time = time + 1;
  1202.                 stuffcmd (self, "bf\n");
  1203.             }
  1204.         }
  1205.  
  1206.         if (self.super_damage_finished < time)
  1207.         {    // just stopped
  1208.             self.items = self.items - IT_QUAD;
  1209.             self.super_damage_finished = 0;
  1210.             self.super_time = 0;
  1211.         }
  1212.         if (self.super_damage_finished > time)
  1213.             self.effects = self.effects | EF_DIMLIGHT;
  1214.         else
  1215.             self.effects = self.effects - (self.effects & EF_DIMLIGHT);
  1216.     }    
  1217.  
  1218. // suit    
  1219.     if (self.radsuit_finished)
  1220.     {
  1221.         self.air_finished = time + 12;        // don't drown
  1222.  
  1223. // sound and screen flash when items starts to run out
  1224.         if (self.radsuit_finished < time + 3)
  1225.         {
  1226.             if (self.rad_time == 1)
  1227.             {
  1228.                 sprint (self, "Air supply in Biosuit expiring\n");
  1229.                 stuffcmd (self, "bf\n");
  1230.                 sound (self, CHAN_AUTO, "items/suit2.wav", 1, ATTN_NORM);
  1231.                 self.rad_time = time + 1;
  1232.             }
  1233.             
  1234.             if (self.rad_time < time)
  1235.             {
  1236.                 self.rad_time = time + 1;
  1237.                 stuffcmd (self, "bf\n");
  1238.             }
  1239.         }
  1240.  
  1241.         if (self.radsuit_finished < time)
  1242.         {    // just stopped
  1243.             self.items = self.items - IT_SUIT;
  1244.             self.rad_time = 0;
  1245.             self.radsuit_finished = 0;
  1246.         }
  1247.     }    
  1248.  
  1249. };
  1250.  
  1251.  
  1252. /*
  1253. ================
  1254. PlayerPostThink
  1255.  
  1256. Called every frame after physics are run
  1257. ================
  1258. */
  1259. void() PlayerPostThink =
  1260. {
  1261.     local    float    mspeed, aspeed;
  1262.     local    float    r;
  1263.  
  1264.     if (self.view_ofs == '0 0 0')
  1265.         return;        // intermission or finale
  1266.     if (self.deadflag)
  1267.         return;
  1268.         
  1269. // do weapon stuff
  1270.  
  1271.     W_WeaponFrame ();
  1272.  
  1273. // check to see if player landed and play landing sound    
  1274.     if ((self.jump_flag < -300) && (self.flags & FL_ONGROUND) && (self.health > 0))
  1275.     {
  1276.         if (self.watertype == CONTENT_WATER)
  1277.             sound (self, CHAN_BODY, "player/h2ojump.wav", 1, ATTN_NORM);
  1278.         else if (self.jump_flag < -650)
  1279.         {
  1280.             T_Damage (self, world, world, 5); 
  1281.             sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  1282.             self.deathtype = "falling";
  1283.         }
  1284.         else
  1285.             sound (self, CHAN_VOICE, "player/land.wav", 1, ATTN_NORM);
  1286.  
  1287.         self.jump_flag = 0;
  1288.     }
  1289.  
  1290.     if (!(self.flags & FL_ONGROUND))
  1291.         self.jump_flag = self.velocity_z;
  1292.  
  1293.     CheckPowerups ();
  1294. };
  1295.  
  1296.  
  1297. /*
  1298. ===========
  1299. ClientConnect
  1300.  
  1301. called when a player connects to a server
  1302. ============
  1303. */
  1304. void() ClientConnect =
  1305. {
  1306.     bprint (self.netname);
  1307.     bprint (" entered the game\n");
  1308.     
  1309. // a client connecting during an intermission can cause problems
  1310.     if (intermission_running)
  1311.         ExitIntermission ();
  1312. };
  1313.  
  1314.  
  1315. /*
  1316. ===========
  1317. ClientDisconnect
  1318.  
  1319. called when a player disconnects from a server
  1320. ============
  1321. */
  1322. void() ClientDisconnect =
  1323. {
  1324.     if (gameover)
  1325.         return;
  1326.     // if the level end trigger has been activated, just return
  1327.     // since they aren't *really* leaving
  1328.  
  1329.     // let everyone else know
  1330.     bprint (self.netname);
  1331.     bprint (" left the game with ");
  1332.     bprint (ftos(self.frags));
  1333.     bprint (" frags\n");
  1334.     sound (self, CHAN_BODY, "player/tornoff2.wav", 1, ATTN_NONE);
  1335.     set_suicide_frame ();
  1336. };
  1337.  
  1338. /*
  1339. ===========
  1340. ClientObituary
  1341.  
  1342. called when a player dies
  1343. ============
  1344. */
  1345. void(entity targ, entity attacker) ClientObituary =
  1346. {
  1347.     local    float rnum;
  1348.     local    string deathstring, deathstring2;
  1349.     rnum = random();
  1350.  
  1351.     if (targ.classname == "player")
  1352.     {
  1353.         if (attacker.classname == "teledeath")
  1354.         {
  1355.             bprint (targ.netname);
  1356.             bprint (" was telefragged by ");
  1357.             bprint (attacker.owner.netname);
  1358.             bprint ("\n");
  1359.  
  1360. // No kills for telefrags! {JDS}
  1361. //                      attacker.owner.frags = attacker.owner.frags + 1;
  1362.             return;
  1363.         }
  1364.  
  1365.         if (attacker.classname == "teledeath2")
  1366.         {
  1367.             bprint ("Satan's power deflects ");
  1368.             bprint (targ.netname);
  1369.             bprint ("'s telefrag\n");
  1370.  
  1371. // {JDS}                targ.frags = targ.frags - 1;
  1372.             return;
  1373.         }
  1374.  
  1375.         if (attacker.classname == "player")
  1376.         {
  1377.             if (targ == attacker)
  1378.             {
  1379.                 // killed self
  1380.                 attacker.frags = attacker.frags - 1;
  1381.                 bprint (targ.netname);
  1382.                 
  1383.                 if (targ.weapon == 64 && targ.waterlevel > 1)
  1384.                 {
  1385.                     bprint (" discharges into the water.\n");
  1386.                     return;
  1387.                 }
  1388.                 if (targ.weapon == 16)
  1389.                     bprint (" tries to put the pin back in\n");
  1390.                 else if (rnum)
  1391.                                         bprint (" becomes bored with life\n");
  1392.                 else
  1393.                     bprint (" checks if his weapon is loaded\n");
  1394.                 return;
  1395.             }
  1396.             else
  1397.             {
  1398. // {JDS}  If teamplay is negative and you kill a teammate, add teamplay frags.
  1399. // (That is, lose frags since teamplay is negative.)  This allows a variable penalty for
  1400. // killing your teammates.  
  1401. // If teamplay is 100, and you kill a teammate, Take 1000 damage from yourself.
  1402. // (GIB!)  And gain a frag which you will lose in a sec when you gib.
  1403. // If teamplay is -100 and you kill a teammate, GIB and lose a frag.
  1404.                                 if((teamplay == 100) && (attacker.team == targ.team))
  1405.                                 {
  1406.                                         T_Damage(attacker, attacker, attacker, 1000);
  1407.                     bprint(attacker.netname);
  1408.                     bprint(" killed his teammate, ");
  1409.                     bprint(targ.netname);
  1410.                     bprint("!\n");
  1411.                                 }
  1412.                                 if((teamplay < 0) && (attacker.team == targ.team))
  1413.                                 {
  1414.                                         if(teamplay == -100)
  1415.                                                 T_Damage(attacker, attacker, attacker, 1000);
  1416.                         // Will take penalty for killing yourself.
  1417.                                         else attacker.frags = attacker.frags + teamplay;
  1418.                     bprint(attacker.netname);
  1419.                     bprint(" killed his teammate, ");
  1420.                     bprint(targ.netname);
  1421.                     bprint("!\n");
  1422.                                 
  1423.                                 }
  1424.                                 else attacker.frags = attacker.frags + 1;
  1425.                                 // If teamplay is 100, you'll lose this frag in a second
  1426.                                 // for killing yourself.
  1427.                 
  1428. // {JDS}
  1429.                                 if (attacker.invincible_time)
  1430.                                 {
  1431.                                         bprint(targ.netname);
  1432.                                         bprint(" was eviscerated by ");
  1433.                                         bprint(attacker.netname);
  1434.                                         bprint("\n");
  1435.                                         return;
  1436.                                 }
  1437.  
  1438.                 rnum = attacker.weapon;
  1439.                 if (rnum == IT_AXE)
  1440.                 {
  1441.                     deathstring = " was ax-murdered by ";
  1442.                     deathstring2 = "\n";
  1443.                 }
  1444.                 if (rnum == IT_SHOTGUN)
  1445.                 {
  1446.                     deathstring = " chewed on ";
  1447.                     deathstring2 = "'s boomstick\n";
  1448.                 }
  1449.                 if (rnum == IT_SUPER_SHOTGUN)
  1450.                 {
  1451.                     deathstring = " ate 2 loads of ";
  1452.                     deathstring2 = "'s buckshot\n";
  1453.                 }
  1454.                 if (rnum == IT_NAILGUN)
  1455.                 {
  1456.                     deathstring = " was nailed by ";
  1457.                     deathstring2 = "\n";
  1458.                 }
  1459.                 if (rnum == IT_SUPER_NAILGUN)
  1460.                 {
  1461.                     deathstring = " was punctured by ";
  1462.                     deathstring2 = "\n";
  1463.                 }
  1464.                 if (rnum == IT_NAILBOMB)
  1465.                 {
  1466.                                         deathstring = " was nailbombed by ";
  1467.                     deathstring2 = "\n";
  1468.                 }
  1469.                                 if (rnum == IT_HOMER)
  1470.                 {
  1471.                                         deathstring = " didn't see ";
  1472.                                         deathstring2 = "'s Homer coming\n";
  1473.                 }
  1474.                 if (rnum == IT_GRENADE_LAUNCHER)
  1475.                 {
  1476.                     deathstring = " eats ";
  1477.                     deathstring2 = "'s pineapple\n";
  1478.                     if (targ.health < -40)
  1479.                     {
  1480.                         deathstring = " was gibbed by ";
  1481.                         deathstring2 = "'s grenade\n";
  1482.                     }
  1483.                 }
  1484.                 if (rnum == IT_ROCKET_LAUNCHER)
  1485.                 {
  1486.                     deathstring = " rides ";
  1487.                     deathstring2 = "'s rocket\n";
  1488.                     if (targ.health < -40)
  1489.                     {
  1490.                         deathstring = " was gibbed by ";
  1491.                         deathstring2 = "'s rocket\n" ;
  1492.                     }
  1493.                 }
  1494.                 if (rnum == IT_LIGHTNING)
  1495.                 {
  1496.                     deathstring = " accepts ";
  1497.                     if (attacker.waterlevel > 1)
  1498.                         deathstring2 = "'s discharge\n";
  1499.                     else
  1500.                         deathstring2 = "'s shaft\n";
  1501.                 }
  1502.                 bprint (targ.netname);
  1503.                 bprint (deathstring);
  1504.                 bprint (attacker.netname);
  1505.                 bprint (deathstring2);
  1506.             }
  1507.             return;
  1508.         }
  1509.         else
  1510.         {
  1511.             targ.frags = targ.frags - 1;        // killed self
  1512.             rnum = targ.watertype;
  1513.  
  1514.             bprint (targ.netname);
  1515.             if (rnum == -3)
  1516.             {
  1517.                 if (random() < 0.5)
  1518.                     bprint (" sleeps with the fishes\n");
  1519.                 else
  1520.                     bprint (" sucks it down\n");
  1521.                 return;
  1522.             }
  1523.             else if (rnum == -4)
  1524.             {
  1525.                 if (random() < 0.5)
  1526.                     bprint (" gulped a load of slime\n");
  1527.                 else
  1528.                     bprint (" can't exist on slime alone\n");
  1529.                 return;
  1530.             }
  1531.             else if (rnum == -5)
  1532.             {
  1533.                 if (targ.health < -15)
  1534.                 {
  1535.                     bprint (" burst into flames\n");
  1536.                     return;
  1537.                 }
  1538.                 if (random() < 0.5)
  1539.                     bprint (" turned into hot slag\n");
  1540.                 else
  1541.                     bprint (" visits the Volcano God\n");
  1542.                 return;
  1543.             }
  1544.  
  1545.             if (attacker.flags & FL_MONSTER)
  1546.             {
  1547.                 if (attacker.classname == "monster_army")
  1548.                     bprint (" was shot by a Grunt\n");
  1549.                 if (attacker.classname == "monster_demon1")
  1550.                     bprint (" was eviscerated by a Fiend\n");
  1551.                 if (attacker.classname == "monster_dog")
  1552.                     bprint (" was mauled by a Rottweiler\n");
  1553.                 if (attacker.classname == "monster_dragon")
  1554.                     bprint (" was fried by a Dragon\n");
  1555.                 if (attacker.classname == "monster_enforcer")
  1556.                     bprint (" was blasted by an Enforcer\n");
  1557.                 if (attacker.classname == "monster_fish")
  1558.                     bprint (" was fed to the Rotfish\n");
  1559.                 if (attacker.classname == "monster_hell_knight")
  1560.                     bprint (" was slain by a Death Knight\n");
  1561.                 if (attacker.classname == "monster_knight")
  1562.                     bprint (" was slashed by a Knight\n");
  1563.                 if (attacker.classname == "monster_ogre")
  1564.                     bprint (" was destroyed by an Ogre\n");
  1565.                 if (attacker.classname == "monster_oldone")
  1566.                     bprint (" became one with Shub-Niggurath\n");
  1567.                 if (attacker.classname == "monster_shalrath")
  1568.                     bprint (" was exploded by a Vore\n");
  1569.                 if (attacker.classname == "monster_shambler")
  1570.                     bprint (" was smashed by a Shambler\n");
  1571.                 if (attacker.classname == "monster_tarbaby")
  1572.                     bprint (" was slimed by a Spawn\n");
  1573.                 if (attacker.classname == "monster_vomit")
  1574.                     bprint (" was vomited on by a Vomitus\n");
  1575.                 if (attacker.classname == "monster_wizard")
  1576.                     bprint (" was scragged by a Scrag\n");
  1577.                 if (attacker.classname == "monster_zombie")
  1578.                     bprint (" joins the Zombies\n");
  1579.  
  1580.                 return;
  1581.             }
  1582.             if (attacker.classname == "explo_box")
  1583.             {
  1584.                 bprint (" blew up\n");
  1585.                 return;
  1586.             }
  1587.             if (attacker.solid == SOLID_BSP && attacker != world)
  1588.             {    
  1589.                 bprint (" was squished\n");
  1590.                 return;
  1591.             }
  1592.             if (targ.deathtype == "falling")
  1593.             {
  1594.                 targ.deathtype = "";
  1595.                 bprint (" fell to his death\n");
  1596.                 return;
  1597.             }
  1598.             if (attacker.classname == "trap_shooter" || attacker.classname == "trap_spikeshooter")
  1599.             {
  1600.                 bprint (" was spiked\n");
  1601.                 return;
  1602.             }
  1603.             if (attacker.classname == "fireball")
  1604.             {
  1605.                 bprint (" ate a lavaball\n");
  1606.                 return;
  1607.             }
  1608.             if (attacker.classname == "trigger_changelevel")
  1609.             {
  1610.                 bprint (" tried to leave\n");
  1611.                 return;
  1612.             }
  1613.  
  1614.             bprint (" died\n");
  1615.         }
  1616.     }
  1617. };
  1618.                                                         
  1619.