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