home *** CD-ROM | disk | FTP | other *** search
/ Quake 'em / QUAKEEM.BIN / quake / programs / mon_dm09 / items.qc < prev    next >
Encoding:
Text File  |  1996-08-20  |  22.0 KB  |  1,072 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.     return 1;
  94. };
  95.  
  96. /*QUAKED item_health (.3 .3 1) (0 0 0) (32 32 32) rotten megahealth
  97. Health box. Normally gives 25 points.
  98. Rotten box heals 5-10 points,
  99. megahealth will add 100 health, then 
  100. rot you down to your maximum health limit, 
  101. one point per second.
  102. */
  103.  
  104. float    H_ROTTEN = 1;
  105. float    H_MEGA = 2;
  106. .float    healamount, healtype;
  107. void() health_touch;
  108. void() item_megahealth_rot;
  109.  
  110. void() item_health =
  111. {    
  112.     self.touch = health_touch;
  113.  
  114.     if (self.spawnflags & H_ROTTEN)
  115.     {
  116.         precache_model("maps/b_bh10.bsp");
  117.  
  118.         precache_sound("items/r_item1.wav");
  119.         setmodel(self, "maps/b_bh10.bsp");
  120.         self.noise = "items/r_item1.wav";
  121.         self.healamount = 15;
  122.         self.healtype = 0;
  123.     }
  124.     else
  125.     if (self.spawnflags & H_MEGA)
  126.     {
  127.         precache_model("maps/b_bh100.bsp");
  128.         precache_sound("items/r_item2.wav");
  129.         setmodel(self, "maps/b_bh100.bsp");
  130.         self.noise = "items/r_item2.wav";
  131.         self.healamount = 100;
  132.         self.healtype = 2;
  133.     }
  134.     else
  135.     {
  136.         precache_model("maps/b_bh25.bsp");
  137.         precache_sound("items/health1.wav");
  138.         setmodel(self, "maps/b_bh25.bsp");
  139.         self.noise = "items/health1.wav";
  140.         self.healamount = 25;
  141.         self.healtype = 1;
  142.     }
  143.     setsize (self, '0 0 0', '32 32 56');
  144.     StartItem ();
  145. };
  146.  
  147.  
  148. void() health_touch =
  149. {
  150.     local    float amount;
  151.     local    string    s;
  152.     
  153.     if (other.classname != "player")
  154.         return;
  155.  
  156.         else if (other.effects & EF_DEMON)
  157.                 return;
  158.  
  159.         else if (other.effects & EF_WIZARD)
  160.                 return;
  161.  
  162.         else if (other.effects & EF_HKNIGHT)
  163.                 return;
  164.  
  165.         else if (other.effects & EF_OGRE)
  166.                 return;
  167.  
  168.         else if (other.effects & EF_SHALRATH)
  169.                 return;
  170.  
  171.     if (self.healtype == 2) // Megahealth?  Ignore max_health...
  172.     {
  173.         if (!T_Heal(other, self.healamount, 1))
  174.             return;
  175.     }
  176.     else
  177.     {
  178.         if (!T_Heal(other, self.healamount, 0))
  179.             return;
  180.     }
  181.     
  182.     sprint(other, "You receive ");
  183.     s = ftos(self.healamount);
  184.     sprint(other, s);
  185.     sprint(other, " health\n");
  186.     
  187. // health touch sound
  188.     sound(other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  189.  
  190.     stuffcmd (other, "bf\n");
  191.     
  192.     self.model = string_null;
  193.     self.solid = SOLID_NOT;
  194.  
  195.     // Megahealth = rot down the player's super health
  196.     if (self.healtype == 2)
  197.     {
  198.         other.items = other.items | IT_SUPERHEALTH;
  199.         self.nextthink = time + 5;
  200.         self.think = item_megahealth_rot;
  201.         self.owner = other;
  202.     }
  203.     else
  204.     {
  205.         if (deathmatch != 2)        // deathmatch 2 is the silly old rules
  206.         {
  207.             if (deathmatch)
  208.                 self.nextthink = time + 20;
  209.             self.think = SUB_regen;
  210.         }
  211.     }
  212.     
  213.     activator = other;
  214.     SUB_UseTargets();                // fire all targets / killtargets
  215. };    
  216.  
  217. void() item_megahealth_rot =
  218. {
  219.     other = self.owner;
  220.     
  221.     if (other.health > other.max_health)
  222.     {
  223.         other.health = other.health - 1;
  224.         self.nextthink = time + 1;
  225.         return;
  226.     }
  227.  
  228. // it is possible for a player to die and respawn between rots, so don't
  229. // just blindly subtract the flag off
  230.     other.items = other.items - (other.items & IT_SUPERHEALTH);
  231.     
  232.     if (deathmatch == 1)    // deathmatch 2 is silly old rules
  233.     {
  234.         self.nextthink = time + 20;
  235.         self.think = SUB_regen;
  236.     }
  237. };
  238.  
  239. /*
  240. ===============================================================================
  241.  
  242. ARMOR
  243.  
  244. ===============================================================================
  245. */
  246.  
  247. void() armor_touch;
  248.  
  249. void() armor_touch =
  250. {
  251.     local    float    type, value, bit;
  252.     
  253.     if (other.health <= 0)
  254.         return;
  255.     if (other.classname != "player")
  256.         return;
  257.         if (other.effects & EF_DEMON)
  258.           return;
  259.         else if (other.effects & EF_SHALRATH)
  260.           return;
  261.         else if (other.effects & EF_OGRE)
  262.           return;
  263.         else if (other.effects & EF_WIZARD)
  264.           return;
  265.  
  266.     if (self.classname == "item_armor1")
  267.     {
  268.         type = 0.3;
  269.         value = 100;
  270.         bit = IT_ARMOR1;
  271.     }
  272.     if (self.classname == "item_armor2")
  273.     {
  274.         type = 0.6;
  275.         value = 150;
  276.         bit = IT_ARMOR2;
  277.     }
  278.     if (self.classname == "item_armorInv")
  279.     {
  280.         type = 0.8;
  281.         value = 200;
  282.         bit = IT_ARMOR3;
  283.     }
  284.     if (other.armortype*other.armorvalue >= type*value)
  285.         return;
  286.         
  287.     other.armortype = type;
  288.     other.armorvalue = value;
  289.     other.items = other.items - (other.items & (IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + bit;
  290.  
  291.     self.solid = SOLID_NOT;
  292.     self.model = string_null;
  293.     if (deathmatch == 1)
  294.         self.nextthink = time + 20;
  295.     self.think = SUB_regen;
  296.  
  297.     sprint(other, "You got armor\n");
  298. // armor touch sound
  299.     sound(other, CHAN_ITEM, "items/armor1.wav", 1, ATTN_NORM);
  300.     stuffcmd (other, "bf\n");
  301.     
  302.     activator = other;
  303.     SUB_UseTargets();                // fire all targets / killtargets
  304.  
  305. };
  306.  
  307.  
  308.  
  309. /*QUAKED item_armor1 (0 .5 .8) (-16 -16 0) (16 16 32)
  310. */
  311.  
  312. void() item_armor1 =
  313. {
  314.     self.touch = armor_touch;
  315.     precache_model ("progs/armor.mdl");
  316.     setmodel (self, "progs/armor.mdl");
  317.     self.skin = 0;
  318.     setsize (self, '-16 -16 0', '16 16 56');
  319.     StartItem ();
  320. };
  321.  
  322. /*QUAKED item_armor2 (0 .5 .8) (-16 -16 0) (16 16 32)
  323. */
  324.  
  325. void() item_armor2 =
  326. {
  327.     self.touch = armor_touch;
  328.     precache_model ("progs/armor.mdl");
  329.     setmodel (self, "progs/armor.mdl");
  330.     self.skin = 1;
  331.     setsize (self, '-16 -16 0', '16 16 56');
  332.     StartItem ();
  333. };
  334.  
  335. /*QUAKED item_armorInv (0 .5 .8) (-16 -16 0) (16 16 32)
  336. */
  337.  
  338. void() item_armorInv =
  339. {
  340.     self.touch = armor_touch;
  341.     precache_model ("progs/armor.mdl");
  342.     setmodel (self, "progs/armor.mdl");
  343.     self.skin = 2;
  344.     setsize (self, '-16 -16 0', '16 16 56');
  345.     StartItem ();
  346. };
  347.  
  348. /*
  349. ===============================================================================
  350.  
  351. WEAPONS
  352.  
  353. ===============================================================================
  354. */
  355.  
  356. void() bound_other_ammo =
  357. {
  358.         if (other.ammo_shells > 0)
  359.                 other.ammo_shells = 0;
  360.         if (other.ammo_nails > 0)
  361.                 other.ammo_nails = 0;
  362.         if (other.ammo_rockets > 0)
  363.                 other.ammo_rockets = 0;        
  364.         if (other.ammo_cells > 0)
  365.                 other.ammo_cells = 0;  
  366. };
  367.  
  368.  
  369. float(float w) RankForWeapon =
  370. {
  371.     if (w == IT_LIGHTNING)
  372.         return 1;
  373.     if (w == IT_ROCKET_LAUNCHER)
  374.         return 2;
  375.     if (w == IT_SUPER_NAILGUN)
  376.         return 3;
  377.     if (w == IT_GRENADE_LAUNCHER)
  378.         return 4;
  379.     if (w == IT_SUPER_SHOTGUN)
  380.         return 5;
  381.     if (w == IT_NAILGUN)
  382.         return 6;
  383.     return 7;
  384. };
  385.  
  386. /*
  387. =============
  388. Deathmatch_Weapon
  389.  
  390. Deathmatch weapon change rules for picking up a weapon
  391.  
  392. .float        ammo_shells, ammo_nails, ammo_rockets, ammo_cells;
  393. =============
  394. */
  395. void(float old, float new) Deathmatch_Weapon =
  396. {
  397.     local float or, nr;
  398.  
  399. // change self.weapon if desired
  400.     or = RankForWeapon (self.weapon);
  401.     nr = RankForWeapon (new);
  402.     if ( nr < or )
  403.         self.weapon = new;
  404. };
  405.  
  406. /*
  407. =============
  408. weapon_touch
  409. =============
  410. */
  411. float() W_BestWeapon;
  412.  
  413. void() weapon_touch =
  414. {
  415.     local    float    hadammo, best, new, old;
  416.     local    entity    stemp;
  417.     local    float    leave;
  418.  
  419.     if (!(other.flags & FL_CLIENT))
  420.         return;
  421.  
  422. // if the player was using his best weapon, change up to the new one if better        
  423.     stemp = self;
  424.     self = other;
  425.     best = W_BestWeapon();
  426.     self = stemp;
  427.  
  428.     if (deathmatch == 2 || coop)
  429.         leave = 1;
  430.     else
  431.         leave = 0;
  432.     
  433.     if (self.classname == "weapon_nailgun")
  434.     {
  435.         if (leave && (other.items & IT_NAILGUN) )
  436.             return;
  437.         hadammo = other.ammo_nails;            
  438.         new = IT_NAILGUN;
  439.         other.ammo_nails = other.ammo_nails + 30;
  440.     }
  441.     else if (self.classname == "weapon_supernailgun")
  442.     {
  443.         if (leave && (other.items & IT_SUPER_NAILGUN) )
  444.             return;
  445.         hadammo = other.ammo_rockets;            
  446.         new = IT_SUPER_NAILGUN;
  447.         other.ammo_nails = other.ammo_nails + 30;
  448.     }
  449.     else if (self.classname == "weapon_supershotgun")
  450.     {
  451.         if (leave && (other.items & IT_SUPER_SHOTGUN) )
  452.             return;
  453.         hadammo = other.ammo_rockets;            
  454.         new = IT_SUPER_SHOTGUN;
  455.         other.ammo_shells = other.ammo_shells + 5;
  456.     }
  457.     else if (self.classname == "weapon_rocketlauncher")
  458.     {
  459.         if (leave && (other.items & IT_ROCKET_LAUNCHER) )
  460.             return;
  461.         hadammo = other.ammo_rockets;            
  462.         new = IT_ROCKET_LAUNCHER;
  463.         other.ammo_rockets = other.ammo_rockets + 5;
  464.     }
  465.     else if (self.classname == "weapon_grenadelauncher")
  466.     {
  467.         if (leave && (other.items & IT_GRENADE_LAUNCHER) )
  468.             return;
  469.         hadammo = other.ammo_rockets;            
  470.         new = IT_GRENADE_LAUNCHER;
  471.         other.ammo_rockets = other.ammo_rockets + 5;
  472.     }
  473.     else if (self.classname == "weapon_lightning")
  474.     {
  475.         if (leave && (other.items & IT_LIGHTNING) )
  476.             return;
  477.         hadammo = other.ammo_rockets;            
  478.         new = IT_LIGHTNING;
  479.         other.ammo_cells = other.ammo_cells + 15;
  480.     }
  481.     else
  482.         objerror ("weapon_touch: unknown classname");
  483.  
  484.     sprint (other, "You got the ");
  485.     sprint (other, self.netname);
  486.     sprint (other, "\n");
  487. // weapon touch sound
  488.     sound (other, CHAN_ITEM, "weapons/pkup.wav", 1, ATTN_NORM);
  489.     stuffcmd (other, "bf\n");
  490.  
  491.     bound_other_ammo ();
  492.  
  493. // change to the weapon
  494.     old = other.items;
  495.     other.items = other.items | new;
  496.     
  497.     stemp = self;
  498.     self = other;
  499.  
  500.     if (!deathmatch)
  501.         self.weapon = new;
  502.     else
  503.         Deathmatch_Weapon (old, new);
  504.  
  505.     W_SetCurrentAmmo();
  506.  
  507.     self = stemp;
  508.  
  509.     if (leave)
  510.         return;
  511.  
  512. // remove it in single player, or setup for respawning in deathmatch
  513.     self.model = string_null;
  514.     self.solid = SOLID_NOT;
  515.     if (deathmatch == 1)
  516.         self.nextthink = time + 30;
  517.     self.think = SUB_regen;
  518.     
  519.     activator = other;
  520.     SUB_UseTargets();                // fire all targets / killtargets
  521. };
  522.  
  523.  
  524.  
  525. /*QUAKED weapon_supershotgun (0 .5 .8) (-16 -16 0) (16 16 32)
  526. */
  527.  
  528. void() weapon_supershotgun =
  529. {
  530. return;
  531. };
  532.  
  533. /*QUAKED weapon_nailgun (0 .5 .8) (-16 -16 0) (16 16 32)
  534. */
  535.  
  536. void() weapon_nailgun =
  537. {
  538. return;
  539. };
  540.  
  541. /*QUAKED weapon_supernailgun (0 .5 .8) (-16 -16 0) (16 16 32)
  542. */
  543.  
  544. void() weapon_supernailgun =
  545. {
  546. return;
  547. };
  548.  
  549. /*QUAKED weapon_grenadelauncher (0 .5 .8) (-16 -16 0) (16 16 32)
  550. */
  551.  
  552. void() weapon_grenadelauncher =
  553. {
  554. return;
  555. };
  556.  
  557. /*QUAKED weapon_rocketlauncher (0 .5 .8) (-16 -16 0) (16 16 32)
  558. */
  559.  
  560. void() weapon_rocketlauncher =
  561. {
  562. return;
  563. };
  564.  
  565.  
  566. /*QUAKED weapon_lightning (0 .5 .8) (-16 -16 0) (16 16 32)
  567. */
  568.  
  569. void() weapon_lightning =
  570. {
  571. return;
  572. };
  573.  
  574.  
  575. /*
  576. ===============================================================================
  577.  
  578. AMMO
  579.  
  580. ===============================================================================
  581. */
  582.  
  583. void() ammo_touch =
  584. {
  585. return;
  586. };
  587.  
  588. float WEAPON_BIG2 = 1;
  589.  
  590. /*QUAKED item_shells (0 .5 .8) (0 0 0) (32 32 32) big
  591. */
  592.  
  593. void() item_shells =
  594. {
  595. return;
  596. };
  597.  
  598. /*QUAKED item_spikes (0 .5 .8) (0 0 0) (32 32 32) big
  599. */
  600.  
  601. void() item_spikes =
  602. {
  603. return;
  604. };
  605.  
  606. /*QUAKED item_rockets (0 .5 .8) (0 0 0) (32 32 32) big
  607. */
  608.  
  609. void() item_rockets =
  610. {
  611. return;
  612. };
  613.  
  614.  
  615. /*QUAKED item_cells (0 .5 .8) (0 0 0) (32 32 32) big
  616. */
  617.  
  618. void() item_cells =
  619. {
  620. return;
  621. };
  622.  
  623.  
  624. /*QUAKED item_weapon (0 .5 .8) (0 0 0) (32 32 32) shotgun rocket spikes big
  625. DO NOT USE THIS!!!! IT WILL BE REMOVED!
  626. */
  627.  
  628. float WEAPON_SHOTGUN = 1;
  629. float WEAPON_ROCKET = 2;
  630. float WEAPON_SPIKES = 4;
  631. float WEAPON_BIG = 8;
  632. void() item_weapon =
  633. {
  634.     self.touch = ammo_touch;
  635.  
  636.     if (self.spawnflags & WEAPON_SHOTGUN)
  637.     {
  638.         if (self.spawnflags & WEAPON_BIG)
  639.         {
  640.             precache_model ("maps/b_shell1.bsp");
  641.             setmodel (self, "maps/b_shell1.bsp");
  642.             self.aflag = 40;
  643.         }
  644.         else
  645.         {
  646.             precache_model ("maps/b_shell0.bsp");
  647.             setmodel (self, "maps/b_shell0.bsp");
  648.             self.aflag = 20;
  649.         }
  650.         self.weapon = 1;
  651.         self.netname = "shells";
  652.     }
  653.  
  654.     if (self.spawnflags & WEAPON_SPIKES)
  655.     {
  656.         if (self.spawnflags & WEAPON_BIG)
  657.         {
  658.             precache_model ("maps/b_nail1.bsp");
  659.             setmodel (self, "maps/b_nail1.bsp");
  660.             self.aflag = 40;
  661.         }
  662.         else
  663.         {
  664.             precache_model ("maps/b_nail0.bsp");
  665.             setmodel (self, "maps/b_nail0.bsp");
  666.             self.aflag = 20;
  667.         }
  668.         self.weapon = 2;
  669.         self.netname = "spikes";
  670.     }
  671.  
  672.     if (self.spawnflags & WEAPON_ROCKET)
  673.     {
  674.         if (self.spawnflags & WEAPON_BIG)
  675.         {
  676.             precache_model ("maps/b_rock1.bsp");
  677.             setmodel (self, "maps/b_rock1.bsp");
  678.             self.aflag = 10;
  679.         }
  680.         else
  681.         {
  682.             precache_model ("maps/b_rock0.bsp");
  683.             setmodel (self, "maps/b_rock0.bsp");
  684.             self.aflag = 5;
  685.         }
  686.         self.weapon = 3;
  687.         self.netname = "rockets";
  688.     }
  689.     
  690.     setsize (self, '0 0 0', '32 32 56');
  691.     StartItem ();
  692. };
  693.  
  694.  
  695. /*
  696. ===============================================================================
  697.  
  698. KEYS
  699.  
  700. ===============================================================================
  701. */
  702.  
  703. void() key_touch =
  704. {
  705. local entity    stemp;
  706. local float        best;
  707.  
  708.     if (other.classname != "player")
  709.         return;
  710.     if (other.health <= 0)
  711.         return;
  712.     if (other.items & self.items)
  713.         return;
  714.  
  715.     sprint (other, "You got the ");
  716.     sprint (other, self.netname);
  717.     sprint (other,"\n");
  718.  
  719.     sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  720.     stuffcmd (other, "bf\n");
  721.     other.items = other.items | self.items;
  722.  
  723.     if (!coop)
  724.     {    
  725.         self.solid = SOLID_NOT;
  726.         self.model = string_null;
  727.     }
  728.  
  729.     activator = other;
  730.     SUB_UseTargets();                // fire all targets / killtargets
  731. };
  732.  
  733.  
  734. void() key_setsounds =
  735. {
  736.     if (world.worldtype == 0)
  737.     {
  738.         precache_sound ("misc/medkey.wav");
  739.         self.noise = "misc/medkey.wav";
  740.     }
  741.     if (world.worldtype == 1)
  742.     {
  743.         precache_sound ("misc/runekey.wav");
  744.         self.noise = "misc/runekey.wav";
  745.     }
  746.     if (world.worldtype == 2)
  747.     {
  748.         precache_sound2 ("misc/basekey.wav");
  749.         self.noise = "misc/basekey.wav";
  750.     }
  751. };
  752.  
  753. /*QUAKED item_key1 (0 .5 .8) (-16 -16 -24) (16 16 32)
  754. SILVER key
  755. In order for keys to work
  756. you MUST set your maps
  757. worldtype to one of the
  758. following:
  759. 0: medieval
  760. 1: metal
  761. 2: base
  762. */
  763.  
  764. void() item_key1 =
  765. {
  766.     if (world.worldtype == 0)
  767.     {
  768.         precache_model ("progs/w_s_key.mdl");
  769.         setmodel (self, "progs/w_s_key.mdl");
  770.         self.netname = "silver key";
  771.     }
  772.     else if (world.worldtype == 1)
  773.     {
  774.         precache_model ("progs/m_s_key.mdl");
  775.         setmodel (self, "progs/m_s_key.mdl");
  776.         self.netname = "silver runekey";
  777.     }
  778.     else if (world.worldtype == 2)
  779.     {
  780.         precache_model2 ("progs/b_s_key.mdl");
  781.         setmodel (self, "progs/b_s_key.mdl");
  782.         self.netname = "silver keycard";
  783.     }
  784.     key_setsounds();
  785.     self.touch = key_touch;
  786.     self.items = IT_KEY1;
  787.     setsize (self, '-16 -16 -24', '16 16 32');
  788.     StartItem ();
  789. };
  790.  
  791. /*QUAKED item_key2 (0 .5 .8) (-16 -16 -24) (16 16 32)
  792. GOLD key
  793. In order for keys to work
  794. you MUST set your maps
  795. worldtype to one of the
  796. following:
  797. 0: medieval
  798. 1: metal
  799. 2: base
  800. */
  801.  
  802. void() item_key2 =
  803. {
  804.     if (world.worldtype == 0)
  805.     {
  806.         precache_model ("progs/w_g_key.mdl");
  807.         setmodel (self, "progs/w_g_key.mdl");
  808.         self.netname = "gold key";
  809.     }
  810.     if (world.worldtype == 1)
  811.     {
  812.         precache_model ("progs/m_g_key.mdl");
  813.         setmodel (self, "progs/m_g_key.mdl");
  814.         self.netname = "gold runekey";
  815.     }
  816.     if (world.worldtype == 2)
  817.     {
  818.         precache_model2 ("progs/b_g_key.mdl");
  819.         setmodel (self, "progs/b_g_key.mdl");
  820.         self.netname = "gold keycard";
  821.     }
  822.     key_setsounds();
  823.     self.touch = key_touch;
  824.     self.items = IT_KEY2;
  825.     setsize (self, '-16 -16 -24', '16 16 32');
  826.     StartItem ();
  827. };
  828.  
  829.  
  830.  
  831. /*
  832. ===============================================================================
  833.  
  834. END OF LEVEL RUNES
  835.  
  836. ===============================================================================
  837. */
  838.  
  839. void() sigil_touch =
  840. {
  841. local entity    stemp;
  842. local float        best;
  843.  
  844.     if (other.classname != "player")
  845.         return;
  846.     if (other.health <= 0)
  847.         return;
  848.  
  849.     centerprint (other, "You got the rune!");
  850.  
  851.     sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  852.     stuffcmd (other, "bf\n");
  853.     self.solid = SOLID_NOT;
  854.     self.model = string_null;
  855.     serverflags = serverflags | (self.spawnflags & 15);
  856.     self.classname = "";        // so rune doors won't find it
  857.     
  858.     activator = other;
  859.     SUB_UseTargets();                // fire all targets / killtargets
  860. };
  861.  
  862.  
  863. /*QUAKED item_sigil (0 .5 .8) (-16 -16 -24) (16 16 32) E1 E2 E3 E4
  864. End of level sigil, pick up to end episode and return to jrstart.
  865. */
  866.  
  867. void() item_sigil =
  868. {
  869.     if (!self.spawnflags)
  870.         objerror ("no spawnflags");
  871.  
  872.     precache_sound ("misc/runekey.wav");
  873.     self.noise = "misc/runekey.wav";
  874.  
  875.     if (self.spawnflags & 1)
  876.     {
  877.         precache_model ("progs/end1.mdl");
  878.         setmodel (self, "progs/end1.mdl");
  879.     }
  880.     if (self.spawnflags & 2)
  881.     {
  882.         precache_model2 ("progs/end2.mdl");
  883.         setmodel (self, "progs/end2.mdl");
  884.     }
  885.     if (self.spawnflags & 4)
  886.     {
  887.         precache_model2 ("progs/end3.mdl");
  888.         setmodel (self, "progs/end3.mdl");
  889.     }
  890.     if (self.spawnflags & 8)
  891.     {
  892.         precache_model2 ("progs/end4.mdl");
  893.         setmodel (self, "progs/end4.mdl");
  894.     }
  895.     
  896.     self.touch = sigil_touch;
  897.     setsize (self, '-16 -16 -24', '16 16 32');
  898.     StartItem ();
  899. };
  900.  
  901. /*
  902. ===============================================================================
  903.  
  904. POWERUPS
  905.  
  906. ===============================================================================
  907. */
  908.  
  909. void() powerup_touch;
  910.  
  911.  
  912. void() powerup_touch =
  913. {
  914. local entity    stemp;
  915. local float        best;
  916.  
  917.     if (other.classname != "player")
  918.         return;
  919.     if (other.health <= 0)
  920.         return;
  921.  
  922.     sprint (other, "You got the ");
  923.     sprint (other, self.netname);
  924.     sprint (other,"\n");
  925.  
  926.     if (deathmatch)
  927.     {
  928.         self.mdl = self.model;
  929.         
  930.         if ((self.classname == "item_artifact_invulnerability") ||
  931.             (self.classname == "item_artifact_invisibility"))
  932.             self.nextthink = time + 60*5;
  933.         else
  934.             self.nextthink = time + 60;
  935.         
  936.         self.think = SUB_regen;
  937.     }    
  938.  
  939.     sound (other, CHAN_VOICE, self.noise, 1, ATTN_NORM);
  940.     stuffcmd (other, "bf\n");
  941.     self.solid = SOLID_NOT;
  942.     other.items = other.items | self.items;
  943.     self.model = string_null;
  944.  
  945. // do the apropriate action
  946.     if (self.classname == "item_artifact_envirosuit")
  947.     {
  948.         other.rad_time = 1;
  949.         other.radsuit_finished = time + 30;
  950.     }
  951.     
  952.     if (self.classname == "item_artifact_invulnerability")
  953.     {
  954.         other.invincible_time = 1;
  955.         other.invincible_finished = time + 30;
  956.     }
  957.     
  958.     if (self.classname == "item_artifact_invisibility")
  959.     {
  960.         other.invisible_time = 1;
  961.         other.invisible_finished = time + 30;
  962.     }
  963.  
  964.     if (self.classname == "item_artifact_super_damage")
  965.     {
  966.         other.super_time = 1;
  967.         other.super_damage_finished = time + 30;
  968.     }    
  969.  
  970.     activator = other;
  971.     SUB_UseTargets();                // fire all targets / killtargets
  972. };
  973.  
  974.  
  975.  
  976. /*QUAKED item_artifact_invulnerability (0 .5 .8) (-16 -16 -24) (16 16 32)
  977. Player is invulnerable for 30 seconds
  978. */
  979. void() item_artifact_invulnerability =
  980. {
  981.     self.touch = powerup_touch;
  982.  
  983.     precache_model ("progs/invulner.mdl");
  984.     precache_sound ("items/protect.wav");
  985.     precache_sound ("items/protect2.wav");
  986.     precache_sound ("items/protect3.wav");
  987.     self.noise = "items/protect.wav";
  988.     setmodel (self, "progs/invulner.mdl");
  989.     self.netname = "Pentagram of Protection";
  990.     self.items = IT_INVULNERABILITY;
  991.     setsize (self, '-16 -16 -24', '16 16 32');
  992.     StartItem ();
  993. };
  994.  
  995. /*QUAKED item_artifact_envirosuit (0 .5 .8) (-16 -16 -24) (16 16 32)
  996. Player takes no damage from water or slime for 30 seconds
  997. */
  998. void() item_artifact_envirosuit =
  999. {
  1000.     self.touch = powerup_touch;
  1001.  
  1002.     precache_model ("progs/suit.mdl");
  1003.     precache_sound ("items/suit.wav");
  1004.     precache_sound ("items/suit2.wav");
  1005.     self.noise = "items/suit.wav";
  1006.     setmodel (self, "progs/suit.mdl");
  1007.     self.netname = "Biosuit";
  1008.     self.items = IT_SUIT;
  1009.     setsize (self, '-16 -16 -24', '16 16 32');
  1010.     StartItem ();
  1011. };
  1012.  
  1013.  
  1014. /*QUAKED item_artifact_invisibility (0 .5 .8) (-16 -16 -24) (16 16 32)
  1015. Player is invisible for 30 seconds
  1016. */
  1017. void() item_artifact_invisibility =
  1018. {
  1019.     self.touch = powerup_touch;
  1020.  
  1021.     precache_model ("progs/invisibl.mdl");
  1022.     precache_sound ("items/inv1.wav");
  1023.     precache_sound ("items/inv2.wav");
  1024.     precache_sound ("items/inv3.wav");
  1025.     self.noise = "items/inv1.wav";
  1026.     setmodel (self, "progs/invisibl.mdl");
  1027.     self.netname = "Ring of Shadows";
  1028.     self.items = IT_INVISIBILITY;
  1029.     setsize (self, '-16 -16 -24', '16 16 32');
  1030.     StartItem ();
  1031. };
  1032.  
  1033.  
  1034. /*QUAKED item_artifact_super_damage (0 .5 .8) (-16 -16 -24) (16 16 32)
  1035. The next attack from the player will do 4x damage
  1036. */
  1037. void() item_artifact_super_damage =
  1038. {
  1039.     self.touch = powerup_touch;
  1040.  
  1041.     precache_model ("progs/quaddama.mdl");
  1042.     precache_sound ("items/damage.wav");
  1043.     precache_sound ("items/damage2.wav");
  1044.     precache_sound ("items/damage3.wav");
  1045.     self.noise = "items/damage.wav";
  1046.     setmodel (self, "progs/quaddama.mdl");
  1047.     self.netname = "Quad Damage";
  1048.     self.items = IT_QUAD;
  1049.     setsize (self, '-16 -16 -24', '16 16 32');
  1050.     StartItem ();
  1051. };
  1052.  
  1053.  
  1054.  
  1055. /*
  1056. ===============================================================================
  1057.  
  1058. PLAYER BACKPACKS
  1059.  
  1060. ===============================================================================
  1061. */
  1062.  
  1063. /*
  1064. ===============
  1065. DropBackpack
  1066. ===============
  1067. */
  1068. void() DropBackpack =
  1069. {
  1070. return;
  1071. };
  1072.