Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- =============
- weapon_touch
- =============
- */
- float() W_BestWeapon;
- void() weapon_touch =
- {
- local float hadammo, best, new, old;
- local entity stemp;
- local float leave;
- if (!(other.flags & FL_CLIENT))
- return;
- // if the player was using his best weapon, change up to the new one if better
- stemp = self;
- self = other;
- best = W_BestWeapon();
- self = stemp;
- if (deathmatch == 2 || coop)
- leave = 1;
- else
- leave = 0;
- if (self.classname == "weapon_nailgun")
- {
- if (leave && (other.items & IT_NAILGUN) )
- return;
- hadammo = other.ammo_nails;
- new = IT_NAILGUN;
- other.ammo_nails = other.ammo_nails + 30;
- precache_sound ("weapons/pkng.wav");
- self.noise = "weapons/pkng.wav";
- }
- else if (self.classname == "weapon_infantrygun")
- {
- if (leave && (other.items & IT_INFANTRY_GUN) )
- return;
- hadammo = other.ammo_nails; // ammo_rockets
- new = IT_INFANTRY_GUN;
- other.ammo_nails = other.ammo_nails + 30;
- precache_sound ("weapons/pkinf.wav");
- self.noise = "weapons/pkinf.wav";
- }
- else if (self.classname == "weapon_supernailgun")
- {
- if (leave && (other.items & IT_SUPER_NAILGUN) )
- return;
- hadammo = other.ammo_rockets;
- new = IT_SUPER_NAILGUN;
- other.ammo_nails = other.ammo_nails + 30;
- precache_sound ("weapons/pksng.wav");
- self.noise = "weapons/pksng.wav";
- }
- else if (self.classname == "weapon_gatlinggun")
- {
- if (leave && (other.items & IT_GATLING_GUN) )
- return;
- hadammo = other.ammo_rockets;
- new = IT_GATLING_GUN;
- other.ammo_nails = other.ammo_nails + 50;
- precache_sound ("weapons/pkgtln.wav");
- self.noise = "weapons/pkgtln.wav";
- }
- else if (self.classname == "weapon_supershotgun")
- {
- if (leave && (other.items & IT_SUPER_SHOTGUN) )
- return;
- hadammo = other.ammo_rockets;
- new = IT_SUPER_SHOTGUN;
- other.ammo_shells = other.ammo_shells + 5;
- precache_sound ("weapons/pkssg.wav");
- self.noise = "weapons/pkssg.wav";
- }
- else if (self.classname == "weapon_rocketlauncher")
- {
- if (leave && (other.items & IT_ROCKET_LAUNCHER) )
- return;
- hadammo = other.ammo_rockets;
- new = IT_ROCKET_LAUNCHER;
- other.ammo_rockets = other.ammo_rockets + 5;
- precache_sound ("weapons/pkrkt.wav");
- self.noise = "weapons/pkrkt.wav";
- }
- else if (self.classname == "weapon_grenadelauncher")
- {
- if (leave && (other.items & IT_GRENADE_LAUNCHER) )
- return;
- hadammo = other.ammo_rockets;
- new = IT_GRENADE_LAUNCHER;
- other.ammo_rockets = other.ammo_rockets + 5;
- precache_sound ("weapons/pkgrnd.wav");
- self.noise = "weapons/pkgrnd.wav";
- }
- else if (self.classname == "weapon_lightning")
- {
- if (leave && (other.items & IT_LIGHTNING) )
- return;
- hadammo = other.ammo_rockets;
- new = IT_LIGHTNING;
- other.ammo_cells = other.ammo_cells + 15;
- precache_sound ("weapons/pkthnd.wav");
- self.noise = "weapons/pkthnd.wav";
- }
- else if (self.classname == "weapon_bfg9500")
- {
- if (leave && (other.items & IT_BFG9500) )
- return;
- hadammo = other.ammo_rockets;
- new = IT_BFG9500;
- other.ammo_cells = other.ammo_cells + 30;
- precache_sound ("weapons/pkbfg.wav");
- self.noise = "weapons/pkbfg.wav";
- }
- else
- objerror ("weapon_touch: unknown classname");
- sprint (other, "You got the ");
- sprint (other, self.netname);
- sprint (other, "\n");
- // weapon touch sound
- sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
- stuffcmd (other, "bf\n");
- bound_other_ammo ();
- // change to the weapon
- old = other.items;
- other.items = other.items | new;
- stemp = self;
- self = other;
- if (!deathmatch)
- self.weapon = new;
- else
- Deathmatch_Weapon (old, new);
- W_SetCurrentAmmo();
- self = stemp;
- if (leave)
- return;
- // remove it in single player, or setup for respawning in deathmatch
- self.model = string_null;
- self.solid = SOLID_NOT;
- if (deathmatch == 1)
- self.nextthink = time + 30;
- self.think = SUB_regen;
- activator = other;
- SUB_UseTargets(); // fire all targets / killtargets
- };
- /*QUAKED weapon_supershotgun (0 .5 .8) (-16 -16 0) (16 16 32)
- */
- void() weapon_supershotgun =
- {
- precache_model ("progs/g_shot.mdl");
- setmodel (self, "progs/g_shot.mdl");
- self.weapon = IT_SUPER_SHOTGUN;
- self.netname = "Double-barrelled Shotgun";
- self.touch = weapon_touch;
- setsize (self, '-16 -16 0', '16 16 56');
- StartItem ();
- };
- /*QUAKED weapon_nailgun (0 .5 .8) (-16 -16 0) (16 16 32)
- */
- void() weapon_nailgun =
- {
- precache_model ("progs/g_nail.mdl");
- setmodel (self, "progs/g_nail.mdl");
- self.weapon = IT_NAILGUN;
- self.netname = "nailgun";
- self.touch = weapon_touch;
- setsize (self, '-16 -16 0', '16 16 56');
- StartItem ();
- };
- /*QUAKED weapon_infantrygun (0 .5 .8) (-16 -16 0) (16 16 32)
- */
- void() weapon_infantrygun =
- {
- precache_model ("progs/g_infg.mdl");
- setmodel (self, "progs/g_infg.mdl");
- self.weapon = IT_INFANTRY_GUN;
- self.netname = "Infantry Gun";
- self.touch = weapon_touch;
- setsize (self, '-16 -16 0', '16 16 56');
- StartItem ();
- };
- /*QUAKED weapon_supernailgun (0 .5 .8) (-16 -16 0) (16 16 32)
- */
- void() weapon_supernailgun =
- {
- precache_model ("progs/g_nail2.mdl");
- setmodel (self, "progs/g_nail2.mdl");
- self.weapon = IT_SUPER_NAILGUN;
- self.netname = "Super Nailgun";
- self.touch = weapon_touch;
- setsize (self, '-16 -16 0', '16 16 56');
- StartItem ();
- };
- /*QUAKED weapon_gatlinggun (0 .5 .8) (-16 -16 0) (16 16 32)
- */
- void() weapon_gatlinggun =
- {
- precache_model ("progs/g_gatlg.mdl");
- setmodel (self, "progs/g_gatlg.mdl");
- self.weapon = IT_GATLING_GUN;
- self.netname = "Gatling Gun";
- self.touch = weapon_touch;
- setsize (self, '-16 -16 0', '16 16 56');
- StartItem ();
- };
- /*QUAKED weapon_grenadelauncher (0 .5 .8) (-16 -16 0) (16 16 32)
- */
- void() weapon_grenadelauncher =
- {
- precache_model ("progs/g_rock.mdl");
- setmodel (self, "progs/g_rock.mdl");
- self.weapon = 3;
- self.netname = "Grenade Launcher";
- self.touch = weapon_touch;
- setsize (self, '-16 -16 0', '16 16 56');
- StartItem ();
- };
- /*QUAKED weapon_rocketlauncher (0 .5 .8) (-16 -16 0) (16 16 32)
- */
- void() weapon_rocketlauncher =
- {
- precache_model ("progs/g_rock2.mdl");
- setmodel (self, "progs/g_rock2.mdl");
- self.weapon = 3;
- self.netname = "Rocket Launcher";
- self.touch = weapon_touch;
- setsize (self, '-16 -16 0', '16 16 56');
- StartItem ();
- };
- /*QUAKED weapon_lightning (0 .5 .8) (-16 -16 0) (16 16 32)
- */
- void() weapon_lightning =
- {
- precache_model ("progs/g_light.mdl");
- setmodel (self, "progs/g_light.mdl");
- self.weapon = 3;
- self.netname = "Thunderbolt";
- self.touch = weapon_touch;
- setsize (self, '-16 -16 0', '16 16 56');
- StartItem ();
- };
- /*QUAKED weapon_bfg9500 (0 .5 .8) (-16 -16 0) (16 16 32)
- */
- void() weapon_bfg9500 =
- {
- precache_model ("progs/g_bfg.mdl");
- setmodel (self, "progs/g_bfg.mdl");
- self.weapon = 3;
- self.netname = "BFG9500";
- self.touch = weapon_touch;
- setsize (self, '-16 -16 0', '16 16 56');
- StartItem ();
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement