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

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