home *** CD-ROM | disk | FTP | other *** search
/ Quake 'em / QUAKEEM.BIN / quake / programs / sgqcver2 / client.qc < prev    next >
Encoding:
Text File  |  1996-08-22  |  32.8 KB  |  1,209 lines

  1. void () W_WeaponFrame;
  2. void() W_SetCurrentAmmo;
  3. void() player_pain;
  4. void() player_stand1;
  5. void() player_fall;
  6. void (vector org) spawn_tfog;
  7. void (vector org, entity death_owner) spawn_tdeath;
  8. float    modelindex_eyes, modelindex_player;
  9.  
  10. float    intermission_running;
  11. float    intermission_exittime;
  12.  
  13. /*QUAKED info_intermission (1 0.5 0.5) (-16 -16 -16) (16 16 16)
  14. This is the camera point for the intermission.
  15. Use mangle instead of angle, so you can set pitch or roll as well as yaw.  'pitch roll yaw'
  16. */
  17. void() info_intermission =
  18. {
  19. };
  20. void() SetChangeParms =
  21. {
  22.     self.items = self.items - (self.items & 
  23.     (IT_KEY1 | IT_KEY2 | IT_INVISIBILITY | IT_INVULNERABILITY | IT_SUIT | IT_QUAD) );
  24.     if (self.health > 100)
  25.         self.health = 100;
  26.     if (self.health < 50)
  27.         self.health = 50;
  28.     parm1 = self.items;
  29.     parm2 = self.health;
  30.     parm3 = self.armorvalue;
  31.     if (self.ammo_shells < 25)
  32.         parm4 = 25;
  33.     else
  34.         parm4 = self.ammo_shells;
  35.     parm5 = self.ammo_nails;
  36.     parm6 = self.ammo_rockets;
  37.     parm7 = self.ammo_cells;
  38.     parm8 = self.weapon;
  39.     parm9 = self.armortype * 100;
  40.       parm10 = self.skin;
  41.     parm11 = self.num_axes;
  42. };
  43.  
  44. void() SetNewParms =
  45. {
  46.       parm1 = IT_SHOTGUN | IT_AXE | IT_THROWING_AXE; 
  47.       parm2 = 100;
  48.       parm3 = 0;
  49.       parm4 = 25;
  50.       parm5 = 0;
  51.       parm6 = 0;
  52.       parm7 = 0;
  53.       parm8 = 1;
  54.       parm9 = 0;
  55.       parm10 = self.skin;
  56.       parm11 = 5; //Number of thrown axes to start with
  57. };
  58.  
  59. void() DecodeLevelParms =
  60. {
  61.     if (serverflags)
  62.     {
  63.         if (world.model == "maps/start.bsp")
  64.             SetNewParms ();        // take away all stuff on starting new episode
  65.     }
  66.     self.items = parm1;
  67.     self.health = parm2;
  68.     self.armorvalue = parm3;
  69.     self.ammo_shells = parm4;
  70.     self.ammo_nails = parm5;
  71.     self.ammo_rockets = parm6;
  72.     self.ammo_cells = parm7;
  73.     self.weapon = parm8;
  74.     self.armortype = parm9 * 0.01;
  75.       self.skin = parm10;
  76.     self.num_axes = parm11;
  77. };
  78.  
  79. entity() FindIntermission =
  80. {
  81.     local    entity spot;
  82.     local    float cyc;
  83.  
  84.     spot = find (world, classname, "info_intermission");
  85.     if (spot)
  86.         {
  87.         cyc = random() * 4;
  88.         while (cyc > 1)
  89.         {
  90.             spot = find (spot, classname, "info_intermission");
  91.             if (!spot)
  92.                 spot = find (spot, classname, "info_intermission");
  93.             cyc = cyc - 1;
  94.         }
  95.         return spot;
  96.     }
  97.     spot = find (world, classname, "info_player_start");
  98.     if (spot)
  99.         return spot;
  100.     spot = find (world, classname, "testplayerstart");
  101.     if (spot)
  102.         return spot;
  103.     objerror ("FindIntermission: no spot");
  104. };
  105.  
  106. string nextmap;
  107. void() GotoNextMap =
  108. {
  109.     if (cvar("samelevel"))    // if samelevel is set, stay on same level
  110.         changelevel (mapname);
  111.     else
  112.         changelevel (nextmap);
  113. };
  114.  
  115.  
  116. void() ExitIntermission =
  117. {
  118.     if (deathmatch)
  119.     {
  120.         GotoNextMap ();
  121.         return;
  122.     }
  123.     
  124.     intermission_exittime = time + 1;
  125.     intermission_running = intermission_running + 1;
  126.     if (intermission_running == 2)
  127.     {
  128.         if (world.model == "maps/e1m7.bsp")
  129.         {
  130.             WriteByte (MSG_ALL, SVC_CDTRACK);
  131.             WriteByte (MSG_ALL, 2);
  132.             WriteByte (MSG_ALL, 3);
  133.             if (!cvar("registered"))
  134.             {
  135.                 WriteByte (MSG_ALL, SVC_FINALE);
  136.                 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!");
  137.             }
  138.             else
  139.             {
  140.                 WriteByte (MSG_ALL, SVC_FINALE);
  141.                 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!");
  142.             }
  143.             return;
  144.         }
  145.         else if (world.model == "maps/e2m6.bsp")
  146.         {
  147.             WriteByte (MSG_ALL, SVC_CDTRACK);
  148.             WriteByte (MSG_ALL, 2);
  149.             WriteByte (MSG_ALL, 3);
  150.  
  151.             WriteByte (MSG_ALL, SVC_FINALE);
  152.             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.");
  153.             return;
  154.         }
  155.         else if (world.model == "maps/e3m6.bsp")
  156.         {
  157.             WriteByte (MSG_ALL, SVC_CDTRACK);
  158.             WriteByte (MSG_ALL, 2);
  159.             WriteByte (MSG_ALL, 3);
  160.  
  161.             WriteByte (MSG_ALL, SVC_FINALE);
  162.             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.");
  163.             return;
  164.         }
  165.         else if (world.model == "maps/e4m7.bsp")
  166.         {
  167.             WriteByte (MSG_ALL, SVC_CDTRACK);
  168.             WriteByte (MSG_ALL, 2);
  169.             WriteByte (MSG_ALL, 3);
  170.  
  171.             WriteByte (MSG_ALL, SVC_FINALE);
  172.             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.");
  173.             return;
  174.         }
  175.  
  176.         GotoNextMap();
  177.     }
  178.     if (intermission_running == 3)
  179.     {
  180.         if (!cvar("registered"))
  181.         {    // shareware episode has been completed, go to sell screen
  182.             WriteByte (MSG_ALL, SVC_SELLSCREEN);
  183.             return;
  184.         }
  185.         
  186.         if ( (serverflags&15) == 15)
  187.         {
  188.             WriteByte (MSG_ALL, SVC_FINALE);
  189.             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.");
  190.             return;
  191.         }
  192.     }
  193.     GotoNextMap();
  194. };
  195.  
  196. void() IntermissionThink =
  197. {
  198.     if (time < intermission_exittime)
  199.         return;
  200.     if (!self.button0 && !self.button1 && !self.button2)
  201.         return;
  202.     ExitIntermission ();
  203. };
  204.  
  205. void() execute_changelevel =
  206. {
  207.     local entity    pos;
  208.  
  209.     intermission_running = 1;
  210.     if (deathmatch)
  211.         intermission_exittime = time + 5;
  212.     else
  213.         intermission_exittime = time + 2;
  214.     WriteByte (MSG_ALL, SVC_CDTRACK);
  215.     WriteByte (MSG_ALL, 3);
  216.     WriteByte (MSG_ALL, 3);
  217.     pos = FindIntermission ();
  218.         other = find (world, classname, "player");
  219.     while (other != world)
  220.     {
  221.         other.view_ofs = '0 0 0';
  222.         other.angles = other.v_angle = pos.mangle;
  223.         other.fixangle = TRUE;        // turn this way immediately
  224.         other.nextthink = time + 0.5;
  225.         other.takedamage = DAMAGE_NO;
  226.         other.solid = SOLID_NOT;
  227.         other.movetype = MOVETYPE_NONE;
  228.         other.modelindex = 0;
  229.         setorigin (other, pos.origin);
  230.         other = find (other, classname, "player");
  231.     }    
  232.     WriteByte (MSG_ALL, SVC_INTERMISSION);
  233. };
  234.  
  235.  
  236. void() changelevel_touch =
  237. {
  238.     local entity    pos;
  239.  
  240.     if (other.classname != "player")
  241.         return;
  242.     if (cvar("noexit"))
  243.     {
  244.         T_Damage (other, self, self, 50000);
  245.         return;
  246.     }
  247.     bprint (other.netname);
  248.     bprint (" exited the level\n");
  249.     nextmap = self.map;
  250.     SUB_UseTargets ();
  251.     if ( (self.spawnflags & 1) && (deathmatch == 0) )
  252.     {    // NO_INTERMISSION
  253.         GotoNextMap();
  254.         return;
  255.     }
  256.     self.touch = SUB_Null;
  257.     self.think = execute_changelevel;
  258.     self.nextthink = time + 0.1;
  259. };
  260.  
  261. /*QUAKED trigger_changelevel (0.5 0.5 0.5) ? NO_INTERMISSION
  262. 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.
  263. */
  264. void() trigger_changelevel =
  265. {
  266.     if (!self.map)
  267.                 objerror ("changelevel trigger doesn't have map");
  268.     InitTrigger ();
  269.     self.touch = changelevel_touch;
  270. };
  271.  
  272. void() set_suicide_frame;
  273.  
  274. void() respawn =
  275. {
  276.         if (coop)
  277.     {
  278.                 CopyToBodyQue (self);
  279.         setspawnparms (self);
  280.         PutClientInServer ();
  281.     }
  282.     else if (deathmatch)
  283.     {
  284.                 CopyToBodyQue (self);
  285.         SetNewParms ();
  286.                 PutClientInServer (self.skin);
  287.     }
  288.     else
  289.         {
  290.         localcmd ("restart\n");
  291.     }
  292. };
  293.  
  294. void(entity killer) TeamPlayKill =
  295. {
  296.         killer.classname = "team_kill";
  297.         T_Damage (killer, killer, killer, 50000);
  298.         return;
  299. };
  300.  
  301. void() ClientKill =
  302. {
  303.     bprint (self.netname);
  304.     bprint (" suicides\n");
  305.     set_suicide_frame ();
  306.     self.modelindex = modelindex_player;
  307.     self.frags = self.frags - 2;    // extra penalty
  308.     respawn ();
  309. };
  310.  
  311. float(vector v) CheckSpawnPoint =
  312. {
  313.     return FALSE;
  314. };
  315.  
  316. entity() SelectSpawnPoint =
  317. {
  318.     local    entity spot;
  319.     
  320.     spot = find (world, classname, "testplayerstart");
  321.     if (spot)
  322.         return spot;
  323.     if (coop)
  324.     {
  325.         lastspawn = find(lastspawn, classname, "info_player_coop");
  326.         if (lastspawn == world)
  327.             lastspawn = find (lastspawn, classname, "info_player_start");
  328.         if (lastspawn != world)
  329.             return lastspawn;
  330.     }
  331.     else if (deathmatch)
  332.     {
  333.         lastspawn = find(lastspawn, classname, "info_player_deathmatch");
  334.         if (lastspawn == world)
  335.             lastspawn = find (lastspawn, classname, "info_player_deathmatch");
  336.         if (lastspawn != world)
  337.             return lastspawn;
  338.     }
  339.     if (serverflags)
  340.     {    // return with a rune to start
  341.         spot = find (world, classname, "info_player_start2");
  342.         if (spot)
  343.             return spot;
  344.     }
  345.     spot = find (world, classname, "info_player_start");
  346.     if (!spot)
  347.                 error ("PutClientInServer: no info_player_start on level");
  348.     return spot;
  349. };
  350.  
  351. void() DecodeLevelParms;
  352. void() PlayerDie;
  353.  
  354. void(float player_skin) PutClientInServer =
  355. {
  356.     local    entity spot;
  357.  
  358.     self.classname = "player";
  359.     self.health = 100;
  360.     self.takedamage = DAMAGE_AIM;
  361.     self.solid = SOLID_SLIDEBOX;
  362.     self.movetype = MOVETYPE_WALK;
  363.     self.show_hostile = 0;
  364.     self.max_health = 100;
  365.       self.flags = FL_CLIENT;
  366.       self.flags = self.flags - (self.flags & FL_ATTACKED);
  367.     self.air_finished = time + 12;
  368.     self.dmg = 2;           // initial water damage
  369.     self.super_damage_finished = 0;
  370.     self.radsuit_finished = 0;
  371.       self.invisible_finished = 0;
  372.       self.invincible_finished = 0;
  373.     self.effects = 0;
  374.       self.impulse = 0;
  375.     DecodeLevelParms ();
  376.       self.skin = player_skin;
  377.     W_SetCurrentAmmo ();
  378.     self.attack_finished = time;
  379.     self.th_pain = player_pain;
  380.     self.th_die = PlayerDie;
  381.     self.deadflag = DEAD_NO;
  382.     self.pausetime = 0;
  383.     spot = SelectSpawnPoint ();
  384.     self.origin = spot.origin + '0 0 1';
  385.     self.angles = spot.angles;
  386.     self.fixangle = TRUE;        // turn this way immediately
  387.     setmodel (self, "progs/eyes.mdl");
  388.     modelindex_eyes = self.modelindex;
  389.     setmodel (self, "progs/player.mdl");
  390.     modelindex_player = self.modelindex;
  391.     setsize (self, VEC_HULL_MIN, VEC_HULL_MAX);
  392.     self.view_ofs = '0 0 22';
  393.     player_stand1 ();
  394.     if (deathmatch || coop)
  395.     {
  396.         makevectors(self.angles);
  397.         spawn_tfog (self.origin + v_forward*20);
  398.     }
  399.     spawn_tdeath (self.origin, self);
  400.     if (self.skin == 0) sprint(self, "Mr. Quake himself!"); else
  401.         if (self.skin == 1) sprint(self,"Hey man, nice suit! C&R?"); else
  402.     if (self.skin == 2) sprint(self, "No time to play with yourself here!"); else
  403.     if (self.skin == 3) sprint(self,"Protect the innocent, uphold your law"); else
  404.     if (self.skin == 4) sprint(self,"MC Kill Whitey"); else
  405.     if (self.skin == 5) sprint(self,"She does have a wart"); else
  406.     if (self.skin == 6) sprint(self,"I can see you"); else
  407.     if (self.skin == 7) sprint(self,"We are not ninja!"); else
  408.     if (self.skin == 8) sprint(self, "You're one pretty toad!"); else
  409.     if (self.skin == 9) sprint(self,"I'm the Predator, you're the prey!"); else
  410.     if (self.skin == 10) sprint(self, "Judge Dredd! Let's restore some order!"); else
  411.     if (self.skin == 11) sprint(self, "You are back!"); else
  412.     if (self.skin == 12) sprint(self,"Oh R2 where are you?!?"); else
  413.     if (self.skin == 13) sprint(self, "Wow Stormtrooper, you're tough!"); else
  414.     if (self.skin == 14) sprint(self,"If it isn't Boba, go get Han Solo!"); else
  415.     if (self.skin == 15) sprint(self,"Grrrrrr!"); else
  416.       if (self.skin == 16) sprint(self,"Yes your worship?"); else
  417.       if (self.skin == 17) sprint(self,"I'm on a mission from God!");
  418. };
  419.  
  420. /*QUAKED info_player_start (1 0 0) (-16 -16 -24) (16 16 24)
  421. The normal starting point for a level.
  422. */
  423. void() info_player_start =
  424. {
  425. };
  426.  
  427. /*QUAKED info_player_start2 (1 0 0) (-16 -16 -24) (16 16 24)
  428. Only used on start map for the return point from an episode.
  429. */
  430. void() info_player_start2 =
  431. {
  432. };
  433.  
  434. void() testplayerstart =
  435. {
  436. };
  437.  
  438. /*QUAKED info_player_deathmatch (1 0 1) (-16 -16 -24) (16 16 24)
  439. potential spawning position for deathmatch games
  440. */
  441. void() info_player_deathmatch =
  442. {
  443. };
  444.  
  445. /*QUAKED info_player_coop (1 0 1) (-16 -16 -24) (16 16 24)
  446. potential spawning position for coop games
  447. */
  448. void() info_player_coop =
  449. {
  450. };
  451.  
  452. void(entity c) PrintClientScore =
  453. {
  454.     if (c.frags > -10 && c.frags < 0)
  455.         bprint (" ");
  456.     else if (c.frags >= 0)
  457.     {
  458.         if (c.frags < 100)
  459.             bprint (" ");
  460.         if (c.frags < 10)
  461.             bprint (" ");
  462.     }
  463.     bprint (ftos(c.frags));
  464.     bprint (" ");
  465.     bprint (c.netname);
  466.     bprint ("\n");
  467. };
  468.  
  469. void() DumpScore =
  470. {
  471.     local entity    e, sort, walk;
  472.  
  473.     if (world.chain)
  474.         error ("DumpScore: world.chain is set");
  475.     e = find(world, classname, "player");
  476.     sort = world;
  477.     while (e)
  478.     {
  479.         if (!sort)
  480.         {
  481.             sort = e;
  482.             e.chain = world;
  483.         }
  484.         else
  485.         {
  486.             if (e.frags > sort.frags)
  487.             {
  488.                 e.chain = sort;
  489.                 sort = e;
  490.             }
  491.             else
  492.             {
  493.                 walk = sort;
  494.                 do
  495.                 {
  496.                     if (!walk.chain)
  497.                     {
  498.                         e.chain = world;
  499.                         walk.chain = e;
  500.                     }
  501.                     else if (walk.chain.frags < e.frags)
  502.                     {
  503.                         e.chain = walk.chain;
  504.                         walk.chain = e;
  505.                     }
  506.                     else
  507.                         walk = walk.chain;
  508.                 } while (walk.chain != e);
  509.             }
  510.         }
  511.         
  512.         e = find(e, classname, "player");
  513.     }
  514.     bprint ("\n");    
  515.     while (sort)
  516.     {
  517.         PrintClientScore (sort);
  518.         sort = sort.chain;
  519.     }
  520.     bprint ("\n");
  521. };
  522.  
  523. void() NextLevel =
  524. {
  525.     local entity o;
  526.  
  527.     o = find(world, classname, "trigger_changelevel");
  528.     if (!o || mapname == "start")
  529.     {    // go back to same map if no trigger_changelevel
  530.         o = spawn();
  531.         o.map = mapname;
  532.     }
  533.     nextmap = o.map;
  534.     if (o.nextthink < time)
  535.     {
  536.         o.think = execute_changelevel;
  537.         o.nextthink = time + 0.1;
  538.     }
  539. };
  540.  
  541. void() CheckRules =
  542. {
  543.     local    float        timelimit;
  544.     local    float        fraglimit;
  545.     
  546.     if (gameover)    // someone else quit the game already
  547.         return;
  548.     timelimit = cvar("timelimit") * 60;
  549.     fraglimit = cvar("fraglimit");
  550.     if (timelimit && time >= timelimit)
  551.     {
  552.                 NextLevel ();
  553.         return;
  554.     }
  555.     if (fraglimit && self.frags >= fraglimit)
  556.     {
  557.                 NextLevel ();
  558.         return;
  559.     }    
  560. };
  561.  
  562. void() PlayerDeathThink =
  563. {
  564.     local entity    old_self;
  565.     local float        forward;
  566.  
  567.     if ((self.flags & FL_ONGROUND))
  568.     {
  569.         forward = vlen (self.velocity);
  570.         forward = forward - 20;
  571.         if (forward <= 0)
  572.             self.velocity = '0 0 0';
  573.         else    
  574.             self.velocity = forward * normalize(self.velocity);
  575.     }
  576.     if (self.deadflag == DEAD_DEAD)
  577.     {
  578.         if (self.button2 || self.button1 || self.button0)
  579.             return;
  580.         self.deadflag = DEAD_RESPAWNABLE;
  581.         return;
  582.     }
  583.     if (!self.button2 && !self.button1 && !self.button0)
  584.         return;
  585.     self.button0 = 0;
  586.     self.button1 = 0;
  587.     self.button2 = 0;
  588.     respawn();
  589. };
  590.  
  591.  
  592. void() PlayerJump =
  593. {
  594.     local vector start, end;
  595.     
  596.         if (self.flags & FL_ISFEIGN)       // experimental
  597.                 return;
  598.     if (self.flags & FL_WATERJUMP)
  599.         return;
  600.     if (self.waterlevel >= 2)
  601.     {
  602.         if (self.watertype == CONTENT_WATER)
  603.             self.velocity_z = 100;
  604.         else if (self.watertype == CONTENT_SLIME)
  605.             self.velocity_z = 80;
  606.         else
  607.             self.velocity_z = 50;
  608.         if (self.swim_flag < time)
  609.         {
  610.             self.swim_flag = time + 1;
  611.             if (random() < 0.5)
  612.                 sound (self, CHAN_BODY, "misc/water1.wav", 1, ATTN_NORM);
  613.             else
  614.                 sound (self, CHAN_BODY, "misc/water2.wav", 1, ATTN_NORM);
  615.         }
  616.         return;
  617.     }
  618.     if (!(self.flags & FL_ONGROUND))
  619.         return;
  620.     if ( !(self.flags & FL_JUMPRELEASED) )
  621.         return;        // don't pogo stick
  622.     self.flags = self.flags - (self.flags & FL_JUMPRELEASED);
  623.     self.flags = self.flags - FL_ONGROUND;    // don't stairwalk
  624.     self.button2 = 0;
  625.     sound (self, CHAN_BODY, "player/plyrjmp8.wav", 1, ATTN_NORM);
  626.     self.velocity_z = self.velocity_z + 270;
  627. };
  628.  
  629.  
  630. .float    dmgtime;
  631.  
  632. void() WaterMove =
  633. {
  634.     if (self.movetype == MOVETYPE_NOCLIP)
  635.         return;
  636.     if (self.health < 0)
  637.         return;
  638.     if (self.waterlevel != 3)
  639.     {
  640.         if (self.air_finished < time)
  641.             sound (self, CHAN_VOICE, "player/gasp2.wav", 1, ATTN_NORM);
  642.         else if (self.air_finished < time + 9)
  643.             sound (self, CHAN_VOICE, "player/gasp1.wav", 1, ATTN_NORM);
  644.         self.air_finished = time + 12;
  645.         self.dmg = 2;
  646.     }
  647.         else if (self.air_finished < time)
  648.     {    // drown!
  649.         if (self.pain_finished < time)
  650.         {
  651.             self.dmg = self.dmg + 2;
  652.             if (self.dmg > 15)
  653.                 self.dmg = 10;
  654.                         self.radsuit_finished = -1;  //for no armor save
  655.             T_Damage (self, world, world, self.dmg);
  656.                         self.radsuit_finished = 0;  //restore so other damage
  657.                                                     //uses armor save
  658.             self.pain_finished = time + 1;
  659.         }
  660.     }
  661.     if (!self.waterlevel)
  662.     {
  663.         if (self.flags & FL_INWATER)
  664.         {    
  665.             // play leave water sound
  666.             sound (self, CHAN_BODY, "misc/outwater.wav", 1, ATTN_NORM);
  667.             self.flags = self.flags - FL_INWATER;
  668.         }
  669.         return;
  670.     }
  671.     if (self.watertype == CONTENT_LAVA)
  672.     {    // do damage
  673.         if (self.dmgtime < time)
  674.         {
  675.             if (self.radsuit_finished > time)
  676.                 self.dmgtime = time + 1;
  677.             else
  678.                 self.dmgtime = time + 0.2;
  679.             T_Damage (self, world, world, 10*self.waterlevel);
  680.         }
  681.     }
  682.     else if (self.watertype == CONTENT_SLIME)
  683.     {    // do damage
  684.         if (self.dmgtime < time && self.radsuit_finished < time)
  685.         {
  686.             self.dmgtime = time + 1;
  687.             T_Damage (self, world, world, 4*self.waterlevel);
  688.         }
  689.     }
  690.     if ( !(self.flags & FL_INWATER) )
  691.     {    
  692.         if (self.watertype == CONTENT_LAVA)
  693.             sound (self, CHAN_BODY, "player/inlava.wav", 1, ATTN_NORM);
  694.         if (self.watertype == CONTENT_WATER)
  695.             sound (self, CHAN_BODY, "player/inh2o.wav", 1, ATTN_NORM);
  696.         if (self.watertype == CONTENT_SLIME)
  697.             sound (self, CHAN_BODY, "player/slimbrn2.wav", 1, ATTN_NORM);
  698.         self.flags = self.flags + FL_INWATER;
  699.         self.dmgtime = 0;
  700.     }
  701.          if (! (self.flags & FL_WATERJUMP) )
  702.         self.velocity = self.velocity - 0.8*self.waterlevel*frametime*self.velocity;
  703. };
  704.  
  705. void() CheckWaterJump =
  706. {
  707.     local vector start, end;
  708.  
  709.     makevectors (self.angles);
  710.     start = self.origin;
  711.     start_z = start_z + 8; 
  712.     v_forward_z = 0;
  713.     normalize(v_forward);
  714.     end = start + v_forward*24;
  715.     traceline (start, end, TRUE, self);
  716.     if (trace_fraction < 1)
  717.     {    // solid at waist
  718.         start_z = start_z + self.maxs_z - 8;
  719.         end = start + v_forward*24;
  720.         self.movedir = trace_plane_normal * -50;
  721.         traceline (start, end, TRUE, self);
  722.         if (trace_fraction == 1)
  723.         {    // open at eye level
  724.             self.flags = self.flags | FL_WATERJUMP;
  725.             self.velocity_z = 225;
  726.             self.flags = self.flags - (self.flags & FL_JUMPRELEASED);
  727.             self.teleport_time = time + 2;    // safety net
  728.             return;
  729.         }
  730.     }
  731. };
  732.  
  733. void() PlayerPreThink =
  734. {
  735.     local    float    mspeed, aspeed;
  736.     local    float    r;
  737.  
  738.     if (intermission_running)
  739.     {
  740.         IntermissionThink ();    // otherwise a button could be missed between
  741.         return;                    // the think tics
  742.     }
  743.     if (self.view_ofs == '0 0 0')
  744.         return;        // intermission or finale
  745.         makevectors (self.v_angle);             // is this still used
  746.      CheckRules ();
  747.     WaterMove ();
  748.     if (self.waterlevel == 2)
  749.         CheckWaterJump ();
  750.     if (self.deadflag >= DEAD_DEAD)
  751.     {
  752.         PlayerDeathThink ();
  753.         return;
  754.     }
  755.     if (self.deadflag == DEAD_DYING)
  756.         return;    // dying, so do nothing
  757.     if (self.button2)
  758.     {
  759.         PlayerJump ();
  760.     }
  761.     else
  762.         self.flags = self.flags | FL_JUMPRELEASED;
  763.     if (time < self.pausetime)
  764.         self.velocity = '0 0 0';
  765. };
  766.     
  767. void() CheckPowerups =
  768. {
  769.     if (self.health <= 0)
  770.         return;
  771.     if (self.invisible_finished)
  772.     {
  773.         if (self.invisible_sound < time)
  774.         {
  775.             sound (self, CHAN_AUTO, "items/inv3.wav", 0.5, ATTN_IDLE);
  776.             self.invisible_sound = time + ((random() * 3) + 1);
  777.         }
  778.         if (self.invisible_finished < time + 3)
  779.         {
  780.             if (self.invisible_time == 1)
  781.             {
  782.                 sprint (self, "Ring of Shadows magic is fading\n");
  783.                 stuffcmd (self, "bf\n");
  784.                 sound (self, CHAN_AUTO, "items/inv2.wav", 1, ATTN_NORM);
  785.                 self.invisible_time = time + 1;
  786.             }
  787.             if (self.invisible_time < time)
  788.             {
  789.                 self.invisible_time = time + 1;
  790.                 stuffcmd (self, "bf\n");
  791.             }
  792.         }
  793.         if (self.invisible_finished < time)
  794.         {    // just stopped
  795.             self.items = self.items - IT_INVISIBILITY;
  796.             self.invisible_finished = 0;
  797.             self.invisible_time = 0;
  798.         }
  799.         self.frame = 0;
  800.         self.modelindex = modelindex_eyes;
  801.     }
  802.     else
  803.         self.modelindex = modelindex_player;    // don't use eyes
  804.     if (self.invincible_finished)
  805.     {
  806.         if (self.invincible_finished < time + 3)
  807.         {
  808.             if (self.invincible_time == 1)
  809.             {
  810.                 sprint (self, "Protection is almost burned out\n");
  811.                 stuffcmd (self, "bf\n");
  812.                 sound (self, CHAN_AUTO, "items/protect2.wav", 1, ATTN_NORM);
  813.                 self.invincible_time = time + 1;
  814.             }
  815.             if (self.invincible_time < time)
  816.             {
  817.                 self.invincible_time = time + 1;
  818.                 stuffcmd (self, "bf\n");
  819.             }
  820.         }
  821.         if (self.invincible_finished < time)
  822.         {    // just stopped
  823.             self.items = self.items - IT_INVULNERABILITY;
  824.             self.invincible_time = 0;
  825.             self.invincible_finished = 0;
  826.         }
  827.         if (self.invincible_finished > time)
  828.             self.effects = self.effects | EF_DIMLIGHT;
  829.         else
  830.             self.effects = self.effects - (self.effects & EF_DIMLIGHT);
  831.     }
  832.     if (self.super_damage_finished)
  833.     {
  834.         if (self.super_damage_finished < time + 3)
  835.         {
  836.             if (self.super_time == 1)
  837.             {
  838.                 sprint (self, "Quad Damage is wearing off\n");
  839.                 stuffcmd (self, "bf\n");
  840.                 sound (self, CHAN_AUTO, "items/damage2.wav", 1, ATTN_NORM);
  841.                 self.super_time = time + 1;
  842.             }      
  843.             if (self.super_time < time)
  844.             {
  845.                 self.super_time = time + 1;
  846.                 stuffcmd (self, "bf\n");
  847.             }
  848.         }
  849.         if (self.super_damage_finished < time)
  850.         {    // just stopped
  851.             self.items = self.items - IT_QUAD;
  852.             self.super_damage_finished = 0;
  853.             self.super_time = 0;
  854.         }
  855.         if (self.super_damage_finished > time)
  856.             self.effects = self.effects | EF_DIMLIGHT;
  857.         else
  858.             self.effects = self.effects - (self.effects & EF_DIMLIGHT);
  859.     }    
  860.     if (self.radsuit_finished)
  861.     {
  862.         self.air_finished = time + 12;        // don't drown
  863.         if (self.radsuit_finished < time + 3)
  864.         {
  865.             if (self.rad_time == 1)
  866.             {
  867.                 sprint (self, "Air supply in Biosuit expiring\n");
  868.                 stuffcmd (self, "bf\n");
  869.                 sound (self, CHAN_AUTO, "items/suit2.wav", 1, ATTN_NORM);
  870.                 self.rad_time = time + 1;
  871.             }
  872.             if (self.rad_time < time)
  873.             {
  874.                 self.rad_time = time + 1;
  875.                 stuffcmd (self, "bf\n");
  876.             }
  877.         }
  878.         if (self.radsuit_finished < time)
  879.         {    // just stopped
  880.             self.items = self.items - IT_SUIT;
  881.             self.rad_time = 0;
  882.             self.radsuit_finished = 0;
  883.         }
  884.     }    
  885. };
  886.  
  887. void() PlayerPostThink =
  888. {
  889.     local    float    mspeed, aspeed;
  890.     local    float    r;
  891.  
  892.     if (self.view_ofs == '0 0 0')
  893.         return;        // intermission or finale
  894.     if (self.deadflag)
  895.         return;
  896.     W_WeaponFrame ();
  897.     if ((self.jump_flag < -300) && (self.flags & FL_ONGROUND) && (self.health > 0))
  898.     {
  899.         if (self.watertype == CONTENT_WATER)
  900.             sound (self, CHAN_BODY, "player/h2ojump.wav", 1, ATTN_NORM);
  901.         else if (self.jump_flag < -650)
  902.         {
  903.             self.th_pain = player_fall;
  904.             T_Damage (self, world, world, 5); 
  905.             self.th_pain = player_pain;
  906.             sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  907.             self.deathtype = "falling";
  908.         }
  909.         else
  910.             sound (self, CHAN_VOICE, "player/land.wav", 1, ATTN_NORM);
  911.         self.jump_flag = 0;
  912.     }
  913.     if (!(self.flags & FL_ONGROUND))
  914.         self.jump_flag = self.velocity_z;
  915.     CheckPowerups ();
  916. };
  917.  
  918. void() ClientConnect =
  919. {
  920.     bprint (self.netname);
  921.     bprint (" entered the game\n");
  922.     
  923.     if (intermission_running)
  924.         ExitIntermission ();
  925. };
  926.  
  927. void() ClientDisconnect =
  928. {
  929.     if (gameover)
  930.         return;
  931.     bprint (self.netname);
  932.     bprint (" left the game with ");
  933.     bprint (ftos(self.frags));
  934.     bprint (" frags\n");
  935.     sound (self, CHAN_BODY, "player/tornoff2.wav", 1, ATTN_NONE);
  936.     set_suicide_frame ();
  937. };
  938.  
  939. void(entity targ, entity attacker) ClientObituary =
  940. {
  941.     local    float rnum;
  942.     local    string deathstring, deathstring2;
  943.     rnum = random();
  944.  
  945.         if (targ.classname == "skinchange")
  946.         {
  947.                 bprint (targ.netname);
  948.                 bprint (" tried to change teams\n");
  949.                 targ.frags = targ.frags - 2;
  950.                 return;
  951.         } else if (targ.classname == "team_kill")
  952.         {
  953.                 bprint (targ.netname);
  954.                 bprint (" has paid the price of treachery!\n");
  955.                 targ.frags = targ.frags - 2;
  956.                 return;
  957.         } else if (targ.classname == "player")
  958.     {
  959.         if (attacker.classname == "teledeath")
  960.         {
  961.             bprint (targ.netname);
  962.             bprint (" was telefragged by ");
  963.             bprint (attacker.owner.netname);
  964.             bprint ("\n");
  965.             attacker.owner.frags = attacker.owner.frags + 1;
  966.             return;
  967.         }
  968.         if (attacker.classname == "teledeath2")
  969.         {
  970.             bprint ("Satan's power deflects ");
  971.             bprint (targ.netname);
  972.             bprint ("'s telefrag\n");
  973.                         targ.frags = targ.frags - 1;
  974.             return;
  975.         }
  976.         if (attacker.classname == "player")
  977.         {
  978.             if (targ == attacker)
  979.             {
  980.                 attacker.frags = attacker.frags - 1;
  981.                 bprint (targ.netname);
  982.                                 if (targ.weapon == IT_THROWING_AXE)
  983.                                 {
  984.                                         bprint (" axed a question.\n");
  985.                                         return;
  986.                                 }
  987.                 if (targ.weapon == 64 && targ.waterlevel > 1)
  988.                 {
  989.                     bprint (" discharges into the water.\n");
  990.                     return;
  991.                 }
  992.                 if (targ.weapon == 16)
  993.                     bprint (" tries to put the pin back in\n");
  994.                                 else if (rnum > 0.5)
  995.                     bprint (" becomes bored with life\n");
  996.                 else
  997.                     bprint (" checks if his weapon is loaded\n");
  998.                 return;
  999.             }
  1000.             else if ( (teamplay == 3) && (targ.team == attacker.team) )
  1001.             {
  1002.                 bprint (targ.netname);
  1003.                 bprint (" was TeamMateFragged by ");
  1004.                 bprint (attacker.owner.netname);
  1005.                 bprint ("\n");
  1006.                                 TeamPlayKill(attacker);
  1007.                 return;
  1008.             }
  1009.             else if ( (teamplay == 4) && (targ.skin == attacker.skin) )
  1010.                         {
  1011.                 bprint (targ.netname);
  1012.                 bprint (" was TeamMateFragged by ");
  1013.                 bprint (attacker.owner.netname);
  1014.                 bprint ("\n");
  1015.                                 TeamPlayKill(attacker);
  1016.                 return;
  1017.             }
  1018.             else  
  1019.             {
  1020.                 attacker.frags = attacker.frags + 1;
  1021.                                 rnum = attacker.weapon;
  1022.                                 if (rnum == IT_THROWING_AXE)
  1023.                                 {
  1024.                                        deathstring = " was butchered by ";
  1025.                                        deathstring2 = "'s throwing axe!\n";
  1026.                                 }
  1027.                 if (rnum == IT_AXE)
  1028.                 {
  1029.                     deathstring = " was ax-murdered by ";
  1030.                     deathstring2 = "\n";
  1031.                 }
  1032.                                 if (rnum == IT_MORNINGSTAR)
  1033.                                 {
  1034.                                         deathstring = " was disemboweled by ";
  1035.                                         deathstring2 = "\n";
  1036.                                 }
  1037.                 if (rnum == IT_SHOTGUN)
  1038.                 {
  1039.                     deathstring = " chewed on ";
  1040.                     deathstring2 = "'s boomstick\n";
  1041.                 }
  1042.                 if (rnum == IT_SUPER_SHOTGUN)
  1043.                 {
  1044.                     deathstring = " ate 2 loads of ";
  1045.                     deathstring2 = "'s buckshot\n";
  1046.                 }
  1047.                 if (rnum == IT_NAILGUN)
  1048.                 {
  1049.                     deathstring = " was nailed by ";
  1050.                     deathstring2 = "\n";
  1051.                 }
  1052.                 if (rnum == IT_SUPER_NAILGUN)
  1053.                 {
  1054.                     deathstring = " was punctured by ";
  1055.                     deathstring2 = "\n";
  1056.                 }
  1057.                 if (rnum == IT_GRENADE_LAUNCHER)
  1058.                 {
  1059.                     if (targ.health < -40)
  1060.                     {
  1061.                         deathstring = " was gibbed by ";
  1062.                         deathstring2 = "'s grenade\n";
  1063.                     }
  1064.                                         else
  1065.                                         {
  1066.                                                 deathstring = " eats ";
  1067.                                                 deathstring2 = "'s pineapple\n";
  1068.                                         }
  1069.                 }
  1070.                 if (rnum == IT_ROCKET_LAUNCHER)
  1071.                 {
  1072.                     if (targ.health < -40)
  1073.                     {
  1074.                         deathstring = " was gibbed by ";
  1075.                         deathstring2 = "'s rocket\n" ;
  1076.                     }
  1077.                                         else
  1078.                                         {
  1079.                                                 deathstring = " rides ";
  1080.                                                 deathstring2 = "'s rocket\n";
  1081.                                         }
  1082.                 }
  1083.                 if (rnum == IT_LIGHTNING)
  1084.                 {
  1085.                     deathstring = " accepts ";
  1086.                     if (attacker.waterlevel > 1)
  1087.                         deathstring2 = "'s discharge\n";
  1088.                     else
  1089.                         deathstring2 = "'s shaft\n";
  1090.                 }
  1091.                 bprint (targ.netname);
  1092.                 bprint (deathstring);
  1093.                 bprint (attacker.netname);
  1094.                 bprint (deathstring2);
  1095.             }
  1096.             return;
  1097.         }
  1098.         else
  1099.         {
  1100.             targ.frags = targ.frags - 1;        // killed self
  1101.             rnum = targ.watertype;
  1102.             bprint (targ.netname);
  1103.             if (rnum == -3)
  1104.             {
  1105.                 if (random() < 0.5)
  1106.                     bprint (" sleeps with the fishes\n");
  1107.                 else
  1108.                     bprint (" sucks it down\n");
  1109.                 return;
  1110.             }
  1111.             else if (rnum == -4)
  1112.             {
  1113.                 if (random() < 0.5)
  1114.                     bprint (" gulped a load of slime\n");
  1115.                 else
  1116.                     bprint (" can't exist on slime alone\n");
  1117.                 return;
  1118.             }
  1119.             else if (rnum == -5)
  1120.             {
  1121.                 if (targ.health < -15)
  1122.                 {
  1123.                     bprint (" burst into flames\n");
  1124.                     return;
  1125.                 }
  1126.                 if (random() < 0.5)
  1127.                     bprint (" turned into hot slag\n");
  1128.                 else
  1129.                     bprint (" visits the Volcano God\n");
  1130.                 return;
  1131.             }
  1132.             if (attacker.flags & FL_MONSTER)
  1133.             {
  1134.                 if (attacker.classname == "monster_army")
  1135.                     bprint (" was shot by a Grunt\n");
  1136.                 if (attacker.classname == "monster_demon1")
  1137.                     bprint (" was eviscerated by a Fiend\n");
  1138.                 if (attacker.classname == "monster_dog")
  1139.                     bprint (" was mauled by a Rottweiler\n");
  1140.                 if (attacker.classname == "monster_dragon")
  1141.                     bprint (" was fried by a Dragon\n");
  1142.                 if (attacker.classname == "monster_enforcer")
  1143.                     bprint (" was blasted by an Enforcer\n");
  1144.                 if (attacker.classname == "monster_fish")
  1145.                     bprint (" was fed to the Rotfish\n");
  1146.                 if (attacker.classname == "monster_hell_knight")
  1147.                     bprint (" was slain by a Death Knight\n");
  1148.                 if (attacker.classname == "monster_knight")
  1149.                     bprint (" was slashed by a Knight\n");
  1150.                 if (attacker.classname == "monster_ogre")
  1151.                     bprint (" was destroyed by an Ogre\n");
  1152.                 if (attacker.classname == "monster_oldone")
  1153.                     bprint (" became one with Shub-Niggurath\n");
  1154.                 if (attacker.classname == "monster_shalrath")
  1155.                     bprint (" was exploded by a Vore\n");
  1156.                 if (attacker.classname == "monster_shambler")
  1157.                     bprint (" was smashed by a Shambler\n");
  1158.                 if (attacker.classname == "monster_tarbaby")
  1159.                     bprint (" was slimed by a Spawn\n");
  1160.                 if (attacker.classname == "monster_vomit")
  1161.                     bprint (" was vomited on by a Vomitus\n");
  1162.                 if (attacker.classname == "monster_wizard")
  1163.                     bprint (" was scragged by a Scrag\n");
  1164.                 if (attacker.classname == "monster_zombie")
  1165.                     bprint (" joins the Zombies\n");
  1166.                 return;
  1167.             }
  1168.             if (attacker.classname == "explo_box")
  1169.             {
  1170.                 bprint (" blew up\n");
  1171.                 return;
  1172.             }
  1173.                         if (attacker.classname == "explo_pack")
  1174.             {
  1175.                                 bprint (" ate backpack\n");
  1176.                 return;
  1177.             }
  1178.             if (attacker.solid == SOLID_BSP && attacker != world)
  1179.             {    
  1180.                 bprint (" was squished\n");
  1181.                 return;
  1182.             }
  1183.             if (targ.deathtype == "falling")
  1184.             {
  1185.                 targ.deathtype = "";
  1186.                 bprint (" fell to his death\n");
  1187.                 return;
  1188.             }
  1189.             if (attacker.classname == "trap_shooter" || attacker.classname == "trap_spikeshooter")
  1190.             {
  1191.                 bprint (" was spiked\n");
  1192.                 return;
  1193.             }
  1194.             if (attacker.classname == "fireball")
  1195.             {
  1196.                 bprint (" ate a lavaball\n");
  1197.                 return;
  1198.             }
  1199.             if (attacker.classname == "trigger_changelevel")
  1200.             {
  1201.                 bprint (" tried to leave\n");
  1202.                 return;
  1203.             }
  1204.             bprint (" died\n");
  1205.         }
  1206.     }
  1207. };
  1208.  
  1209.