2002-02-15 18:27:57 +00:00
|
|
|
void (entity targ, entity inflictor, entity attacker, float damage) T_Damage;
|
|
|
|
void () player_run;
|
2004-02-10 00:00:13 +00:00
|
|
|
void (entity bomb, entity attacker, float rad, entity ignore) T_RadiusDamage;
|
|
|
|
void (vector org, vector vel, float damage) SpawnBlood;
|
|
|
|
void () SuperDamageSound;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
// called by worldspawn
|
|
|
|
void() W_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
|
|
|
|
};
|
|
|
|
|
|
|
|
float() crandom =
|
|
|
|
{
|
2004-02-10 00:00:13 +00:00
|
|
|
return 2 * (random () - 0.5);
|
2002-02-15 18:27:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
W_FireAxe
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void() W_FireAxe =
|
|
|
|
{
|
2004-02-10 00:00:13 +00:00
|
|
|
local vector org, source;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
makevectors (self.v_angle);
|
|
|
|
source = self.origin + '0 0 16';
|
2004-02-09 00:03:10 +00:00
|
|
|
traceline (source, source + v_forward * 64, FALSE, self);
|
2002-02-15 18:27:57 +00:00
|
|
|
if (trace_fraction == 1.0)
|
|
|
|
return;
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
org = trace_endpos - v_forward * 4;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
if (trace_ent.takedamage) {
|
2002-02-15 18:27:57 +00:00
|
|
|
trace_ent.axhitme = 1;
|
|
|
|
SpawnBlood (org, '0 0 0', 20);
|
|
|
|
T_Damage (trace_ent, self, self, 20);
|
2004-02-09 00:03:10 +00:00
|
|
|
} else { // hit wall
|
2002-02-15 18:27:57 +00:00
|
|
|
sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
|
2004-02-09 00:03:10 +00:00
|
|
|
WriteBytes (MSG_BROADCAST, SVC_TEMPENTITY, TE_GUNSHOT);
|
|
|
|
WriteCoordV (MSG_BROADCAST, org);
|
2002-02-15 18:27:57 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
vector() wall_velocity =
|
|
|
|
{
|
|
|
|
local vector vel;
|
|
|
|
|
|
|
|
vel = normalize (self.velocity);
|
2004-02-09 00:03:10 +00:00
|
|
|
vel = normalize (vel + v_up * (random () - 0.5)
|
|
|
|
+ v_right * (random () - 0.5));
|
|
|
|
vel = vel + 2 * trace_plane_normal;
|
2002-02-15 18:27:57 +00:00
|
|
|
vel = vel * 200;
|
|
|
|
|
|
|
|
return vel;
|
|
|
|
};
|
|
|
|
|
|
|
|
void(vector org, vector vel) SpawnMeatSpray =
|
|
|
|
{
|
2004-02-09 00:03:10 +00:00
|
|
|
local entity missile;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
missile = spawn ();
|
|
|
|
missile.owner = self;
|
|
|
|
missile.movetype = MOVETYPE_BOUNCE;
|
|
|
|
missile.solid = SOLID_NOT;
|
|
|
|
|
|
|
|
makevectors (self.angles);
|
|
|
|
|
|
|
|
missile.velocity = vel;
|
2004-02-09 00:03:10 +00:00
|
|
|
missile.velocity_z = missile.velocity_z + 250 + 50 * random ();
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
missile.avelocity = '3000 1000 2000';
|
2004-02-09 00:03:10 +00:00
|
|
|
|
|
|
|
// set missile duration
|
|
|
|
missile.nextthink = time + 1.0;
|
2002-02-15 18:27:57 +00:00
|
|
|
missile.think = SUB_Remove;
|
|
|
|
|
|
|
|
setmodel (missile, "progs/zom_gib.mdl");
|
|
|
|
setsize (missile, '0 0 0', '0 0 0');
|
|
|
|
setorigin (missile, org);
|
|
|
|
};
|
|
|
|
|
|
|
|
void(vector org, vector vel, float damage) SpawnBlood =
|
|
|
|
{
|
2004-02-09 00:03:10 +00:00
|
|
|
particle (org, vel * 0.1, 73, damage * 2);
|
2002-02-15 18:27:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void(float damage) spawn_touchblood =
|
|
|
|
{
|
|
|
|
local vector vel;
|
|
|
|
|
|
|
|
vel = wall_velocity () * 0.2;
|
2004-02-09 00:03:10 +00:00
|
|
|
SpawnBlood (self.origin + vel * 0.01, vel, damage);
|
2002-02-15 18:27:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void(vector org, vector vel) SpawnChunk =
|
|
|
|
{
|
2004-02-09 00:03:10 +00:00
|
|
|
particle (org, vel * 0.02, 0, 10);
|
2002-02-15 18:27:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
MULTI-DAMAGE
|
|
|
|
|
|
|
|
Collects multiple small damages into a single damage
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
entity multi_ent;
|
|
|
|
float multi_damage;
|
|
|
|
|
|
|
|
void() ClearMultiDamage =
|
|
|
|
{
|
|
|
|
multi_ent = world;
|
|
|
|
multi_damage = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
void() ApplyMultiDamage =
|
|
|
|
{
|
|
|
|
if (!multi_ent)
|
|
|
|
return;
|
|
|
|
T_Damage (multi_ent, self, self, multi_damage);
|
|
|
|
};
|
|
|
|
|
|
|
|
void(entity hit, float damage) AddMultiDamage =
|
|
|
|
{
|
|
|
|
if (!hit)
|
|
|
|
return;
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
if (hit != multi_ent) {
|
2002-02-15 18:27:57 +00:00
|
|
|
ApplyMultiDamage ();
|
|
|
|
multi_damage = damage;
|
|
|
|
multi_ent = hit;
|
2004-02-09 00:03:10 +00:00
|
|
|
} else {
|
2002-02-15 18:27:57 +00:00
|
|
|
multi_damage = multi_damage + damage;
|
2004-02-09 00:03:10 +00:00
|
|
|
}
|
2002-02-15 18:27:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
BULLETS
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
void(float damage, vector dir) TraceAttack =
|
|
|
|
{
|
2004-02-09 00:03:10 +00:00
|
|
|
local vector vel, org;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
vel = normalize (dir + v_up * crandom () + v_right * crandom ());
|
|
|
|
vel = vel + 2 * trace_plane_normal;
|
2002-02-15 18:27:57 +00:00
|
|
|
vel = vel * 200;
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
org = trace_endpos - dir * 4;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
if (trace_ent.takedamage) {
|
|
|
|
SpawnBlood (org, vel * 0.2, damage);
|
2002-02-15 18:27:57 +00:00
|
|
|
AddMultiDamage (trace_ent, damage);
|
2004-02-09 00:03:10 +00:00
|
|
|
} else {
|
|
|
|
WriteBytes (MSG_BROADCAST, SVC_TEMPENTITY, TE_GUNSHOT);
|
|
|
|
WriteCoordV (MSG_BROADCAST, org);
|
2002-02-15 18:27:57 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
FireBullets
|
|
|
|
|
|
|
|
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) FireBullets =
|
|
|
|
{
|
2004-02-09 00:03:10 +00:00
|
|
|
local vector direction, src;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
makevectors (self.v_angle);
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
src = self.origin + v_forward*10;
|
|
|
|
src_z = self.absmin_z + self.size_z * 0.7;
|
|
|
|
|
|
|
|
ClearMultiDamage ();
|
2004-02-09 00:03:10 +00:00
|
|
|
while (shotcount > 0) {
|
|
|
|
direction = dir + crandom () * spread_x * v_right
|
|
|
|
+ crandom () * spread_y * v_up;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
traceline (src, src + direction * 2048, FALSE, self);
|
2002-02-15 18:27:57 +00:00
|
|
|
if (trace_fraction != 1.0)
|
|
|
|
TraceAttack (4, direction);
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
shotcount--;
|
2002-02-15 18:27:57 +00:00
|
|
|
}
|
|
|
|
ApplyMultiDamage ();
|
|
|
|
};
|
|
|
|
|
|
|
|
void() W_FireShotgun =
|
|
|
|
{
|
2004-02-09 00:03:10 +00:00
|
|
|
local vector dir;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM);
|
|
|
|
|
|
|
|
self.punchangle_x = -2;
|
2004-02-10 00:00:13 +00:00
|
|
|
|
|
|
|
self.currentammo = --self.ammo_shells;
|
2002-02-15 18:27:57 +00:00
|
|
|
dir = aim (self, 100000);
|
|
|
|
FireBullets (6, dir, '0.04 0.04 0');
|
|
|
|
};
|
|
|
|
|
|
|
|
void() W_FireSuperShotgun =
|
|
|
|
{
|
2004-02-09 00:03:10 +00:00
|
|
|
local vector dir;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
if (self.currentammo == 1) {
|
2002-02-15 18:27:57 +00:00
|
|
|
W_FireShotgun ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
sound (self, CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM);
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
self.punchangle_x = -4;
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
self.currentammo = self.ammo_shells -= 2;
|
2002-02-15 18:27:57 +00:00
|
|
|
dir = aim (self, 100000);
|
|
|
|
FireBullets (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() BecomeExplosion =
|
|
|
|
{
|
|
|
|
self.movetype = MOVETYPE_NONE;
|
|
|
|
self.velocity = '0 0 0';
|
|
|
|
self.touch = SUB_Null;
|
|
|
|
setmodel (self, "progs/s_explod.spr");
|
|
|
|
self.solid = SOLID_NOT;
|
|
|
|
s_explode1 ();
|
|
|
|
};
|
|
|
|
|
|
|
|
void() T_MissileTouch =
|
|
|
|
{
|
2004-02-10 00:00:13 +00:00
|
|
|
local float damg;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
if (other == self.owner)
|
|
|
|
return; // don't explode on owner
|
|
|
|
|
2004-02-10 00:00:13 +00:00
|
|
|
if (pointcontents (self.origin) == CONTENT_SKY) {
|
2004-02-09 00:03:10 +00:00
|
|
|
remove (self);
|
2002-02-15 18:27:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
damg = 100 + random () * 20;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
if (other.health) {
|
2002-02-15 18:27:57 +00:00
|
|
|
if (other.classname == "monster_shambler")
|
|
|
|
damg = damg * 0.5; // mostly immune
|
|
|
|
T_Damage (other, self, self.owner, damg );
|
|
|
|
}
|
|
|
|
|
|
|
|
// don't do radius damage to the other, because all the damage
|
|
|
|
// was done in the impact
|
|
|
|
T_RadiusDamage (self, self.owner, 120, other);
|
|
|
|
|
|
|
|
// sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);
|
|
|
|
self.origin = self.origin - 8*normalize(self.velocity);
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
WriteBytes (MSG_BROADCAST, SVC_TEMPENTITY, TE_EXPLOSION);
|
|
|
|
WriteCoordV (MSG_BROADCAST, self.origin);
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
BecomeExplosion ();
|
|
|
|
};
|
|
|
|
|
|
|
|
void() W_FireRocket =
|
|
|
|
{
|
2004-02-10 00:00:13 +00:00
|
|
|
local entity missile;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
self.currentammo = self.ammo_rockets--;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
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";
|
2004-02-09 00:03:10 +00:00
|
|
|
|
|
|
|
// set missile speed
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
makevectors (self.v_angle);
|
2004-02-09 00:03:10 +00:00
|
|
|
missile.velocity = aim (self, 1000);
|
2002-02-15 18:27:57 +00:00
|
|
|
missile.velocity = missile.velocity * 1000;
|
2004-02-09 00:03:10 +00:00
|
|
|
missile.angles = vectoangles (missile.velocity);
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
missile.touch = T_MissileTouch;
|
2004-02-09 00:03:10 +00:00
|
|
|
|
|
|
|
// set missile duration
|
|
|
|
missile.nextthink = time + 5.0;
|
2002-02-15 18:27:57 +00:00
|
|
|
missile.think = SUB_Remove;
|
|
|
|
|
|
|
|
setmodel (missile, "progs/missile.mdl");
|
2004-02-09 00:03:10 +00:00
|
|
|
setsize (missile, '0 0 0', '0 0 0');
|
|
|
|
setorigin (missile, self.origin + v_forward * 8 + '0 0 16');
|
2002-02-15 18:27:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============================================================================
|
|
|
|
|
|
|
|
LIGHTNING
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
void(vector p1, vector p2, entity from, float damage) LightningDamage =
|
|
|
|
{
|
|
|
|
local entity e1, e2;
|
|
|
|
local vector f;
|
|
|
|
|
|
|
|
f = p2 - p1;
|
|
|
|
normalize (f);
|
|
|
|
f_x = 0 - f_y;
|
|
|
|
f_y = f_x;
|
|
|
|
f_z = 0;
|
2004-02-09 00:03:10 +00:00
|
|
|
f = f * 16;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
e1 = e2 = world;
|
|
|
|
|
|
|
|
traceline (p1, p2, FALSE, self);
|
2004-02-09 00:03:10 +00:00
|
|
|
if (trace_ent.takedamage) {
|
|
|
|
particle (trace_endpos, '0 0 100', 225, damage * 4);
|
2002-02-15 18:27:57 +00:00
|
|
|
T_Damage (trace_ent, from, from, damage);
|
2004-02-09 00:03:10 +00:00
|
|
|
if (self.classname == "player") {
|
2002-02-15 18:27:57 +00:00
|
|
|
if (other.classname == "player")
|
|
|
|
trace_ent.velocity_z = trace_ent.velocity_z + 400;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
e1 = trace_ent;
|
|
|
|
|
|
|
|
traceline (p1 + f, p2 + f, FALSE, self);
|
2004-02-09 00:03:10 +00:00
|
|
|
if (trace_ent != e1 && trace_ent.takedamage) {
|
|
|
|
particle (trace_endpos, '0 0 100', 225, damage * 4);
|
2002-02-15 18:27:57 +00:00
|
|
|
T_Damage (trace_ent, from, from, damage);
|
|
|
|
}
|
|
|
|
e2 = trace_ent;
|
|
|
|
|
|
|
|
traceline (p1 - f, p2 - f, FALSE, self);
|
2004-02-09 00:03:10 +00:00
|
|
|
if (trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage) {
|
|
|
|
particle (trace_endpos, '0 0 100', 225, damage * 4);
|
2002-02-15 18:27:57 +00:00
|
|
|
T_Damage (trace_ent, from, from, damage);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void() W_FireLightning =
|
|
|
|
{
|
2004-02-09 00:03:10 +00:00
|
|
|
local float cells;
|
|
|
|
local vector org;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
if (self.ammo_cells < 1) {
|
2002-02-15 18:27:57 +00:00
|
|
|
self.weapon = W_BestWeapon ();
|
|
|
|
W_SetCurrentAmmo ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
// explode if under water
|
|
|
|
if (self.waterlevel > 1) {
|
2002-02-15 18:27:57 +00:00
|
|
|
cells = self.ammo_cells;
|
|
|
|
self.ammo_cells = 0;
|
|
|
|
W_SetCurrentAmmo ();
|
2004-02-09 00:03:10 +00:00
|
|
|
T_RadiusDamage (self, self, 35 * cells, world);
|
2002-02-15 18:27:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
if (self.t_width < time) {
|
2002-02-15 18:27:57 +00:00
|
|
|
sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
|
|
|
|
self.t_width = time + 0.6;
|
|
|
|
}
|
|
|
|
self.punchangle_x = -2;
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
self.currentammo = self.ammo_cells--;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
org = self.origin + '0 0 16';
|
|
|
|
|
|
|
|
traceline (org, org + v_forward*600, TRUE, self);
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
WriteBytes (MSG_BROADCAST, SVC_TEMPENTITY, TE_LIGHTNING2);
|
2002-02-15 18:27:57 +00:00
|
|
|
WriteEntity (MSG_BROADCAST, self);
|
2004-02-09 00:03:10 +00:00
|
|
|
WriteCoordV (MSG_BROADCAST, org);
|
|
|
|
WriteCoordV (MSG_BROADCAST, trace_endpos);
|
2002-02-15 18:27:57 +00:00
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
LightningDamage (self.origin, trace_endpos + v_forward * 4, self, 30);
|
|
|
|
};
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
void() GrenadeExplode =
|
|
|
|
{
|
|
|
|
T_RadiusDamage (self, self.owner, 120, world);
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
WriteBytes (MSG_BROADCAST, SVC_TEMPENTITY, TE_EXPLOSION);
|
|
|
|
WriteCoordV (MSG_BROADCAST, self.origin);
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
BecomeExplosion ();
|
|
|
|
};
|
|
|
|
|
|
|
|
void() GrenadeTouch =
|
|
|
|
{
|
|
|
|
if (other == self.owner)
|
|
|
|
return; // don't explode on owner
|
2004-02-09 00:03:10 +00:00
|
|
|
if (other.takedamage == DAMAGE_AIM) {
|
|
|
|
GrenadeExplode ();
|
2002-02-15 18:27:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM); // bounce sound
|
|
|
|
if (self.velocity == '0 0 0')
|
|
|
|
self.avelocity = '0 0 0';
|
|
|
|
};
|
|
|
|
|
|
|
|
void() W_FireGrenade =
|
|
|
|
{
|
2004-02-09 00:03:10 +00:00
|
|
|
local entity missile;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
self.currentammo = self.ammo_rockets--;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
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";
|
2004-02-09 00:03:10 +00:00
|
|
|
|
|
|
|
// set missile speed
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
makevectors (self.v_angle);
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
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);
|
2002-02-15 18:27:57 +00:00
|
|
|
missile.velocity = missile.velocity * 600;
|
|
|
|
missile.velocity_z = 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
missile.avelocity = '300 300 300';
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
missile.angles = vectoangles (missile.velocity);
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
missile.touch = GrenadeTouch;
|
2004-02-09 00:03:10 +00:00
|
|
|
|
|
|
|
// set missile duration
|
2002-02-15 18:27:57 +00:00
|
|
|
missile.nextthink = time + 2.5;
|
|
|
|
missile.think = GrenadeExplode;
|
|
|
|
|
|
|
|
setmodel (missile, "progs/grenade.mdl");
|
|
|
|
setsize (missile, '0 0 0', '0 0 0');
|
|
|
|
setorigin (missile, self.origin);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
void() spike_touch;
|
|
|
|
void() superspike_touch;
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
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;
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
newmis.angles = vectoangles (dir);
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
newmis.touch = spike_touch;
|
|
|
|
newmis.classname = "spike";
|
|
|
|
newmis.think = SUB_Remove;
|
|
|
|
newmis.nextthink = time + 6;
|
|
|
|
setmodel (newmis, "progs/spike.mdl");
|
|
|
|
setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
|
|
|
|
setorigin (newmis, org);
|
|
|
|
|
|
|
|
newmis.velocity = dir * 1000;
|
|
|
|
};
|
|
|
|
|
|
|
|
void() W_FireSuperSpikes =
|
|
|
|
{
|
|
|
|
local vector dir;
|
|
|
|
|
|
|
|
sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
|
|
|
|
self.attack_finished = time + 0.2;
|
2004-02-09 00:03:10 +00:00
|
|
|
self.currentammo = self.ammo_nails -= 2;
|
2002-02-15 18:27:57 +00:00
|
|
|
dir = aim (self, 1000);
|
|
|
|
launch_spike (self.origin + '0 0 16', dir);
|
|
|
|
newmis.touch = superspike_touch;
|
|
|
|
setmodel (newmis, "progs/s_spike.mdl");
|
|
|
|
setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
|
|
|
|
self.punchangle_x = -2;
|
|
|
|
};
|
|
|
|
|
|
|
|
void(float ox) W_FireSpikes =
|
|
|
|
{
|
|
|
|
local vector dir;
|
|
|
|
|
|
|
|
makevectors (self.v_angle);
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
if (self.ammo_nails >= 2 && self.weapon == IT_SUPER_NAILGUN) {
|
2002-02-15 18:27:57 +00:00
|
|
|
W_FireSuperSpikes ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
if (self.ammo_nails < 1) {
|
2002-02-15 18:27:57 +00:00
|
|
|
self.weapon = W_BestWeapon ();
|
|
|
|
W_SetCurrentAmmo ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
|
|
|
|
self.attack_finished = time + 0.2;
|
2004-02-09 00:03:10 +00:00
|
|
|
self.currentammo = self.ammo_nails--;
|
2002-02-15 18:27:57 +00:00
|
|
|
dir = aim (self, 1000);
|
2004-02-09 00:03:10 +00:00
|
|
|
launch_spike (self.origin + '0 0 16' + v_right * ox, dir);
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
self.punchangle_x = -2;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.float hit_z;
|
|
|
|
void() spike_touch =
|
|
|
|
{
|
|
|
|
if (other == self.owner)
|
|
|
|
return;
|
|
|
|
if (other.solid == SOLID_TRIGGER)
|
|
|
|
return; // trigger field, do nothing
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
if (pointcontents (self.origin) == CONTENT_SKY) {
|
|
|
|
remove (self);
|
2002-02-15 18:27:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// hit something that bleeds
|
2004-02-09 00:03:10 +00:00
|
|
|
if (other.takedamage) {
|
2002-02-15 18:27:57 +00:00
|
|
|
spawn_touchblood (9);
|
|
|
|
T_Damage (other, self, self.owner, 9);
|
2004-02-09 00:03:10 +00:00
|
|
|
} else {
|
2004-02-10 00:00:13 +00:00
|
|
|
local float spike = TE_SPIKE;
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
switch (self.classname) {
|
|
|
|
case "wizspike":
|
2004-02-10 00:00:13 +00:00
|
|
|
spike = TE_WIZSPIKE;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case "knightspike":
|
2004-02-10 00:00:13 +00:00
|
|
|
spike = TE_KNIGHTSPIKE;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
default:
|
2004-02-10 00:00:13 +00:00
|
|
|
// Already set in declaration
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
}
|
2004-02-10 00:00:13 +00:00
|
|
|
WriteBytes (MSG_BROADCAST, SVC_TEMPENTITY, spike);
|
2004-02-09 00:03:10 +00:00
|
|
|
WriteCoordV (MSG_BROADCAST, self.origin);
|
2002-02-15 18:27:57 +00:00
|
|
|
}
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
remove (self);
|
2002-02-15 18:27:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void() superspike_touch =
|
|
|
|
{
|
|
|
|
if (other == self.owner)
|
|
|
|
return;
|
|
|
|
if (other.solid == SOLID_TRIGGER)
|
|
|
|
return; // trigger field, do nothing
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
if (pointcontents (self.origin) == CONTENT_SKY) {
|
|
|
|
remove (self);
|
2002-02-15 18:27:57 +00:00
|
|
|
return;
|
|
|
|
}
|
2004-02-09 00:03:10 +00:00
|
|
|
|
|
|
|
// hit something that bleeds
|
|
|
|
if (other.takedamage) {
|
2002-02-15 18:27:57 +00:00
|
|
|
spawn_touchblood (18);
|
|
|
|
T_Damage (other, self, self.owner, 18);
|
2004-02-09 00:03:10 +00:00
|
|
|
} else {
|
|
|
|
WriteBytes (MSG_BROADCAST, SVC_TEMPENTITY, TE_SUPERSPIKE);
|
|
|
|
WriteCoordV (MSG_BROADCAST, self.origin);
|
2002-02-15 18:27:57 +00:00
|
|
|
}
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
remove (self);
|
2002-02-15 18:27:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============================================================================
|
|
|
|
|
|
|
|
PLAYER WEAPON USE
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
void() W_SetCurrentAmmo =
|
|
|
|
{
|
|
|
|
player_run (); // get out of any weapon firing states
|
|
|
|
|
2004-02-08 04:37:28 +00:00
|
|
|
self.items &= ~(IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS);
|
2004-02-09 00:03:10 +00:00
|
|
|
|
|
|
|
switch (self.weapon) {
|
|
|
|
case IT_AXE:
|
2002-02-15 18:27:57 +00:00
|
|
|
self.currentammo = 0;
|
|
|
|
self.weaponmodel = "progs/v_axe.mdl";
|
|
|
|
self.weaponframe = 0;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case IT_SHOTGUN:
|
2002-02-15 18:27:57 +00:00
|
|
|
self.currentammo = self.ammo_shells;
|
|
|
|
self.weaponmodel = "progs/v_shot.mdl";
|
|
|
|
self.weaponframe = 0;
|
2004-02-09 00:03:10 +00:00
|
|
|
self.items |= IT_SHELLS;
|
|
|
|
break;
|
|
|
|
case IT_SUPER_SHOTGUN:
|
2002-02-15 18:27:57 +00:00
|
|
|
self.currentammo = self.ammo_shells;
|
|
|
|
self.weaponmodel = "progs/v_shot2.mdl";
|
|
|
|
self.weaponframe = 0;
|
2004-02-09 00:03:10 +00:00
|
|
|
self.items |= IT_SHELLS;
|
|
|
|
break;
|
|
|
|
case IT_NAILGUN:
|
2002-02-15 18:27:57 +00:00
|
|
|
self.currentammo = self.ammo_nails;
|
|
|
|
self.weaponmodel = "progs/v_nail.mdl";
|
|
|
|
self.weaponframe = 0;
|
2004-02-09 00:03:10 +00:00
|
|
|
self.items |= IT_NAILS;
|
|
|
|
break;
|
|
|
|
case IT_SUPER_NAILGUN:
|
2002-02-15 18:27:57 +00:00
|
|
|
self.currentammo = self.ammo_nails;
|
|
|
|
self.weaponmodel = "progs/v_nail2.mdl";
|
|
|
|
self.weaponframe = 0;
|
|
|
|
self.items = self.items | IT_NAILS;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case IT_GRENADE_LAUNCHER:
|
2002-02-15 18:27:57 +00:00
|
|
|
self.currentammo = self.ammo_rockets;
|
|
|
|
self.weaponmodel = "progs/v_rock.mdl";
|
|
|
|
self.weaponframe = 0;
|
2004-02-09 00:03:10 +00:00
|
|
|
self.items |= IT_ROCKETS;
|
|
|
|
break;
|
|
|
|
case IT_ROCKET_LAUNCHER:
|
2002-02-15 18:27:57 +00:00
|
|
|
self.currentammo = self.ammo_rockets;
|
|
|
|
self.weaponmodel = "progs/v_rock2.mdl";
|
|
|
|
self.weaponframe = 0;
|
2004-02-09 00:03:10 +00:00
|
|
|
self.items |= IT_ROCKETS;
|
|
|
|
break;
|
|
|
|
case IT_LIGHTNING:
|
2002-02-15 18:27:57 +00:00
|
|
|
self.currentammo = self.ammo_cells;
|
|
|
|
self.weaponmodel = "progs/v_light.mdl";
|
|
|
|
self.weaponframe = 0;
|
2004-02-09 00:03:10 +00:00
|
|
|
self.items |= IT_CELLS;
|
|
|
|
break;
|
|
|
|
default:
|
2002-02-15 18:27:57 +00:00
|
|
|
self.currentammo = 0;
|
|
|
|
self.weaponmodel = "";
|
|
|
|
self.weaponframe = 0;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
2002-02-15 18:27:57 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
float() W_BestWeapon =
|
|
|
|
{
|
2004-02-09 00:03:10 +00:00
|
|
|
local float it;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
it = self.items;
|
|
|
|
|
2004-02-09 17:03:23 +00:00
|
|
|
if (self.waterlevel <= 1 && self.ammo_cells >= 1 && (it & IT_LIGHTNING))
|
2004-02-09 00:03:10 +00:00
|
|
|
return IT_LIGHTNING;
|
|
|
|
if (self.ammo_nails >= 2 && (it & IT_SUPER_NAILGUN))
|
2002-02-15 18:27:57 +00:00
|
|
|
return IT_SUPER_NAILGUN;
|
2004-02-09 17:03:23 +00:00
|
|
|
if (self.ammo_shells >= 2 && (it & IT_SUPER_SHOTGUN))
|
2002-02-15 18:27:57 +00:00
|
|
|
return IT_SUPER_SHOTGUN;
|
2004-02-09 17:03:23 +00:00
|
|
|
if (self.ammo_nails >= 1 && (it & IT_NAILGUN))
|
2002-02-15 18:27:57 +00:00
|
|
|
return IT_NAILGUN;
|
2004-02-09 17:03:23 +00:00
|
|
|
if (self.ammo_shells >= 1 && (it & IT_SHOTGUN))
|
2002-02-15 18:27:57 +00:00
|
|
|
return IT_SHOTGUN;
|
|
|
|
return IT_AXE;
|
|
|
|
};
|
|
|
|
|
|
|
|
float() W_CheckNoAmmo =
|
|
|
|
{
|
|
|
|
if (self.currentammo > 0)
|
|
|
|
return TRUE;
|
|
|
|
if (self.weapon == IT_AXE)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
self.weapon = W_BestWeapon ();
|
|
|
|
|
|
|
|
W_SetCurrentAmmo ();
|
2004-02-09 00:03:10 +00:00
|
|
|
|
|
|
|
// drop the weapon down
|
2002-02-15 18:27:57 +00:00
|
|
|
return FALSE;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
W_Attack
|
|
|
|
|
|
|
|
An attack impulse can be triggered now
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
void() player_axe1;
|
|
|
|
void() player_axeb1;
|
|
|
|
void() player_axec1;
|
|
|
|
void() player_axed1;
|
|
|
|
void() player_shot1;
|
|
|
|
void() player_nail1;
|
|
|
|
void() player_light1;
|
|
|
|
void() player_rocket1;
|
|
|
|
|
|
|
|
void() W_Attack =
|
|
|
|
{
|
2004-02-09 00:03:10 +00:00
|
|
|
local float r;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
if (!W_CheckNoAmmo ())
|
|
|
|
return;
|
|
|
|
|
|
|
|
makevectors (self.v_angle); // calculate forward angle for velocity
|
|
|
|
self.show_hostile = time + 1; // wake monsters up
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
switch (self.weapon) {
|
|
|
|
case IT_AXE:
|
2002-02-15 18:27:57 +00:00
|
|
|
sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
|
2004-02-09 00:03:10 +00:00
|
|
|
r = random ();
|
2002-02-15 18:27:57 +00:00
|
|
|
if (r < 0.25)
|
|
|
|
player_axe1 ();
|
2004-02-09 00:03:10 +00:00
|
|
|
else if (r < 0.5)
|
2002-02-15 18:27:57 +00:00
|
|
|
player_axeb1 ();
|
2004-02-09 00:03:10 +00:00
|
|
|
else if (r < 0.75)
|
2002-02-15 18:27:57 +00:00
|
|
|
player_axec1 ();
|
|
|
|
else
|
|
|
|
player_axed1 ();
|
|
|
|
self.attack_finished = time + 0.5;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case IT_SHOTGUN:
|
2002-02-15 18:27:57 +00:00
|
|
|
player_shot1 ();
|
|
|
|
W_FireShotgun ();
|
|
|
|
self.attack_finished = time + 0.5;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case IT_SUPER_SHOTGUN:
|
2002-02-15 18:27:57 +00:00
|
|
|
player_shot1 ();
|
|
|
|
W_FireSuperShotgun ();
|
|
|
|
self.attack_finished = time + 0.7;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case IT_NAILGUN:
|
2002-02-15 18:27:57 +00:00
|
|
|
player_nail1 ();
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case IT_SUPER_NAILGUN:
|
2002-02-15 18:27:57 +00:00
|
|
|
player_nail1 ();
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case IT_GRENADE_LAUNCHER:
|
2002-02-15 18:27:57 +00:00
|
|
|
player_rocket1();
|
|
|
|
W_FireGrenade();
|
|
|
|
self.attack_finished = time + 0.6;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case IT_ROCKET_LAUNCHER:
|
2002-02-15 18:27:57 +00:00
|
|
|
player_rocket1();
|
|
|
|
W_FireRocket();
|
|
|
|
self.attack_finished = time + 0.8;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case IT_LIGHTNING:
|
2002-02-15 18:27:57 +00:00
|
|
|
player_light1();
|
|
|
|
self.attack_finished = time + 0.1;
|
|
|
|
sound (self, CHAN_AUTO, "weapons/lstart.wav", 1, ATTN_NORM);
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
2002-02-15 18:27:57 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void() W_ChangeWeapon =
|
|
|
|
{
|
2004-02-09 00:03:10 +00:00
|
|
|
local float it, am;
|
|
|
|
local float fl = 0;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
it = self.items;
|
|
|
|
am = 0;
|
2004-02-09 00:03:10 +00:00
|
|
|
|
|
|
|
switch (self.impulse) {
|
|
|
|
case 1:
|
2002-02-15 18:27:57 +00:00
|
|
|
fl = IT_AXE;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2002-02-15 18:27:57 +00:00
|
|
|
fl = IT_SHOTGUN;
|
|
|
|
if (self.ammo_shells < 1)
|
|
|
|
am = 1;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2002-02-15 18:27:57 +00:00
|
|
|
fl = IT_SUPER_SHOTGUN;
|
|
|
|
if (self.ammo_shells < 2)
|
|
|
|
am = 1;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
2002-02-15 18:27:57 +00:00
|
|
|
fl = IT_NAILGUN;
|
|
|
|
if (self.ammo_nails < 1)
|
|
|
|
am = 1;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case 5:
|
2002-02-15 18:27:57 +00:00
|
|
|
fl = IT_SUPER_NAILGUN;
|
|
|
|
if (self.ammo_nails < 2)
|
|
|
|
am = 1;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case 6:
|
2002-02-15 18:27:57 +00:00
|
|
|
fl = IT_GRENADE_LAUNCHER;
|
|
|
|
if (self.ammo_rockets < 1)
|
|
|
|
am = 1;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case 7:
|
2002-02-15 18:27:57 +00:00
|
|
|
fl = IT_ROCKET_LAUNCHER;
|
|
|
|
if (self.ammo_rockets < 1)
|
|
|
|
am = 1;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case 8:
|
2002-02-15 18:27:57 +00:00
|
|
|
fl = IT_LIGHTNING;
|
|
|
|
if (self.ammo_cells < 1)
|
|
|
|
am = 1;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
2002-02-15 18:27:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
self.impulse = 0;
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
if (!(self.items & fl)) { // don't have the weapon or the ammo
|
2002-02-15 18:27:57 +00:00
|
|
|
sprint (self, "no weapon.\n");
|
|
|
|
return;
|
|
|
|
}
|
2004-02-09 00:03:10 +00:00
|
|
|
|
|
|
|
if (am) { // don't have the ammo
|
2002-02-15 18:27:57 +00:00
|
|
|
sprint (self, "not enough ammo.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
// set weapon, set ammo
|
2002-02-15 18:27:57 +00:00
|
|
|
self.weapon = fl;
|
|
|
|
W_SetCurrentAmmo ();
|
|
|
|
};
|
|
|
|
|
|
|
|
void() CheatCommand =
|
|
|
|
{
|
|
|
|
if (deathmatch || coop)
|
|
|
|
return;
|
|
|
|
|
|
|
|
self.ammo_rockets = 100;
|
|
|
|
self.ammo_nails = 200;
|
|
|
|
self.ammo_shells = 100;
|
2004-02-08 04:37:28 +00:00
|
|
|
self.items |= (IT_AXE | IT_SHOTGUN | IT_SUPER_SHOTGUN | IT_NAILGUN
|
|
|
|
| IT_SUPER_NAILGUN | IT_GRENADE_LAUNCHER
|
|
|
|
| IT_ROCKET_LAUNCHER | IT_KEY1 | IT_KEY2);
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
self.ammo_cells = 200;
|
2004-02-08 04:37:28 +00:00
|
|
|
self.items |= IT_LIGHTNING;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
self.weapon = IT_ROCKET_LAUNCHER;
|
|
|
|
self.impulse = 0;
|
|
|
|
W_SetCurrentAmmo ();
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
CycleWeaponCommand
|
|
|
|
|
|
|
|
Go to the next weapon with ammo
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
void() CycleWeaponCommand =
|
|
|
|
{
|
2004-02-09 00:03:10 +00:00
|
|
|
local float it, am;
|
2002-02-15 18:27:57 +00:00
|
|
|
|
|
|
|
it = self.items;
|
|
|
|
self.impulse = 0;
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
while (1) {
|
2002-02-15 18:27:57 +00:00
|
|
|
am = 0;
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
switch (self.weapon) {
|
|
|
|
case IT_AXE:
|
2002-02-15 18:27:57 +00:00
|
|
|
self.weapon = IT_SHOTGUN;
|
|
|
|
if (self.ammo_shells < 1)
|
|
|
|
am = 1;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case IT_SHOTGUN:
|
2002-02-15 18:27:57 +00:00
|
|
|
self.weapon = IT_SUPER_SHOTGUN;
|
|
|
|
if (self.ammo_shells < 2)
|
|
|
|
am = 1;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case IT_SUPER_SHOTGUN:
|
2002-02-15 18:27:57 +00:00
|
|
|
self.weapon = IT_NAILGUN;
|
|
|
|
if (self.ammo_nails < 1)
|
|
|
|
am = 1;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case IT_NAILGUN:
|
2002-02-15 18:27:57 +00:00
|
|
|
self.weapon = IT_SUPER_NAILGUN;
|
|
|
|
if (self.ammo_nails < 2)
|
|
|
|
am = 1;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case IT_SUPER_NAILGUN:
|
2002-02-15 18:27:57 +00:00
|
|
|
self.weapon = IT_GRENADE_LAUNCHER;
|
|
|
|
if (self.ammo_rockets < 1)
|
|
|
|
am = 1;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case IT_GRENADE_LAUNCHER:
|
2002-02-15 18:27:57 +00:00
|
|
|
self.weapon = IT_ROCKET_LAUNCHER;
|
|
|
|
if (self.ammo_rockets < 1)
|
|
|
|
am = 1;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case IT_ROCKET_LAUNCHER:
|
2002-02-15 18:27:57 +00:00
|
|
|
self.weapon = IT_LIGHTNING;
|
|
|
|
if (self.ammo_cells < 1)
|
|
|
|
am = 1;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case IT_LIGHTNING:
|
|
|
|
self.weapon = IT_AXE;
|
|
|
|
break;
|
2002-02-15 18:27:57 +00:00
|
|
|
}
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
if ((it & self.weapon) && am == 0) {
|
2002-02-15 18:27:57 +00:00
|
|
|
W_SetCurrentAmmo ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
CycleWeaponReverseCommand
|
|
|
|
|
|
|
|
Go to the prev weapon with ammo
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
void() CycleWeaponReverseCommand =
|
|
|
|
{
|
|
|
|
local float it, am;
|
|
|
|
|
|
|
|
it = self.items;
|
|
|
|
self.impulse = 0;
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
while (1) {
|
2002-02-15 18:27:57 +00:00
|
|
|
am = 0;
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
switch (self.weapon) {
|
|
|
|
case IT_AXE:
|
|
|
|
self.weapon = IT_LIGHTNING;
|
|
|
|
if (self.ammo_cells < 1)
|
|
|
|
am = 1;
|
|
|
|
break;
|
|
|
|
case IT_LIGHTNING:
|
2002-02-15 18:27:57 +00:00
|
|
|
self.weapon = IT_ROCKET_LAUNCHER;
|
|
|
|
if (self.ammo_rockets < 1)
|
|
|
|
am = 1;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case IT_ROCKET_LAUNCHER:
|
2002-02-15 18:27:57 +00:00
|
|
|
self.weapon = IT_GRENADE_LAUNCHER;
|
|
|
|
if (self.ammo_rockets < 1)
|
|
|
|
am = 1;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case IT_GRENADE_LAUNCHER:
|
2002-02-15 18:27:57 +00:00
|
|
|
self.weapon = IT_SUPER_NAILGUN;
|
|
|
|
if (self.ammo_nails < 2)
|
|
|
|
am = 1;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case IT_SUPER_NAILGUN:
|
2002-02-15 18:27:57 +00:00
|
|
|
self.weapon = IT_NAILGUN;
|
|
|
|
if (self.ammo_nails < 1)
|
|
|
|
am = 1;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case IT_NAILGUN:
|
2002-02-15 18:27:57 +00:00
|
|
|
self.weapon = IT_SUPER_SHOTGUN;
|
|
|
|
if (self.ammo_shells < 2)
|
|
|
|
am = 1;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case IT_SUPER_SHOTGUN:
|
2002-02-15 18:27:57 +00:00
|
|
|
self.weapon = IT_SHOTGUN;
|
|
|
|
if (self.ammo_shells < 1)
|
|
|
|
am = 1;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case IT_SHOTGUN:
|
2002-02-15 18:27:57 +00:00
|
|
|
self.weapon = IT_AXE;
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
2002-02-15 18:27:57 +00:00
|
|
|
}
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
if ((it & self.weapon) && am == 0) {
|
2002-02-15 18:27:57 +00:00
|
|
|
W_SetCurrentAmmo ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
ServerflagsCommand
|
|
|
|
|
|
|
|
Just for development
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
void() ServerflagsCommand =
|
|
|
|
{
|
|
|
|
serverflags = serverflags * 2 + 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
void() QuadCheat =
|
|
|
|
{
|
|
|
|
if (deathmatch || coop)
|
|
|
|
return;
|
|
|
|
self.super_time = 1;
|
|
|
|
self.super_damage_finished = time + 30;
|
2004-02-08 04:37:28 +00:00
|
|
|
self.items |= IT_QUAD;
|
2002-02-15 18:27:57 +00:00
|
|
|
dprint ("quad cheat\n");
|
|
|
|
};
|
|
|
|
|
|
|
|
void() ImpulseCommands =
|
|
|
|
{
|
|
|
|
if (self.impulse >= 1 && self.impulse <= 8)
|
|
|
|
W_ChangeWeapon ();
|
|
|
|
|
2004-02-09 00:03:10 +00:00
|
|
|
switch (self.impulse) {
|
|
|
|
case 9:
|
2002-02-15 18:27:57 +00:00
|
|
|
CheatCommand ();
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case 10:
|
2002-02-15 18:27:57 +00:00
|
|
|
CycleWeaponCommand ();
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case 11:
|
2002-02-15 18:27:57 +00:00
|
|
|
ServerflagsCommand ();
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case 12:
|
2002-02-15 18:27:57 +00:00
|
|
|
CycleWeaponReverseCommand ();
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
case 255:
|
2002-02-15 18:27:57 +00:00
|
|
|
QuadCheat ();
|
2004-02-09 00:03:10 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-02-15 18:27:57 +00:00
|
|
|
self.impulse = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
W_WeaponFrame
|
|
|
|
|
|
|
|
Called every frame so impulse events can be handled as well as possible
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
void() W_WeaponFrame =
|
|
|
|
{
|
|
|
|
if (time < self.attack_finished)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ImpulseCommands ();
|
2004-02-09 00:03:10 +00:00
|
|
|
|
|
|
|
// check for attack
|
|
|
|
if (self.button0) {
|
2002-02-15 18:27:57 +00:00
|
|
|
SuperDamageSound ();
|
|
|
|
W_Attack ();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
========
|
|
|
|
SuperDamageSound
|
|
|
|
|
|
|
|
Plays sound if needed
|
|
|
|
========
|
|
|
|
*/
|
|
|
|
void() SuperDamageSound =
|
|
|
|
{
|
2004-02-09 00:03:10 +00:00
|
|
|
if (self.super_damage_finished > time) {
|
|
|
|
if (self.super_sound < time) {
|
2002-02-15 18:27:57 +00:00
|
|
|
self.super_sound = time + 1;
|
|
|
|
sound (self, CHAN_BODY, "items/damage3.wav", 1, ATTN_NORM);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
};
|