home *** CD-ROM | disk | FTP | other *** search
/ Phenomenon / Phenomenon.iso / quake / teamfort / sources / snip_src / source / items.qc < prev    next >
Encoding:
Text File  |  1996-08-10  |  27.2 KB  |  1,354 lines

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