home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1997 June / CDW0697.iso / Quake / NIVELES / GRAP111.ZIP / ITEMS.QC < prev    next >
Encoding:
Text File  |  1996-10-16  |  29.5 KB  |  1,389 lines

  1. void() W_SetCurrentAmmo;
  2. /* ALL LIGHTS SHOULD BE 0 1 0 IN COLOR ALL OTHER ITEMS SHOULD
  3. BE .8 .3 .4 IN COLOR */
  4.  
  5.  
  6. void() SUB_regen =
  7. {
  8.     self.model = self.mdl;        // restore original model
  9.     self.solid = SOLID_TRIGGER;    // allow it to be touched again
  10.     sound (self, CHAN_VOICE, "items/itembk2.wav", 1, ATTN_NORM);    // play respawn sound
  11.     setorigin (self, self.origin);
  12. };
  13.  
  14.  
  15.  
  16. /*QUAKED noclass (0 0 0) (-8 -8 -8) (8 8 8)
  17. prints a warning message when spawned
  18. */
  19. void() noclass =
  20. {
  21.     dprint ("noclass spawned at");
  22.     dprint (vtos(self.origin));
  23.     dprint ("\n");
  24.     remove (self);
  25. };
  26.  
  27.  
  28.  
  29. /*
  30. ============
  31. PlaceItem
  32.  
  33. plants the object on the floor
  34. ============
  35. */
  36. void() PlaceItem =
  37. {
  38.     local float    oldz;
  39.  
  40.     self.mdl = self.model;        // so it can be restored on respawn
  41.     self.flags = FL_ITEM;        // make extra wide
  42.     self.solid = SOLID_TRIGGER;
  43.     self.movetype = MOVETYPE_TOSS;    
  44.     self.velocity = '0 0 0';
  45.     self.origin_z = self.origin_z + 6;
  46.     oldz = self.origin_z;
  47.     if (!droptofloor())
  48.     {
  49.         dprint ("Bonus item fell out of level at ");
  50.         dprint (vtos(self.origin));
  51.         dprint ("\n");
  52.         remove(self);
  53.         return;
  54.     }
  55. };
  56.  
  57. /*
  58. ============
  59. StartItem
  60.  
  61. Sets the clipping size and plants the object on the floor
  62. ============
  63. */
  64. void() StartItem =
  65. {
  66.     self.nextthink = time + 0.2;    // items start after other solids
  67.     self.think = PlaceItem;
  68. };
  69.  
  70. /*
  71. =========================================================================
  72.  
  73. HEALTH BOX
  74.  
  75. =========================================================================
  76. */
  77. //
  78. // T_Heal: add health to an entity, limiting health to max_health
  79. // "ignore" will ignore max_health limit
  80. //
  81. float (entity e, float healamount, float ignore) T_Heal =
  82. {
  83.     if (e.health <= 0)
  84.         return 0;
  85.     if ((!ignore) && (e.health >= other.max_health))
  86.         return 0;
  87.     healamount = ceil(healamount);
  88.  
  89.     e.health = e.health + healamount;
  90.     if ((!ignore) && (e.health >= other.max_health))
  91.         e.health = other.max_health;
  92.         
  93.     if (e.health > 250)
  94.         e.health = 250;
  95.     return 1;
  96. };
  97.  
  98. /*QUAKED item_health (.3 .3 1) (0 0 0) (32 32 32) rotten megahealth
  99. Health box. Normally gives 25 points.
  100. Rotten box heals 5-10 points,
  101. megahealth will add 100 health, then 
  102. rot you down to your maximum health limit, 
  103. one point per second.
  104. */
  105.  
  106. float    H_ROTTEN = 1;
  107. float    H_MEGA = 2;
  108. .float    healamount, healtype;
  109. void() health_touch;
  110. void() item_megahealth_rot;
  111.  
  112. void() item_health =
  113. {    
  114.     self.touch = health_touch;
  115.  
  116.     if (self.spawnflags & H_ROTTEN)
  117.     {
  118.         precache_model("maps/b_bh10.bsp");
  119.  
  120.         precache_sound("items/r_item1.wav");
  121.         setmodel(self, "maps/b_bh10.bsp");
  122.         self.noise = "items/r_item1.wav";
  123.         self.healamount = 15;
  124.         self.healtype = 0;
  125.     }
  126.     else
  127.     if (self.spawnflags & H_MEGA)
  128.     {
  129.         precache_model("maps/b_bh100.bsp");
  130.         precache_sound("items/r_item2.wav");
  131.         setmodel(self, "maps/b_bh100.bsp");
  132.         self.noise = "items/r_item2.wav";
  133.         self.healamount = 100;
  134.         self.healtype = 2;
  135.     }
  136.     else
  137.     {
  138.         precache_model("maps/b_bh25.bsp");
  139.         precache_sound("items/health1.wav");
  140.         setmodel(self, "maps/b_bh25.bsp");
  141.         self.noise = "items/health1.wav";
  142.         self.healamount = 25;
  143.         self.healtype = 1;
  144.     }
  145.     setsize (self, '0 0 0', '32 32 56');
  146.     StartItem ();
  147. };
  148.  
  149.  
  150. void() health_touch =
  151. {
  152.     local    float amount;
  153.     local    string    s;
  154.     
  155.     if (other.classname != "player")
  156.         return;
  157.     
  158.     if (self.healtype == 2) // Megahealth?  Ignore max_health...
  159.     {
  160.         if (other.health >= 250)
  161.             return;
  162.         if (!T_Heal(other, self.healamount, 1))
  163.             return;
  164.     }
  165.     else
  166.     {
  167.         if (!T_Heal(other, self.healamount, 0))
  168.             return;
  169.     }
  170.     
  171.     sprint(other, "You receive ");
  172.     s = ftos(self.healamount);
  173.     sprint(other, s);
  174.     sprint(other, " health\n");
  175.     
  176. // health touch sound
  177.     sound(other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  178.  
  179.     stuffcmd (other, "bf\n");
  180.     
  181.     self.model = string_null;
  182.     self.solid = SOLID_NOT;
  183.  
  184.     // Megahealth = rot down the player's super health
  185.     if (self.healtype == 2)
  186.     {
  187.         other.items = other.items | IT_SUPERHEALTH;
  188.         self.nextthink = time + 5;
  189.         self.think = item_megahealth_rot;
  190.         self.owner = other;
  191.     }
  192.     else
  193.     {
  194.         if (deathmatch != 2)        // deathmatch 2 is the silly old rules
  195.         {
  196.             if (deathmatch)
  197.                 self.nextthink = time + 20;
  198.             self.think = SUB_regen;
  199.         }
  200.     }
  201.     
  202.     activator = other;
  203.     SUB_UseTargets();                // fire all targets / killtargets
  204. };    
  205.  
  206. void() item_megahealth_rot =
  207. {
  208.     other = self.owner;
  209.     
  210.     if (other.health > other.max_health)
  211.     {
  212.         other.health = other.health - 1;
  213.         self.nextthink = time + 1;
  214.         return;
  215.     }
  216.  
  217. // it is possible for a player to die and respawn between rots, so don't
  218. // just blindly subtract the flag off
  219.     other.items = other.items - (other.items & IT_SUPERHEALTH);
  220.     
  221.     if (deathmatch == 1)    // deathmatch 2 is silly old rules
  222.     {
  223.         self.nextthink = time + 20;
  224.         self.think = SUB_regen;
  225.     }
  226. };
  227.  
  228. /*
  229. ===============================================================================
  230.  
  231. ARMOR
  232.  
  233. ===============================================================================
  234. */
  235.  
  236. void() armor_touch;
  237.  
  238. void() armor_touch =
  239. {
  240.     local    float    type, value, bit;
  241.     
  242.     if (other.health <= 0)
  243.         return;
  244.     if (other.classname != "player")
  245.         return;
  246.  
  247.     if (self.classname == "item_armor1")
  248.     {
  249.         type = 0.3;
  250.         value = 100;
  251.         bit = IT_ARMOR1;
  252.     }
  253.     if (self.classname == "item_armor2")
  254.     {
  255.         type = 0.6;
  256.         value = 150;
  257.         bit = IT_ARMOR2;
  258.     }
  259.     if (self.classname == "item_armorInv")
  260.     {
  261.         type = 0.8;
  262.         value = 200;
  263.         bit = IT_ARMOR3;
  264.     }
  265.     if (other.armortype*other.armorvalue >= type*value)
  266.         return;
  267.         
  268.     other.armortype = type;
  269.     other.armorvalue = value;
  270.     other.items = other.items - (other.items & (IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + bit;
  271.  
  272.     self.solid = SOLID_NOT;
  273.     self.model = string_null;
  274.     if (deathmatch == 1)
  275.         self.nextthink = time + 20;
  276.     self.think = SUB_regen;
  277.  
  278.     sprint(other, "You got armor\n");
  279. // armor touch sound
  280.     sound(other, CHAN_ITEM, "items/armor1.wav", 1, ATTN_NORM);
  281.     stuffcmd (other, "bf\n");
  282.     
  283.     activator = other;
  284.     SUB_UseTargets();                // fire all targets / killtargets
  285. };
  286.  
  287.  
  288. /*QUAKED item_armor1 (0 .5 .8) (-16 -16 0) (16 16 32)
  289. */
  290.  
  291. void() item_armor1 =
  292. {
  293.     self.touch = armor_touch;
  294.     precache_model ("progs/armor.mdl");
  295.     setmodel (self, "progs/armor.mdl");
  296.     self.skin = 0;
  297.     setsize (self, '-16 -16 0', '16 16 56');
  298.     StartItem ();
  299. };
  300.  
  301. /*QUAKED item_armor2 (0 .5 .8) (-16 -16 0) (16 16 32)
  302. */
  303.  
  304. void() item_armor2 =
  305. {
  306.     self.touch = armor_touch;
  307.     precache_model ("progs/armor.mdl");
  308.     setmodel (self, "progs/armor.mdl");
  309.     self.skin = 1;
  310.     setsize (self, '-16 -16 0', '16 16 56');
  311.     StartItem ();
  312. };
  313.  
  314. /*QUAKED item_armorInv (0 .5 .8) (-16 -16 0) (16 16 32)
  315. */
  316.  
  317. void() item_armorInv =
  318. {
  319.     self.touch = armor_touch;
  320.     precache_model ("progs/armor.mdl");
  321.     setmodel (self, "progs/armor.mdl");
  322.     self.skin = 2;
  323.     setsize (self, '-16 -16 0', '16 16 56');
  324.     StartItem ();
  325. };
  326.  
  327. /*
  328. ===============================================================================
  329.  
  330. WEAPONS
  331.  
  332. ===============================================================================
  333. */
  334.  
  335. void() bound_other_ammo =
  336. {
  337.     if (other.ammo_shells > 100)
  338.         other.ammo_shells = 100;
  339.     if (other.ammo_nails > 200)
  340.         other.ammo_nails = 200;
  341.     if (other.ammo_rockets > 100)
  342.         other.ammo_rockets = 100;        
  343.     if (other.ammo_cells > 100)
  344.         other.ammo_cells = 100;        
  345. };
  346.  
  347.  
  348. float(float w) RankForWeapon =
  349. {
  350.     if (w == IT_LIGHTNING)
  351.         return 1;
  352.     if (w == IT_ROCKET_LAUNCHER)
  353.         return 2;
  354.     if (w == IT_SUPER_NAILGUN)
  355.         return 3;
  356.     if (w == IT_GRENADE_LAUNCHER)
  357.         return 4;
  358.     if (w == IT_SUPER_SHOTGUN)
  359.         return 5;
  360.     if (w == IT_NAILGUN)
  361.         return 6;
  362.     return 7;
  363. };
  364.  
  365. /*
  366. =============
  367. Deathmatch_Weapon
  368.  
  369. Deathmatch weapon change rules for picking up a weapon
  370.  
  371. .float        ammo_shells, ammo_nails, ammo_rockets, ammo_cells;
  372. =============
  373. */
  374. void(float old, float new) Deathmatch_Weapon =
  375. {
  376.     local float or, nr;
  377.  
  378. // change self.weapon if desired
  379.     or = RankForWeapon (self.weapon);
  380.     nr = RankForWeapon (new);
  381.     if ( nr < or )
  382.         self.weapon = new;
  383. };
  384.  
  385. /*
  386. =============
  387. weapon_touch
  388. =============
  389. */
  390. float() W_BestWeapon;
  391.  
  392. void() weapon_touch =
  393. {
  394.     local    float    hadammo, best, new, old;
  395.     local    entity    stemp;
  396.     local    float    leave;
  397.  
  398.     if (!(other.flags & FL_CLIENT))
  399.         return;
  400.  
  401. // if the player was using his best weapon, change up to the new one if better        
  402.     stemp = self;
  403.     self = other;
  404.     best = W_BestWeapon();
  405.     self = stemp;
  406.  
  407.     if (deathmatch == 2 || coop)
  408.         leave = 1;
  409.     else
  410.         leave = 0;
  411.     
  412.     if (self.classname == "weapon_nailgun")
  413.     {
  414.         if (leave && (other.items & IT_NAILGUN) )
  415.             return;
  416.         hadammo = other.ammo_nails;            
  417.         new = IT_NAILGUN;
  418.         other.ammo_nails = other.ammo_nails + 30;
  419.     }
  420.     else if (self.classname == "weapon_supernailgun")
  421.     {
  422.         if (leave && (other.items & IT_SUPER_NAILGUN) )
  423.             return;
  424.         hadammo = other.ammo_rockets;            
  425.         new = IT_SUPER_NAILGUN;
  426.         other.ammo_nails = other.ammo_nails + 30;
  427.     }
  428.     else if (self.classname == "weapon_supershotgun")
  429.     {
  430.         if (leave && (other.items & IT_SUPER_SHOTGUN) )
  431.             return;
  432.         hadammo = other.ammo_rockets;            
  433.         new = IT_SUPER_SHOTGUN;
  434.         other.ammo_shells = other.ammo_shells + 5;
  435.     }
  436.     else if (self.classname == "weapon_rocketlauncher")
  437.     {
  438.         if (leave && (other.items & IT_ROCKET_LAUNCHER) )
  439.             return;
  440.         hadammo = other.ammo_rockets;            
  441.         new = IT_ROCKET_LAUNCHER;
  442.         other.ammo_rockets = other.ammo_rockets + 5;
  443.     }
  444.     else if (self.classname == "weapon_grenadelauncher")
  445.     {
  446.         if (leave && (other.items & IT_GRENADE_LAUNCHER) )
  447.             return;
  448.         hadammo = other.ammo_rockets;            
  449.         new = IT_GRENADE_LAUNCHER;
  450.         other.ammo_rockets = other.ammo_rockets + 5;
  451.     }
  452.     else if (self.classname == "weapon_lightning")
  453.     {
  454.         if (leave && (other.items & IT_LIGHTNING) )
  455.             return;
  456.         hadammo = other.ammo_rockets;            
  457.         new = IT_LIGHTNING;
  458.         other.ammo_cells = other.ammo_cells + 15;
  459.     }
  460.     else
  461.         objerror ("weapon_touch: unknown classname");
  462.  
  463.     sprint (other, "You got the ");
  464.     sprint (other, self.netname);
  465.     sprint (other, "\n");
  466. // weapon touch sound
  467.     sound (other, CHAN_ITEM, "weapons/pkup.wav", 1, ATTN_NORM);
  468.     stuffcmd (other, "bf\n");
  469.  
  470.     bound_other_ammo ();
  471.  
  472. // change to the weapon
  473.     old = other.items;
  474.     other.items = other.items | new;
  475.     
  476.     stemp = self;
  477.     self = other;
  478.  
  479.     if (!deathmatch)
  480.         self.weapon = new;
  481.     else
  482.         Deathmatch_Weapon (old, new);
  483.  
  484.     W_SetCurrentAmmo();
  485.  
  486.     self = stemp;
  487.  
  488.     if (leave)
  489.         return;
  490.  
  491. // remove it in single player, or setup for respawning in deathmatch
  492.     self.model = string_null;
  493.     self.solid = SOLID_NOT;
  494.     if (deathmatch == 1)
  495.         self.nextthink = time + 30;
  496.     self.think = SUB_regen;
  497.     
  498.     activator = other;
  499.     SUB_UseTargets();                // fire all targets / killtargets
  500. };
  501.  
  502.  
  503. /*QUAKED weapon_supershotgun (0 .5 .8) (-16 -16 0) (16 16 32)
  504. */
  505.  
  506. void() weapon_supershotgun =
  507. {
  508.     precache_model ("progs/g_shot.mdl");
  509.     setmodel (self, "progs/g_shot.mdl");
  510.     self.weapon = IT_SUPER_SHOTGUN;
  511.     self.netname = "Double-barrelled Shotgun";
  512.     self.touch = weapon_touch;
  513.     setsize (self, '-16 -16 0', '16 16 56');
  514.     StartItem ();
  515. };
  516.  
  517. /*QUAKED weapon_nailgun (0 .5 .8) (-16 -16 0) (16 16 32)
  518. */
  519.  
  520. void() weapon_nailgun =
  521. {
  522.     precache_model ("progs/g_nail.mdl");
  523.     setmodel (self, "progs/g_nail.mdl");
  524.     self.weapon = IT_NAILGUN;
  525.     self.netname = "nailgun";
  526.     self.touch = weapon_touch;
  527.     setsize (self, '-16 -16 0', '16 16 56');
  528.     StartItem ();
  529. };
  530.  
  531. /*QUAKED weapon_supernailgun (0 .5 .8) (-16 -16 0) (16 16 32)
  532. */
  533.  
  534. void() weapon_supernailgun =
  535. {
  536.     precache_model ("progs/g_nail2.mdl");
  537.     setmodel (self, "progs/g_nail2.mdl");
  538.     self.weapon = IT_SUPER_NAILGUN;
  539.     self.netname = "Super Nailgun";
  540.     self.touch = weapon_touch;
  541.     setsize (self, '-16 -16 0', '16 16 56');
  542.     StartItem ();
  543. };
  544.  
  545. /*QUAKED weapon_grenadelauncher (0 .5 .8) (-16 -16 0) (16 16 32)
  546. */
  547.  
  548. void() weapon_grenadelauncher =
  549. {
  550.     precache_model ("progs/g_rock.mdl");
  551.     setmodel (self, "progs/g_rock.mdl");
  552.     self.weapon = 3;
  553.     self.netname = "Grenade Launcher";
  554.     self.touch = weapon_touch;
  555.     setsize (self, '-16 -16 0', '16 16 56');
  556.     StartItem ();
  557. };
  558.  
  559. /*QUAKED weapon_rocketlauncher (0 .5 .8) (-16 -16 0) (16 16 32)
  560. */
  561.  
  562. void() weapon_rocketlauncher =
  563. {
  564.     precache_model ("progs/g_rock2.mdl");
  565.     setmodel (self, "progs/g_rock2.mdl");
  566.     self.weapon = 3;
  567.     self.netname = "Rocket Launcher";
  568.     self.touch = weapon_touch;
  569.     setsize (self, '-16 -16 0', '16 16 56');
  570.     StartItem ();
  571. };
  572.  
  573.  
  574. /*QUAKED weapon_lightning (0 .5 .8) (-16 -16 0) (16 16 32)
  575. */
  576.  
  577. void() weapon_lightning =
  578. {
  579.     precache_model ("progs/g_light.mdl");
  580.     setmodel (self, "progs/g_light.mdl");
  581.     self.weapon = 3;
  582.     self.netname = "Thunderbolt";
  583.     self.touch = weapon_touch;
  584.     setsize (self, '-16 -16 0', '16 16 56');
  585.     StartItem ();
  586. };
  587.  
  588.  
  589. /*
  590. ===============================================================================
  591.  
  592. AMMO
  593.  
  594. ===============================================================================
  595. */
  596.  
  597. void() ammo_touch =
  598. {
  599. local entity    stemp;
  600. local float        best;
  601.  
  602.     if (other.classname != "player")
  603.         return;
  604.     if (other.health <= 0)
  605.         return;
  606.  
  607. // if the player was using his best weapon, change up to the new one if better        
  608.     stemp = self;
  609.     self = other;
  610.     best = W_BestWeapon();
  611.     self = stemp;
  612.  
  613.  
  614. // shotgun
  615.     if (self.weapon == 1)
  616.     {
  617.         if (other.ammo_shells >= 100)
  618.             return;
  619.         other.ammo_shells = other.ammo_shells + self.aflag;
  620.     }
  621.  
  622. // spikes
  623.     if (self.weapon == 2)
  624.     {
  625.         if (other.ammo_nails >= 200)
  626.             return;
  627.         other.ammo_nails = other.ammo_nails + self.aflag;
  628.     }
  629.  
  630. //    rockets
  631.     if (self.weapon == 3)
  632.     {
  633.         if (other.ammo_rockets >= 100)
  634.             return;
  635.         other.ammo_rockets = other.ammo_rockets + self.aflag;
  636.     }
  637.  
  638. //    cells
  639.     if (self.weapon == 4)
  640.     {
  641.         if (other.ammo_cells >= 100)
  642.             return;
  643.         other.ammo_cells = other.ammo_cells + self.aflag;
  644.     }
  645.  
  646.     bound_other_ammo ();
  647.     
  648.     sprint (other, "You got the ");
  649.     sprint (other, self.netname);
  650.     sprint (other, "\n");
  651. // ammo touch sound
  652.     sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
  653.     stuffcmd (other, "bf\n");
  654.  
  655. // change to a better weapon if appropriate
  656.  
  657.     if ( other.weapon == best )
  658.     {
  659.         stemp = self;
  660.         self = other;
  661.         self.weapon = W_BestWeapon();
  662.         W_SetCurrentAmmo ();
  663.         self = stemp;
  664.     }
  665.  
  666. // if changed current ammo, update it
  667.     stemp = self;
  668.     self = other;
  669.     W_SetCurrentAmmo();
  670.     self = stemp;
  671.  
  672. // remove it in single player, or setup for respawning in deathmatch
  673.     self.model = string_null;
  674.     self.solid = SOLID_NOT;
  675.     if (deathmatch == 1)
  676.         self.nextthink = time + 30;
  677.     self.think = SUB_regen;
  678.  
  679.     activator = other;
  680.     SUB_UseTargets();                // fire all targets / killtargets
  681. };
  682.  
  683.  
  684.  
  685.  
  686. float WEAPON_BIG2 = 1;
  687.  
  688. /*QUAKED item_shells (0 .5 .8) (0 0 0) (32 32 32) big
  689. */
  690.  
  691. void() item_shells =
  692. {
  693.     self.touch = ammo_touch;
  694.  
  695.     if (self.spawnflags & WEAPON_BIG2)
  696.     {
  697.         precache_model ("maps/b_shell1.bsp");
  698.         setmodel (self, "maps/b_shell1.bsp");
  699.         self.aflag = 40;
  700.                 self.netname = "box of shells";
  701.     }
  702.     else
  703.     {
  704.         precache_model ("maps/b_shell0.bsp");
  705.         setmodel (self, "maps/b_shell0.bsp");
  706.         self.aflag = 20;
  707.                 self.netname = "shells";
  708.     }
  709.     self.weapon = 1;
  710.     setsize (self, '0 0 0', '32 32 56');
  711.     StartItem ();
  712. };
  713.  
  714. /*QUAKED item_spikes (0 .5 .8) (0 0 0) (32 32 32) big
  715. */
  716.  
  717. void() item_spikes =
  718. {
  719.     self.touch = ammo_touch;
  720.  
  721.     if (self.spawnflags & WEAPON_BIG2)
  722.     {
  723.         precache_model ("maps/b_nail1.bsp");
  724.         setmodel (self, "maps/b_nail1.bsp");
  725.         self.aflag = 50;
  726.                 self.netname = "crate of nails";
  727.     }
  728.     else
  729.     {
  730.         precache_model ("maps/b_nail0.bsp");
  731.         setmodel (self, "maps/b_nail0.bsp");
  732.         self.aflag = 25;
  733.                 self.netname = "nails";
  734.     }
  735.     self.weapon = 2;
  736.     setsize (self, '0 0 0', '32 32 56');
  737.     StartItem ();
  738. };
  739.  
  740. /*QUAKED item_rockets (0 .5 .8) (0 0 0) (32 32 32) big
  741. */
  742.  
  743. void() item_rockets =
  744. {
  745.     self.touch = ammo_touch;
  746.  
  747.     if (self.spawnflags & WEAPON_BIG2)
  748.     {
  749.         precache_model ("maps/b_rock1.bsp");
  750.         setmodel (self, "maps/b_rock1.bsp");
  751.         self.aflag = 10;
  752.                 self.netname = "pack of rockets";
  753.     }
  754.     else
  755.     {
  756.         precache_model ("maps/b_rock0.bsp");
  757.         setmodel (self, "maps/b_rock0.bsp");
  758.         self.aflag = 5;
  759.                 self.netname = "rockets";
  760.     }
  761.     self.weapon = 3;
  762.     setsize (self, '0 0 0', '32 32 56');
  763.     StartItem ();
  764. };
  765.  
  766.  
  767. /*QUAKED item_cells (0 .5 .8) (0 0 0) (32 32 32) big
  768. */
  769.  
  770. void() item_cells =
  771. {
  772.     self.touch = ammo_touch;
  773.  
  774.     if (self.spawnflags & WEAPON_BIG2)
  775.     {
  776.         precache_model ("maps/b_batt1.bsp");
  777.         setmodel (self, "maps/b_batt1.bsp");
  778.         self.aflag = 12;
  779.                 self.netname = "battery pack";
  780.     }
  781.     else
  782.     {
  783.         precache_model ("maps/b_batt0.bsp");
  784.         setmodel (self, "maps/b_batt0.bsp");
  785.         self.aflag = 6;
  786.                 self.netname = "cells";
  787.     }
  788.     self.weapon = 4;
  789.     setsize (self, '0 0 0', '32 32 56');
  790.     StartItem ();
  791. };
  792.  
  793.  
  794. /*QUAKED item_weapon (0 .5 .8) (0 0 0) (32 32 32) shotgun rocket spikes big
  795. DO NOT USE THIS!!!! IT WILL BE REMOVED!
  796. */
  797.  
  798. float WEAPON_SHOTGUN = 1;
  799. float WEAPON_ROCKET = 2;
  800. float WEAPON_SPIKES = 4;
  801. float WEAPON_BIG = 8;
  802. void() item_weapon =
  803. {
  804.     self.touch = ammo_touch;
  805.  
  806.     if (self.spawnflags & WEAPON_SHOTGUN)
  807.     {
  808.         if (self.spawnflags & WEAPON_BIG)
  809.         {
  810.             precache_model ("maps/b_shell1.bsp");
  811.             setmodel (self, "maps/b_shell1.bsp");
  812.             self.aflag = 40;
  813.         }
  814.         else
  815.         {
  816.             precache_model ("maps/b_shell0.bsp");
  817.             setmodel (self, "maps/b_shell0.bsp");
  818.             self.aflag = 20;
  819.         }
  820.         self.weapon = 1;
  821.         self.netname = "shells";
  822.     }
  823.  
  824.     if (self.spawnflags & WEAPON_SPIKES)
  825.     {
  826.         if (self.spawnflags & WEAPON_BIG)
  827.         {
  828.             precache_model ("maps/b_nail1.bsp");
  829.             setmodel (self, "maps/b_nail1.bsp");
  830.             self.aflag = 40;
  831.         }
  832.         else
  833.         {
  834.             precache_model ("maps/b_nail0.bsp");
  835.             setmodel (self, "maps/b_nail0.bsp");
  836.             self.aflag = 20;
  837.         }
  838.         self.weapon = 2;
  839.         self.netname = "spikes";
  840.     }
  841.  
  842.     if (self.spawnflags & WEAPON_ROCKET)
  843.     {
  844.         if (self.spawnflags & WEAPON_BIG)
  845.         {
  846.             precache_model ("maps/b_rock1.bsp");
  847.             setmodel (self, "maps/b_rock1.bsp");
  848.             self.aflag = 10;
  849.         }
  850.         else
  851.         {
  852.             precache_model ("maps/b_rock0.bsp");
  853.             setmodel (self, "maps/b_rock0.bsp");
  854.             self.aflag = 5;
  855.         }
  856.         self.weapon = 3;
  857.         self.netname = "rockets";
  858.     }
  859.     
  860.     setsize (self, '0 0 0', '32 32 56');
  861.     StartItem ();
  862. };
  863.  
  864.  
  865. /*
  866. ===============================================================================
  867.  
  868. KEYS
  869.  
  870. ===============================================================================
  871. */
  872.  
  873. void() key_touch =
  874. {
  875. local entity    stemp;
  876. local float        best;
  877.  
  878.     if (other.classname != "player")
  879.         return;
  880.     if (other.health <= 0)
  881.         return;
  882.     if (other.items & self.items)
  883.         return;
  884.  
  885.     sprint (other, "You got the ");
  886.     sprint (other, self.netname);
  887.     sprint (other,"\n");
  888.  
  889.     sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  890.     stuffcmd (other, "bf\n");
  891.     other.items = other.items | self.items;
  892.  
  893.     if (!coop)
  894.     {    
  895.         self.solid = SOLID_NOT;
  896.         self.model = string_null;
  897.     }
  898.  
  899.     activator = other;
  900.     SUB_UseTargets();                // fire all targets / killtargets
  901. };
  902.  
  903.  
  904. void() key_setsounds =
  905. {
  906.     if (world.worldtype == 0)
  907.     {
  908.         precache_sound ("misc/medkey.wav");
  909.         self.noise = "misc/medkey.wav";
  910.     }
  911.     if (world.worldtype == 1)
  912.     {
  913.         precache_sound ("misc/runekey.wav");
  914.         self.noise = "misc/runekey.wav";
  915.     }
  916.     if (world.worldtype == 2)
  917.     {
  918.         precache_sound2 ("misc/basekey.wav");
  919.         self.noise = "misc/basekey.wav";
  920.     }
  921. };
  922.  
  923. /*QUAKED item_key1 (0 .5 .8) (-16 -16 -24) (16 16 32)
  924. SILVER key
  925. In order for keys to work
  926. you MUST set your maps
  927. worldtype to one of the
  928. following:
  929. 0: medieval
  930. 1: metal
  931. 2: base
  932. */
  933.  
  934. void() item_key1 =
  935. {
  936.     if (world.worldtype == 0)
  937.     {
  938.         precache_model ("progs/w_s_key.mdl");
  939.         setmodel (self, "progs/w_s_key.mdl");
  940.         self.netname = "silver key";
  941.     }
  942.     else if (world.worldtype == 1)
  943.     {
  944.         precache_model ("progs/m_s_key.mdl");
  945.         setmodel (self, "progs/m_s_key.mdl");
  946.         self.netname = "silver runekey";
  947.     }
  948.     else if (world.worldtype == 2)
  949.     {
  950.         precache_model2 ("progs/b_s_key.mdl");
  951.         setmodel (self, "progs/b_s_key.mdl");
  952.         self.netname = "silver keycard";
  953.     }
  954.     key_setsounds();
  955.     self.touch = key_touch;
  956.     self.items = IT_KEY1;
  957.     setsize (self, '-16 -16 -24', '16 16 32');
  958.     StartItem ();
  959. };
  960.  
  961. /*QUAKED item_key2 (0 .5 .8) (-16 -16 -24) (16 16 32)
  962. GOLD key
  963. In order for keys to work
  964. you MUST set your maps
  965. worldtype to one of the
  966. following:
  967. 0: medieval
  968. 1: metal
  969. 2: base
  970. */
  971.  
  972. void() item_key2 =
  973. {
  974.     if (world.worldtype == 0)
  975.     {
  976.         precache_model ("progs/w_g_key.mdl");
  977.         setmodel (self, "progs/w_g_key.mdl");
  978.         self.netname = "gold key";
  979.     }
  980.     if (world.worldtype == 1)
  981.     {
  982.         precache_model ("progs/m_g_key.mdl");
  983.         setmodel (self, "progs/m_g_key.mdl");
  984.         self.netname = "gold runekey";
  985.     }
  986.     if (world.worldtype == 2)
  987.     {
  988.         precache_model2 ("progs/b_g_key.mdl");
  989.         setmodel (self, "progs/b_g_key.mdl");
  990.         self.netname = "gold keycard";
  991.     }
  992.     key_setsounds();
  993.     self.touch = key_touch;
  994.     self.items = IT_KEY2;
  995.     setsize (self, '-16 -16 -24', '16 16 32');
  996.     StartItem ();
  997. };
  998.  
  999.  
  1000.  
  1001. /*
  1002. ===============================================================================
  1003.  
  1004. END OF LEVEL RUNES
  1005.  
  1006. ===============================================================================
  1007. */
  1008.  
  1009. void() sigil_touch =
  1010. {
  1011. local entity    stemp;
  1012. local float        best;
  1013.  
  1014.     if (other.classname != "player")
  1015.         return;
  1016.     if (other.health <= 0)
  1017.         return;
  1018.  
  1019.     centerprint (other, "You got the rune!");
  1020.  
  1021.     sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  1022.     stuffcmd (other, "bf\n");
  1023.     self.solid = SOLID_NOT;
  1024.     self.model = string_null;
  1025.     serverflags = serverflags | (self.spawnflags & 15);
  1026.     self.classname = "";        // so rune doors won't find it
  1027.     
  1028.     activator = other;
  1029.     SUB_UseTargets();                // fire all targets / killtargets
  1030. };
  1031.  
  1032.  
  1033. /*QUAKED item_sigil (0 .5 .8) (-16 -16 -24) (16 16 32) E1 E2 E3 E4
  1034. End of level sigil, pick up to end episode and return to jrstart.
  1035. */
  1036.  
  1037. void() item_sigil =
  1038. {
  1039.     if (!self.spawnflags)
  1040.         objerror ("no spawnflags");
  1041.  
  1042.     precache_sound ("misc/runekey.wav");
  1043.     self.noise = "misc/runekey.wav";
  1044.  
  1045.     if (self.spawnflags & 1)
  1046.     {
  1047.         precache_model ("progs/end1.mdl");
  1048.         setmodel (self, "progs/end1.mdl");
  1049.     }
  1050.     if (self.spawnflags & 2)
  1051.     {
  1052.         precache_model2 ("progs/end2.mdl");
  1053.         setmodel (self, "progs/end2.mdl");
  1054.     }
  1055.     if (self.spawnflags & 4)
  1056.     {
  1057.         precache_model2 ("progs/end3.mdl");
  1058.         setmodel (self, "progs/end3.mdl");
  1059.     }
  1060.     if (self.spawnflags & 8)
  1061.     {
  1062.         precache_model2 ("progs/end4.mdl");
  1063.         setmodel (self, "progs/end4.mdl");
  1064.     }
  1065.     
  1066.     self.touch = sigil_touch;
  1067.     setsize (self, '-16 -16 -24', '16 16 32');
  1068.     StartItem ();
  1069. };
  1070.  
  1071. /*
  1072. ===============================================================================
  1073.  
  1074. POWERUPS
  1075.  
  1076. ===============================================================================
  1077. */
  1078.  
  1079. void() powerup_touch;
  1080.  
  1081.  
  1082. void() powerup_touch =
  1083. {
  1084. local entity    stemp;
  1085. local float        best;
  1086.  
  1087.     if (other.classname != "player")
  1088.         return;
  1089.     if (other.health <= 0)
  1090.         return;
  1091.  
  1092.     sprint (other, "You got the ");
  1093.     sprint (other, self.netname);
  1094.     sprint (other,"\n");
  1095.  
  1096.     if (deathmatch)
  1097.     {
  1098.         self.mdl = self.model;
  1099.         
  1100.         if ((self.classname == "item_artifact_invulnerability") ||
  1101.             (self.classname == "item_artifact_invisibility"))
  1102.             self.nextthink = time + 60*5;
  1103.         else
  1104.             self.nextthink = time + 60;
  1105.         
  1106.         self.think = SUB_regen;
  1107.     }    
  1108.  
  1109.     sound (other, CHAN_VOICE, self.noise, 1, ATTN_NORM);
  1110.     stuffcmd (other, "bf\n");
  1111.     self.solid = SOLID_NOT;
  1112.     other.items = other.items | self.items;
  1113.     self.model = string_null;
  1114.  
  1115. // do the apropriate action
  1116.     if (self.classname == "item_artifact_envirosuit")
  1117.     {
  1118.         other.rad_time = 1;
  1119.         other.radsuit_finished = time + 30;
  1120.     }
  1121.     
  1122.     if (self.classname == "item_artifact_invulnerability")
  1123.     {
  1124.         other.invincible_time = 1;
  1125.         other.invincible_finished = time + 30;
  1126.     }
  1127.     
  1128.     if (self.classname == "item_artifact_invisibility")
  1129.     {
  1130.         other.invisible_time = 1;
  1131.         other.invisible_finished = time + 30;
  1132.     }
  1133.  
  1134.     if (self.classname == "item_artifact_super_damage")
  1135.     {
  1136.         other.super_time = 1;
  1137.         other.super_damage_finished = time + 30;
  1138.     }    
  1139.  
  1140.     activator = other;
  1141.     SUB_UseTargets();                // fire all targets / killtargets
  1142. };
  1143.  
  1144.  
  1145.  
  1146. /*QUAKED item_artifact_invulnerability (0 .5 .8) (-16 -16 -24) (16 16 32)
  1147. Player is invulnerable for 30 seconds
  1148. */
  1149. void() item_artifact_invulnerability =
  1150. {
  1151.     self.touch = powerup_touch;
  1152.  
  1153.     precache_model ("progs/invulner.mdl");
  1154.     precache_sound ("items/protect.wav");
  1155.     precache_sound ("items/protect2.wav");
  1156.     precache_sound ("items/protect3.wav");
  1157.     self.noise = "items/protect.wav";
  1158.     setmodel (self, "progs/invulner.mdl");
  1159.     self.netname = "Pentagram of Protection";
  1160.     self.items = IT_INVULNERABILITY;
  1161.     setsize (self, '-16 -16 -24', '16 16 32');
  1162.     StartItem ();
  1163. };
  1164.  
  1165. /*QUAKED item_artifact_envirosuit (0 .5 .8) (-16 -16 -24) (16 16 32)
  1166. Player takes no damage from water or slime for 30 seconds
  1167. */
  1168. void() item_artifact_envirosuit =
  1169. {
  1170.     self.touch = powerup_touch;
  1171.  
  1172.     precache_model ("progs/suit.mdl");
  1173.     precache_sound ("items/suit.wav");
  1174.     precache_sound ("items/suit2.wav");
  1175.     self.noise = "items/suit.wav";
  1176.     setmodel (self, "progs/suit.mdl");
  1177.     self.netname = "Biosuit";
  1178.     self.items = IT_SUIT;
  1179.     setsize (self, '-16 -16 -24', '16 16 32');
  1180.     StartItem ();
  1181. };
  1182.  
  1183.  
  1184. /*QUAKED item_artifact_invisibility (0 .5 .8) (-16 -16 -24) (16 16 32)
  1185. Player is invisible for 30 seconds
  1186. */
  1187. void() item_artifact_invisibility =
  1188. {
  1189.     self.touch = powerup_touch;
  1190.  
  1191.     precache_model ("progs/invisibl.mdl");
  1192.     precache_sound ("items/inv1.wav");
  1193.     precache_sound ("items/inv2.wav");
  1194.     precache_sound ("items/inv3.wav");
  1195.     self.noise = "items/inv1.wav";
  1196.     setmodel (self, "progs/invisibl.mdl");
  1197.     self.netname = "Ring of Shadows";
  1198.     self.items = IT_INVISIBILITY;
  1199.     setsize (self, '-16 -16 -24', '16 16 32');
  1200.     StartItem ();
  1201. };
  1202.  
  1203.  
  1204. /*QUAKED item_artifact_super_damage (0 .5 .8) (-16 -16 -24) (16 16 32)
  1205. The next attack from the player will do 4x damage
  1206. */
  1207. void() item_artifact_super_damage =
  1208. {
  1209.     self.touch = powerup_touch;
  1210.  
  1211.     precache_model ("progs/quaddama.mdl");
  1212.     precache_sound ("items/damage.wav");
  1213.     precache_sound ("items/damage2.wav");
  1214.     precache_sound ("items/damage3.wav");
  1215.     self.noise = "items/damage.wav";
  1216.     setmodel (self, "progs/quaddama.mdl");
  1217.     self.netname = "Quad Damage";
  1218.     self.items = IT_QUAD;
  1219.     setsize (self, '-16 -16 -24', '16 16 32');
  1220.     StartItem ();
  1221. };
  1222.  
  1223.  
  1224.  
  1225. /*
  1226. ===============================================================================
  1227.  
  1228. PLAYER BACKPACKS
  1229.  
  1230. ===============================================================================
  1231. */
  1232.  
  1233. void() BackpackTouch =
  1234. {
  1235.     local string    s;
  1236.     local    float    best, old, new;
  1237.     local        entity    stemp;
  1238.     local    float    acount;
  1239.     
  1240.     if (other.classname != "player")
  1241.         return;
  1242.     if (other.health <= 0)
  1243.         return;
  1244.  
  1245.     acount = 0;
  1246.     sprint (other, "You get ");
  1247.  
  1248.     if (self.items)
  1249.         if ((other.items & self.items) == 0)
  1250.         {
  1251.             acount = 1;
  1252.             sprint (other, "the ");
  1253.             sprint (other, self.netname);
  1254.         }
  1255.  
  1256. // if the player was using his best weapon, change up to the new one if better        
  1257.     stemp = self;
  1258.     self = other;
  1259.     best = W_BestWeapon();
  1260.     self = stemp;
  1261.  
  1262. // change weapons
  1263.     other.ammo_shells = other.ammo_shells + self.ammo_shells;
  1264.     other.ammo_nails = other.ammo_nails + self.ammo_nails;
  1265.     other.ammo_rockets = other.ammo_rockets + self.ammo_rockets;
  1266.     other.ammo_cells = other.ammo_cells + self.ammo_cells;
  1267.  
  1268.     new = self.items;
  1269.     if (!new)
  1270.         new = other.weapon;
  1271.     old = other.items;
  1272.     other.items = other.items | new;
  1273.     
  1274.     bound_other_ammo ();
  1275.  
  1276.     if (self.ammo_shells)
  1277.     {
  1278.         if (acount)
  1279.             sprint(other, ", ");
  1280.         acount = 1;
  1281.         s = ftos(self.ammo_shells);
  1282.         sprint (other, s);
  1283.         sprint (other, " shells");
  1284.     }
  1285.     if (self.ammo_nails)
  1286.     {
  1287.         if (acount)
  1288.             sprint(other, ", ");
  1289.         acount = 1;
  1290.         s = ftos(self.ammo_nails);
  1291.         sprint (other, s);
  1292.         sprint (other, " nails");
  1293.     }
  1294.     if (self.ammo_rockets)
  1295.     {
  1296.         if (acount)
  1297.             sprint(other, ", ");
  1298.         acount = 1;
  1299.         s = ftos(self.ammo_rockets);
  1300.         sprint (other, s);
  1301.         sprint (other, " rockets");
  1302.     }
  1303.     if (self.ammo_cells)
  1304.     {
  1305.         if (acount)
  1306.             sprint(other, ", ");
  1307.         acount = 1;
  1308.         s = ftos(self.ammo_cells);
  1309.         sprint (other, s);
  1310.         sprint (other, " cells");
  1311.     }
  1312.     
  1313.     sprint (other, "\n");
  1314. // backpack touch sound
  1315.     sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
  1316.     stuffcmd (other, "bf\n");
  1317.  
  1318. // remove the backpack, change self to the player
  1319.     remove(self);
  1320.     self = other;
  1321.  
  1322. // change to the weapon
  1323.     if (!deathmatch)
  1324.         self.weapon = new;
  1325.     else
  1326.         Deathmatch_Weapon (old, new);
  1327.  
  1328.     W_SetCurrentAmmo ();
  1329. };
  1330.  
  1331. /*
  1332. ===============
  1333. DropBackpack
  1334. ===============
  1335. */
  1336. void() DropBackpack =
  1337. {
  1338.     local entity    item;
  1339.  
  1340.     if (!(self.ammo_shells + self.ammo_nails + self.ammo_rockets + self.ammo_cells))
  1341.         return;    // nothing in it
  1342.  
  1343.     item = spawn();
  1344.     item.origin = self.origin - '0 0 24';
  1345.     
  1346.     item.items = self.weapon;
  1347.     if (item.items == IT_AXE)
  1348.         item.netname = "Axe";
  1349. // Grapple:  A new weapon to grab, natch.
  1350.         else if (item.items == IT_MORNINGSTAR)
  1351.                 item.netname = "Morning Star";
  1352. //
  1353.     else if (item.items == IT_SHOTGUN)
  1354.         item.netname = "Shotgun";
  1355.     else if (item.items == IT_SUPER_SHOTGUN)
  1356.         item.netname = "Double-barrelled Shotgun";
  1357.     else if (item.items == IT_NAILGUN)
  1358.         item.netname = "Nailgun";
  1359.     else if (item.items == IT_SUPER_NAILGUN)
  1360.         item.netname = "Super Nailgun";
  1361.     else if (item.items == IT_GRENADE_LAUNCHER)
  1362.         item.netname = "Grenade Launcher";
  1363.     else if (item.items == IT_ROCKET_LAUNCHER)
  1364.         item.netname = "Rocket Launcher";
  1365.     else if (item.items == IT_LIGHTNING)
  1366.         item.netname = "Thunderbolt";
  1367.     else
  1368.         item.netname = "";
  1369.  
  1370.     item.ammo_shells = self.ammo_shells;
  1371.     item.ammo_nails = self.ammo_nails;
  1372.     item.ammo_rockets = self.ammo_rockets;
  1373.     item.ammo_cells = self.ammo_cells;
  1374.  
  1375.     item.velocity_z = 300;
  1376.     item.velocity_x = -100 + (random() * 200);
  1377.     item.velocity_y = -100 + (random() * 200);
  1378.     
  1379.     item.flags = FL_ITEM;
  1380.     item.solid = SOLID_TRIGGER;
  1381.     item.movetype = MOVETYPE_TOSS;
  1382.     setmodel (item, "progs/backpack.mdl");
  1383.     setsize (item, '-16 -16 0', '16 16 56');
  1384.     item.touch = BackpackTouch;
  1385.     
  1386.     item.nextthink = time + 120;    // remove after 2 minutes
  1387.     item.think = SUB_Remove;
  1388. };
  1389.