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