super-coop/source/p_weapons.qc

1077 lines
22 KiB
Plaintext

// p_weapons.qc: weapon functions
// called by worldspawn
void() wep_precache = {
precache_sound("weapons/r_exp3.wav"); // new rocket explosion
precache_sound("weapons/rocket1i.wav"); // spike gun
precache_sound("weapons/sgun1.wav");
precache_sound("weapons/guncock.wav"); // player shotgun
precache_sound("weapons/ric1.wav"); // ricochet(used in c code)
precache_sound("weapons/ric2.wav"); // ricochet(used in c code)
precache_sound("weapons/ric3.wav"); // ricochet(used in c code)
precache_sound("weapons/spike2.wav"); // super spikes
precache_sound("weapons/tink1.wav"); // spikes tink(used in c code)
precache_sound("weapons/grenade.wav"); // grenade launcher
precache_sound("weapons/bounce.wav"); // grenade bounce
precache_sound("weapons/shotgn2.wav"); // super shotgun
};
/*
================
wep_fire_axe
================
*/
void() wep_fire_axe = {
vector source;
vector org;
make_vectors(self.v_angle);
source = self.origin + '0 0 16';
trace_line(source, source + v_forward * 64, FALSE, self);
if(trace_fraction == 1.0) {
return;
}
org = trace_endpos - v_forward * 4;
if(trace_ent.takedamage) {
trace_ent.axhitme = 1;
spawn_blood(org, VEC_ORIGIN, 20);
ent_damage(trace_ent, self, self, 20);
} else {
// hit wall
sound(self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
write_byte(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(MSG_BROADCAST, TE_GUNSHOT);
write_coord(MSG_BROADCAST, org_x);
write_coord(MSG_BROADCAST, org_y);
write_coord(MSG_BROADCAST, org_z);
}
};
//============================================================================
vector() wall_velocity = {
vector vel;
vel = normalize(self.velocity);
vel = normalize(vel + v_up * (random() - 0.5) + v_right * (random() - 0.5));
vel = vel + 2 * trace_plane_normal;
vel = vel * 200;
return vel;
};
/*
================
spawn_meat_spray
================
*/
void(vector org, vector vel) spawn_meat_spray = {
entity missile, mpuff;
vector org;
missile = spawn();
missile.owner = self;
missile.movetype = MOVETYPE_BOUNCE;
missile.solid = SOLID_NOT;
make_vectors(self.angles);
missile.velocity = vel;
missile.velocity_z = missile.velocity_z + 250 + 50 * random();
missile.avelocity = '3000 1000 2000';
// set missile duration
missile.nextthink = time + 1;
missile.think = sub_remove;
set_model(missile, "progs/zom_gib.mdl");
set_size(missile, VEC_ORIGIN, VEC_ORIGIN);
set_origin(missile, org);
};
/*
================
spawn_blood
================
*/
void(vector org, vector vel, float damage) spawn_blood = {
particle(org, vel * 0.1, 73, damage * 2);
};
/*
================
spawn_touchblood
================
*/
void(float damage) spawn_touchblood = {
vector vel;
vel = wall_velocity() * 0.2;
spawn_blood(self.origin + vel * 0.01, vel, damage);
};
/*
================
spawn_chunk
================
*/
void(vector org, vector vel) spawn_chunk = {
particle(org, vel * 0.02, 0, 10);
};
/*
==============================================================================
MULTI-DAMAGE
Collects multiple small damages into a single damage
==============================================================================
*/
void() multi_damage_clear = {
multi_ent = world;
multi_damage = 0;
};
void() multi_damage_apply = {
if(!multi_ent) {
return;
}
ent_damage(multi_ent, self, self, multi_damage);
};
void(entity hit, float damage) multi_damage_add = {
if(!hit) {
return;
}
if(hit != multi_ent) {
multi_damage_apply();
multi_damage = damage;
multi_ent = hit;
} else {
multi_damage = multi_damage + damage;
}
};
/*
==============================================================================
BULLETS
==============================================================================
*/
/*
================
trace_attack
================
*/
void(float damage, vector dir) trace_attack = {
vector vel, org;
vel = normalize(dir + v_up * crandom() + v_right * crandom());
vel = vel + 2 * trace_plane_normal;
vel = vel * 200;
org = trace_endpos - dir * 4;
if(trace_ent.takedamage) {
spawn_blood(org, vel * 0.2, damage);
multi_damage_add(trace_ent, damage);
} else {
write_byte(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(MSG_BROADCAST, TE_GUNSHOT);
write_coord(MSG_BROADCAST, org_x);
write_coord(MSG_BROADCAST, org_y);
write_coord(MSG_BROADCAST, org_z);
}
};
/*
================
fire_bullets
Used by shotgun, super shotgun, and enemy soldier firing
Go to the trouble of combining multiple pellets into a single damage call.
================
*/
void(float shotcount, vector dir, vector spread) fire_bullets = {
vector direction, src;
make_vectors(self.v_angle);
src = self.origin + v_forward * 10;
src_z = self.absmin_z + self.size_z * 0.7;
multi_damage_clear();
while(shotcount > 0) {
direction = dir + crandom() * spread_x * v_right + crandom() * spread_y * v_up;
trace_line(src, src + direction * 2048, FALSE, self);
if(trace_fraction != 1.0) {
trace_attack(4, direction);
}
shotcount = shotcount - 1;
}
multi_damage_apply();
};
/*
================
wep_fire_shotgun
================
*/
void() wep_fire_shotgun = {
vector dir;
sound(self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM);
self.punchangle_x = -2;
self.currentammo = self.ammo_shells = self.ammo_shells - 1;
dir = aim(self, 100000);
fire_bullets(6, dir, '0.04 0.04 0');
};
/*
================
wep_fire_super_shotgun
================
*/
void() wep_fire_super_shotgun = {
vector dir;
if(self.currentammo == 1) {
wep_fire_shotgun();
return;
}
sound(self, CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM);
self.punchangle_x = -4;
self.currentammo = self.ammo_shells = self.ammo_shells - 2;
dir = aim(self, 100000);
fire_bullets(14, dir, '0.14 0.08 0');
};
/*
==============================================================================
ROCKETS
==============================================================================
*/
void() s_explode1 = [0, s_explode2] {};
void() s_explode2 = [1, s_explode3] {};
void() s_explode3 = [2, s_explode4] {};
void() s_explode4 = [3, s_explode5] {};
void() s_explode5 = [4, s_explode6] {};
void() s_explode6 = [5, sub_remove] {};
void() become_explosion = {
self.movetype = MOVETYPE_NONE;
self.velocity = VEC_ORIGIN;
self.touch = sub_null;
set_model(self, "progs/s_explod.spr");
self.solid = SOLID_NOT;
s_explode1();
};
void() ent_missile_touch = {
float damg;
if(other == self.owner) {
return; // don't explode on owner
}
if(point_contents(self.origin) == CONTENT_SKY) {
remove(self);
return;
}
damg = 100 + random() * 20;
if(other.health) {
if(other.classname == "monster_shambler") {
damg = damg * 0.5; // mostly immune
}
ent_damage(other, self, self.owner, damg);
}
// don't do radius damage to the other, because all the damage
// was done in the impact
ent_radius_damage(self, self.owner, 120, other);
// sound(self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);
self.origin = self.origin - 8 * normalize(self.velocity);
write_byte(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(MSG_BROADCAST, TE_EXPLOSION);
write_coord(MSG_BROADCAST, self.origin_x);
write_coord(MSG_BROADCAST, self.origin_y);
write_coord(MSG_BROADCAST, self.origin_z);
become_explosion();
};
/*
================
wep_fire_rocket
================
*/
void() wep_fire_rocket = {
entity missile, mpuff;
self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
sound(self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
self.punchangle_x = -2;
missile = spawn();
missile.owner = self;
missile.movetype = MOVETYPE_FLYMISSILE;
missile.solid = SOLID_BBOX;
missile.classname = "missile";
// set missile speed
make_vectors(self.v_angle);
missile.velocity = aim(self, 1000);
missile.velocity = missile.velocity * 1000;
missile.angles = vec_to_angles(missile.velocity);
missile.touch = ent_missile_touch;
// set missile duration
missile.nextthink = time + 5;
missile.think = sub_remove;
set_model(missile, "progs/missile.mdl");
set_size(missile, VEC_ORIGIN, VEC_ORIGIN);
set_origin(missile, self.origin + v_forward * 8 + '0 0 16');
};
/*
===============================================================================
LIGHTNING
===============================================================================
*/
/*
=================
lightning_damage
=================
*/
void(vector p1, vector p2, entity from, float damage) lightning_damage = {
entity e1, e2;
vector f;
f = p2 - p1;
normalize(f);
f_x = 0 - f_y;
f_y = f_x;
f_z = 0;
f *= 16;
e1 = e2 = world;
trace_line(p1, p2, FALSE, self);
if(trace_ent.takedamage) {
particle(trace_endpos, '0 0 100', 225, damage * 4);
ent_damage(trace_ent, from, from, damage);
if(self.classname == "player" && other.classname == "player") {
trace_ent.velocity_z = trace_ent.velocity_z + 400;
}
}
e1 = trace_ent;
trace_line(p1 + f, p2 + f, FALSE, self);
if(trace_ent != e1 && trace_ent.takedamage) {
particle(trace_endpos, '0 0 100', 225, damage * 4);
ent_damage(trace_ent, from, from, damage);
}
e2 = trace_ent;
trace_line(p1 - f, p2 - f, FALSE, self);
if(trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage) {
particle(trace_endpos, '0 0 100', 225, damage * 4);
ent_damage(trace_ent, from, from, damage);
}
};
void() wep_fire_lightning = {
vector org;
float cells;
make_vectors(self.v_angle);
if(self.ammo_cells < 1) {
self.weapon = wep_best_weapon();
wep_set_current_ammo();
return;
}
// explode if under water
if(self.waterlevel > 1) {
cells = self.ammo_cells;
self.ammo_cells = 0;
wep_set_current_ammo();
ent_radius_damage(self, self, 35 * cells, world);
return;
}
if(self.t_width < time) {
sound(self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
self.t_width = time + 0.6;
}
self.punchangle_x = -2;
self.currentammo = self.ammo_cells = self.ammo_cells - 1;
org = self.origin + '0 0 16';
trace_line(org, org + v_forward * 600, TRUE, self);
write_byte(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(MSG_BROADCAST, TE_LIGHTNING2);
write_entity(MSG_BROADCAST, self);
write_coord(MSG_BROADCAST, org_x);
write_coord(MSG_BROADCAST, org_y);
write_coord(MSG_BROADCAST, org_z);
write_coord(MSG_BROADCAST, trace_endpos_x);
write_coord(MSG_BROADCAST, trace_endpos_y);
write_coord(MSG_BROADCAST, trace_endpos_z);
lightning_damage(self.origin, trace_endpos + v_forward * 4, self, 30);
};
//=============================================================================
void() grenade_explode = {
ent_radius_damage(self, self.owner, 120, world);
write_byte(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(MSG_BROADCAST, TE_EXPLOSION);
write_coord(MSG_BROADCAST, self.origin_x);
write_coord(MSG_BROADCAST, self.origin_y);
write_coord(MSG_BROADCAST, self.origin_z);
become_explosion();
};
void() grenade_touch = {
if(other == self.owner) {
return; // don't explode on owner
}
if(other.takedamage == DAMAGE_AIM) {
grenade_explode();
return;
}
sound(self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM); // bounce sound
if(self.velocity == VEC_ORIGIN) {
self.avelocity = VEC_ORIGIN;
}
};
/*
================
wep_fire_grenade
================
*/
void() wep_fire_grenade = {
entity missile, mpuff;
self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
sound(self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);
self.punchangle_x = -2;
missile = spawn();
missile.owner = self;
missile.movetype = MOVETYPE_BOUNCE;
missile.solid = SOLID_BBOX;
missile.classname = "grenade";
// set missile speed
make_vectors(self.v_angle);
if(self.v_angle_x) {
missile.velocity = v_forward * 600 + v_up * 200 + crandom() * v_right * 10 + crandom() * v_up * 10;
} else {
missile.velocity = aim(self, 10000);
missile.velocity = missile.velocity * 600;
missile.velocity_z = 200;
}
missile.avelocity = '300 300 300';
missile.angles = vec_to_angles(missile.velocity);
missile.touch = grenade_touch;
// set missile duration
missile.nextthink = time + 2.5;
missile.think = grenade_explode;
set_model(missile, "progs/grenade.mdl");
set_size(missile, VEC_ORIGIN, VEC_ORIGIN);
set_origin(missile, self.origin);
};
//=============================================================================
void() spike_touch = {
float rand;
if(other == self.owner) {
return;
}
if(other.solid == SOLID_TRIGGER) {
return; // trigger field, do nothing
}
if(point_contents(self.origin) == CONTENT_SKY) {
remove(self);
return;
}
// hit something that bleeds
if(other.takedamage) {
spawn_touchblood(9);
ent_damage(other, self, self.owner, 9);
} else {
write_byte(MSG_BROADCAST, SVC_TEMPENTITY);
if(self.classname == "wizspike") {
write_byte(MSG_BROADCAST, TE_WIZSPIKE);
} else if(self.classname == "knightspike") {
write_byte(MSG_BROADCAST, TE_KNIGHTSPIKE);
} else {
write_byte(MSG_BROADCAST, TE_SPIKE);
}
write_coord(MSG_BROADCAST, self.origin_x);
write_coord(MSG_BROADCAST, self.origin_y);
write_coord(MSG_BROADCAST, self.origin_z);
}
remove(self);
};
/*
===============
launch_spike
Used for both the player and the ogre
===============
*/
void(vector org, vector dir) launch_spike = {
newmis = spawn();
newmis.owner = self;
newmis.movetype = MOVETYPE_FLYMISSILE;
newmis.solid = SOLID_BBOX;
newmis.angles = vec_to_angles(dir);
newmis.touch = spike_touch;
newmis.classname = "spike";
newmis.think = sub_remove;
newmis.nextthink = time + 6;
set_model(newmis, "progs/spike.mdl");
set_size(newmis, VEC_ORIGIN, VEC_ORIGIN);
set_origin(newmis, org);
newmis.velocity = dir * 1000;
};
void() wep_fire_super_nail = {
vector dir;
entity old;
sound(self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
self.attack_finished = time + 0.2;
self.currentammo = self.ammo_nails = self.ammo_nails - 2;
dir = aim(self, 1000);
launch_spike(self.origin + '0 0 16', dir);
newmis.touch = superspike_touch;
set_model(newmis, "progs/s_spike.mdl");
set_size(newmis, VEC_ORIGIN, VEC_ORIGIN);
self.punchangle_x = -2;
};
void(float ox) wep_fire_nail = {
vector dir;
entity old;
make_vectors(self.v_angle);
if(self.ammo_nails >= 2 && self.weapon == IT_SUPER_NAILGUN) {
wep_fire_super_nail();
return;
}
if(self.ammo_nails < 1) {
self.weapon = wep_best_weapon();
wep_set_current_ammo();
return;
}
sound(self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
self.attack_finished = time + 0.2;
self.currentammo = self.ammo_nails = self.ammo_nails - 1;
dir = aim(self, 1000);
launch_spike(self.origin + '0 0 16' + v_right * ox, dir);
self.punchangle_x = -2;
};
void() superspike_touch = {
float rand;
if(other == self.owner) {
return;
}
if(other.solid == SOLID_TRIGGER) {
return; // trigger field, do nothing
}
if(point_contents(self.origin) == CONTENT_SKY) {
remove(self);
return;
}
// hit something that bleeds
if(other.takedamage) {
spawn_touchblood(18);
ent_damage(other, self, self.owner, 18);
} else {
write_byte(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(MSG_BROADCAST, TE_SUPERSPIKE);
write_coord(MSG_BROADCAST, self.origin_x);
write_coord(MSG_BROADCAST, self.origin_y);
write_coord(MSG_BROADCAST, self.origin_z);
}
remove(self);
};
/*
===============================================================================
PLAYER WEAPON USE
===============================================================================
*/
void() wep_set_current_ammo = {
player_run(); // get out of any weapon firing states
self.items &= ~(IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS);
switch(self.weapon) {
case IT_AXE:
self.currentammo = 0;
self.weaponmodel = "progs/v_axe.mdl";
self.weaponframe = 0;
break;
case IT_SHOTGUN:
self.currentammo = self.ammo_shells;
self.weaponmodel = "progs/v_shot.mdl";
self.weaponframe = 0;
self.items |= IT_SHELLS;
break;
case IT_SUPER_SHOTGUN:
self.currentammo = self.ammo_shells;
self.weaponmodel = "progs/v_shot2.mdl";
self.weaponframe = 0;
self.items |= IT_SHELLS;
break;
case IT_NAILGUN:
self.currentammo = self.ammo_nails;
self.weaponmodel = "progs/v_nail.mdl";
self.weaponframe = 0;
self.items |= IT_NAILS;
break;
case IT_SUPER_NAILGUN:
self.currentammo = self.ammo_nails;
self.weaponmodel = "progs/v_nail2.mdl";
self.weaponframe = 0;
self.items |= IT_NAILS;
break;
case IT_GRENADE_LAUNCHER:
self.currentammo = self.ammo_rockets;
self.weaponmodel = "progs/v_rock.mdl";
self.weaponframe = 0;
self.items |= IT_ROCKETS;
break;
case IT_ROCKET_LAUNCHER:
self.currentammo = self.ammo_rockets;
self.weaponmodel = "progs/v_rock2.mdl";
self.weaponframe = 0;
self.items |= IT_ROCKETS;
break;
case IT_LIGHTNING:
self.currentammo = self.ammo_cells;
self.weaponmodel = "progs/v_light.mdl";
self.weaponframe = 0;
self.items |= IT_CELLS;
break;
default:
self.currentammo = 0;
self.weaponmodel = string_null;
self.weaponframe = 0;
break;
}
};
float() wep_best_weapon = {
float it;
it = self.items;
if(self.waterlevel <= 1 && self.ammo_cells >= 1 && (it & IT_LIGHTNING)) {
return IT_LIGHTNING;
}
if(self.ammo_nails >= 2 && (it & IT_SUPER_NAILGUN)) {
return IT_SUPER_NAILGUN;
}
if(self.ammo_shells >= 2 && (it & IT_SUPER_SHOTGUN)) {
return IT_SUPER_SHOTGUN;
}
if(self.ammo_nails >= 1 && (it & IT_NAILGUN)) {
return IT_NAILGUN;
}
if(self.ammo_shells >= 1 && (it & IT_SHOTGUN)) {
return IT_SHOTGUN;
}
return IT_AXE;
};
/*
============
wep_attack
An attack impulse can be triggered now
============
*/
void() wep_attack = {
float r;
if(self.currentammo <= 0 && self.weapon != IT_AXE) {
self.weapon = wep_best_weapon();
wep_set_current_ammo();
return;
}
make_vectors(self.v_angle); // calculate forward angle for velocity
self.show_hostile = time + 1; // wake monsters up
switch(self.weapon) {
case IT_AXE:
sound(self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
r = random();
if(r < 0.25) {
player_axe1();
} else if(r < 0.5) {
player_axeb1();
} else if(r < 0.75) {
player_axec1();
} else {
player_axed1();
}
self.attack_finished = time + 0.5;
break;
case IT_SHOTGUN:
player_shot1();
wep_fire_shotgun();
self.attack_finished = time + 0.5;
break;
case IT_SUPER_SHOTGUN:
player_shot1();
wep_fire_super_shotgun();
self.attack_finished = time + 0.7;
break;
case IT_NAILGUN:
case IT_SUPER_NAILGUN:
player_nail1();
break;
case IT_GRENADE_LAUNCHER:
player_rocket1();
wep_fire_grenade();
self.attack_finished = time + 0.6;
break;
case IT_ROCKET_LAUNCHER:
player_rocket1();
wep_fire_rocket();
self.attack_finished = time + 0.8;
break;
case IT_LIGHTNING:
player_light1();
self.attack_finished = time + 0.1;
sound(self, CHAN_AUTO, "weapons/lstart.wav", 1, ATTN_NORM);
break;
}
};
/*
============
wep_change_weapon
============
*/
void(float wep) wep_change_weapon = {
float it, am, fl;
it = self.items;
am = 0;
switch(wep) {
case 1:
fl = IT_AXE;
break;
case 2:
fl = IT_SHOTGUN;
if(self.ammo_shells < 1) {
am = 1;
}
break;
case 3:
fl = IT_SUPER_SHOTGUN;
if(self.ammo_shells < 2) {
am = 1;
}
break;
case 4:
fl = IT_NAILGUN;
if(self.ammo_nails < 1) {
am = 1;
}
break;
case 5:
fl = IT_SUPER_NAILGUN;
if(self.ammo_nails < 2) {
am = 1;
}
break;
case 6:
fl = IT_GRENADE_LAUNCHER;
if(self.ammo_rockets < 1) {
am = 1;
}
break;
case 7:
fl = IT_ROCKET_LAUNCHER;
if(self.ammo_rockets < 1) {
am = 1;
}
break;
case 8:
fl = IT_LIGHTNING;
if(self.ammo_cells < 1) {
am = 1;
}
break;
}
if(!(self.items & fl)) {
// don't have the weapon or the ammo
print_cl(self, "no weapon.\n");
return;
}
if(am) {
// don't have the ammo
print_cl(self, "not enough ammo.\n");
return;
}
// set weapon, set ammo
self.weapon = fl;
wep_set_current_ammo();
};
/*
============
wep_cycle_weapon
Go to the next weapon with ammo
============
*/
void() wep_cycle_weapon = {
float it, am;
it = self.items;
for(;;) {
am = 0;
switch(self.weapon) {
case IT_LIGHTNING:
self.weapon = IT_AXE;
break;
case IT_AXE:
self.weapon = IT_SHOTGUN;
if(self.ammo_shells < 1) {
am = 1;
}
break;
case IT_SHOTGUN:
self.weapon = IT_SUPER_SHOTGUN;
if(self.ammo_shells < 2) {
am = 1;
}
break;
case IT_SUPER_SHOTGUN:
self.weapon = IT_NAILGUN;
if(self.ammo_nails < 1) {
am = 1;
}
break;
case IT_NAILGUN:
self.weapon = IT_SUPER_NAILGUN;
if(self.ammo_nails < 2) {
am = 1;
}
break;
case IT_SUPER_NAILGUN:
self.weapon = IT_GRENADE_LAUNCHER;
if(self.ammo_rockets < 1) {
am = 1;
}
break;
case IT_GRENADE_LAUNCHER:
self.weapon = IT_ROCKET_LAUNCHER;
if(self.ammo_rockets < 1) {
am = 1;
}
break;
case IT_ROCKET_LAUNCHER:
self.weapon = IT_LIGHTNING;
if(self.ammo_cells < 1) {
am = 1;
}
break;
default:
return;
}
if((it & self.weapon) && am == 0) {
wep_set_current_ammo();
return;
}
}
};
/*
============
wep_cycle_weapon_reverse
Go to the prev weapon with ammo
============
*/
void() wep_cycle_weapon_reverse = {
float it, am;
it = self.items;
for(;;) {
am = 0;
switch(self.weapon) {
case IT_LIGHTNING:
self.weapon = IT_ROCKET_LAUNCHER;
if(self.ammo_rockets < 1) {
am = 1;
}
break;
case IT_ROCKET_LAUNCHER:
self.weapon = IT_GRENADE_LAUNCHER;
if(self.ammo_rockets < 1) {
am = 1;
}
break;
case IT_GRENADE_LAUNCHER:
self.weapon = IT_SUPER_NAILGUN;
if(self.ammo_nails < 2) {
am = 1;
}
break;
case IT_SUPER_NAILGUN:
self.weapon = IT_NAILGUN;
if(self.ammo_nails < 1) {
am = 1;
}
break;
case IT_NAILGUN:
self.weapon = IT_SUPER_SHOTGUN;
if(self.ammo_shells < 2) {
am = 1;
}
break;
case IT_SUPER_SHOTGUN:
self.weapon = IT_SHOTGUN;
if(self.ammo_shells < 1) {
am = 1;
}
break;
case IT_SHOTGUN:
self.weapon = IT_AXE;
break;
case IT_AXE:
self.weapon = IT_LIGHTNING;
if(self.ammo_cells < 1) {
am = 1;
}
break;
default:
return;
}
if((it & self.weapon) && am == 0) {
wep_set_current_ammo();
return;
}
}
};
/*
============
wep_weapon_frame
Called every frame so impulse events can be handled as well as possible
============
*/
void() wep_weapon_frame = {
// check for attack
if(self.button0) {
super_damage_sound();
wep_attack();
}
};
/*
========
super_damage_sound
Plays sound if needed
========
*/
void() super_damage_sound = {
if(self.super_damage_finished > time) {
if(self.super_sound < time) {
self.super_sound = time + 1;
sound(self, CHAN_BODY, "items/damage3.wav", 1, ATTN_NORM);
}
}
return;
};