home *** CD-ROM | disk | FTP | other *** search
/ Quake 'em / QUAKEEM.BIN / quake / programs / qplus11 / items.qc < prev    next >
Encoding:
Text File  |  1996-08-26  |  39.8 KB  |  1,762 lines

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