home *** CD-ROM | disk | FTP | other *** search
/ PC/CD Gamer UK 46 / PCGAMER46.bin / Quake / QuakeC / Collect / COLLECT.EXE / SOURCES.ZIP / ITEMS.QC < prev    next >
Encoding:
Text File  |  1997-01-17  |  39.4 KB  |  2,636 lines

  1. void() W_SetCurrentAmmo;
  2.  
  3. /* ALL LIGHTS SHOULD BE 0 1 0 IN COLOR ALL OTHER ITEMS SHOULD
  4.  
  5. BE .8 .3 .4 IN COLOR */
  6.  
  7. // Daniel 15/01/97
  8. // Function declaration for the playdead routine and the awake routine.
  9. void() PlayDead;
  10. void() Awake;
  11.  
  12. void() SUB_regen =
  13.  
  14. {
  15.  
  16.         self.model = self.mdl;          // restore original model
  17.  
  18.         self.solid = SOLID_TRIGGER;     // allow it to be touched again
  19.  
  20.         sound (self, CHAN_VOICE, "items/itembk2.wav", 1, ATTN_NORM);    // play respawn sound
  21.  
  22.         setorigin (self, self.origin);
  23.  
  24. };
  25.  
  26. /*QUAKED noclass (0 0 0) (-8 -8 -8) (8 8 8)
  27.  
  28. prints a warning message when spawned
  29.  
  30. */
  31.  
  32. void() noclass =
  33.  
  34. {
  35.  
  36.         dprint ("noclass spawned at");
  37.  
  38.         dprint (vtos(self.origin));
  39.  
  40.         dprint ("\n");
  41.  
  42.         remove (self);
  43.  
  44. };
  45.  
  46.  
  47. /*
  48.  
  49. ============
  50.  
  51. PlaceItem
  52.  
  53.  
  54.  
  55. plants the object on the floor
  56.  
  57. ============
  58.  
  59. */
  60.  
  61. void() PlaceItem =
  62.  
  63. {
  64.  
  65.         local float     oldz;
  66.  
  67.  
  68.  
  69.         self.mdl = self.model;          // so it can be restored on respawn
  70.  
  71.         self.flags = FL_ITEM;           // make extra wide
  72.  
  73.         self.solid = SOLID_TRIGGER;
  74.  
  75.         self.movetype = MOVETYPE_TOSS;  
  76.  
  77.         self.velocity = '0 0 0';
  78.  
  79.         self.origin_z = self.origin_z + 6;
  80.  
  81.         oldz = self.origin_z;
  82.  
  83.         if (!droptofloor())
  84.  
  85.         {
  86.  
  87.                 dprint ("Bonus item fell out of level at ");
  88.  
  89.                 dprint (vtos(self.origin));
  90.  
  91.                 dprint ("\n");
  92.  
  93.                 remove(self);
  94.  
  95.                 return;
  96.  
  97.         }
  98.  
  99. };
  100.  
  101.  
  102.  
  103. /*
  104.  
  105. ============
  106.  
  107. StartItem
  108.  
  109.  
  110.  
  111. Sets the clipping size and plants the object on the floor
  112.  
  113. ============
  114.  
  115. */
  116.  
  117. void() StartItem =
  118.  
  119. {
  120.  
  121.         self.nextthink = time + 0.2;    // items start after other solids
  122.  
  123.         self.think = PlaceItem;
  124.  
  125. };
  126.  
  127.  
  128. /*
  129.  
  130. =========================================================================
  131.  
  132.  
  133.  
  134. HEALTH BOX
  135.  
  136.  
  137.  
  138. =========================================================================
  139.  
  140. */
  141.  
  142. //
  143.  
  144. // T_Heal: add health to an entity, limiting health to max_health
  145.  
  146. // "ignore" will ignore max_health limit
  147.  
  148. //
  149.  
  150. float (entity e, float healamount, float ignore) T_Heal =
  151.  
  152. {
  153.  
  154.         if (e.health <= 0)
  155.  
  156.                 return 0;
  157.  
  158.         if ((!ignore) && (e.health >= other.max_health))
  159.  
  160.                 return 0;
  161.  
  162.         healamount = ceil(healamount);
  163.  
  164.  
  165.  
  166.         e.health = e.health + healamount;
  167.  
  168.         if ((!ignore) && (e.health >= other.max_health))
  169.  
  170.                 e.health = other.max_health;
  171.  
  172.                 
  173.  
  174.         if (e.health > 250)
  175.  
  176.                 e.health = 250;
  177.  
  178.         return 1;
  179.  
  180. };
  181.  
  182.  
  183.  
  184. /*QUAKED item_health (.3 .3 1) (0 0 0) (32 32 32) rotten megahealth
  185.  
  186. Health box. Normally gives 25 points.
  187.  
  188. Rotten box heals 5-10 points,
  189.  
  190. megahealth will add 100 health, then 
  191.  
  192. rot you down to your maximum health limit, 
  193.  
  194. one point per second.
  195.  
  196. */
  197.  
  198.  
  199.  
  200. float   H_ROTTEN = 1;
  201.  
  202. float   H_MEGA = 2;
  203.  
  204. .float  healamount, healtype;
  205.  
  206. void() health_touch;
  207.  
  208. void() item_megahealth_rot;
  209.  
  210.  
  211.  
  212. void() item_health =
  213.  
  214. {       
  215.  
  216.         self.touch = health_touch;
  217.  
  218.  
  219.  
  220.         if (self.spawnflags & H_ROTTEN)
  221.  
  222.         {
  223.  
  224.                 precache_model("maps/b_bh10.bsp");
  225.  
  226.  
  227.  
  228.                 precache_sound("items/r_item1.wav");
  229.  
  230.                 setmodel(self, "maps/b_bh10.bsp");
  231.  
  232.                 self.noise = "items/r_item1.wav";
  233.  
  234.                 self.healamount = 15;
  235.  
  236.                 self.healtype = 0;
  237.  
  238.         }
  239.  
  240.         else
  241.  
  242.         if (self.spawnflags & H_MEGA)
  243.  
  244.         {
  245.  
  246.                 precache_model("maps/b_bh100.bsp");
  247.  
  248.                 precache_sound("items/r_item2.wav");
  249.  
  250.                 setmodel(self, "maps/b_bh100.bsp");
  251.  
  252.                 self.noise = "items/r_item2.wav";
  253.  
  254.                 self.healamount = 100;
  255.  
  256.                 self.healtype = 2;
  257.  
  258.         }
  259.  
  260.         else
  261.  
  262.         {
  263.  
  264.                 precache_model("maps/b_bh25.bsp");
  265.  
  266.                 precache_sound("items/health1.wav");
  267.  
  268.                 setmodel(self, "maps/b_bh25.bsp");
  269.  
  270.                 self.noise = "items/health1.wav";
  271.  
  272.                 self.healamount = 25;
  273.  
  274.                 self.healtype = 1;
  275.  
  276.         }
  277.  
  278.         setsize (self, '0 0 0', '32 32 56');
  279.  
  280.         StartItem ();
  281.  
  282. };
  283.  
  284.  
  285.  
  286.  
  287. void() health_touch =
  288.  
  289. {
  290.  
  291.         local   float amount;
  292.  
  293.         local   string  s;
  294.  
  295.         
  296.  
  297.         if (other.classname != "player")
  298.  
  299.                 return;
  300.  
  301.         
  302.  
  303.         if (self.healtype == 2) // Megahealth?  Ignore max_health...
  304.  
  305.         {
  306.  
  307.                 if (other.health >= 250)
  308.  
  309.                         return;
  310.  
  311.                 if (!T_Heal(other, self.healamount, 1))
  312.  
  313.                         return;
  314.  
  315.         }
  316.  
  317.         else
  318.  
  319.         {
  320.  
  321.                 if (!T_Heal(other, self.healamount, 0))
  322.  
  323.                         return;
  324.  
  325.         }
  326.  
  327.         
  328.  
  329.         sprint(other, "You receive ");
  330.  
  331.         s = ftos(self.healamount);
  332.  
  333.         sprint(other, s);
  334.  
  335.         sprint(other, " health\n");
  336.  
  337.         
  338.  
  339. // health touch sound
  340.  
  341.         sound(other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  342.  
  343.  
  344.  
  345.         stuffcmd (other, "bf\n");
  346.  
  347.         
  348.  
  349.         self.model = string_null;
  350.  
  351.         self.solid = SOLID_NOT;
  352.  
  353.  
  354.  
  355.         // Megahealth = rot down the player's super health
  356.  
  357.         if (self.healtype == 2)
  358.  
  359.         {
  360.  
  361.                 other.items = other.items | IT_SUPERHEALTH;
  362.  
  363.                 self.nextthink = time + 5;
  364.  
  365.                 self.think = item_megahealth_rot;
  366.  
  367.                 self.owner = other;
  368.  
  369.         }
  370.  
  371.         else
  372.  
  373.         {
  374.  
  375.                 if (deathmatch != 2)            // deathmatch 2 is the silly old rules
  376.  
  377.                 {
  378.  
  379.                         if (deathmatch)
  380.  
  381.                                 self.nextthink = time + 20;
  382.  
  383.                         self.think = SUB_regen;
  384.  
  385.                 }
  386.  
  387.         }
  388.  
  389.         
  390.  
  391.         activator = other;
  392.  
  393.         SUB_UseTargets();                               // fire all targets / killtargets
  394.  
  395. };      
  396.  
  397.  
  398.  
  399. void() item_megahealth_rot =
  400.  
  401. {
  402.  
  403.         other = self.owner;
  404.  
  405.         
  406.  
  407.         if (other.health > other.max_health)
  408.  
  409.         {
  410.  
  411.                 other.health = other.health - 1;
  412.  
  413.                 self.nextthink = time + 1;
  414.  
  415.                 return;
  416.  
  417.         }
  418.  
  419.  
  420.  
  421. // it is possible for a player to die and respawn between rots, so don't
  422.  
  423. // just blindly subtract the flag off
  424.  
  425.         other.items = other.items - (other.items & IT_SUPERHEALTH);
  426.  
  427.         
  428.  
  429.         if (deathmatch == 1)    // deathmatch 2 is silly old rules
  430.  
  431.         {
  432.  
  433.                 self.nextthink = time + 20;
  434.  
  435.                 self.think = SUB_regen;
  436.  
  437.         }
  438.  
  439. };
  440.  
  441.  
  442. /*
  443.  
  444. ===============================================================================
  445.  
  446.  
  447.  
  448. ARMOR
  449.  
  450.  
  451.  
  452. ===============================================================================
  453.  
  454. */
  455.  
  456.  
  457.  
  458. void() armor_touch;
  459.  
  460.  
  461.  
  462. void() armor_touch =
  463.  
  464. {
  465.  
  466.         local   float   type, value, bit;
  467.  
  468.         
  469.  
  470.         if (other.health <= 0)
  471.  
  472.                 return;
  473.  
  474.         if (other.classname != "player")
  475.  
  476.                 return;
  477.  
  478.  
  479.  
  480.         if (self.classname == "item_armor1")
  481.  
  482.         {
  483.  
  484.                 type = 0.3;
  485.  
  486.                 value = 100;
  487.  
  488.                 bit = IT_ARMOR1;
  489.  
  490.         }
  491.  
  492.         if (self.classname == "item_armor2")
  493.  
  494.         {
  495.  
  496.                 type = 0.6;
  497.  
  498.                 value = 150;
  499.  
  500.                 bit = IT_ARMOR2;
  501.  
  502.         }
  503.  
  504.         if (self.classname == "item_armorInv")
  505.  
  506.         {
  507.  
  508.                 type = 0.8;
  509.  
  510.                 value = 200;
  511.  
  512.                 bit = IT_ARMOR3;
  513.  
  514.         }
  515.  
  516.         if (other.armortype*other.armorvalue >= type*value)
  517.  
  518.                 return;
  519.  
  520.                 
  521.  
  522.         other.armortype = type;
  523.  
  524.         other.armorvalue = value;
  525.  
  526.         other.items = other.items - (other.items & (IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + bit;
  527.  
  528.  
  529.  
  530.         self.solid = SOLID_NOT;
  531.  
  532.         self.model = string_null;
  533.  
  534.         if (deathmatch == 1)
  535.  
  536.                 self.nextthink = time + 20;
  537.  
  538.         self.think = SUB_regen;
  539.  
  540.  
  541.  
  542.         sprint(other, "You got armor\n");
  543.  
  544. // armor touch sound
  545.  
  546.         sound(other, CHAN_ITEM, "items/armor1.wav", 1, ATTN_NORM);
  547.  
  548.         stuffcmd (other, "bf\n");
  549.  
  550.         
  551.  
  552.         activator = other;
  553.  
  554.         SUB_UseTargets();                               // fire all targets / killtargets
  555.  
  556. };
  557.  
  558.  
  559.  
  560.  
  561.  
  562. /*QUAKED item_armor1 (0 .5 .8) (-16 -16 0) (16 16 32)
  563.  
  564. */
  565.  
  566.  
  567.  
  568. void() item_armor1 =
  569.  
  570. {
  571.  
  572.         self.touch = armor_touch;
  573.  
  574.         precache_model ("progs/armor.mdl");
  575.  
  576.         setmodel (self, "progs/armor.mdl");
  577.  
  578.         self.skin = 0;
  579.  
  580.         setsize (self, '-16 -16 0', '16 16 56');
  581.  
  582.         StartItem ();
  583.  
  584. };
  585.  
  586.  
  587.  
  588. /*QUAKED item_armor2 (0 .5 .8) (-16 -16 0) (16 16 32)
  589.  
  590. */
  591.  
  592.  
  593.  
  594. void() item_armor2 =
  595.  
  596. {
  597.  
  598.         self.touch = armor_touch;
  599.  
  600.         precache_model ("progs/armor.mdl");
  601.  
  602.         setmodel (self, "progs/armor.mdl");
  603.  
  604.         self.skin = 1;
  605.  
  606.         setsize (self, '-16 -16 0', '16 16 56');
  607.  
  608.         StartItem ();
  609.  
  610. };
  611.  
  612.  
  613.  
  614. /*QUAKED item_armorInv (0 .5 .8) (-16 -16 0) (16 16 32)
  615.  
  616. */
  617.  
  618.  
  619.  
  620. void() item_armorInv =
  621.  
  622. {
  623.  
  624.         self.touch = armor_touch;
  625.  
  626.         precache_model ("progs/armor.mdl");
  627.  
  628.         setmodel (self, "progs/armor.mdl");
  629.  
  630.         self.skin = 2;
  631.  
  632.         setsize (self, '-16 -16 0', '16 16 56');
  633.  
  634.         StartItem ();
  635.  
  636. };
  637.  
  638.  
  639.  
  640. /*
  641.  
  642. ===============================================================================
  643.  
  644.  
  645.  
  646. WEAPONS
  647.  
  648.  
  649.  
  650. ===============================================================================
  651.  
  652. */
  653.  
  654.  
  655.  
  656. void() bound_other_ammo =
  657.  
  658. {
  659.  
  660.         if (other.ammo_shells > 100)
  661.  
  662.                 other.ammo_shells = 100;
  663.  
  664.         if (other.ammo_nails > 200)
  665.  
  666.                 other.ammo_nails = 200;
  667.  
  668.         if (other.ammo_rockets > 100)
  669.  
  670.                 other.ammo_rockets = 100;               
  671.  
  672.         if (other.ammo_cells > 100)
  673.  
  674.                 other.ammo_cells = 100;         
  675.  
  676. };
  677.  
  678. float(float w) RankForWeapon =
  679.  
  680. {
  681.  
  682.         if (w == IT_LIGHTNING)
  683.  
  684.                 return 1;
  685.  
  686.         if (w == IT_ROCKET_LAUNCHER)
  687.  
  688.                 return 2;
  689.  
  690.         if (w == IT_SUPER_NAILGUN)
  691.  
  692.                 return 3;
  693.  
  694.         if (w == IT_GRENADE_LAUNCHER)
  695.  
  696.                 return 4;
  697.  
  698.         if (w == IT_SUPER_SHOTGUN)
  699.  
  700.                 return 5;
  701.  
  702.         if (w == IT_NAILGUN)
  703.  
  704.                 return 6;
  705.  
  706.         return 7;
  707.  
  708. };
  709.  
  710.  
  711.  
  712. /*
  713.  
  714. =============
  715.  
  716. Deathmatch_Weapon
  717.  
  718.  
  719.  
  720. Deathmatch weapon change rules for picking up a weapon
  721.  
  722.  
  723.  
  724. .float          ammo_shells, ammo_nails, ammo_rockets, ammo_cells;
  725.  
  726. =============
  727.  
  728. */
  729.  
  730. void(float old, float new) Deathmatch_Weapon =
  731.  
  732. {
  733.  
  734.         local float or, nr;
  735.  
  736. // change self.weapon if desired
  737.  
  738.         or = RankForWeapon (self.weapon);
  739.  
  740.         nr = RankForWeapon (new);
  741.  
  742.         if ( nr < or )
  743.  
  744.                 self.weapon = new;
  745.  
  746. };
  747.  
  748.  
  749.  
  750. /*
  751.  
  752. =============
  753.  
  754. weapon_touch
  755.  
  756. =============
  757.  
  758. */
  759.  
  760. float() W_BestWeapon;
  761.  
  762. void() weapon_touch =
  763.  
  764. {
  765.  
  766.         local   float   hadammo, best, new, old;
  767.  
  768.         local   entity  stemp;
  769.  
  770.         local   float   leave;
  771.  
  772.  
  773.  
  774.         if (!(other.flags & FL_CLIENT))
  775.  
  776.                 return;
  777.  
  778.         // if the player was using his best weapon, change up to the new one if better          
  779.  
  780.         stemp = self;
  781.  
  782.         self = other;
  783.  
  784.         best = W_BestWeapon();
  785.  
  786.         self = stemp;
  787.         
  788.         if (deathmatch == 2 || coop)
  789.  
  790.                 leave = 1;
  791.  
  792.         else
  793.  
  794.                 leave = 0;
  795.  
  796.         
  797.  
  798.         if (self.classname == "weapon_nailgun")
  799.  
  800.         {
  801.  
  802.                 if (leave && (other.items & IT_NAILGUN) )
  803.  
  804.                         return;
  805.  
  806.                 hadammo = other.ammo_nails;                     
  807.  
  808.                 new = IT_NAILGUN;
  809.  
  810.                 other.ammo_nails = other.ammo_nails + 30;
  811.  
  812.         }
  813.  
  814.         else if (self.classname == "weapon_supernailgun")
  815.  
  816.         {
  817.  
  818.                 if (leave && (other.items & IT_SUPER_NAILGUN) )
  819.  
  820.                         return;
  821.  
  822.                 hadammo = other.ammo_rockets;                   
  823.  
  824.                 new = IT_SUPER_NAILGUN;
  825.  
  826.                 other.ammo_nails = other.ammo_nails + 30;
  827.  
  828.         }
  829.  
  830.         else if (self.classname == "weapon_supershotgun")
  831.  
  832.         {
  833.  
  834.                 if (leave && (other.items & IT_SUPER_SHOTGUN) )
  835.  
  836.                         return;
  837.  
  838.                 hadammo = other.ammo_rockets;                   
  839.  
  840.                 new = IT_SUPER_SHOTGUN;
  841.  
  842.                 other.ammo_shells = other.ammo_shells + 5;
  843.  
  844.         }
  845.  
  846.         else if (self.classname == "weapon_rocketlauncher")
  847.  
  848.         {
  849.  
  850.                 if (leave && (other.items & IT_ROCKET_LAUNCHER) )
  851.  
  852.                         return;
  853.  
  854.                 hadammo = other.ammo_rockets;                   
  855.  
  856.                 new = IT_ROCKET_LAUNCHER;
  857.  
  858.                 other.ammo_rockets = other.ammo_rockets + 5;
  859.  
  860.         }
  861.  
  862.         else if (self.classname == "weapon_grenadelauncher")
  863.  
  864.         {
  865.  
  866.                 if (leave && (other.items & IT_GRENADE_LAUNCHER) )
  867.  
  868.                         return;
  869.  
  870.                 hadammo = other.ammo_rockets;                   
  871.  
  872.                 new = IT_GRENADE_LAUNCHER;
  873.  
  874.                 other.ammo_rockets = other.ammo_rockets + 5;
  875.  
  876.         }
  877.  
  878.         else if (self.classname == "weapon_lightning")
  879.  
  880.         {
  881.  
  882.                 if (leave && (other.items & IT_LIGHTNING) )
  883.  
  884.                         return;
  885.  
  886.                 hadammo = other.ammo_rockets;                   
  887.  
  888.                 new = IT_LIGHTNING;
  889.  
  890.                 other.ammo_cells = other.ammo_cells + 15;
  891.  
  892.         }
  893.  
  894.         else
  895.  
  896.                 objerror ("weapon_touch: unknown classname");
  897.  
  898.  
  899.         sprint (other, "You got the ");
  900.  
  901.         sprint (other, self.netname);
  902.  
  903.         sprint (other, "\n");
  904.  
  905. // weapon touch sound
  906.  
  907.         sound (other, CHAN_ITEM, "weapons/pkup.wav", 1, ATTN_NORM);
  908.  
  909.         stuffcmd (other, "bf\n");
  910.  
  911.  
  912.         bound_other_ammo ();
  913.  
  914. // Daniel 14/01/97
  915. // Prevents changing to a better weapon when playing dead.
  916.         if (!self.play_dead)
  917.         {
  918.         // change to the weapon
  919.  
  920.                 old = other.items;
  921.  
  922.                 other.items = other.items | new;      
  923.  
  924.                 stemp = self;
  925.  
  926.                 self = other;
  927.  
  928.                 if (!deathmatch)
  929.  
  930.                         self.weapon = new;
  931.  
  932.                 else
  933.  
  934.                         Deathmatch_Weapon (old, new);
  935.  
  936.  
  937.                 W_SetCurrentAmmo();
  938.  
  939.                 self = stemp;
  940.         }
  941.  
  942.         if (leave)
  943.                 return;
  944.  
  945.  
  946.  
  947. // remove it in single player, or setup for respawning in deathmatch
  948.  
  949.         self.model = string_null;
  950.  
  951.         self.solid = SOLID_NOT;
  952.  
  953.         if (deathmatch == 1)
  954.  
  955.                 self.nextthink = time + 30;
  956.  
  957.         self.think = SUB_regen;
  958.  
  959.         activator = other;
  960.  
  961.         SUB_UseTargets();                               // fire all targets / killtargets
  962.  
  963. };
  964.  
  965.  
  966.  
  967.  
  968.  
  969. /*QUAKED weapon_supershotgun (0 .5 .8) (-16 -16 0) (16 16 32)
  970.  
  971. */
  972.  
  973.  
  974.  
  975. void() weapon_supershotgun =
  976.  
  977. {
  978.  
  979.         precache_model ("progs/g_shot.mdl");
  980.  
  981.         setmodel (self, "progs/g_shot.mdl");
  982.  
  983.         self.weapon = IT_SUPER_SHOTGUN;
  984.  
  985.         self.netname = "Double-barrelled Shotgun";
  986.  
  987.         self.touch = weapon_touch;
  988.  
  989.         setsize (self, '-16 -16 0', '16 16 56');
  990.  
  991.         StartItem ();
  992.  
  993. };
  994.  
  995.  
  996.  
  997. /*QUAKED weapon_nailgun (0 .5 .8) (-16 -16 0) (16 16 32)
  998.  
  999. */
  1000.  
  1001.  
  1002.  
  1003. void() weapon_nailgun =
  1004.  
  1005. {
  1006.  
  1007.         precache_model ("progs/g_nail.mdl");
  1008.  
  1009.         setmodel (self, "progs/g_nail.mdl");
  1010.  
  1011.         self.weapon = IT_NAILGUN;
  1012.  
  1013.         self.netname = "nailgun";
  1014.  
  1015.         self.touch = weapon_touch;
  1016.  
  1017.         setsize (self, '-16 -16 0', '16 16 56');
  1018.  
  1019.         StartItem ();
  1020.  
  1021. };
  1022.  
  1023.  
  1024.  
  1025. /*QUAKED weapon_supernailgun (0 .5 .8) (-16 -16 0) (16 16 32)
  1026.  
  1027. */
  1028.  
  1029.  
  1030.  
  1031. void() weapon_supernailgun =
  1032.  
  1033. {
  1034.  
  1035.         precache_model ("progs/g_nail2.mdl");
  1036.  
  1037.         setmodel (self, "progs/g_nail2.mdl");
  1038.  
  1039.         self.weapon = IT_SUPER_NAILGUN;
  1040.  
  1041.         self.netname = "Super Nailgun";
  1042.  
  1043.         self.touch = weapon_touch;
  1044.  
  1045.         setsize (self, '-16 -16 0', '16 16 56');
  1046.  
  1047.         StartItem ();
  1048.  
  1049. };
  1050.  
  1051.  
  1052.  
  1053. /*QUAKED weapon_grenadelauncher (0 .5 .8) (-16 -16 0) (16 16 32)
  1054.  
  1055. */
  1056.  
  1057.  
  1058.  
  1059. void() weapon_grenadelauncher =
  1060.  
  1061. {
  1062.  
  1063.         precache_model ("progs/g_rock.mdl");
  1064.  
  1065.         setmodel (self, "progs/g_rock.mdl");
  1066.  
  1067.         self.weapon = 3;
  1068.  
  1069.         self.netname = "Grenade Launcher";
  1070.  
  1071.         self.touch = weapon_touch;
  1072.  
  1073.         setsize (self, '-16 -16 0', '16 16 56');
  1074.  
  1075.         StartItem ();
  1076.  
  1077. };
  1078.  
  1079.  
  1080.  
  1081. /*QUAKED weapon_rocketlauncher (0 .5 .8) (-16 -16 0) (16 16 32)
  1082.  
  1083. */
  1084.  
  1085.  
  1086.  
  1087. void() weapon_rocketlauncher =
  1088.  
  1089. {
  1090.  
  1091.         precache_model ("progs/g_rock2.mdl");
  1092.  
  1093.         setmodel (self, "progs/g_rock2.mdl");
  1094.  
  1095.         self.weapon = 3;
  1096.  
  1097.         self.netname = "Rocket Launcher";
  1098.  
  1099.         self.touch = weapon_touch;
  1100.  
  1101.         setsize (self, '-16 -16 0', '16 16 56');
  1102.  
  1103.         StartItem ();
  1104.  
  1105. };
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111. /*QUAKED weapon_lightning (0 .5 .8) (-16 -16 0) (16 16 32)
  1112.  
  1113. */
  1114.  
  1115.  
  1116.  
  1117. void() weapon_lightning =
  1118.  
  1119. {
  1120.  
  1121.         precache_model ("progs/g_light.mdl");
  1122.  
  1123.         setmodel (self, "progs/g_light.mdl");
  1124.  
  1125.         self.weapon = 3;
  1126.  
  1127.         self.netname = "Thunderbolt";
  1128.  
  1129.         self.touch = weapon_touch;
  1130.  
  1131.         setsize (self, '-16 -16 0', '16 16 56');
  1132.  
  1133.         StartItem ();
  1134.  
  1135. };
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141. /*
  1142.  
  1143. ===============================================================================
  1144.  
  1145.  
  1146.  
  1147. AMMO
  1148.  
  1149.  
  1150.  
  1151. ===============================================================================
  1152.  
  1153. */
  1154.  
  1155.  
  1156.  
  1157. void() ammo_touch =
  1158.  
  1159. {
  1160.  
  1161. local entity    stemp;
  1162.  
  1163. local float             best;
  1164.  
  1165.  
  1166.         if (other.classname != "player")
  1167.  
  1168.                 return;
  1169.  
  1170.         if (other.health <= 0)
  1171.  
  1172.                 return;
  1173.  
  1174.  
  1175.  
  1176. // if the player was using his best weapon, change up to the new one if better          
  1177.  
  1178.         stemp = self;
  1179.  
  1180.         self = other;
  1181.  
  1182.         best = W_BestWeapon();
  1183.  
  1184.         self = stemp;
  1185.  
  1186.  
  1187. // shotgun
  1188.  
  1189.         if (self.weapon == 1)
  1190.  
  1191.         {
  1192.  
  1193.                 if (other.ammo_shells >= 100)
  1194.  
  1195.                         return;
  1196.  
  1197.                 other.ammo_shells = other.ammo_shells + self.aflag;
  1198.  
  1199.         }
  1200.  
  1201.  
  1202.  
  1203. // spikes
  1204.  
  1205.         if (self.weapon == 2)
  1206.  
  1207.         {
  1208.  
  1209.                 if (other.ammo_nails >= 200)
  1210.  
  1211.                         return;
  1212.  
  1213.                 other.ammo_nails = other.ammo_nails + self.aflag;
  1214.  
  1215.         }
  1216.  
  1217.  
  1218.  
  1219. //      rockets
  1220.  
  1221.         if (self.weapon == 3)
  1222.  
  1223.         {
  1224.  
  1225.                 if (other.ammo_rockets >= 100)
  1226.  
  1227.                         return;
  1228.  
  1229.                 other.ammo_rockets = other.ammo_rockets + self.aflag;
  1230.  
  1231.         }
  1232.  
  1233.  
  1234.  
  1235. //      cells
  1236.  
  1237.         if (self.weapon == 4)
  1238.  
  1239.         {
  1240.  
  1241.                 if (other.ammo_cells >= 100)
  1242.  
  1243.                         return;
  1244.  
  1245.                 other.ammo_cells = other.ammo_cells + self.aflag;
  1246.  
  1247.         }
  1248.  
  1249.  
  1250.  
  1251.         bound_other_ammo ();
  1252.  
  1253.         
  1254.  
  1255.         sprint (other, "You got the ");
  1256.  
  1257.         sprint (other, self.netname);
  1258.  
  1259.         sprint (other, "\n");
  1260.  
  1261. // ammo touch sound
  1262.  
  1263.         sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
  1264.  
  1265.         stuffcmd (other, "bf\n");
  1266.  
  1267.  
  1268.  
  1269. // change to a better weapon if appropriate
  1270.  
  1271.  
  1272.         if ( other.weapon == best && !self.play_dead)
  1273.  
  1274.         {
  1275.  
  1276.                 stemp = self;
  1277.  
  1278.                 self = other;
  1279.  
  1280.                 self.weapon = W_BestWeapon();
  1281.  
  1282.                 W_SetCurrentAmmo ();
  1283.  
  1284.                 self = stemp;
  1285.  
  1286.         }
  1287.  
  1288.  
  1289.  
  1290. // if changed current ammo, update it
  1291.  
  1292.         stemp = self;
  1293.  
  1294.         self = other;
  1295.  
  1296.         W_SetCurrentAmmo();
  1297.  
  1298.         self = stemp;
  1299.  
  1300.  
  1301.  
  1302. // remove it in single player, or setup for respawning in deathmatch
  1303.  
  1304.         self.model = string_null;
  1305.  
  1306.         self.solid = SOLID_NOT;
  1307.  
  1308.         if (deathmatch == 1)
  1309.  
  1310.                 self.nextthink = time + 30;
  1311.  
  1312.         self.think = SUB_regen;
  1313.  
  1314.  
  1315.  
  1316.         activator = other;
  1317.  
  1318.         SUB_UseTargets();                               // fire all targets / killtargets
  1319.  
  1320. };
  1321.  
  1322.  
  1323.  
  1324.  
  1325.  
  1326.  
  1327.  
  1328.  
  1329.  
  1330. float WEAPON_BIG2 = 1;
  1331.  
  1332.  
  1333.  
  1334. /*QUAKED item_shells (0 .5 .8) (0 0 0) (32 32 32) big
  1335.  
  1336. */
  1337.  
  1338.  
  1339.  
  1340. void() item_shells =
  1341.  
  1342. {
  1343.  
  1344.         self.touch = ammo_touch;
  1345.  
  1346.  
  1347.  
  1348.         if (self.spawnflags & WEAPON_BIG2)
  1349.  
  1350.         {
  1351.  
  1352.                 precache_model ("maps/b_shell1.bsp");
  1353.  
  1354.                 setmodel (self, "maps/b_shell1.bsp");
  1355.  
  1356.                 self.aflag = 40;
  1357.  
  1358.         }
  1359.  
  1360.         else
  1361.  
  1362.         {
  1363.  
  1364.                 precache_model ("maps/b_shell0.bsp");
  1365.  
  1366.                 setmodel (self, "maps/b_shell0.bsp");
  1367.  
  1368.                 self.aflag = 20;
  1369.  
  1370.         }
  1371.  
  1372.         self.weapon = 1;
  1373.  
  1374.         self.netname = "shells";
  1375.  
  1376.         setsize (self, '0 0 0', '32 32 56');
  1377.  
  1378.         StartItem ();
  1379.  
  1380. };
  1381.  
  1382.  
  1383.  
  1384. /*QUAKED item_spikes (0 .5 .8) (0 0 0) (32 32 32) big
  1385.  
  1386. */
  1387.  
  1388.  
  1389.  
  1390. void() item_spikes =
  1391.  
  1392. {
  1393.  
  1394.         self.touch = ammo_touch;
  1395.  
  1396.  
  1397.  
  1398.         if (self.spawnflags & WEAPON_BIG2)
  1399.  
  1400.         {
  1401.  
  1402.                 precache_model ("maps/b_nail1.bsp");
  1403.  
  1404.                 setmodel (self, "maps/b_nail1.bsp");
  1405.  
  1406.                 self.aflag = 50;
  1407.  
  1408.         }
  1409.  
  1410.         else
  1411.  
  1412.         {
  1413.  
  1414.                 precache_model ("maps/b_nail0.bsp");
  1415.  
  1416.                 setmodel (self, "maps/b_nail0.bsp");
  1417.  
  1418.                 self.aflag = 25;
  1419.  
  1420.         }
  1421.  
  1422.         self.weapon = 2;
  1423.  
  1424.         self.netname = "nails";
  1425.  
  1426.         setsize (self, '0 0 0', '32 32 56');
  1427.  
  1428.         StartItem ();
  1429.  
  1430. };
  1431.  
  1432.  
  1433.  
  1434. /*QUAKED item_rockets (0 .5 .8) (0 0 0) (32 32 32) big
  1435.  
  1436. */
  1437.  
  1438.  
  1439.  
  1440. void() item_rockets =
  1441.  
  1442. {
  1443.  
  1444.         self.touch = ammo_touch;
  1445.  
  1446.  
  1447.  
  1448.         if (self.spawnflags & WEAPON_BIG2)
  1449.  
  1450.         {
  1451.  
  1452.                 precache_model ("maps/b_rock1.bsp");
  1453.  
  1454.                 setmodel (self, "maps/b_rock1.bsp");
  1455.  
  1456.                 self.aflag = 10;
  1457.  
  1458.         }
  1459.  
  1460.         else
  1461.  
  1462.         {
  1463.  
  1464.                 precache_model ("maps/b_rock0.bsp");
  1465.  
  1466.                 setmodel (self, "maps/b_rock0.bsp");
  1467.  
  1468.                 self.aflag = 5;
  1469.  
  1470.         }
  1471.  
  1472.         self.weapon = 3;
  1473.  
  1474.         self.netname = "rockets";
  1475.  
  1476.         setsize (self, '0 0 0', '32 32 56');
  1477.  
  1478.         StartItem ();
  1479.  
  1480. };
  1481.  
  1482.  
  1483.  
  1484.  
  1485.  
  1486. /*QUAKED item_cells (0 .5 .8) (0 0 0) (32 32 32) big
  1487.  
  1488. */
  1489.  
  1490.  
  1491.  
  1492. void() item_cells =
  1493.  
  1494. {
  1495.  
  1496.         self.touch = ammo_touch;
  1497.  
  1498.  
  1499.  
  1500.         if (self.spawnflags & WEAPON_BIG2)
  1501.  
  1502.         {
  1503.  
  1504.                 precache_model ("maps/b_batt1.bsp");
  1505.  
  1506.                 setmodel (self, "maps/b_batt1.bsp");
  1507.  
  1508.                 self.aflag = 12;
  1509.  
  1510.         }
  1511.  
  1512.         else
  1513.  
  1514.         {
  1515.  
  1516.                 precache_model ("maps/b_batt0.bsp");
  1517.  
  1518.                 setmodel (self, "maps/b_batt0.bsp");
  1519.  
  1520.                 self.aflag = 6;
  1521.  
  1522.         }
  1523.  
  1524.         self.weapon = 4;
  1525.  
  1526.         self.netname = "cells";
  1527.  
  1528.         setsize (self, '0 0 0', '32 32 56');
  1529.  
  1530.         StartItem ();
  1531.  
  1532. };
  1533.  
  1534.  
  1535.  
  1536.  
  1537. /*QUAKED item_weapon (0 .5 .8) (0 0 0) (32 32 32) shotgun rocket spikes big
  1538.  
  1539. DO NOT USE THIS!!!! IT WILL BE REMOVED!
  1540.  
  1541. */
  1542.  
  1543.  
  1544.  
  1545. float WEAPON_SHOTGUN = 1;
  1546.  
  1547. float WEAPON_ROCKET = 2;
  1548.  
  1549. float WEAPON_SPIKES = 4;
  1550.  
  1551. float WEAPON_BIG = 8;
  1552.  
  1553. void() item_weapon =
  1554.  
  1555. {
  1556.  
  1557.         self.touch = ammo_touch;
  1558.  
  1559.  
  1560.  
  1561.         if (self.spawnflags & WEAPON_SHOTGUN)
  1562.  
  1563.         {
  1564.  
  1565.                 if (self.spawnflags & WEAPON_BIG)
  1566.  
  1567.                 {
  1568.  
  1569.                         precache_model ("maps/b_shell1.bsp");
  1570.  
  1571.                         setmodel (self, "maps/b_shell1.bsp");
  1572.  
  1573.                         self.aflag = 40;
  1574.  
  1575.                 }
  1576.  
  1577.                 else
  1578.  
  1579.                 {
  1580.  
  1581.                         precache_model ("maps/b_shell0.bsp");
  1582.  
  1583.                         setmodel (self, "maps/b_shell0.bsp");
  1584.  
  1585.                         self.aflag = 20;
  1586.  
  1587.                 }
  1588.  
  1589.                 self.weapon = 1;
  1590.  
  1591.                 self.netname = "shells";
  1592.  
  1593.         }
  1594.  
  1595.  
  1596.  
  1597.         if (self.spawnflags & WEAPON_SPIKES)
  1598.  
  1599.         {
  1600.  
  1601.                 if (self.spawnflags & WEAPON_BIG)
  1602.  
  1603.                 {
  1604.  
  1605.                         precache_model ("maps/b_nail1.bsp");
  1606.  
  1607.                         setmodel (self, "maps/b_nail1.bsp");
  1608.  
  1609.                         self.aflag = 40;
  1610.  
  1611.                 }
  1612.  
  1613.                 else
  1614.  
  1615.                 {
  1616.  
  1617.                         precache_model ("maps/b_nail0.bsp");
  1618.  
  1619.                         setmodel (self, "maps/b_nail0.bsp");
  1620.  
  1621.                         self.aflag = 20;
  1622.  
  1623.                 }
  1624.  
  1625.                 self.weapon = 2;
  1626.  
  1627.                 self.netname = "spikes";
  1628.  
  1629.         }
  1630.  
  1631.  
  1632.  
  1633.         if (self.spawnflags & WEAPON_ROCKET)
  1634.  
  1635.         {
  1636.  
  1637.                 if (self.spawnflags & WEAPON_BIG)
  1638.  
  1639.                 {
  1640.  
  1641.                         precache_model ("maps/b_rock1.bsp");
  1642.  
  1643.                         setmodel (self, "maps/b_rock1.bsp");
  1644.  
  1645.                         self.aflag = 10;
  1646.  
  1647.                 }
  1648.  
  1649.                 else
  1650.  
  1651.                 {
  1652.  
  1653.                         precache_model ("maps/b_rock0.bsp");
  1654.  
  1655.                         setmodel (self, "maps/b_rock0.bsp");
  1656.  
  1657.                         self.aflag = 5;
  1658.  
  1659.                 }
  1660.  
  1661.                 self.weapon = 3;
  1662.  
  1663.                 self.netname = "rockets";
  1664.  
  1665.         }
  1666.  
  1667.         
  1668.  
  1669.         setsize (self, '0 0 0', '32 32 56');
  1670.  
  1671.         StartItem ();
  1672.  
  1673. };
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679. /*
  1680.  
  1681. ===============================================================================
  1682.  
  1683.  
  1684.  
  1685. KEYS
  1686.  
  1687.  
  1688.  
  1689. ===============================================================================
  1690.  
  1691. */
  1692.  
  1693.  
  1694.  
  1695. void() key_touch =
  1696.  
  1697. {
  1698.  
  1699. local entity    stemp;
  1700.  
  1701. local float             best;
  1702.  
  1703.  
  1704.  
  1705.         if (other.classname != "player")
  1706.  
  1707.                 return;
  1708.  
  1709.         if (other.health <= 0)
  1710.  
  1711.                 return;
  1712.  
  1713.         if (other.items & self.items)
  1714.  
  1715.                 return;
  1716.  
  1717.  
  1718.  
  1719.         sprint (other, "You got the ");
  1720.  
  1721.         sprint (other, self.netname);
  1722.  
  1723.         sprint (other,"\n");
  1724.  
  1725.  
  1726.  
  1727.         sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  1728.  
  1729.         stuffcmd (other, "bf\n");
  1730.  
  1731.         other.items = other.items | self.items;
  1732.  
  1733.  
  1734.  
  1735.         if (!coop)
  1736.  
  1737.         {       
  1738.  
  1739.                 self.solid = SOLID_NOT;
  1740.  
  1741.                 self.model = string_null;
  1742.  
  1743.         }
  1744.  
  1745.  
  1746.  
  1747.         activator = other;
  1748.  
  1749.         SUB_UseTargets();                               // fire all targets / killtargets
  1750.  
  1751. };
  1752.  
  1753.  
  1754.  
  1755.  
  1756.  
  1757. void() key_setsounds =
  1758.  
  1759. {
  1760.  
  1761.         if (world.worldtype == 0)
  1762.  
  1763.         {
  1764.  
  1765.                 precache_sound ("misc/medkey.wav");
  1766.  
  1767.                 self.noise = "misc/medkey.wav";
  1768.  
  1769.         }
  1770.  
  1771.         if (world.worldtype == 1)
  1772.  
  1773.         {
  1774.  
  1775.                 precache_sound ("misc/runekey.wav");
  1776.  
  1777.                 self.noise = "misc/runekey.wav";
  1778.  
  1779.         }
  1780.  
  1781.         if (world.worldtype == 2)
  1782.  
  1783.         {
  1784.  
  1785.                 precache_sound2 ("misc/basekey.wav");
  1786.  
  1787.                 self.noise = "misc/basekey.wav";
  1788.  
  1789.         }
  1790.  
  1791. };
  1792.  
  1793.  
  1794. /*QUAKED item_key1 (0 .5 .8) (-16 -16 -24) (16 16 32)
  1795.  
  1796. SILVER key
  1797.  
  1798. In order for keys to work
  1799.  
  1800. you MUST set your maps
  1801.  
  1802. worldtype to one of the
  1803.  
  1804. following:
  1805.  
  1806. 0: medieval
  1807.  
  1808. 1: metal
  1809.  
  1810. 2: base
  1811.  
  1812. */
  1813.  
  1814.  
  1815.  
  1816. void() item_key1 =
  1817.  
  1818. {
  1819.  
  1820.         if (world.worldtype == 0)
  1821.  
  1822.         {
  1823.  
  1824.                 precache_model ("progs/w_s_key.mdl");
  1825.  
  1826.                 setmodel (self, "progs/w_s_key.mdl");
  1827.  
  1828.                 self.netname = "silver key";
  1829.  
  1830.         }
  1831.  
  1832.         else if (world.worldtype == 1)
  1833.  
  1834.         {
  1835.  
  1836.                 precache_model ("progs/m_s_key.mdl");
  1837.  
  1838.                 setmodel (self, "progs/m_s_key.mdl");
  1839.  
  1840.                 self.netname = "silver runekey";
  1841.  
  1842.         }
  1843.  
  1844.         else if (world.worldtype == 2)
  1845.  
  1846.         {
  1847.  
  1848.                 precache_model2 ("progs/b_s_key.mdl");
  1849.  
  1850.                 setmodel (self, "progs/b_s_key.mdl");
  1851.  
  1852.                 self.netname = "silver keycard";
  1853.  
  1854.         }
  1855.  
  1856.         key_setsounds();
  1857.  
  1858.         self.touch = key_touch;
  1859.  
  1860.         self.items = IT_KEY1;
  1861.  
  1862.         setsize (self, '-16 -16 -24', '16 16 32');
  1863.  
  1864.         StartItem ();
  1865.  
  1866. };
  1867.  
  1868.  
  1869.  
  1870. /*QUAKED item_key2 (0 .5 .8) (-16 -16 -24) (16 16 32)
  1871.  
  1872. GOLD key
  1873.  
  1874. In order for keys to work
  1875.  
  1876. you MUST set your maps
  1877.  
  1878. worldtype to one of the
  1879.  
  1880. following:
  1881.  
  1882. 0: medieval
  1883.  
  1884. 1: metal
  1885.  
  1886. 2: base
  1887.  
  1888. */
  1889.  
  1890.  
  1891.  
  1892. void() item_key2 =
  1893.  
  1894. {
  1895.  
  1896.         if (world.worldtype == 0)
  1897.  
  1898.         {
  1899.  
  1900.                 precache_model ("progs/w_g_key.mdl");
  1901.  
  1902.                 setmodel (self, "progs/w_g_key.mdl");
  1903.  
  1904.                 self.netname = "gold key";
  1905.  
  1906.         }
  1907.  
  1908.         if (world.worldtype == 1)
  1909.  
  1910.         {
  1911.  
  1912.                 precache_model ("progs/m_g_key.mdl");
  1913.  
  1914.                 setmodel (self, "progs/m_g_key.mdl");
  1915.  
  1916.                 self.netname = "gold runekey";
  1917.  
  1918.         }
  1919.  
  1920.         if (world.worldtype == 2)
  1921.  
  1922.         {
  1923.  
  1924.                 precache_model2 ("progs/b_g_key.mdl");
  1925.  
  1926.                 setmodel (self, "progs/b_g_key.mdl");
  1927.  
  1928.                 self.netname = "gold keycard";
  1929.  
  1930.         }
  1931.  
  1932.         key_setsounds();
  1933.  
  1934.         self.touch = key_touch;
  1935.  
  1936.         self.items = IT_KEY2;
  1937.  
  1938.         setsize (self, '-16 -16 -24', '16 16 32');
  1939.  
  1940.         StartItem ();
  1941.  
  1942. };
  1943.  
  1944.  
  1945.  
  1946.  
  1947.  
  1948.  
  1949.  
  1950. /*
  1951.  
  1952. ===============================================================================
  1953.  
  1954.  
  1955.  
  1956. END OF LEVEL RUNES
  1957.  
  1958.  
  1959.  
  1960. ===============================================================================
  1961.  
  1962. */
  1963.  
  1964.  
  1965.  
  1966. void() sigil_touch =
  1967.  
  1968. {
  1969.  
  1970. local entity    stemp;
  1971.  
  1972. local float             best;
  1973.  
  1974.  
  1975.  
  1976.         if (other.classname != "player")
  1977.  
  1978.                 return;
  1979.  
  1980.         if (other.health <= 0)
  1981.  
  1982.                 return;
  1983.  
  1984.  
  1985.  
  1986.         centerprint (other, "You got the rune!");
  1987.  
  1988.  
  1989.  
  1990.         sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  1991.  
  1992.         stuffcmd (other, "bf\n");
  1993.  
  1994.         self.solid = SOLID_NOT;
  1995.  
  1996.         self.model = string_null;
  1997.  
  1998.         serverflags = serverflags | (self.spawnflags & 15);
  1999.  
  2000.         self.classname = "";            // so rune doors won't find it
  2001.  
  2002.         
  2003.  
  2004.         activator = other;
  2005.  
  2006.         SUB_UseTargets();                               // fire all targets / killtargets
  2007.  
  2008. };
  2009.  
  2010.  
  2011.  
  2012.  
  2013.  
  2014. /*QUAKED item_sigil (0 .5 .8) (-16 -16 -24) (16 16 32) E1 E2 E3 E4
  2015.  
  2016. End of level sigil, pick up to end episode and return to jrstart.
  2017.  
  2018. */
  2019.  
  2020.  
  2021.  
  2022. void() item_sigil =
  2023.  
  2024. {
  2025.  
  2026.         if (!self.spawnflags)
  2027.  
  2028.                 objerror ("no spawnflags");
  2029.  
  2030.  
  2031.  
  2032.         precache_sound ("misc/runekey.wav");
  2033.  
  2034.         self.noise = "misc/runekey.wav";
  2035.  
  2036.  
  2037.  
  2038.         if (self.spawnflags & 1)
  2039.  
  2040.         {
  2041.  
  2042.                 precache_model ("progs/end1.mdl");
  2043.  
  2044.                 setmodel (self, "progs/end1.mdl");
  2045.  
  2046.         }
  2047.  
  2048.         if (self.spawnflags & 2)
  2049.  
  2050.         {
  2051.  
  2052.                 precache_model2 ("progs/end2.mdl");
  2053.  
  2054.                 setmodel (self, "progs/end2.mdl");
  2055.  
  2056.         }
  2057.  
  2058.         if (self.spawnflags & 4)
  2059.  
  2060.         {
  2061.  
  2062.                 precache_model2 ("progs/end3.mdl");
  2063.  
  2064.                 setmodel (self, "progs/end3.mdl");
  2065.  
  2066.         }
  2067.  
  2068.         if (self.spawnflags & 8)
  2069.  
  2070.         {
  2071.  
  2072.                 precache_model2 ("progs/end4.mdl");
  2073.  
  2074.                 setmodel (self, "progs/end4.mdl");
  2075.  
  2076.         }
  2077.  
  2078.         
  2079.  
  2080.         self.touch = sigil_touch;
  2081.  
  2082.         setsize (self, '-16 -16 -24', '16 16 32');
  2083.  
  2084.         StartItem ();
  2085.  
  2086. };
  2087.  
  2088.  
  2089. /*
  2090.  
  2091. ===============================================================================
  2092.  
  2093.  
  2094.  
  2095. POWERUPS
  2096.  
  2097.  
  2098.  
  2099. ===============================================================================
  2100.  
  2101. */
  2102.  
  2103.  
  2104.  
  2105. void() powerup_touch;
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111. void() powerup_touch =
  2112.  
  2113. {
  2114.  
  2115. local entity    stemp;
  2116.  
  2117. local float             best;
  2118.  
  2119.  
  2120.  
  2121.         if (other.classname != "player")
  2122.  
  2123.                 return;
  2124.  
  2125.         if (other.health <= 0)
  2126.  
  2127.                 return;
  2128.  
  2129.  
  2130.  
  2131.         sprint (other, "You got the ");
  2132.  
  2133.         sprint (other, self.netname);
  2134.  
  2135.         sprint (other,"\n");
  2136.  
  2137.  
  2138.  
  2139.         if (deathmatch)
  2140.  
  2141.         {
  2142.  
  2143.                 self.mdl = self.model;
  2144.  
  2145.                 
  2146.  
  2147.                 if ((self.classname == "item_artifact_invulnerability") ||
  2148.  
  2149.                         (self.classname == "item_artifact_invisibility"))
  2150.  
  2151.                         self.nextthink = time + 60*5;
  2152.  
  2153.                 else
  2154.  
  2155.                         self.nextthink = time + 60;
  2156.  
  2157.                 
  2158.  
  2159.                 self.think = SUB_regen;
  2160.  
  2161.         }       
  2162.  
  2163.  
  2164.  
  2165.         sound (other, CHAN_VOICE, self.noise, 1, ATTN_NORM);
  2166.  
  2167.         stuffcmd (other, "bf\n");
  2168.  
  2169.         self.solid = SOLID_NOT;
  2170.  
  2171.         other.items = other.items | self.items;
  2172.  
  2173.         self.model = string_null;
  2174.  
  2175.  
  2176.  
  2177. // do the apropriate action
  2178.  
  2179.         if (self.classname == "item_artifact_envirosuit")
  2180.  
  2181.         {
  2182.  
  2183.                 other.rad_time = 1;
  2184.  
  2185.                 other.radsuit_finished = time + 30;
  2186.  
  2187.         }
  2188.  
  2189.         
  2190.  
  2191.         if (self.classname == "item_artifact_invulnerability")
  2192.  
  2193.         {
  2194.  
  2195.                 other.invincible_time = 1;
  2196.  
  2197.                 other.invincible_finished = time + 30;
  2198.  
  2199.         }
  2200.  
  2201.         
  2202.  
  2203.         if (self.classname == "item_artifact_invisibility")
  2204.  
  2205.         {
  2206.  
  2207.                 other.invisible_time = 1;
  2208.  
  2209.                 other.invisible_finished = time + 30;
  2210.  
  2211.         }
  2212.  
  2213.  
  2214.  
  2215.         if (self.classname == "item_artifact_super_damage")
  2216.  
  2217.         {
  2218.  
  2219.                 other.super_time = 1;
  2220.  
  2221.                 other.super_damage_finished = time + 30;
  2222.  
  2223.         }       
  2224.  
  2225.  
  2226.  
  2227.         activator = other;
  2228.  
  2229.         SUB_UseTargets();                               // fire all targets / killtargets
  2230.  
  2231. };
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239. /*QUAKED item_artifact_invulnerability (0 .5 .8) (-16 -16 -24) (16 16 32)
  2240.  
  2241. Player is invulnerable for 30 seconds
  2242.  
  2243. */
  2244.  
  2245. void() item_artifact_invulnerability =
  2246.  
  2247. {
  2248.  
  2249.         self.touch = powerup_touch;
  2250.  
  2251.  
  2252.  
  2253.         precache_model ("progs/invulner.mdl");
  2254.  
  2255.         precache_sound ("items/protect.wav");
  2256.  
  2257.         precache_sound ("items/protect2.wav");
  2258.  
  2259.         precache_sound ("items/protect3.wav");
  2260.  
  2261.         self.noise = "items/protect.wav";
  2262.  
  2263.         setmodel (self, "progs/invulner.mdl");
  2264.  
  2265.         self.netname = "Pentagram of Protection";
  2266.  
  2267.         self.items = IT_INVULNERABILITY;
  2268.  
  2269.         setsize (self, '-16 -16 -24', '16 16 32');
  2270.  
  2271.         StartItem ();
  2272.  
  2273. };
  2274.  
  2275.  
  2276.  
  2277. /*QUAKED item_artifact_envirosuit (0 .5 .8) (-16 -16 -24) (16 16 32)
  2278.  
  2279. Player takes no damage from water or slime for 30 seconds
  2280.  
  2281. */
  2282.  
  2283. void() item_artifact_envirosuit =
  2284.  
  2285. {
  2286.  
  2287.         self.touch = powerup_touch;
  2288.  
  2289.  
  2290.  
  2291.         precache_model ("progs/suit.mdl");
  2292.  
  2293.         precache_sound ("items/suit.wav");
  2294.  
  2295.         precache_sound ("items/suit2.wav");
  2296.  
  2297.         self.noise = "items/suit.wav";
  2298.  
  2299.         setmodel (self, "progs/suit.mdl");
  2300.  
  2301.         self.netname = "Biosuit";
  2302.  
  2303.         self.items = IT_SUIT;
  2304.  
  2305.         setsize (self, '-16 -16 -24', '16 16 32');
  2306.  
  2307.         StartItem ();
  2308.  
  2309. };
  2310.  
  2311.  
  2312.  
  2313.  
  2314.  
  2315. /*QUAKED item_artifact_invisibility (0 .5 .8) (-16 -16 -24) (16 16 32)
  2316.  
  2317. Player is invisible for 30 seconds
  2318.  
  2319. */
  2320.  
  2321. void() item_artifact_invisibility =
  2322.  
  2323. {
  2324.  
  2325.         self.touch = powerup_touch;
  2326.  
  2327.  
  2328.  
  2329.         precache_model ("progs/invisibl.mdl");
  2330.  
  2331.         precache_sound ("items/inv1.wav");
  2332.  
  2333.         precache_sound ("items/inv2.wav");
  2334.  
  2335.         precache_sound ("items/inv3.wav");
  2336.  
  2337.         self.noise = "items/inv1.wav";
  2338.  
  2339.         setmodel (self, "progs/invisibl.mdl");
  2340.  
  2341.         self.netname = "Ring of Shadows";
  2342.  
  2343.         self.items = IT_INVISIBILITY;
  2344.  
  2345.         setsize (self, '-16 -16 -24', '16 16 32');
  2346.  
  2347.         StartItem ();
  2348.  
  2349. };
  2350.  
  2351.  
  2352.  
  2353.  
  2354.  
  2355. /*QUAKED item_artifact_super_damage (0 .5 .8) (-16 -16 -24) (16 16 32)
  2356.  
  2357. The next attack from the player will do 4x damage
  2358.  
  2359. */
  2360.  
  2361. void() item_artifact_super_damage =
  2362.  
  2363. {
  2364.  
  2365.         self.touch = powerup_touch;
  2366.  
  2367.  
  2368.  
  2369.         precache_model ("progs/quaddama.mdl");
  2370.  
  2371.         precache_sound ("items/damage.wav");
  2372.  
  2373.         precache_sound ("items/damage2.wav");
  2374.  
  2375.         precache_sound ("items/damage3.wav");
  2376.  
  2377.         self.noise = "items/damage.wav";
  2378.  
  2379.         setmodel (self, "progs/quaddama.mdl");
  2380.  
  2381.         self.netname = "Quad Damage";
  2382.  
  2383.         self.items = IT_QUAD;
  2384.  
  2385.         setsize (self, '-16 -16 -24', '16 16 32');
  2386.  
  2387.         StartItem ();
  2388.  
  2389. };
  2390.  
  2391.  
  2392.  
  2393.  
  2394.  
  2395.  
  2396.  
  2397. /*
  2398.  
  2399. ===============================================================================
  2400.  
  2401.  
  2402.  
  2403. PLAYER BACKPACKS
  2404.  
  2405.  
  2406.  
  2407. ===============================================================================
  2408.  
  2409. */
  2410.  
  2411.  
  2412.  
  2413. void() BackpackTouch =
  2414.  
  2415. {
  2416.  
  2417.         local string    s;
  2418.  
  2419.         local   float   best, old, new;
  2420.  
  2421.         local           entity  stemp;
  2422.  
  2423.         
  2424.  
  2425.         if (other.classname != "player")
  2426.  
  2427.                 return;
  2428.  
  2429.         if (other.health <= 0)
  2430.  
  2431.                 return;
  2432.  
  2433.               
  2434. // if the player was using his best weapon, change up to the new one if better          
  2435.  
  2436.         stemp = self;
  2437.  
  2438.         self = other;
  2439.  
  2440.         best = W_BestWeapon();
  2441.  
  2442.         self = stemp;
  2443.  
  2444.  
  2445.  
  2446. // change weapons
  2447.  
  2448.         other.ammo_shells = other.ammo_shells + self.ammo_shells;
  2449.  
  2450.         other.ammo_nails = other.ammo_nails + self.ammo_nails;
  2451.  
  2452.         other.ammo_rockets = other.ammo_rockets + self.ammo_rockets;
  2453.  
  2454.         other.ammo_cells = other.ammo_cells + self.ammo_cells;
  2455.  
  2456.  
  2457.  
  2458.         new = self.items;
  2459.  
  2460.         if (!new)
  2461.  
  2462.                 new = other.weapon;
  2463.  
  2464.         old = other.items;
  2465.  
  2466.         other.items = other.items | new;
  2467.  
  2468.         
  2469.  
  2470.         bound_other_ammo ();
  2471.  
  2472.  
  2473.  
  2474.         sprint (other, "You get ");
  2475.  
  2476.  
  2477.  
  2478.         if (self.ammo_shells)
  2479.  
  2480.         {
  2481.  
  2482.                 s = ftos(self.ammo_shells);
  2483.  
  2484.                 sprint (other, s);
  2485.  
  2486.                 sprint (other, " shells  ");
  2487.  
  2488.         }
  2489.  
  2490.         if (self.ammo_nails)
  2491.  
  2492.         {
  2493.  
  2494.                 s = ftos(self.ammo_nails);
  2495.  
  2496.                 sprint (other, s);
  2497.  
  2498.                 sprint (other, " nails ");
  2499.  
  2500.         }
  2501.  
  2502.         if (self.ammo_rockets)
  2503.  
  2504.         {
  2505.  
  2506.                 s = ftos(self.ammo_rockets);
  2507.  
  2508.                 sprint (other, s);
  2509.  
  2510.                 sprint (other, " rockets  ");
  2511.  
  2512.         }
  2513.  
  2514.         if (self.ammo_cells)
  2515.  
  2516.         {
  2517.  
  2518.                 s = ftos(self.ammo_cells);
  2519.  
  2520.                 sprint (other, s);
  2521.  
  2522.                 sprint (other, " cells  ");
  2523.  
  2524.         }
  2525.  
  2526.         
  2527.  
  2528.         sprint (other, "\n");
  2529.  
  2530. // backpack touch sound
  2531.  
  2532.         sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
  2533.  
  2534.         stuffcmd (other, "bf\n");
  2535.  
  2536.  
  2537.  
  2538. // remove the backpack, change self to the player
  2539.  
  2540.         remove(self);
  2541.  
  2542.         self = other;
  2543.  
  2544.  
  2545.  
  2546. // change to the weapon
  2547.  
  2548.         if (!deathmatch)
  2549.  
  2550.                 self.weapon = new;
  2551.  
  2552.         else
  2553.  
  2554.                 Deathmatch_Weapon (old, new);
  2555.  
  2556.  
  2557.  
  2558.         W_SetCurrentAmmo ();
  2559.  
  2560. };
  2561.  
  2562.  
  2563.  
  2564. /*
  2565.  
  2566. ===============
  2567.  
  2568. DropBackpack
  2569.  
  2570. ===============
  2571.  
  2572. */
  2573.  
  2574. void() DropBackpack =
  2575.  
  2576. {
  2577.         local entity    item;
  2578.  
  2579.  
  2580.  
  2581.         if (!(self.ammo_shells + self.ammo_nails + self.ammo_rockets + self.ammo_cells))
  2582.  
  2583.                 return; // nothing in it
  2584.  
  2585.  
  2586.  
  2587.         item = spawn();
  2588.  
  2589.         item.origin = self.origin - '0 0 24';
  2590.  
  2591.         
  2592.  
  2593.         item.items = self.weapon;
  2594.  
  2595.  
  2596.  
  2597.         item.ammo_shells = self.ammo_shells;
  2598.  
  2599.         item.ammo_nails = self.ammo_nails;
  2600.  
  2601.         item.ammo_rockets = self.ammo_rockets;
  2602.  
  2603.         item.ammo_cells = self.ammo_cells;
  2604.  
  2605.  
  2606.  
  2607.         item.velocity_z = 300;
  2608.  
  2609.         item.velocity_x = -100 + (random() * 200);
  2610.  
  2611.         item.velocity_y = -100 + (random() * 200);
  2612.  
  2613.         
  2614.  
  2615.         item.flags = FL_ITEM;
  2616.  
  2617.         item.solid = SOLID_TRIGGER;
  2618.  
  2619.         item.movetype = MOVETYPE_TOSS;
  2620.  
  2621.         setmodel (item, "progs/backpack.mdl");
  2622.  
  2623.         setsize (item, '-16 -16 0', '16 16 56');
  2624.  
  2625.         item.touch = BackpackTouch;
  2626.  
  2627.         
  2628.  
  2629.         item.nextthink = time + 120;    // remove after 2 minutes
  2630.  
  2631.         item.think = SUB_Remove;
  2632.  
  2633. };
  2634.  
  2635.  
  2636.