home *** CD-ROM | disk | FTP | other *** search
/ CD Shareware Magazine 1997 January / CD_shareware_1-97.iso / DOS / JUEGOS / QPLUS15.ZIP / CLIENT.QC < prev    next >
Encoding:
Text File  |  1996-09-28  |  40.8 KB  |  1,679 lines

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