Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ===============================================================================
- AMMO
- ===============================================================================
- */
- void() ammo_touch =
- {
- local entity stemp;
- local float best;
- if (other.classname != "player")
- return;
- if (other.health <= 0)
- 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;
- // shotgun
- if (self.weapon == 1)
- {
- if (other.ammo_shells >= 100)
- return;
- other.ammo_shells = other.ammo_shells + self.aflag;
- }
- // spikes
- if (self.weapon == 2)
- {
- if (other.ammo_nails >= 200)
- return;
- other.ammo_nails = other.ammo_nails + self.aflag;
- }
- // rockets
- if (self.weapon == 3)
- {
- if (other.ammo_rockets >= 100)
- return;
- other.ammo_rockets = other.ammo_rockets + self.aflag;
- }
- // cells
- if (self.weapon == 4)
- {
- if (other.ammo_cells >= 100)
- return;
- other.ammo_cells = other.ammo_cells + self.aflag;
- }
- bound_other_ammo ();
- sprint (other, "You got ");
- sprint (other, self.netname);
- sprint (other, "\n");
- // ammo touch sound
- sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM); //this allows to play different pickup sounds depending on the item
- stuffcmd (other, "bf\n");
- // change to a better weapon if appropriate
- if ( other.weapon == best )
- {
- stemp = self;
- self = other;
- self.weapon = W_BestWeapon();
- W_SetCurrentAmmo ();
- self = stemp;
- }
- // if changed current ammo, update it
- stemp = self;
- self = other;
- W_SetCurrentAmmo();
- self = stemp;
- // 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
- };
- float WEAPON_BIG2 = 1;
- /*QUAKED item_shells (0 .5 .8) (0 0 0) (32 32 32) big
- */
- void() item_shells =
- {
- self.touch = ammo_touch;
- if (self.spawnflags & WEAPON_BIG2)
- {
- precache_model ("maps/b_shell1.bsp");
- setmodel (self, "maps/b_shell1.bsp");
- precache_sound ("weapons/shell2.wav");
- self.noise = "weapons/shell2.wav"; //the path field under "self.noise" will be used for the sound declaration above
- self.aflag = 40;
- self.netname = "40 shells";
- }
- else
- {
- precache_model ("maps/b_shell0.bsp");
- setmodel (self, "maps/b_shell0.bsp");
- precache_sound ("weapons/shell1.wav");
- self.noise = "weapons/shell1.wav";
- self.aflag = 20;
- self.netname = "20 shells";
- }
- self.weapon = 1;
- setsize (self, '0 0 0', '32 32 56');
- StartItem ();
- };
- /*QUAKED item_spikes (0 .5 .8) (0 0 0) (32 32 32) big
- */
- void() item_spikes =
- {
- self.touch = ammo_touch;
- if (self.spawnflags & WEAPON_BIG2)
- {
- precache_model ("maps/b_nail1.bsp");
- setmodel (self, "maps/b_nail1.bsp");
- precache_sound ("weapons/nail2.wav");
- self.noise = "weapons/nail2.wav";
- self.aflag = 50;
- self.netname = "50 nails";
- }
- else
- {
- precache_model ("maps/b_nail0.bsp");
- setmodel (self, "maps/b_nail0.bsp");
- precache_sound ("weapons/nail1.wav");
- self.noise = "weapons/nail1.wav";
- self.aflag = 25;
- self.netname = "25 nails";
- }
- self.weapon = 2;
- setsize (self, '0 0 0', '32 32 56');
- StartItem ();
- };
- /*QUAKED item_rockets (0 .5 .8) (0 0 0) (32 32 32) big
- */
- void() item_rockets =
- {
- self.touch = ammo_touch;
- if (self.spawnflags & WEAPON_BIG2)
- {
- precache_model ("maps/b_rock1.bsp");
- setmodel (self, "maps/b_rock1.bsp");
- precache_sound ("weapons/rocket2.wav");
- self.noise = "weapons/rocket2.wav";
- self.aflag = 10;
- self.netname = "10 rockets";
- }
- else
- {
- precache_model ("maps/b_rock0.bsp");
- setmodel (self, "maps/b_rock0.bsp");
- precache_sound ("weapons/rocket1.wav");
- self.noise = "weapons/rocket1.wav";
- self.aflag = 5;
- self.netname = "5 rockets";
- }
- self.weapon = 3;
- setsize (self, '0 0 0', '32 32 56');
- StartItem ();
- };
- /*QUAKED item_cells (0 .5 .8) (0 0 0) (32 32 32) big
- */
- void() item_cells =
- {
- self.touch = ammo_touch;
- if (self.spawnflags & WEAPON_BIG2)
- {
- precache_model ("maps/b_batt1.bsp");
- setmodel (self, "maps/b_batt1.bsp");
- precache_sound ("weapons/cell2.wav");
- self.noise = "weapons/cell2.wav";
- self.aflag = 12;
- self.netname = "12 cells";
- }
- else
- {
- precache_model ("maps/b_batt0.bsp");
- setmodel (self, "maps/b_batt0.bsp");
- precache_sound ("weapons/cell1.wav");
- self.noise = "weapons/cell1.wav";
- self.aflag = 6;
- self.netname = "6 cells";
- }
- self.weapon = 4;
- setsize (self, '0 0 0', '32 32 56');
- StartItem ();
- };
Add Comment
Please, Sign In to add comment