SHARE
TWEET

Untitled

a guest Apr 22nd, 2016 21 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. ===============================================================================
  3.  
  4. AMMO
  5.  
  6. ===============================================================================
  7. */
  8.  
  9. void() ammo_touch =
  10. {
  11. local entity    stemp;
  12. local float     best;
  13.  
  14.     if (other.classname != "player")
  15.         return;
  16.     if (other.health <= 0)
  17.         return;
  18.  
  19. // if the player was using his best weapon, change up to the new one if better     
  20.     stemp = self;
  21.     self = other;
  22.     best = W_BestWeapon();
  23.     self = stemp;
  24.  
  25.  
  26. // shotgun
  27.     if (self.weapon == 1)
  28.     {
  29.         if (other.ammo_shells >= 100)
  30.             return;
  31.         other.ammo_shells = other.ammo_shells + self.aflag;
  32.     }
  33.  
  34. // spikes
  35.     if (self.weapon == 2)
  36.     {
  37.         if (other.ammo_nails >= 200)
  38.             return;
  39.         other.ammo_nails = other.ammo_nails + self.aflag;
  40.     }
  41.  
  42. //  rockets
  43.     if (self.weapon == 3)
  44.     {
  45.         if (other.ammo_rockets >= 100)
  46.             return;
  47.         other.ammo_rockets = other.ammo_rockets + self.aflag;
  48.     }
  49.  
  50. //  cells
  51.     if (self.weapon == 4)
  52.     {
  53.         if (other.ammo_cells >= 100)
  54.             return;
  55.         other.ammo_cells = other.ammo_cells + self.aflag;
  56.     }
  57.  
  58.     bound_other_ammo ();
  59.    
  60.     sprint (other, "You got ");
  61.     sprint (other, self.netname);
  62.     sprint (other, "\n");
  63. // ammo touch sound
  64.     sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM); //this allows to play different pickup sounds depending on the item
  65.     stuffcmd (other, "bf\n");
  66.  
  67. // change to a better weapon if appropriate
  68.  
  69.     if ( other.weapon == best )
  70.     {
  71.         stemp = self;
  72.         self = other;
  73.         self.weapon = W_BestWeapon();
  74.         W_SetCurrentAmmo ();
  75.         self = stemp;
  76.     }
  77.  
  78. // if changed current ammo, update it
  79.     stemp = self;
  80.     self = other;
  81.     W_SetCurrentAmmo();
  82.     self = stemp;
  83.  
  84. // remove it in single player, or setup for respawning in deathmatch
  85.     self.model = string_null;
  86.     self.solid = SOLID_NOT;
  87.     if (deathmatch == 1)
  88.         self.nextthink = time + 30;
  89.     self.think = SUB_regen;
  90.  
  91.     activator = other;
  92.     SUB_UseTargets();               // fire all targets / killtargets
  93. };
  94.  
  95.  
  96.  
  97.  
  98. float WEAPON_BIG2 = 1;
  99.  
  100. /*QUAKED item_shells (0 .5 .8) (0 0 0) (32 32 32) big
  101. */
  102.  
  103. void() item_shells =
  104. {
  105.     self.touch = ammo_touch;
  106.  
  107.     if (self.spawnflags & WEAPON_BIG2)
  108.     {
  109.         precache_model ("maps/b_shell1.bsp");
  110.         setmodel (self, "maps/b_shell1.bsp");
  111.         precache_sound ("weapons/shell2.wav");
  112.         self.noise = "weapons/shell2.wav"; //the path field under "self.noise" will be used for the sound declaration above
  113.         self.aflag = 40;
  114.         self.netname = "40 shells";
  115.     }
  116.     else
  117.     {
  118.         precache_model ("maps/b_shell0.bsp");
  119.         setmodel (self, "maps/b_shell0.bsp");
  120.         precache_sound ("weapons/shell1.wav");
  121.         self.noise = "weapons/shell1.wav";
  122.         self.aflag = 20;
  123.         self.netname = "20 shells";
  124.     }
  125.     self.weapon = 1;
  126.  
  127.     setsize (self, '0 0 0', '32 32 56');
  128.     StartItem ();
  129. };
  130.  
  131. /*QUAKED item_spikes (0 .5 .8) (0 0 0) (32 32 32) big
  132. */
  133.  
  134. void() item_spikes =
  135. {
  136.     self.touch = ammo_touch;
  137.  
  138.     if (self.spawnflags & WEAPON_BIG2)
  139.     {
  140.         precache_model ("maps/b_nail1.bsp");
  141.         setmodel (self, "maps/b_nail1.bsp");
  142.         precache_sound ("weapons/nail2.wav");
  143.         self.noise = "weapons/nail2.wav";
  144.         self.aflag = 50;
  145.         self.netname = "50 nails";
  146.     }
  147.     else
  148.     {
  149.         precache_model ("maps/b_nail0.bsp");
  150.         setmodel (self, "maps/b_nail0.bsp");
  151.         precache_sound ("weapons/nail1.wav");
  152.         self.noise = "weapons/nail1.wav";
  153.         self.aflag = 25;
  154.         self.netname = "25 nails";
  155.     }
  156.     self.weapon = 2;
  157.    
  158.     setsize (self, '0 0 0', '32 32 56');
  159.     StartItem ();
  160. };
  161.  
  162. /*QUAKED item_rockets (0 .5 .8) (0 0 0) (32 32 32) big
  163. */
  164.  
  165. void() item_rockets =
  166. {
  167.     self.touch = ammo_touch;
  168.  
  169.     if (self.spawnflags & WEAPON_BIG2)
  170.     {
  171.         precache_model ("maps/b_rock1.bsp");
  172.         setmodel (self, "maps/b_rock1.bsp");
  173.         precache_sound ("weapons/rocket2.wav");
  174.         self.noise = "weapons/rocket2.wav";
  175.         self.aflag = 10;
  176.         self.netname = "10 rockets";
  177.     }
  178.     else
  179.     {
  180.         precache_model ("maps/b_rock0.bsp");
  181.         setmodel (self, "maps/b_rock0.bsp");
  182.         precache_sound ("weapons/rocket1.wav");
  183.         self.noise = "weapons/rocket1.wav";
  184.         self.aflag = 5;
  185.         self.netname = "5 rockets";
  186.     }
  187.     self.weapon = 3;
  188.    
  189.     setsize (self, '0 0 0', '32 32 56');
  190.     StartItem ();
  191. };
  192.  
  193.  
  194. /*QUAKED item_cells (0 .5 .8) (0 0 0) (32 32 32) big
  195. */
  196.  
  197. void() item_cells =
  198. {
  199.     self.touch = ammo_touch;
  200.  
  201.     if (self.spawnflags & WEAPON_BIG2)
  202.     {
  203.         precache_model ("maps/b_batt1.bsp");
  204.         setmodel (self, "maps/b_batt1.bsp");
  205.         precache_sound ("weapons/cell2.wav");
  206.         self.noise = "weapons/cell2.wav";
  207.         self.aflag = 12;
  208.         self.netname = "12 cells";
  209.     }
  210.     else
  211.     {
  212.         precache_model ("maps/b_batt0.bsp");
  213.         setmodel (self, "maps/b_batt0.bsp");
  214.         precache_sound ("weapons/cell1.wav");
  215.         self.noise = "weapons/cell1.wav";
  216.         self.aflag = 6;
  217.         self.netname = "6 cells";
  218.     }
  219.     self.weapon = 4;
  220.    
  221.     setsize (self, '0 0 0', '32 32 56');
  222.     StartItem ();
  223. };
RAW Paste Data
Challenge yourself this year...
Learn something new in 2017
Top