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