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