home *** CD-ROM | disk | FTP | other *** search
/ Superpower (Alt) / SUPERPOWER.iso / q / patch / mbq067 / client.qc < prev    next >
Encoding:
Text File  |  1996-08-27  |  48.5 KB  |  1,977 lines

  1.  
  2. // prototypes
  3. void () W_WeaponFrame;
  4. void() W_SetCurrentAmmo;
  5. void() player_pain;
  6. void() player_stand1;
  7. void (vector org) spawn_tfog;
  8. void (vector org, entity death_owner) spawn_tdeath;
  9.  
  10. float   modelindex_eyes, modelindex_player;
  11.  
  12. /*
  13. =============================================================================
  14.  
  15.                 LEVEL CHANGING / INTERMISSION
  16.  
  17. =============================================================================
  18. */
  19.  
  20. float   intermission_running;
  21. float   intermission_exittime;
  22.  
  23. /*QUAKED info_intermission (1 0.5 0.5) (-16 -16 -16) (16 16 16)
  24. This is the camera point for the intermission.
  25. Use mangle instead of angle, so you can set pitch or roll as well as yaw.  'pitch roll yaw'
  26. */
  27. void() info_intermission =
  28. {
  29. };
  30.  
  31.  
  32.  
  33. void() SetChangeParms =
  34. {
  35. // remove items
  36.     self.items = self.items - (self.items & (IT_KEY1 | IT_KEY2 | IT_INVISIBILITY | IT_INVULNERABILITY | IT_SUIT | IT_QUAD) );
  37.     self.items2 = self.items2 - (self.items2 & IT2_MEGAPOWER);
  38.  
  39. // cap super health
  40.     if (self.health > 100)
  41.         self.health = 100;
  42.     if (self.health < 50)
  43.         self.health = 50;
  44.     parm1 = self.items;
  45.     parm2 = self.health;
  46.     parm3 = self.armorvalue;
  47.     if (self.ammo_shells < 25)
  48.         parm4 = 25;
  49.     else
  50.         parm4 = self.ammo_shells;
  51.     parm5 = self.ammo_nails;
  52.     parm6 = self.ammo_rockets;
  53.     parm7 = self.ammo_cells;
  54.     parm8 = self.weapon;
  55.     parm9 = self.armortype * 100;
  56. };
  57.  
  58. void() SetNewParms =
  59. {
  60.     parm1 = IT_SHOTGUN | IT_AXE;
  61.     parm2 = 100;
  62.     parm3 = 0;
  63.     parm4 = 25;
  64.     parm5 = 0;
  65.     parm6 = 0;
  66.     parm6 = 0;
  67.     parm8 = 1;
  68.     parm9 = 0;
  69. };
  70.  
  71. void() DecodeLevelParms =
  72. {
  73.     if (serverflags)
  74.     {
  75.         if (world.model == "maps/start.bsp")
  76.             SetNewParms ();         // take away all stuff on starting new episode
  77.     }
  78.     
  79.     self.items = parm1;
  80.     self.items2 = 0;
  81.     self.health = parm2;
  82.     self.armorvalue = parm3;
  83.     self.ammo_shells = parm4;
  84.     self.ammo_nails = parm5;
  85.     self.ammo_rockets = parm6;
  86.     self.ammo_cells = parm7;
  87.     self.weapon = parm8;
  88.     self.armortype = parm9 * 0.01;
  89. };
  90.  
  91. /*
  92. ============
  93. FindIntermission
  94.  
  95. Returns the entity to view from
  96. ============
  97. */
  98. entity() FindIntermission =
  99. {
  100.     local   entity spot;
  101.     local   float cyc;
  102.  
  103. // look for info_intermission first
  104.     spot = find (world, classname, "info_intermission");
  105.     if (spot)
  106.     {       // pick a random one
  107.         cyc = random() * 4;
  108.         while (cyc > 1)
  109.         {
  110.             spot = find (spot, classname, "info_intermission");
  111.             if (!spot)
  112.                 spot = find (spot, classname, "info_intermission");
  113.             cyc = cyc - 1;
  114.         }
  115.         return spot;
  116.     }
  117.  
  118. // then look for the start position
  119.     spot = find (world, classname, "info_player_start");
  120.     if (spot)
  121.         return spot;
  122.     
  123. // testinfo_player_start is only found in regioned levels
  124.     spot = find (world, classname, "testplayerstart");
  125.     if (spot)
  126.         return spot;
  127.     
  128.     objerror ("FindIntermission: no spot");
  129. };
  130.  
  131.  
  132. string nextmap;
  133. void() GotoNextMap =
  134. {
  135.     if (cvar("samelevel"))  // if samelevel is set, stay on same level
  136.         changelevel (mapname);
  137.     else
  138.         changelevel (nextmap);
  139. };
  140.  
  141.  
  142. void() ExitIntermission =
  143. {
  144. // skip any text in deathmatch
  145.     if (deathmatch)
  146.     {
  147.         GotoNextMap ();
  148.         return;
  149.     }
  150.     
  151.     intermission_exittime = time + 1;
  152.     intermission_running = intermission_running + 1;
  153.  
  154. //
  155. // run some text if at the end of an episode
  156. //
  157.     if (intermission_running == 2)
  158.     {
  159.         if (world.model == "maps/e1m7.bsp")
  160.         {
  161.             WriteByte (MSG_ALL, SVC_CDTRACK);
  162.             WriteByte (MSG_ALL, 2);
  163.             WriteByte (MSG_ALL, 3);
  164.             if (!cvar("registered"))
  165.             {
  166.                 WriteByte (MSG_ALL, SVC_FINALE);
  167.                 WriteString (MSG_ALL, "As the corpse of the monstrous entity\nChthon sinks back into the lava whence\nit rose, you grip the Rune of Earth\nMagic tightly. Now that you have\nconquered the Dimension of the Doomed,\nrealm of Earth Magic, you are ready to\ncomplete your task in the other three\nhaunted lands of Quake. Or are you? If\nyou don't register Quake, you'll never\nknow what awaits you in the Realm of\nBlack Magic, the Netherworld, and the\nElder World!");
  168.             }
  169.             else
  170.             {
  171.                 WriteByte (MSG_ALL, SVC_FINALE);
  172.                 WriteString (MSG_ALL, "As the corpse of the monstrous entity\nChthon sinks back into the lava whence\nit rose, you grip the Rune of Earth\nMagic tightly. Now that you have\nconquered the Dimension of the Doomed,\nrealm of Earth Magic, you are ready to\ncomplete your task. A Rune of magic\npower lies at the end of each haunted\nland of Quake. Go forth, seek the\ntotality of the four Runes!");
  173.             }
  174.             return;
  175.         }
  176.         else if (world.model == "maps/e2m6.bsp")
  177.         {
  178.             WriteByte (MSG_ALL, SVC_CDTRACK);
  179.             WriteByte (MSG_ALL, 2);
  180.             WriteByte (MSG_ALL, 3);
  181.  
  182.             WriteByte (MSG_ALL, SVC_FINALE);
  183.             WriteString (MSG_ALL, "The Rune of Black Magic throbs evilly in\nyour hand and whispers dark thoughts\ninto your brain. You learn the inmost\nlore of the Hell-Mother; Shub-Niggurath!\nYou now know that she is behind all the\nterrible plotting which has led to so\nmuch death and horror. But she is not\ninviolate! Armed with this Rune, you\nrealize that once all four Runes are\ncombined, the gate to Shub-Niggurath's\nPit will open, and you can face the\nWitch-Goddess herself in her frightful\notherworld cathedral.");
  184.             return;
  185.         }
  186.         else if (world.model == "maps/e3m6.bsp")
  187.         {
  188.             WriteByte (MSG_ALL, SVC_CDTRACK);
  189.             WriteByte (MSG_ALL, 2);
  190.             WriteByte (MSG_ALL, 3);
  191.  
  192.             WriteByte (MSG_ALL, SVC_FINALE);
  193.             WriteString (MSG_ALL, "The charred viscera of diabolic horrors\nbubble viscously as you seize the Rune\nof Hell Magic. Its heat scorches your\nhand, and its terrible secrets blight\nyour mind. Gathering the shreds of your\ncourage, you shake the devil's shackles\nfrom your soul, and become ever more\nhard and determined to destroy the\nhideous creatures whose mere existence\nthreatens the souls and psyches of all\nthe population of Earth.");
  194.             return;
  195.         }
  196.         else if (world.model == "maps/e4m7.bsp")
  197.         {
  198.             WriteByte (MSG_ALL, SVC_CDTRACK);
  199.             WriteByte (MSG_ALL, 2);
  200.             WriteByte (MSG_ALL, 3);
  201.  
  202.             WriteByte (MSG_ALL, SVC_FINALE);
  203.             WriteString (MSG_ALL, "Despite the awful might of the Elder\nWorld, you have achieved the Rune of\nElder Magic, capstone of all types of\narcane wisdom. Beyond good and evil,\nbeyond life and death, the Rune\npulsates, heavy with import. Patient and\npotent, the Elder Being Shub-Niggurath\nweaves her dire plans to clear off all\nlife from the Earth, and bring her own\nfoul offspring to our world! For all the\ndwellers in these nightmare dimensions\nare her descendants! Once all Runes of\nmagic power are united, the energy\nbehind them will blast open the Gateway\nto Shub-Niggurath, and you can travel\nthere to foil the Hell-Mother's plots\nin person.");
  204.             return;
  205.         }
  206.  
  207.         GotoNextMap();
  208.     }
  209.     
  210.     if (intermission_running == 3)
  211.     {
  212.         if (!cvar("registered"))
  213.         {       // shareware episode has been completed, go to sell screen
  214.             WriteByte (MSG_ALL, SVC_SELLSCREEN);
  215.             return;
  216.         }
  217.         
  218.         if ( (serverflags&15) == 15)
  219.         {
  220.             WriteByte (MSG_ALL, SVC_FINALE);
  221.             WriteString (MSG_ALL, "Now, you have all four Runes. You sense\ntremendous invisible forces moving to\nunseal ancient barriers. Shub-Niggurath\nhad hoped to use the Runes Herself to\nclear off the Earth, but now instead,\nyou will use them to enter her home and\nconfront her as an avatar of avenging\nEarth-life. If you defeat her, you will\nbe remembered forever as the savior of\nthe planet. If she conquers, it will be\nas if you had never been born.");
  222.             return;
  223.         }
  224.         
  225.     }
  226.  
  227.     GotoNextMap();
  228. };
  229.  
  230. /*
  231. ============
  232. IntermissionThink
  233.  
  234. When the player presses attack or jump, change to the next level
  235. ============
  236. */
  237. void() IntermissionThink =
  238. {
  239.     if (time < intermission_exittime)
  240.         return;
  241.  
  242.     if (!self.button0 && !self.button1 && !self.button2)
  243.         return;
  244.     
  245.     ExitIntermission ();
  246. };
  247.  
  248. void() execute_changelevel =
  249. {
  250.     local entity    pos;
  251.  
  252.     intermission_running = 1;
  253.     
  254. // enforce a wait time before allowing changelevel
  255.     if (deathmatch)
  256.         intermission_exittime = time + 5;
  257.     else
  258.         intermission_exittime = time + 2;
  259.  
  260.     WriteByte (MSG_ALL, SVC_CDTRACK);
  261.     WriteByte (MSG_ALL, 3);
  262.     WriteByte (MSG_ALL, 3);
  263.     
  264.     pos = FindIntermission ();
  265.  
  266.     other = find (world, classname, "player");
  267.     while (other != world)
  268.     {
  269.         other.view_ofs = '0 0 0';
  270.         other.angles = other.v_angle = pos.mangle;
  271.         other.fixangle = TRUE;          // turn this way immediately
  272.         other.nextthink = time + 0.5;
  273.         other.takedamage = DAMAGE_NO;
  274.         other.solid = SOLID_NOT;
  275.         other.movetype = MOVETYPE_NONE;
  276.         other.modelindex = 0;
  277.         setorigin (other, pos.origin);
  278.         other = find (other, classname, "player");
  279.     }       
  280.     WriteByte (MSG_ALL, SVC_INTERMISSION);
  281. };
  282.  
  283.  
  284. void() changelevel_touch =
  285. {
  286.     local entity    pos;
  287.     local entity    team0,team1,found;
  288.     local float     found0,found1;
  289.  
  290.  
  291.     if (other.classname != "player")
  292.         return;
  293.  
  294.     if (cvar("noexit"))
  295.     {
  296.         T_Damage (other, self, self, 50000);
  297.         return;
  298.     }
  299.     bprint (other.netname);
  300.     bprint (" exited the level\n");
  301.     
  302.     if (teamplay == 8)
  303.     {
  304.         found=find(world,classname,"player");
  305.         
  306.         found0=FALSE;
  307.         found1=FALSE;
  308.  
  309.         while(found)
  310.         {
  311.             if (found.team == 0 && !(found0))
  312.             {        
  313.                 stuffcmd(found,"name White Team\n");
  314.                 found.netname = "White Team";
  315.                 found0=TRUE;
  316.                 team0=found;
  317.             }
  318.             if (found.team == 1 && !(found1))
  319.             {        
  320.                 stuffcmd(found,"name Gold Team\n");
  321.                 found.netname = "Gold Team";
  322.                 found1=TRUE;
  323.                 team1=found;
  324.             }
  325.             found=found.chain;
  326.         }
  327.         
  328.         found=find(world,classname,"player");
  329.         
  330.         while(found)
  331.         {
  332.             if (found.team == 0 && found != team0)
  333.                 team0.frags = team0.frags + found.frags;
  334.             if (found.team == 1 && found != team1)
  335.                 team1.frags = team1.frags + found.frags;        
  336.             found=found.chain;
  337.         }
  338.     
  339.     }
  340.     
  341.     nextmap = self.map;
  342.  
  343.     SUB_UseTargets ();
  344.  
  345.     if ( (self.spawnflags & 1) && (deathmatch == 0) )
  346.     {       // NO_INTERMISSION
  347.         GotoNextMap();
  348.         return;
  349.     }
  350.     
  351.     self.touch = SUB_Null;
  352.  
  353. // we can't move people right now, because touch functions are called
  354. // in the middle of C movement code, so set a think time to do it
  355.     self.think = execute_changelevel;
  356.     if (teamplay != 8)
  357.         self.nextthink = time + 0.1;
  358.     else
  359.         self.nextthink = time + 3;
  360. };
  361.  
  362. /*QUAKED trigger_changelevel (0.5 0.5 0.5) ? NO_INTERMISSION
  363. 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.
  364. */
  365. void() trigger_changelevel =
  366. {
  367.     if (!self.map)
  368.         objerror ("chagnelevel trigger doesn't have map");
  369.     
  370.     InitTrigger ();
  371.     self.touch = changelevel_touch;
  372. };
  373.  
  374.  
  375. /*
  376. =============================================================================
  377.  
  378.                 PLAYER GAME EDGE FUNCTIONS
  379.  
  380. =============================================================================
  381. */
  382.  
  383. void() set_suicide_frame;
  384.  
  385. // called by ClientKill and DeadThink
  386. void() respawn =
  387. {
  388.     if (coop)
  389.     {
  390.         // make a copy of the dead body for appearances sake
  391.         CopyToBodyQue (self);
  392.         // get the spawn parms as they were at level start
  393.         setspawnparms (self);
  394.         // respawn              
  395.         PutClientInServer ();
  396.     }
  397.     else if (deathmatch)
  398.     {
  399.         // make a copy of the dead body for appearances sake
  400.         CopyToBodyQue (self);
  401.         // set default spawn parms
  402.         SetNewParms ();
  403.         // respawn              
  404.         PutClientInServer ();
  405.     }
  406.     else
  407.     {       // restart the entire server
  408.         localcmd ("restart\n");
  409.     }
  410. };
  411.  
  412.  
  413. /*
  414. ============
  415. ClientKill
  416.  
  417. Player entered the suicide command
  418. ============
  419. */
  420. void() ClientKill =
  421. {
  422.     bprint (self.netname);
  423.     bprint (" suicides\n");
  424.     set_suicide_frame ();
  425.     self.modelindex = modelindex_player;
  426.     self.frags = self.frags - 2;    // extra penalty
  427.     if (self.have_flag)
  428.         DropFlag(TRUE);
  429.     sprint(self,"Do not suicide again within 30 secs\nor you will be kicked.\n");
  430.     if (self.last_suicide > time - 30 && (self.last_suicide))
  431.         {
  432.         sprint(self,"You were warned...\n");
  433.         bprint(self.netname);
  434.         bprint(" was kicked for multiple suicides.\n");
  435.         stuffcmd(self,"disconnect\n");
  436.         }
  437.     self.last_suicide = time;
  438.     respawn ();
  439. };
  440.  
  441. float(vector v) CheckSpawnPoint =
  442. {
  443.     return FALSE;
  444. };
  445.  
  446. /*
  447. ============
  448. SelectSpawnPoint
  449.  
  450. Returns the entity to spawn at
  451. ============
  452. */
  453. entity() SelectSpawnPoint =
  454. {
  455.     local   entity spot;
  456.     
  457. // testinfo_player_start is only found in regioned levels
  458.     spot = find (world, classname, "testplayerstart");
  459.     if (spot)
  460.         return spot;
  461.         
  462. // choose a info_player_deathmatch point
  463.     if (coop)
  464.     {
  465.         lastspawn = find(lastspawn, classname, "info_player_coop");
  466.         if (lastspawn == world)
  467.             lastspawn = find (lastspawn, classname, "info_player_start");
  468.         if (lastspawn != world)
  469.             return lastspawn;
  470.     }
  471.     else if (deathmatch)
  472.     {
  473.         lastspawn = find(lastspawn, classname, "info_player_deathmatch");
  474.         if (lastspawn == world)
  475.             lastspawn = find (lastspawn, classname, "info_player_deathmatch");
  476.         if (lastspawn != world)
  477.             return lastspawn;
  478.     }
  479.  
  480.     if (serverflags)
  481.     {       // return with a rune to start
  482.         spot = find (world, classname, "info_player_start2");
  483.         if (spot)
  484.             return spot;
  485.     }
  486.     
  487.     spot = find (world, classname, "info_player_start");
  488.     if (!spot)
  489.         error ("PutClientInServer: no info_player_start on level");
  490.     
  491.     return spot;
  492. };
  493.  
  494. void() ActivateMega =
  495. {
  496.     
  497.     self.nextthink = time + 100;  //incase it spawned in a bad place.
  498.     self.think = Place_Mega;
  499.     if (!droptofloor())
  500.     {
  501.         remove(self);
  502.         mega_placed = FALSE;
  503.         return;
  504.     }
  505.     setorigin(self,self.origin + '0 0 16');
  506.     self.avelocity = '300 300 300';
  507.     sound (self, CHAN_VOICE, "items/itembk2.wav", 1, ATTN_NORM);    // play respawn sound
  508. };
  509.  
  510. void() Place_Mega =
  511. {
  512.     local float random_spot;
  513.     local float random_num;
  514.     local entity spot1,spot2,spot3,spot4;
  515.     local entity newmega;
  516.     local vector spot;
  517.  
  518.     mega_placed = TRUE;
  519.     if (!(allow_items & ALLOW_MEGA))
  520.         return;
  521.     spot1 = find (world,classname,"info_player_deathmatch");
  522.     spot2 = find (spot1,classname,"info_player_deathmatch");
  523.     spot3 = find (spot2,classname,"info_player_deathmatch");
  524.     spot4 = find (spot3,classname,"info_player_deathmatch");
  525.  
  526.     spot_x = (spot1.origin_x + spot2.origin_x + spot3.origin_x + spot4.origin_x) * 0.25;
  527.     spot_y = (spot1.origin_y + spot2.origin_y + spot3.origin_y + spot4.origin_y) * 0.25;
  528.     spot_z = (spot1.origin_z + spot2.origin_z + spot3.origin_z + spot4.origin_z) * 0.25;
  529.  
  530.     spot_x = spot_x + (700 * crandom());
  531.     spot_y = spot_y + (700 * crandom());
  532.     spot_z = spot_z + (700 * crandom());
  533.  
  534.     newmega = spawn();
  535.     newmega.owner = newmega;
  536.     newmega.movetype = MOVETYPE_NONE;
  537.     newmega.solid = SOLID_TRIGGER;
  538.     newmega.classname = "item_artifact_mega_power";
  539.     newmega.netname = "Super Weapons";
  540.     newmega.items2 = IT2_MEGAPOWER;
  541.     newmega.think = ActivateMega;
  542.     newmega.nextthink = time + 0.1;
  543.     newmega.health = 60;
  544.     newmega.touch = powerup_touch;
  545.     newmega.noise = "items/inv1.wav";
  546.     newmega.effects = newmega.effects | EF_DIMLIGHT;
  547.     setsize (newmega, '0 0 0', '32 32 32');
  548.     newmega.origin = spot;
  549.     setorigin (newmega, newmega.origin);
  550.     newmega.velocity = VEC_ORIGIN;
  551.     setmodel(newmega,"progs/v_axe.mdl");
  552.  
  553.     if (self.classname == "item_artifact_mega_power")
  554.         remove (self);
  555. };
  556.  
  557.  
  558. /*
  559. ===========
  560. PutClientInServer
  561.  
  562. called each time a player is spawned
  563. ============
  564. */
  565. void() DecodeLevelParms;
  566. void() PlayerDie;
  567.  
  568. void() PutClientInServer =
  569. {
  570.     local   entity spot;
  571.  
  572.     if (teamplay > 3 && teamplay < 8)
  573.     {
  574.         if (teamplay == 4) serverflags = 1;
  575.         if (teamplay == 5) serverflags = 2;
  576.         if (teamplay == 6) serverflags = 4;
  577.         if (teamplay == 7) serverflags = 8;
  578.     }
  579.     self.classname = "player";
  580.     self.health = 100;
  581.     self.takedamage = DAMAGE_AIM;
  582.     self.solid = SOLID_SLIDEBOX;
  583.     self.movetype = MOVETYPE_WALK;
  584.     self.show_hostile = 0;
  585.     self.max_health = 100;
  586.     self.flags = FL_CLIENT;
  587.     self.air_finished = time + 12;
  588.     self.dmg = 2;                   // initial water damage
  589.     self.mega_finished = 0;
  590.     self.super_damage_finished = 0;
  591.     self.radsuit_finished = 0;
  592.     self.invisible_finished = 0;
  593.     self.invincible_finished = 0;
  594.     self.effects = 0;
  595.     self.invincible_time = 0;
  596.     self.items2 = 0;
  597.  
  598.     DecodeLevelParms ();
  599.     
  600.     W_SetCurrentAmmo ();
  601.  
  602.     self.attack_finished = time;
  603.     self.th_pain = player_pain;
  604.     self.th_die = PlayerDie;
  605. /*       
  606.     stuffcmd(self,"BIND 0 \"IMPULSE 10\"\n");
  607.     stuffcmd(self,"BIND 9 \"IMPULSE 9\"\n");
  608.     stuffcmd(self,"BIND R \"IMPULSE 15\"\n");
  609.     stuffcmd(self,"BIND D \"IMPULSE 18\"\n");
  610. */        
  611.     stuffcmd(self,"BIND [ \"IMPULSE 201\"\n");
  612.     stuffcmd(self,"BIND ] \"IMPULSE 200\"\n");
  613.     
  614.     self.deadflag = DEAD_NO;
  615. // paustime is set by teleporters to keep the player from moving a while
  616.     self.pausetime = 0;
  617.     
  618.     spot = SelectSpawnPoint ();
  619.  
  620.     self.origin = spot.origin + '0 0 1';
  621.     self.angles = spot.angles;
  622.     self.pos1 = self.origin;
  623.     self.pos2 = self.angles;
  624.     self.fixangle = TRUE;           // turn this way immediately
  625.  
  626. // oh, this is a hack!
  627.     setmodel (self, "progs/eyes.mdl");
  628.     modelindex_eyes = self.modelindex;
  629.  
  630.     setmodel (self, "progs/player.mdl");
  631.     modelindex_player = self.modelindex;
  632.  
  633.     setsize (self, VEC_HULL_MIN, VEC_HULL_MAX);
  634.     
  635.     self.view_ofs = '0 0 22';
  636.  
  637.     player_stand1 ();
  638.     
  639.     if (deathmatch || coop)
  640.     {
  641.         makevectors(self.angles);
  642.         spawn_tfog (self.origin + v_forward*20);
  643.     }
  644.  
  645.     if (teamplay == 4 || teamplay == 5 || teamplay == 6)
  646.     {
  647.         if (self.am_it == TRUE) stuffcmd(self,"COLOR 4\n");
  648.         else stuffcmd(self,"COLOR 0\n");
  649.     }
  650.     spawn_tdeath (self.origin, self);
  651.  
  652. /*
  653. // *************************************************************************
  654. // **                                                                     **
  655. // ** M U L T I S K I N  1.1  (start)                                     **
  656. // **                                                                     **
  657. // *************************************************************************
  658.  
  659.     if (self.skin == 0) centerprint(self, "Mr. Quake himself!"); else
  660.     if (self.skin == 1) centerprint(self, "No time to play with yourself here!"); else
  661.     if (self.skin == 2) centerprint(self, "You're one pretty toad!"); else
  662.     if (self.skin == 3) centerprint(self, "Wow Stormtrooper, you're though!"); else
  663.     if (self.skin == 4) centerprint(self, "Hi Max, looking yellow/blue today!"); else
  664.     if (self.skin == 5) centerprint(self, "You are back!"); else
  665.     if (self.skin == 6) centerprint(self, "Judge Dredd! Let's restore some order!"); else
  666.     if (self.skin == 7) centerprint(self, "Camo! Can't see you, where are you!"); else
  667.     if (self.skin == 8) centerprint(self, "Okay Captain Picard, make it so!"); else
  668.     if (self.skin == 9) centerprint(self, "Whizz whizz.. Wizzard!"); else
  669.     if (self.skin == 10) centerprint(self,"I'm the Predator, you're the prey!"); else
  670.     if (self.skin == 11) centerprint(self,"Welcome Skeleton, looking good!"); else
  671.     if (self.skin == 12) centerprint(self,"Wan-Fu, whoever you are :)"); else
  672.     if (self.skin == 13) centerprint(self,"Oh no, it's Henry Rollins!"); else
  673.     if (self.skin == 14) centerprint(self,"Ooh no, it's She.. eh.. He-Man"); else
  674.     if (self.skin == 15) centerprint(self,"If it isn't Boba, go get Han Solo!"); else
  675.     if (self.skin == 16) centerprint(self,"It's SUPERMAN!"); else
  676.     if (self.skin == 17) centerprint(self,"Protect the innocent, uphold your law"); else
  677.     if (self.skin == 18) centerprint(self,"Why is that symbol on your suit?");
  678.  
  679. // *************************************************************************
  680. // **                                                                     **
  681. // ** M U L T I S K I N  1.1  (end)                                       **
  682. // **                                                                     **
  683. // *************************************************************************
  684. */
  685.  
  686. };
  687.  
  688.  
  689. /*
  690. =============================================================================
  691.  
  692.                 QUAKED FUNCTIONS
  693.  
  694. =============================================================================
  695. */
  696.  
  697.  
  698. /*QUAKED info_player_start (1 0 0) (-16 -16 -24) (16 16 24)
  699. The normal starting point for a level.
  700. */
  701. void() info_player_start =
  702. {
  703. };
  704.  
  705.  
  706. /*QUAKED info_player_start2 (1 0 0) (-16 -16 -24) (16 16 24)
  707. Only used on start map for the return point from an episode.
  708. */
  709. void() info_player_start2 =
  710. {
  711. };
  712.  
  713.  
  714. /*
  715. saved out by quaked in region mode
  716. */
  717. void() testplayerstart =
  718. {
  719. };
  720.  
  721. /*QUAKED info_player_deathmatch (1 0 1) (-16 -16 -24) (16 16 24)
  722. potential spawning position for deathmatch games
  723. */
  724. void() info_player_deathmatch =
  725. {
  726. };
  727.  
  728. /*QUAKED info_player_coop (1 0 1) (-16 -16 -24) (16 16 24)
  729. potential spawning position for coop games
  730. */
  731. void() info_player_coop =
  732. {
  733. };
  734.  
  735. /*
  736. ===============================================================================
  737.  
  738. RULES
  739.  
  740. ===============================================================================
  741. */
  742.  
  743. void(entity c) PrintClientScore =
  744. {
  745.     if (c.frags > -10 && c.frags < 0)
  746.         bprint (" ");
  747.     else if (c.frags >= 0)
  748.     {
  749.         if (c.frags < 100)
  750.             bprint (" ");
  751.         if (c.frags < 10)
  752.             bprint (" ");
  753.     }
  754.     bprint (ftos(c.frags));
  755.     bprint (" ");
  756.     bprint (c.netname);
  757.     bprint ("\n");
  758. };
  759.  
  760. void() DumpScore =
  761. {
  762.     local entity    e, sort, walk;
  763.  
  764.     if (world.chain)
  765.         error ("DumpScore: world.chain is set");
  766.  
  767. // build a sorted lis
  768.     e = find(world, classname, "player");
  769.     sort = world;
  770.     while (e)
  771.     {
  772.         if (!sort)
  773.         {
  774.             sort = e;
  775.             e.chain = world;
  776.         }
  777.         else
  778.         {
  779.             if (e.frags > sort.frags)
  780.             {
  781.                 e.chain = sort;
  782.                 sort = e;
  783.             }
  784.             else
  785.             {
  786.                 walk = sort;
  787.                 do
  788.                 {
  789.                     if (!walk.chain)
  790.                     {
  791.                         e.chain = world;
  792.                         walk.chain = e;
  793.                     }
  794.                     else if (walk.chain.frags < e.frags)
  795.                     {
  796.                         e.chain = walk.chain;
  797.                         walk.chain = e;
  798.                     }
  799.                     else
  800.                         walk = walk.chain;
  801.                 } while (walk.chain != e);
  802.             }
  803.         }
  804.         
  805.         e = find(e, classname, "player");
  806.     }
  807.  
  808. // print the list
  809.     
  810.     bprint ("\n");  
  811.     while (sort)
  812.     {
  813.         PrintClientScore (sort);
  814.         sort = sort.chain;
  815.     }
  816.     bprint ("\n");
  817. };
  818.  
  819. /*
  820. go to the next level for deathmatch
  821. */
  822. void() NextLevel =
  823. {
  824.     local entity o;
  825.  
  826. // find a trigger changelevel
  827.     o = find(world, classname, "trigger_changelevel");
  828.     if (!o || mapname == "start")
  829.     {       // go back to same map if no trigger_changelevel
  830.         o = spawn();
  831.         o.map = mapname;
  832.     }
  833.  
  834.     nextmap = o.map;
  835.     
  836.     if (o.nextthink < time)
  837.     {
  838.         o.think = execute_changelevel;
  839.         o.nextthink = time + 0.1;
  840.     }
  841. };
  842.  
  843. /*
  844. ============
  845. CheckRules
  846.  
  847. Exit deathmatch games upon conditions
  848. ============
  849. */
  850. void() CheckRules =
  851. {
  852.     local   float           timelimit;
  853.     local   float           fraglimit;
  854.     
  855.     if (gameover)   // someone else quit the game already
  856.         return;
  857.         
  858.     timelimit = cvar("timelimit") * 60;
  859.     fraglimit = cvar("fraglimit");
  860.     
  861.     if (timelimit && time >= timelimit)
  862.     {
  863. NextLevel ();
  864. /*
  865.         gameover = TRUE;
  866.         bprint ("\n\n\n==============================\n");
  867.         bprint ("game exited after ");
  868.         bprint (ftos(timelimit/60));
  869.         bprint (" minutes\n");
  870.         DumpScore ();
  871.         localcmd ("killserver\n");
  872. */
  873.         return;
  874.     }
  875.     
  876.     if (fraglimit && self.frags >= fraglimit)
  877.     {
  878. NextLevel ();
  879. /*
  880.         gameover = TRUE;
  881.         bprint ("\n\n\n==============================\n");
  882.         bprint ("game exited after ");
  883.         bprint (ftos(self.frags));
  884.         bprint (" frags\n");
  885.         DumpScore ();
  886.         localcmd ("killserver\n");
  887. */
  888.         return;
  889.     }       
  890. };
  891.  
  892. //============================================================================
  893.  
  894. void() PlayerDeathThink =
  895. {
  896.     local entity    old_self;
  897.     local float             forward;
  898.  
  899.     if ((self.flags & FL_ONGROUND))
  900.     {
  901.         forward = vlen (self.velocity);
  902.         forward = forward - 20;
  903.         if (forward <= 0)
  904.             self.velocity = '0 0 0';
  905.         else    
  906.             self.velocity = forward * normalize(self.velocity);
  907.     }
  908.  
  909. // wait for all buttons released
  910.     if (self.deadflag == DEAD_DEAD)
  911.     {
  912.         if (self.button2 || self.button1 || self.button0)
  913.             return;
  914.         self.deadflag = DEAD_RESPAWNABLE;
  915.         return;
  916.     }
  917.  
  918. // wait for any button down
  919.     if (!self.button2 && !self.button1 && !self.button0)
  920.         return;
  921.  
  922.     self.button0 = 0;
  923.     self.button1 = 0;
  924.     self.button2 = 0;
  925.     respawn();
  926. };
  927.  
  928.  
  929. void() PlayerJump =
  930. {
  931.     local vector start, end;
  932.     
  933.     if (self.flags & FL_WATERJUMP)
  934.         return;
  935.     
  936.     if (self.waterlevel >= 2)
  937.     {
  938.         if (self.watertype == CONTENT_WATER)
  939.             self.velocity_z = 100;
  940.         else if (self.watertype == CONTENT_SLIME)
  941.             self.velocity_z = 80;
  942.         else
  943.             self.velocity_z = 50;
  944.  
  945. // play swiming sound
  946.         if (self.swim_flag < time)
  947.         {
  948.             self.swim_flag = time + 1;
  949.             if (random() < 0.5)
  950.                 sound (self, CHAN_BODY, "misc/water1.wav", 1, ATTN_NORM);
  951.             else
  952.                 sound (self, CHAN_BODY, "misc/water2.wav", 1, ATTN_NORM);
  953.         }
  954.  
  955.         return;
  956.     }
  957.  
  958.     if (!(self.flags & FL_ONGROUND))
  959.         return;
  960.  
  961.     if ( !(self.flags & FL_JUMPRELEASED) )
  962.         return;         // don't pogo stick
  963.  
  964.     self.flags = self.flags - (self.flags & FL_JUMPRELEASED);
  965.  
  966.     self.flags = self.flags - FL_ONGROUND;  // don't stairwalk
  967.     
  968.     self.button2 = 0;
  969. // player jumping sound
  970.     sound (self, CHAN_BODY, "player/plyrjmp8.wav", 1, ATTN_NORM);
  971.     self.velocity_z = self.velocity_z + 270;
  972. };
  973.  
  974.  
  975. /*
  976. ===========
  977. WaterMove
  978.  
  979. ============
  980. */
  981. .float  dmgtime;
  982.  
  983. void() WaterMove =
  984. {
  985. //dprint (ftos(self.waterlevel));
  986.     if (self.movetype == MOVETYPE_NOCLIP)
  987.         return;
  988.     if (self.health < 0)
  989.         return;
  990.  
  991.     if (self.waterlevel != 3)
  992.     {
  993.         if (self.air_finished < time)
  994.             sound (self, CHAN_VOICE, "player/gasp2.wav", 1, ATTN_NORM);
  995.         else if (self.air_finished < time + 9)
  996.             sound (self, CHAN_VOICE, "player/gasp1.wav", 1, ATTN_NORM);
  997.         self.air_finished = time + 12;
  998.         self.dmg = 2;
  999.     }
  1000.     else if (self.air_finished < time)
  1001.     {       // drown!
  1002.         if (self.pain_finished < time)
  1003.         {
  1004.             self.dmg = self.dmg + 2;
  1005.             if (self.dmg > 15)
  1006.                 self.dmg = 10;
  1007.             T_Damage (self, world, world, self.dmg);
  1008.             self.pain_finished = time + 1;
  1009.         }
  1010.     }
  1011.     
  1012.     if (!self.waterlevel)
  1013.     {
  1014.         if (self.flags & FL_INWATER)
  1015.         {       
  1016.             // play leave water sound
  1017.             sound (self, CHAN_BODY, "misc/outwater.wav", 1, ATTN_NORM);
  1018.             self.flags = self.flags - FL_INWATER;
  1019.         }
  1020.         return;
  1021.     }
  1022.  
  1023.     if (self.watertype == CONTENT_LAVA)
  1024.     {       // do damage
  1025.         if (self.dmgtime < time)
  1026.         {
  1027.             if (self.radsuit_finished > time)
  1028.                 self.dmgtime = time + 1;
  1029.             else
  1030.                 self.dmgtime = time + 0.2;
  1031.  
  1032.             T_Damage (self, world, world, 10*self.waterlevel);
  1033.         }
  1034.     }
  1035.     else if (self.watertype == CONTENT_SLIME)
  1036.     {       // do damage
  1037.         if (self.dmgtime < time && self.radsuit_finished < time)
  1038.         {
  1039.             self.dmgtime = time + 1;
  1040.             T_Damage (self, world, world, 4*self.waterlevel);
  1041.         }
  1042.     }
  1043.     
  1044.     if ( !(self.flags & FL_INWATER) )
  1045.     {       
  1046.  
  1047. // player enter water sound
  1048.  
  1049.         if (self.watertype == CONTENT_LAVA)
  1050.             sound (self, CHAN_BODY, "player/inlava.wav", 1, ATTN_NORM);
  1051.         if (self.watertype == CONTENT_WATER)
  1052.             sound (self, CHAN_BODY, "player/inh2o.wav", 1, ATTN_NORM);
  1053.         if (self.watertype == CONTENT_SLIME)
  1054.             sound (self, CHAN_BODY, "player/slimbrn2.wav", 1, ATTN_NORM);
  1055.  
  1056.         self.flags = self.flags + FL_INWATER;
  1057.         self.dmgtime = 0;
  1058.     }
  1059.     
  1060.     if (! (self.flags & FL_WATERJUMP) )
  1061.         self.velocity = self.velocity - 0.8*self.waterlevel*frametime*self.velocity;
  1062. };
  1063.  
  1064. void() CheckWaterJump =
  1065. {
  1066.     local vector start, end;
  1067.  
  1068. // check for a jump-out-of-water
  1069.     makevectors (self.angles);
  1070.     start = self.origin;
  1071.     start_z = start_z + 8; 
  1072.     v_forward_z = 0;
  1073.     normalize(v_forward);
  1074.     end = start + v_forward*24;
  1075.     traceline (start, end, TRUE, self);
  1076.     if (trace_fraction < 1)
  1077.     {       // solid at waist
  1078.         start_z = start_z + self.maxs_z - 8;
  1079.         end = start + v_forward*24;
  1080.         self.movedir = trace_plane_normal * -50;
  1081.         traceline (start, end, TRUE, self);
  1082.         if (trace_fraction == 1)
  1083.         {       // open at eye level
  1084.             self.flags = self.flags | FL_WATERJUMP;
  1085.             self.velocity_z = 225;
  1086.             self.flags = self.flags - (self.flags & FL_JUMPRELEASED);
  1087.             self.teleport_time = time + 2;  // safety net
  1088.             return;
  1089.         }
  1090.     }
  1091. };
  1092.  
  1093. void (entity temp_ent) GiveQuakePower =        
  1094. {
  1095.     temp_ent.items = temp_ent.items | IT_QUAD;
  1096.     temp_ent.super_time = 1;
  1097.     temp_ent.super_damage_finished = time + 1000;
  1098. };
  1099.  
  1100. void (entity temp_ent) RemoveQuakePower =
  1101. {
  1102.     temp_ent.items = temp_ent.items - (temp_ent.items & IT_QUAD);
  1103.     temp_ent.super_damage_finished = 0;
  1104.     temp_ent.super_time = 0;
  1105. };
  1106.  
  1107. /*
  1108. ================
  1109. PlayerPreThink
  1110.  
  1111. Called every frame before physics are run
  1112. ================
  1113. */
  1114. void() PlayerPreThink =
  1115. {
  1116.     local   float   mspeed, aspeed;
  1117.     local   float   r;
  1118.     
  1119.     if (teamplay > 3 && teamplay < 8)
  1120.     {
  1121.         self.effects = self.effects - (self.effects & EF_DIMLIGHT);
  1122.         
  1123.         if (teamplay == 4) 
  1124.         {
  1125.             self.items = self.items - (self.items & IT_KEY2);
  1126.             if (self.am_it == TRUE)
  1127.                 self.items = self.items | IT_KEY1;
  1128.             else
  1129.                 self.items = self.items - (self.items & IT_KEY1);
  1130.         }
  1131.         if (teamplay == 5)
  1132.         {
  1133.             self.items = self.items - (self.items & IT_KEY1);
  1134.             if (self.am_it == TRUE)
  1135.                 self.items = self.items | IT_KEY2;
  1136.             else
  1137.                 self.items = self.items - (self.items & IT_KEY2);
  1138.         }
  1139.         if (teamplay == 6)
  1140.         {
  1141.             if (self.am_it == TRUE)
  1142.                 GiveQuakePower(self);
  1143.             else
  1144.                 self.effects = self.effects - (self.effects & IT_QUAD);
  1145.         }
  1146.         if (teamplay == 7)
  1147.         {
  1148.             if (((teamplay == 7 && world_flag == 0) && (self.have_flag & FLAG_1)) || (teamplay == 7 && (world_flag & FLAG_1) && self.team == FLAG_1))
  1149.                 {        
  1150.                 self.items = self.items | IT_KEY1;
  1151.                 self.effects = self.effects | EF_DIMLIGHT;
  1152.                 }
  1153.             else
  1154.                 self.items = self.items - (self.items & IT_KEY1);
  1155.                 
  1156.             if (((teamplay == 7 && world_flag == 0) && (self.have_flag & FLAG_2)) || (teamplay == 7 && (world_flag & FLAG_2) && self.team == FLAG_2))
  1157.                 {
  1158.                 self.items = self.items | IT_KEY2;
  1159.                 self.effects = self.effects | EF_DIMLIGHT;
  1160.                 }
  1161.             else
  1162.                 self.items = self.items - (self.items & IT_KEY2);
  1163.         }
  1164.     }
  1165.  
  1166.     if (intermission_running)
  1167.     {
  1168.         IntermissionThink ();   // otherwise a button could be missed between
  1169.         return;                                 // the think tics
  1170.     }
  1171.  
  1172.     if (self.view_ofs == '0 0 0')
  1173.         return;         // intermission or finale
  1174.  
  1175.     makevectors (self.v_angle);             // is this still used
  1176.  
  1177.     CheckRules ();
  1178.     WaterMove ();
  1179.     
  1180.     if (self.waterlevel == 2)
  1181.         CheckWaterJump ();
  1182.  
  1183.     if (self.deadflag >= DEAD_DEAD)
  1184.     {
  1185.         PlayerDeathThink ();
  1186.         return;
  1187.     }
  1188.     
  1189.     if (self.deadflag == DEAD_DYING)
  1190.         return; // dying, so do nothing
  1191.  
  1192.     if (self.button2)
  1193.     {
  1194.         PlayerJump ();
  1195.     }
  1196.     else
  1197.         self.flags = self.flags | FL_JUMPRELEASED;
  1198.  
  1199. // teleporters can force a non-moving pause time        
  1200.     if (time < self.pausetime)
  1201.         self.velocity = '0 0 0';
  1202. };
  1203.     
  1204. /*
  1205. ================
  1206. CheckPowerups
  1207.  
  1208. Check for turning off powerups
  1209. ================
  1210. */
  1211. void() CheckPowerups =
  1212. {
  1213.     
  1214.     if (self.health <= 0)
  1215.         return;
  1216.  
  1217. // invisibility
  1218.     if (self.invisible_finished)
  1219.     {
  1220. // sound and screen flash when items starts to run out
  1221.         if (self.invisible_sound < time)
  1222.         {
  1223.             sound (self, CHAN_AUTO, "items/inv3.wav", 0.5, ATTN_IDLE);
  1224.             self.invisible_sound = time + ((random() * 3) + 1);
  1225.         }
  1226.  
  1227.  
  1228.         if (self.invisible_finished < time + 3)
  1229.         {
  1230.             if (self.invisible_time == 1)
  1231.             {
  1232.                 sprint (self, "Ring of Shadows magic is fading\n");
  1233.                 stuffcmd (self, "bf\n");
  1234.                 sound (self, CHAN_AUTO, "items/inv2.wav", 1, ATTN_NORM);
  1235.                 self.invisible_time = time + 1;
  1236.             }
  1237.             
  1238.             if (self.invisible_time < time)
  1239.             {
  1240.                 self.invisible_time = time + 1;
  1241.                 stuffcmd (self, "bf\n");
  1242.             }
  1243.         }
  1244.  
  1245.         if (self.invisible_finished < time)
  1246.         {       // just stopped
  1247.             self.items = self.items - IT_INVISIBILITY;
  1248.             self.invisible_finished = 0;
  1249.             self.invisible_time = 0;
  1250.         }
  1251.         
  1252.     // use the eyes
  1253.         self.frame = 0;
  1254.         self.modelindex = modelindex_eyes;
  1255.     }
  1256.     else
  1257.         self.modelindex = modelindex_player;    // don't use eyes
  1258.  
  1259. // invincibility
  1260.     if (self.invincible_finished)
  1261.     {
  1262. // sound and screen flash when items starts to run out
  1263.         if (self.invincible_finished < time + 3)
  1264.         {
  1265.             if (self.invincible_time == 1)
  1266.             {
  1267.                 sprint (self, "Protection is almost burned out\n");
  1268.                 stuffcmd (self, "bf\n");
  1269.                 sound (self, CHAN_AUTO, "items/protect2.wav", 1, ATTN_NORM);
  1270.                 self.invincible_time = time + 1;
  1271.             }
  1272.             
  1273.             if (self.invincible_time < time)
  1274.             {
  1275.                 self.invincible_time = time + 1;
  1276.                 stuffcmd (self, "bf\n");
  1277.             }
  1278.         }
  1279.         
  1280.         if (self.invincible_finished < time)
  1281.         {       // just stopped
  1282.             self.items = self.items - IT_INVULNERABILITY;
  1283.             self.invincible_time = 0;
  1284.             self.invincible_finished = 0;
  1285.         }
  1286.         if (self.invincible_finished > time)
  1287.             self.effects = self.effects | EF_DIMLIGHT;
  1288.         else
  1289.             self.effects = self.effects - (self.effects & EF_DIMLIGHT);
  1290.     }
  1291.  
  1292. // super damage
  1293.     if (self.super_damage_finished)
  1294.     {
  1295.  
  1296. // sound and screen flash when items starts to run out
  1297.  
  1298.         if (self.super_damage_finished < time + 3)
  1299.         {
  1300.             if (self.super_time == 1)
  1301.             {
  1302.                 sprint (self, "Quad Damage is wearing off\n");
  1303.                 stuffcmd (self, "bf\n");
  1304.                 sound (self, CHAN_AUTO, "items/damage2.wav", 1, ATTN_NORM);
  1305.                 self.super_time = time + 1;
  1306.             }         
  1307.             
  1308.             if (self.super_time < time)
  1309.             {
  1310.                 self.super_time = time + 1;
  1311.                 stuffcmd (self, "bf\n");
  1312.             }
  1313.         }
  1314.  
  1315.         if (self.super_damage_finished < time)
  1316.         {       // just stopped
  1317.             self.items = self.items - IT_QUAD;
  1318.             self.super_damage_finished = 0;
  1319.             self.super_time = 0;
  1320.         }
  1321.         if (self.super_damage_finished > time)
  1322.             self.effects = self.effects | EF_DIMLIGHT;
  1323.         else
  1324.             self.effects = self.effects - (self.effects & EF_DIMLIGHT);
  1325.     }       
  1326.  
  1327. // mega weapons
  1328.     if (self.mega_finished)
  1329.     {
  1330.  
  1331. // sound and screen flash when items starts to run out
  1332.  
  1333.         if (self.mega_finished < time + 3)
  1334.         {
  1335.             if (self.mega_time == 1)
  1336.             {
  1337.                 sprint (self, "Super Weapons is wearing off\n");
  1338.                 stuffcmd (self, "bf\n");
  1339.                 sound (self, CHAN_AUTO, "items/protect2.wav", 1, ATTN_NORM);
  1340.                 self.mega_time = time + 1;
  1341.             }         
  1342.             
  1343.             if (self.mega_time < time)
  1344.             {
  1345.                 self.mega_time = time + 1;
  1346.                 stuffcmd (self, "bf\n");
  1347.             }
  1348.         }
  1349.  
  1350.         if (self.mega_finished < time)
  1351.         {       // just stopped
  1352.             self.items2 = self.items2 - IT2_MEGAPOWER;
  1353.             self.mega_finished = 0;
  1354.             self.mega_time = 0;
  1355.         }
  1356.         if (self.mega_finished > time)
  1357.             self.effects = self.effects | EF_DIMLIGHT;
  1358.         else
  1359.             self.effects = self.effects - (self.effects & EF_DIMLIGHT);
  1360.     }       
  1361.  
  1362. // suit 
  1363.     if (self.radsuit_finished)
  1364.     {
  1365.         self.air_finished = time + 12;          // don't drown
  1366.  
  1367. // sound and screen flash when items starts to run out
  1368.         if (self.radsuit_finished < time + 3)
  1369.         {
  1370.             if (self.rad_time == 1)
  1371.             {
  1372.                 sprint (self, "Air supply in Biosuit expiring\n");
  1373.                 stuffcmd (self, "bf\n");
  1374.                 sound (self, CHAN_AUTO, "items/suit2.wav", 1, ATTN_NORM);
  1375.                 self.rad_time = time + 1;
  1376.             }
  1377.             
  1378.             if (self.rad_time < time)
  1379.             {
  1380.                 self.rad_time = time + 1;
  1381.                 stuffcmd (self, "bf\n");
  1382.             }
  1383.         }
  1384.  
  1385.         if (self.radsuit_finished < time)
  1386.         {       // just stopped
  1387.             self.items = self.items - IT_SUIT;
  1388.             self.rad_time = 0;
  1389.             self.radsuit_finished = 0;
  1390.         }
  1391.     }       
  1392.  
  1393. };
  1394.  
  1395.  
  1396. /*
  1397. ================
  1398. PlayerPostThink
  1399.  
  1400. Called every frame after physics are run
  1401. ================
  1402. */
  1403. void() PlayerPostThink =
  1404. {
  1405.     local   float   mspeed, aspeed;
  1406.     local   float   r;
  1407.  
  1408.     if (deathmatch && !(mega_placed))
  1409.         Place_Mega();
  1410.     
  1411.     if (self.view_ofs == '0 0 0')
  1412.         return;         // intermission or finale
  1413.     if (self.deadflag)
  1414.         return;
  1415.         
  1416. // do weapon stuff
  1417.  
  1418.     W_WeaponFrame ();
  1419.  
  1420. // check to see if player landed and play landing sound 
  1421.     if ((self.jump_flag < -300) && (self.flags & FL_ONGROUND) && (self.health > 0))
  1422.     {
  1423.         if (self.watertype == CONTENT_WATER)
  1424.             sound (self, CHAN_BODY, "player/h2ojump.wav", 1, ATTN_NORM);
  1425.         else if (self.jump_flag < -650)
  1426.         {
  1427.             T_Damage (self, world, world, 5); 
  1428.             sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  1429.             self.deathtype = "falling";
  1430.         }
  1431.         else
  1432.             sound (self, CHAN_VOICE, "player/land.wav", 1, ATTN_NORM);
  1433.  
  1434.         self.jump_flag = 0;
  1435.     }
  1436.  
  1437.     if (!(self.flags & FL_ONGROUND))
  1438.         self.jump_flag = self.velocity_z;
  1439.  
  1440.     CheckPowerups ();
  1441. };
  1442.  
  1443.  
  1444. /*
  1445. ===========
  1446. ClientConnect
  1447.  
  1448. called when a player connects to a server
  1449. ============
  1450. */
  1451. void() ClientConnect =
  1452. {
  1453.     bprint (self.netname);
  1454.     bprint (" entered the game\n");
  1455.     self.am_it = TRUE;
  1456.     numplayers = numplayers + 1;
  1457.     sprint(self,"Welcome to this server... running DMPLUS 1.0\n");
  1458.     sprint(self,"by W.Harris (Paragon_)\n");
  1459. // a client connecting during an intermission can cause problems
  1460.     if (intermission_running)
  1461.         ExitIntermission ();
  1462. };
  1463.  
  1464.  
  1465. /*
  1466. ===========
  1467. ClientDisconnect
  1468.  
  1469. called when a player disconnects from a server
  1470. ============
  1471. */
  1472. void() ClientDisconnect =
  1473. {
  1474.     if (gameover)
  1475.         return;
  1476.     // if the level end trigger has been activated, just return
  1477.     // since they aren't *really* leaving
  1478.  
  1479.     // let everyone else know
  1480.     bprint (self.netname);
  1481.     bprint (" left the game with ");
  1482.     bprint (ftos(self.frags));
  1483.     bprint (" frags\n");
  1484.     sound (self, CHAN_BODY, "player/tornoff2.wav", 1, ATTN_NONE);
  1485.     numplayers = numplayers - 1;
  1486.     DropFlag(TRUE);
  1487.     set_suicide_frame ();
  1488. };
  1489.  
  1490. void (entity attacker, entity targ) CheckTeamplay =
  1491. {
  1492.  
  1493. local entity temp_ent;
  1494.  
  1495. // if teamplay is Capture the Flag, then drop flag(s) if you have them.
  1496. if (teamplay == 7 && self.have_flag)
  1497.     {
  1498.     bprint(targ.netname);
  1499.     bprint(" died carrying ");
  1500.     if (targ.have_flag == FLAG_1)                
  1501.         bprint("silver flag.\n");
  1502.     if (targ.have_flag == FLAG_2)
  1503.         bprint("gold flag.\n");
  1504.     if (targ.have_flag == FLAG_BOTH)
  1505.         bprint("both flags.\n");
  1506.     temp_ent = self;
  1507.     self = targ;
  1508.     DropFlag(TRUE);
  1509.     self = temp_ent;
  1510.     }
  1511.  
  1512. // remain it/ti unless killed by another player.
  1513. if ((attacker.classname != "player") || (attacker == targ))
  1514.     return;
  1515.  
  1516. // if teamplay is 4 then only 'it' can a frag then he is not 'it'.
  1517. if(teamplay == 4)
  1518.     {
  1519.     if (attacker.am_it == TRUE)
  1520.         {
  1521.         attacker.am_it = FALSE;
  1522.         targ.am_it = TRUE;
  1523.         stuffcmd(targ,"COLOR 4\n");
  1524.         stuffcmd(attacker,"COLOR 0\n");
  1525.         sprint(targ,"You are it! Kill someone!\n");
  1526.         sprint(attacker,"No longer it. Get it!\n");
  1527.         }
  1528.     else
  1529.         {
  1530.         if (targ.am_it == TRUE)
  1531.         attacker.frags = attacker.frags + 2;
  1532.         }
  1533.     }
  1534.  
  1535. // if teamplay is 5 then 'ti' gets three frags for killing. killing ti makes you ti.
  1536. if(teamplay == 5)
  1537.     {
  1538.     if (attacker.am_it == FALSE)
  1539.         {
  1540.         // cannot frag unless 'ti'
  1541.         if (targ.am_it == TRUE)
  1542.               {
  1543.               targ.am_it = FALSE;
  1544.               attacker.am_it = TRUE;
  1545.               stuffcmd(targ,"COLOR 0\n");
  1546.               stuffcmd(attacker,"COLOR 4\n");
  1547.               sprint(attacker,"You stole ti. Kill everyone!\n");
  1548.               sprint(targ,"You lose ti! Kill ti!\n");
  1549.               }
  1550.  
  1551.          }
  1552.      else
  1553.          {
  1554.          // give three frags if kill non-ti
  1555.          if (targ.am_it == FALSE)
  1556.             {
  1557.             attacker.frags = attacker.frags + 2;
  1558.             }
  1559.          else
  1560.             {
  1561.             targ.am_it = FALSE;
  1562.             stuffcmd(targ,"COLOR 0\n");
  1563.             stuffcmd(attacker,"COLOR 4\n");
  1564.             }
  1565.          }
  1566.     }
  1567.  
  1568. // if teamplay is 6 then 'ti' gets quake power. killing ti makes you ti
  1569. // and gives you three frags and the quake power.
  1570.                 
  1571. if(teamplay == 6)
  1572.     {
  1573.     if (attacker.am_it == FALSE)
  1574.         {
  1575.         if (targ.am_it == TRUE)
  1576.             {
  1577.             // get quakepower and three frags for killing ti.
  1578.             targ.am_it = FALSE;
  1579.             attacker.am_it = TRUE;
  1580.             stuffcmd(targ,"COLOR 0\n");
  1581.             stuffcmd(attacker,"COLOR 4\n");
  1582.             sprint(attacker,"You stole quake power. Kill everyone!\n");
  1583.             GiveQuakePower(attacker);
  1584.             sprint(targ,"You lose quake power!\n");
  1585.             RemoveQuakePower(targ);
  1586.             attacker.frags = attacker.frags + 2;
  1587.             }
  1588.         }
  1589.     else
  1590.         {
  1591.         if (targ.am_it == TRUE)
  1592.             {
  1593.             // make sure colours are ok
  1594.             targ.am_it = FALSE;
  1595.             stuffcmd(targ,"COLOR 0\n");
  1596.             stuffcmd(attacker,"COLOR 4\n");
  1597.             }
  1598.         }
  1599.     }
  1600.     
  1601. // If teamplay is 2,3 or 8, and you kill a teammate, You GIB
  1602.                 
  1603. if((attacker != targ) && ((teamplay == 2) && (attacker.team == targ.team)))
  1604.     {
  1605.     T_Damage(attacker, attacker, attacker, 1000);
  1606.     bprint(attacker.netname);
  1607.     bprint(" gibbed for killing teammate ");
  1608.     bprint(targ.netname);
  1609.     bprint("!\n");
  1610.     }
  1611. // If teamplay is 3 lose an extra frags as well.
  1612.  
  1613. // If teamplay is 7 lose three extra frags as well.  This is because some
  1614. // nasty person could wait by his flag for his teammates to come back
  1615. // with the enemy flag, kill them, and get the 3 frags for himself.
  1616.  
  1617. if((attacker != targ) && (teamplay == 3 && (attacker.team == targ.team)))
  1618. {
  1619.     T_Damage(attacker, attacker, attacker, 1000);
  1620.     attacker.frags = attacker.frags - 1;
  1621.     if (teamplay == 7)
  1622.         attacker.frags = attacker.frags - 2; 
  1623.     bprint(attacker.netname);
  1624.     bprint(" gibbed for killing teammate ");
  1625.     bprint(targ.netname);
  1626.     bprint("!\n");
  1627. }
  1628.  
  1629. attacker.frags = attacker.frags + 1;
  1630. };
  1631.  
  1632. /*
  1633. ===========
  1634. 1ituary
  1635.  
  1636. called when a player dies
  1637. ============
  1638. */
  1639. void(entity targ, entity attacker) ClientObituary =
  1640. {
  1641.     local   float rnum;
  1642.     local   string deathstring, deathstring2;
  1643.     rnum = random();
  1644.  
  1645.     if (targ.classname == "player")
  1646.     {
  1647.         targ.effects = targ.effects - (targ.effects & EF_DIMLIGHT);
  1648.         if (attacker.classname == "bomb")
  1649.         {
  1650.             if (targ == attacker.owner)
  1651.             {
  1652.             attacker.owner.frags = attacker.owner.frags - 1;
  1653.             bprint (targ.netname);
  1654.             bprint (" blew himself up\n");
  1655.             }
  1656.             else
  1657.             {
  1658.                 if (attacker.items2 & IT2_MEGAPOWER)
  1659.                 {
  1660.                     bprint (attacker.owner.netname);
  1661.                     bprint ("'s super-bomb found ");
  1662.                     bprint (targ.netname);
  1663.                     bprint ("\n");
  1664.                     attacker.owner.frags = attacker.owner.frags + 1;
  1665.                 }
  1666.                 else
  1667.                 {
  1668.                     bprint (targ.netname);
  1669.                     bprint (" was there when ");
  1670.                     bprint (attacker.owner.netname);
  1671.                     bprint ("'s bomb blew\n");
  1672.                     attacker.owner.frags = attacker.owner.frags + 1;
  1673.                 }
  1674.             }
  1675.             CheckTeamplay(attacker.owner, targ);
  1676.             return;
  1677.         }
  1678.         
  1679.         if (attacker.classname == "tripwire")
  1680.         {
  1681.             if (targ == attacker.owner)
  1682.             {
  1683.             attacker.owner.frags = attacker.owner.frags - 1;
  1684.             bprint (targ.netname);
  1685.             bprint (" tripped on his own tripwire\n");
  1686.             }
  1687.             else
  1688.             {
  1689.             bprint (targ.netname);
  1690.             bprint (" was tripwired by ");
  1691.             bprint (attacker.owner.netname);
  1692.             bprint ("\n");
  1693.             attacker.owner.frags = attacker.owner.frags + 1;
  1694.             }
  1695.             CheckTeamplay(attacker.owner, targ);
  1696.             return;
  1697.         }
  1698.         
  1699.         if (attacker.classname == "teledeath")
  1700.         {
  1701.             bprint (targ.netname);
  1702.             bprint (" was telefragged by ");
  1703.             bprint (attacker.owner.netname);
  1704.             bprint ("\n");
  1705.             attacker.owner.frags = attacker.owner.frags + 1;
  1706.             CheckTeamplay(attacker.owner, targ);
  1707.             return;
  1708.         }
  1709.  
  1710.         if (attacker.classname == "teledeath2")
  1711.         {
  1712.             bprint ("Satan's power deflects ");
  1713.             bprint (targ.netname);
  1714.             bprint ("'s telefrag\n");
  1715.             targ.frags = targ.frags - 1;
  1716.             CheckTeamplay(attacker.owner, targ);
  1717.             return;
  1718.         }
  1719.  
  1720.         if (attacker.classname == "player")
  1721.         {
  1722.             if (targ == attacker)
  1723.             {
  1724.                 // killed self
  1725.                 attacker.frags = attacker.frags - 1;
  1726.                 bprint (targ.netname);
  1727.                 
  1728.                 if (targ.weapon == 64 && targ.waterlevel > 1)
  1729.                 {
  1730.                     bprint (" discharges into the water.\n");
  1731.                     CheckTeamplay(attacker,targ);
  1732.                     return;
  1733.                 }
  1734.                 if (targ.weapon == 16)
  1735.                 {        
  1736.                     if (targ.items2 & IT2_MEGAPOWER)
  1737.                         bprint (" gets too close to his cluster\n");
  1738.                     else
  1739.                         bprint (" tries to put the pin back in\n");
  1740.                 }
  1741.                 else if (rnum)
  1742.                     bprint (" becomes bored with life\n");
  1743.                 else
  1744.                     bprint (" checks if his weapon is loaded\n");
  1745.             }
  1746.             else
  1747.             {
  1748.                 rnum = attacker.weapon;
  1749.                 if (rnum == IT_AXE)
  1750.                 {
  1751.                     deathstring = " was ax-murdered by ";
  1752.                     deathstring2 = "\n";
  1753.                 }
  1754.                 if (rnum == IT_SHOTGUN)
  1755.                 {
  1756.                     deathstring = " chewed on ";
  1757.                     deathstring2 = "'s boomstick\n";
  1758.                 }
  1759.                 if (rnum == IT_SUPER_SHOTGUN)
  1760.                 {
  1761.                     deathstring = " ate 2 loads of ";
  1762.                     deathstring2 = "'s buckshot\n";
  1763.                 }
  1764.                 if (rnum == IT_NAILGUN)
  1765.                 {
  1766.                     deathstring = " was nailed by ";
  1767.                     deathstring2 = "\n";
  1768.                 }
  1769.                 if (rnum == IT_SUPER_NAILGUN)
  1770.                 {
  1771.                     deathstring = " was punctured by ";
  1772.                     deathstring2 = "\n";
  1773.                 }
  1774.                 if (rnum == IT_GRENADE_LAUNCHER)
  1775.                 {
  1776.                     if (attacker.items2 & IT2_MEGAPOWER)
  1777.                     {
  1778.                         deathstring = " eats ";
  1779.                         deathstring2 = "'s pineapple's\n";
  1780.                         if (targ.health < -40)
  1781.                         {
  1782.                             deathstring = " was gibbed by ";
  1783.                             deathstring2 = "'s cluster bomb\n";
  1784.                         }
  1785.                     }
  1786.                     else
  1787.                     {
  1788.                         deathstring = " eats ";
  1789.                         deathstring2 = "'s pineapple\n";
  1790.                         if (targ.health < -40)
  1791.                         {
  1792.                             deathstring = " was gibbed by ";
  1793.                             deathstring2 = "'s grenade\n";
  1794.                         }
  1795.                     }
  1796.                 }
  1797.                 if (rnum == IT_ROCKET_LAUNCHER)
  1798.                 {
  1799.                     if (attacker.items2 & IT2_MEGAPOWER)
  1800.                     {        
  1801.                         deathstring = " rides ";
  1802.                         deathstring2 = "'s super-rocket\n";
  1803.                         if (targ.health < -40)
  1804.                         {
  1805.                             deathstring = " was gibbed by ";
  1806.                             deathstring2 = "'s super-rocket\n" ;
  1807.                         }
  1808.                     }
  1809.                     else
  1810.                     {        
  1811.                         deathstring = " rides ";
  1812.                         deathstring2 = "'s rocket\n";
  1813.                         if (targ.health < -40)
  1814.                         {
  1815.                             deathstring = " was gibbed by ";
  1816.                             deathstring2 = "'s rocket\n" ;
  1817.                         }
  1818.                     }
  1819.                 
  1820.                 }
  1821.                 if (rnum == IT_LIGHTNING)
  1822.                 {
  1823.                     deathstring = " accepts ";
  1824.                     if (attacker.waterlevel > 1)
  1825.                         deathstring2 = "'s discharge\n";
  1826.                     else
  1827.                         deathstring2 = "'s shaft\n";
  1828.                 }
  1829.                 if (rnum == IT_BFG)
  1830.                 {
  1831.                     deathstring = " was zapped by ";
  1832.                     deathstring2 = "'s BFG\n";
  1833.                     if (targ.health < -40)
  1834.                     {
  1835.                         deathstring = " was gibbed by ";
  1836.                         deathstring2 = "'s BFG\n";
  1837.                     }
  1838.                 }
  1839.                 if (rnum == IT_BOMB)
  1840.                 {
  1841.                     deathstring = " was caught by ";
  1842.                     deathstring2 = "'s bomb\n";
  1843.                     if (targ.health < -40)
  1844.                     {
  1845.                         deathstring = " was gibbed by ";
  1846.                         deathstring2 = "'s bomb\n";
  1847.                     }
  1848.                 }
  1849.                 bprint (targ.netname);
  1850.                 bprint (deathstring);
  1851.                 bprint (attacker.netname);
  1852.                 bprint (deathstring2);
  1853.             }
  1854.         CheckTeamplay(attacker,targ);
  1855.         return;
  1856.         }
  1857.  
  1858.         else
  1859.         {
  1860.             targ.frags = targ.frags - 1;            // killed self
  1861.             rnum = targ.watertype;
  1862.  
  1863.             bprint (targ.netname);
  1864.             if (rnum == -3)
  1865.             {
  1866.                 if (random() < 0.5)
  1867.                     bprint (" sleeps with the fishes\n");
  1868.                 else
  1869.                     bprint (" sucks it down\n");
  1870.                 CheckTeamplay(attacker,targ);
  1871.                 return;
  1872.             }
  1873.             else if (rnum == -4)
  1874.             {
  1875.                 if (random() < 0.5)
  1876.                     bprint (" gulped a load of slime\n");
  1877.                 else
  1878.                     bprint (" can't exist on slime alone\n");
  1879.                 CheckTeamplay(attacker,targ);
  1880.                 return;
  1881.             }
  1882.             else if (rnum == -5)
  1883.             {
  1884.                 if (targ.health < -15)
  1885.                 {
  1886.                     bprint (" burst into flames\n");
  1887.                     return;
  1888.                 }
  1889.                 if (random() < 0.5)
  1890.                     bprint (" turned into hot slag\n");
  1891.                 else
  1892.                     bprint (" visits the Volcano God\n");
  1893.                 CheckTeamplay(attacker,targ);
  1894.                 return;
  1895.             }
  1896.  
  1897.             if (attacker.flags & FL_MONSTER)
  1898.             {
  1899.                 if (attacker.classname == "monster_army")
  1900.                     bprint (" was shot by a Grunt\n");
  1901.                 if (attacker.classname == "monster_demon1")
  1902.                     bprint (" was eviscerated by a Fiend\n");
  1903.                 if (attacker.classname == "monster_dog")
  1904.                     bprint (" was mauled by a Rottweiler\n");
  1905.                 if (attacker.classname == "monster_dragon")
  1906.                     bprint (" was fried by a Dragon\n");
  1907.                 if (attacker.classname == "monster_enforcer")
  1908.                     bprint (" was blasted by an Enforcer\n");
  1909.                 if (attacker.classname == "monster_fish")
  1910.                     bprint (" was fed to the Rotfish\n");
  1911.                 if (attacker.classname == "monster_hell_knight")
  1912.                     bprint (" was slain by a Death Knight\n");
  1913.                 if (attacker.classname == "monster_knight")
  1914.                     bprint (" was slashed by a Knight\n");
  1915.                 if (attacker.classname == "monster_ogre")
  1916.                     bprint (" was destroyed by an Ogre\n");
  1917.                 if (attacker.classname == "monster_oldone")
  1918.                     bprint (" became one with Shub-Niggurath\n");
  1919.                 if (attacker.classname == "monster_shalrath")
  1920.                     bprint (" was exploded by a Vore\n");
  1921.                 if (attacker.classname == "monster_shambler")
  1922.                     bprint (" was smashed by a Shambler\n");
  1923.                 if (attacker.classname == "monster_tarbaby")
  1924.                     bprint (" was slimed by a Spawn\n");
  1925.                 if (attacker.classname == "monster_vomit")
  1926.                     bprint (" was vomited on by a Vomitus\n");
  1927.                 if (attacker.classname == "monster_wizard")
  1928.                     bprint (" was scragged by a Scrag\n");
  1929.                 if (attacker.classname == "monster_zombie")
  1930.                     bprint (" joins the Zombies\n");
  1931.                 CheckTeamplay(attacker,targ);
  1932.                 return;
  1933.             }
  1934.             if (attacker.classname == "explo_box")
  1935.             {
  1936.                 bprint (" blew up\n");
  1937.                 CheckTeamplay(attacker,targ);
  1938.                 return;
  1939.             }
  1940.             if (attacker.solid == SOLID_BSP && attacker != world)
  1941.             {       
  1942.                 bprint (" was squished\n");
  1943.                 CheckTeamplay(attacker,targ);
  1944.                 return;
  1945.             }
  1946.             if (targ.deathtype == "falling")
  1947.             {
  1948.                 targ.deathtype = "";
  1949.                 bprint (" fell to his death\n");
  1950.                 CheckTeamplay(attacker,targ);
  1951.                 return;
  1952.             }
  1953.             if (attacker.classname == "trap_shooter" || attacker.classname == "trap_spikeshooter")
  1954.             {
  1955.                 bprint (" was spiked\n");
  1956.                 CheckTeamplay(attacker,targ);
  1957.                 return;
  1958.             }
  1959.             if (attacker.classname == "fireball")
  1960.             {
  1961.                 bprint (" ate a lavaball\n");
  1962.                 CheckTeamplay(attacker,targ);
  1963.                 return;
  1964.             }
  1965.             if (attacker.classname == "trigger_changelevel")
  1966.             {
  1967.                 bprint (" tried to leave\n");
  1968.                 CheckTeamplay(attacker,targ);
  1969.                 return;
  1970.             }
  1971.             bprint (" died\n");
  1972.             CheckTeamplay(attacker,targ);
  1973.         }
  1974.     }
  1975. };
  1976.                             
  1977.