SHARE
TWEET

Untitled

a guest Apr 22nd, 2016 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. =============
  3. weapon_touch
  4. =============
  5. */
  6. float() W_BestWeapon;
  7.  
  8. void() weapon_touch =
  9. {
  10.     local   float   hadammo, best, new, old;
  11.     local   entity  stemp;
  12.     local   float   leave;
  13.  
  14.     if (!(other.flags & FL_CLIENT))
  15.         return;
  16.  
  17. // if the player was using his best weapon, change up to the new one if better     
  18.     stemp = self;
  19.     self = other;
  20.     best = W_BestWeapon();
  21.     self = stemp;
  22.  
  23.     if (deathmatch == 2 || coop)
  24.         leave = 1;
  25.     else
  26.         leave = 0;
  27.    
  28.     if (self.classname == "weapon_nailgun")
  29.     {
  30.         if (leave && (other.items & IT_NAILGUN) )
  31.             return;
  32.         hadammo = other.ammo_nails;        
  33.         new = IT_NAILGUN;
  34.         other.ammo_nails = other.ammo_nails + 30;
  35.         precache_sound ("weapons/pkng.wav");
  36.         self.noise = "weapons/pkng.wav";
  37.     }
  38.     else if (self.classname == "weapon_infantrygun")
  39.     {
  40.         if (leave && (other.items & IT_INFANTRY_GUN) )
  41.             return;
  42.         hadammo = other.ammo_nails; //  ammo_rockets   
  43.         new = IT_INFANTRY_GUN;
  44.         other.ammo_nails = other.ammo_nails + 30;
  45.         precache_sound ("weapons/pkinf.wav");
  46.         self.noise = "weapons/pkinf.wav";
  47.     }
  48.     else if (self.classname == "weapon_supernailgun")
  49.     {
  50.         if (leave && (other.items & IT_SUPER_NAILGUN) )
  51.             return;
  52.         hadammo = other.ammo_rockets;          
  53.         new = IT_SUPER_NAILGUN;
  54.         other.ammo_nails = other.ammo_nails + 30;
  55.         precache_sound ("weapons/pksng.wav");
  56.         self.noise = "weapons/pksng.wav";
  57.     }
  58.     else if (self.classname == "weapon_gatlinggun")
  59.     {
  60.         if (leave && (other.items & IT_GATLING_GUN) )
  61.             return;
  62.         hadammo = other.ammo_rockets;          
  63.         new = IT_GATLING_GUN;
  64.         other.ammo_nails = other.ammo_nails + 50;
  65.         precache_sound ("weapons/pkgtln.wav");
  66.         self.noise = "weapons/pkgtln.wav";
  67.     }
  68.     else if (self.classname == "weapon_supershotgun")
  69.     {
  70.         if (leave && (other.items & IT_SUPER_SHOTGUN) )
  71.             return;
  72.         hadammo = other.ammo_rockets;          
  73.         new = IT_SUPER_SHOTGUN;
  74.         other.ammo_shells = other.ammo_shells + 5;
  75.         precache_sound ("weapons/pkssg.wav");
  76.         self.noise = "weapons/pkssg.wav";
  77.     }
  78.     else if (self.classname == "weapon_rocketlauncher")
  79.     {
  80.         if (leave && (other.items & IT_ROCKET_LAUNCHER) )
  81.             return;
  82.         hadammo = other.ammo_rockets;          
  83.         new = IT_ROCKET_LAUNCHER;
  84.         other.ammo_rockets = other.ammo_rockets + 5;
  85.         precache_sound ("weapons/pkrkt.wav");
  86.         self.noise = "weapons/pkrkt.wav";
  87.     }
  88.     else if (self.classname == "weapon_grenadelauncher")
  89.     {
  90.         if (leave && (other.items & IT_GRENADE_LAUNCHER) )
  91.             return;
  92.         hadammo = other.ammo_rockets;          
  93.         new = IT_GRENADE_LAUNCHER;
  94.         other.ammo_rockets = other.ammo_rockets + 5;
  95.         precache_sound ("weapons/pkgrnd.wav");
  96.         self.noise = "weapons/pkgrnd.wav";
  97.     }
  98.     else if (self.classname == "weapon_lightning")
  99.     {
  100.         if (leave && (other.items & IT_LIGHTNING) )
  101.             return;
  102.         hadammo = other.ammo_rockets;          
  103.         new = IT_LIGHTNING;
  104.         other.ammo_cells = other.ammo_cells + 15;
  105.         precache_sound ("weapons/pkthnd.wav");
  106.         self.noise = "weapons/pkthnd.wav";
  107.     }
  108.     else if (self.classname == "weapon_bfg9500")
  109.     {
  110.         if (leave && (other.items & IT_BFG9500) )
  111.             return;
  112.         hadammo = other.ammo_rockets;          
  113.         new = IT_BFG9500;
  114.         other.ammo_cells = other.ammo_cells + 30;
  115.         precache_sound ("weapons/pkbfg.wav");
  116.         self.noise = "weapons/pkbfg.wav";
  117.     }
  118.     else
  119.         objerror ("weapon_touch: unknown classname");
  120.  
  121.     sprint (other, "You got the ");
  122.     sprint (other, self.netname);
  123.     sprint (other, "\n");
  124. // weapon touch sound
  125.     sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  126.     stuffcmd (other, "bf\n");
  127.  
  128.     bound_other_ammo ();
  129.  
  130. // change to the weapon
  131.     old = other.items;
  132.     other.items = other.items | new;
  133.    
  134.     stemp = self;
  135.     self = other;
  136.  
  137.     if (!deathmatch)
  138.         self.weapon = new;
  139.     else
  140.         Deathmatch_Weapon (old, new);
  141.  
  142.     W_SetCurrentAmmo();
  143.  
  144.     self = stemp;
  145.  
  146.     if (leave)
  147.         return;
  148.  
  149. // remove it in single player, or setup for respawning in deathmatch
  150.     self.model = string_null;
  151.     self.solid = SOLID_NOT;
  152.     if (deathmatch == 1)
  153.         self.nextthink = time + 30;
  154.     self.think = SUB_regen;
  155.    
  156.     activator = other;
  157.     SUB_UseTargets();               // fire all targets / killtargets
  158. };
  159.  
  160.  
  161. /*QUAKED weapon_supershotgun (0 .5 .8) (-16 -16 0) (16 16 32)
  162. */
  163.  
  164. void() weapon_supershotgun =
  165. {
  166.     precache_model ("progs/g_shot.mdl");
  167.     setmodel (self, "progs/g_shot.mdl");
  168.     self.weapon = IT_SUPER_SHOTGUN;
  169.     self.netname = "Double-barrelled Shotgun";
  170.     self.touch = weapon_touch;
  171.     setsize (self, '-16 -16 0', '16 16 56');
  172.     StartItem ();
  173. };
  174.  
  175. /*QUAKED weapon_nailgun (0 .5 .8) (-16 -16 0) (16 16 32)
  176. */
  177.  
  178. void() weapon_nailgun =
  179. {
  180.     precache_model ("progs/g_nail.mdl");
  181.     setmodel (self, "progs/g_nail.mdl");
  182.     self.weapon = IT_NAILGUN;
  183.     self.netname = "nailgun";
  184.     self.touch = weapon_touch;
  185.     setsize (self, '-16 -16 0', '16 16 56');
  186.     StartItem ();
  187. };
  188.  
  189. /*QUAKED weapon_infantrygun (0 .5 .8) (-16 -16 0) (16 16 32)
  190. */
  191.  
  192. void() weapon_infantrygun =
  193. {
  194.     precache_model ("progs/g_infg.mdl");
  195.     setmodel (self, "progs/g_infg.mdl");
  196.     self.weapon = IT_INFANTRY_GUN;
  197.     self.netname = "Infantry Gun";
  198.     self.touch = weapon_touch;
  199.     setsize (self, '-16 -16 0', '16 16 56');
  200.     StartItem ();
  201. };
  202.  
  203. /*QUAKED weapon_supernailgun (0 .5 .8) (-16 -16 0) (16 16 32)
  204. */
  205.  
  206. void() weapon_supernailgun =
  207. {
  208.     precache_model ("progs/g_nail2.mdl");
  209.     setmodel (self, "progs/g_nail2.mdl");
  210.     self.weapon = IT_SUPER_NAILGUN;
  211.     self.netname = "Super Nailgun";
  212.     self.touch = weapon_touch;
  213.     setsize (self, '-16 -16 0', '16 16 56');
  214.     StartItem ();
  215. };
  216.  
  217. /*QUAKED weapon_gatlinggun (0 .5 .8) (-16 -16 0) (16 16 32)
  218. */
  219.  
  220. void() weapon_gatlinggun =
  221. {
  222.     precache_model ("progs/g_gatlg.mdl");
  223.     setmodel (self, "progs/g_gatlg.mdl");
  224.     self.weapon = IT_GATLING_GUN;
  225.     self.netname = "Gatling Gun";
  226.     self.touch = weapon_touch;
  227.     setsize (self, '-16 -16 0', '16 16 56');
  228.     StartItem ();
  229. };
  230.  
  231. /*QUAKED weapon_grenadelauncher (0 .5 .8) (-16 -16 0) (16 16 32)
  232. */
  233.  
  234. void() weapon_grenadelauncher =
  235. {
  236.     precache_model ("progs/g_rock.mdl");
  237.     setmodel (self, "progs/g_rock.mdl");
  238.     self.weapon = 3;
  239.     self.netname = "Grenade Launcher";
  240.     self.touch = weapon_touch;
  241.     setsize (self, '-16 -16 0', '16 16 56');
  242.     StartItem ();
  243. };
  244.  
  245. /*QUAKED weapon_rocketlauncher (0 .5 .8) (-16 -16 0) (16 16 32)
  246. */
  247.  
  248. void() weapon_rocketlauncher =
  249. {
  250.     precache_model ("progs/g_rock2.mdl");
  251.     setmodel (self, "progs/g_rock2.mdl");
  252.     self.weapon = 3;
  253.     self.netname = "Rocket Launcher";
  254.     self.touch = weapon_touch;
  255.     setsize (self, '-16 -16 0', '16 16 56');
  256.     StartItem ();
  257. };
  258.  
  259.  
  260. /*QUAKED weapon_lightning (0 .5 .8) (-16 -16 0) (16 16 32)
  261. */
  262.  
  263. void() weapon_lightning =
  264. {
  265.     precache_model ("progs/g_light.mdl");
  266.     setmodel (self, "progs/g_light.mdl");
  267.     self.weapon = 3;
  268.     self.netname = "Thunderbolt";
  269.     self.touch = weapon_touch;
  270.     setsize (self, '-16 -16 0', '16 16 56');
  271.     StartItem ();
  272. };
  273.  
  274. /*QUAKED weapon_bfg9500 (0 .5 .8) (-16 -16 0) (16 16 32)
  275. */
  276.  
  277. void() weapon_bfg9500 =
  278. {
  279.     precache_model ("progs/g_bfg.mdl");
  280.     setmodel (self, "progs/g_bfg.mdl");
  281.     self.weapon = 3;
  282.     self.netname = "BFG9500";
  283.     self.touch = weapon_touch;
  284.     setsize (self, '-16 -16 0', '16 16 56');
  285.     StartItem ();
  286. };
RAW Paste Data
Challenge yourself this year...
Learn something new in 2017
Top