djcev.com

//

Git Repos / fte_dogmode / qc / hazards / shooter.qc

Last update to this file was on 2025-03-30 at 19:29.

Show shooter.qc

//==============================================================================
// trap_spikeshooter from Hipnotic -- with additions by dumptruck_ds
//==============================================================================

// MED 11/09/96 added new spawnflags -- taken from hipdefs.qc - dumptruck_ds

//======================================================================
// constants
//======================================================================

#ifdef SSQC
//----------------------------------------------------------------------
// shooter hazard spawnflags -- CEV
//----------------------------------------------------------------------
typedef enumflags
{
SPAWNFLAG_HAZARD_SHOOTER_SUPERSPIKE = 1,
SPAWNFLAG_HAZARD_SHOOTER_LASER = 2,
SPAWNFLAG_HAZARD_SHOOTER_LAVABALL = 4,
SPAWNFLAG_HAZARD_SHOOTER_ROCKET = 8,
SPAWNFLAG_HAZARD_SHOOTER_VOREBALL = 16,
SPAWNFLAG_HAZARD_SHOOTER_GRENADE = 32,
SPAWNFLAG_HAZARD_SHOOTER_GIBS = 64,
SPAWNFLAG_HAZARD_SHOOTER_SILENT = 128
// SPAWNFLAG_NOT_ON_EASY = 256, // see base_entities.qc -- CEV
// SPAWNFLAG_NOT_ON_NORMAL = 512,
// SPAWNFLAG_NOT_ON_HARD_OR_NIGHTMARE = 1024,
// SPAWNFLAG_NOT_IN_DEATHMATCH = 2048,
// SPAWNFLAG_NOT_IN_COOP = 4096,
// SPAWNFLAG_NOT_IN_SP = 8192,
// SPAWNFLAG_NOT_ON_SKILL2 = 32768, // see base_entities.qc -- CEV
// SPAWNFLAG_NOT_ON_SKILL3 = 65536, // see base_entities.qc -- CEV
// SPAWNFLAG_CENTERPRINTALL = 131072 // see base_entities.qc -- CEV
} base_hazard_shooter_spawnflags;
#endif

//======================================================================
// forward declarations
//======================================================================

// base_hazard_shooter
#ifdef SSQC
void() base_hazard_shooter_think;
void() base_hazard_shooter_use;
void(entity e) base_hazard_shooter_init;
strip void() base_hazard_shooter;
#endif

// trap_spikeshooter
#ifdef SSQC
void(entity e) trap_spikeshooter_init;
void() trap_spikeshooter;
#endif

// trap_shooter
#ifdef SSQC
void(entity e) trap_shooter_init;
void() trap_shooter;
#endif

// trap_switched_shooter
#ifdef SSQC
void() trap_switched_shooter_use;
void(entity e) trap_switched_shooter_init;
void() trap_switched_shooter;
#endif

//------------------------------------------------------------------------------

//----------------------------------------------------------------------
// class base_hazard_shooter: base_mapentity
// {
#ifdef SSQC
//--------------------------------------------------------------
// shooter_think -- MED 11/01/96 added state capability
//--------------------------------------------------------------
void() base_hazard_shooter_think =
{
if (self.state)
// call the use/firing function directly -- CEV
base_hazard_shooter_use ();

self.nextthink = time + self.wait;
};

//--------------------------------------------------------------
// spikeshooter_use
// MED 11/09/96 added lava ball and rocket
// dumptruck_ds added voreball and grenades
//--------------------------------------------------------------
void() base_hazard_shooter_use =
{
local string sndfile = "";
local float spct = 0;
local float fl = 0;
local float tofs = random() * 100.0;
tofs *= -1;

if (self.spawnflags & SPAWNFLAG_HAZARD_SHOOTER_LASER)
{
sndfile = "enforcer/enfire.wav";
local vector l_v = normalize (self.movedir);
// SetSpeed
l_v *= min (LASER_SPEED *
self.proj_speed_mod, PM_MAXVELOCITY);
spawn_projectile_laser (self, self.origin, l_v);
}
else if (self.spawnflags & SPAWNFLAG_HAZARD_SHOOTER_LAVABALL)
{
sndfile = "boss1/throw.wav";
spawn_projectile_lavaball (self, self.origin,
self.movedir * 600);
}
else if (self.spawnflags & SPAWNFLAG_HAZARD_SHOOTER_ROCKET)
{
sndfile = "weapons/sgun1.wav";
spawn_projectile_rocket (self, self.origin,
self.movedir * ROCKET_SPEED,
self.proj_basespeed);
}
else if (self.spawnflags & SPAWNFLAG_HAZARD_SHOOTER_VOREBALL)
{
sndfile = "shalrath/attack2.wav";
spawn_projectile_voreball (self, self.origin,
self.movedir * VOREBALL_SPEED,
self.proj_basespeed);
}
else if (self.spawnflags & SPAWNFLAG_HAZARD_SHOOTER_GRENADE)
{
sndfile = "weapons/grenade.wav";
local vector g_v = self.movedir * 600 +
v_up * 200 + crandom() * v_right * 10 +
crandom() * v_up * 10;
spawn_projectile_grenade (self, self.origin, g_v);
}
else if (self.spawnflags & SPAWNFLAG_HAZARD_SHOOTER_GIBS)
{
sndfile = "zombie/z_shot1.wav";
local vector z_v = self.movedir * 600 +
v_up * 200 + crandom() * v_right * 10 +
crandom() * v_up * 10;

spawn_projectile_zombiechunk (self, self.origin, z_v);
}
else
{
sndfile = "weapons/spike2.wav";
local float damage;

if (self.spawnflags &
SPAWNFLAG_HAZARD_SHOOTER_SUPERSPIKE)
{
damage = SPIKE_SUPER_DAMAGE;
}
else
{
damage = SPIKE_NORMAL_DAMAGE;
}

// shooter spikes move at half the speed of
// player spikes -- CEV
spawn_projectile_spike (self, self.origin,
self.movedir * 500, damage, 500);
}

if (!(self.spawnflags & SPAWNFLAG_HAZARD_SHOOTER_SILENT)) {
if (sndfile != "")
{
sound (self, CHAN_VOICE, sndfile, VOL_MHI,
ATTN_NORM, spct, fl, tofs);
} }
};

//--------------------------------------------------------------
void(entity e) base_hazard_shooter_init =
{
base_mapentity_init (e);
e.think = base_hazard_shooter_think;
e.use = base_hazard_shooter_use;

if (e.proj_speed_mod <= 0)
e.proj_speed_mod = 1;

sub_setmovedir (e);

if (e.spawnflags & SPAWNFLAG_HAZARD_SHOOTER_LASER)
{
precache_model2 ("progs/laser.mdl");
precache_sound2 ("enforcer/enfire.wav");
precache_sound2 ("enforcer/enfstop.wav");
}
else if (e.spawnflags & SPAWNFLAG_HAZARD_SHOOTER_LAVABALL)
{
precache_model ("progs/lavaball.mdl");
// precache_sound2 ("knight/sword2.wav"); // dms
precache_sound2 ("boss1/throw.wav"); // dms
}
else if (e.spawnflags & SPAWNFLAG_HAZARD_SHOOTER_ROCKET)
{
precache_model ("progs/missile.mdl");
precache_sound ("weapons/sgun1.wav");
}
else if (e.spawnflags & SPAWNFLAG_HAZARD_SHOOTER_VOREBALL)
{
precache_model ("progs/v_spike.mdl");
precache_sound ("shalrath/attack2.wav");
}
else if (e.spawnflags & SPAWNFLAG_HAZARD_SHOOTER_GRENADE)
{
precache_model ("progs/grenade.mdl");
// grenade launcher
precache_sound ("weapons/grenade.wav");
}
else if (e.spawnflags & SPAWNFLAG_HAZARD_SHOOTER_GIBS)
{
precache_model ("progs/zom_gib.mdl");
// Zombie gibs
precache_sound ("zombie/z_shot1.wav");
precache_sound ("zombie/z_miss.wav");
precache_sound ("zombie/z_hit.wav");
}
else
{
precache_sound ("weapons/spike2.wav");
}
};

//--------------------------------------------------------------
strip void() base_hazard_shooter =
{
base_hazard_shooter_init (self);
};
#endif
// };

/*QUAKED trap_spikeshooter (0 .5 .8) (-8 -8 -8) (8 8 8) superspike laser lavaball rocket silent X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

When triggered, fires a spike in the direction set in QuakeEd.
Laser is only for REGISTERED.
*/
//----------------------------------------------------------------------
// class trap_spikeshooter: base_hazard_shooter
// {
#ifdef SSQC
//--------------------------------------------------------------
void(entity e) trap_spikeshooter_init =
{
e.classname = "trap_spikeshooter";
e.classtype = CT_HAZARD_SPIKESHOOTER;
base_hazard_shooter_init (e);
};

//--------------------------------------------------------------
void() trap_spikeshooter =
{
// new spawnflags for all entities -- iw
if (SUB_Inhibit())
return;

trap_spikeshooter_init (self);
};
#endif
// };

/*QUAKED trap_shooter (0 .5 .8) (-8 -8 -8) (8 8 8) superspike laser lavaball rocket silent X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
Continuously fires spikes.
"wait" time between spike (1.0 default)
"nextthink" delay before firing first spike, so multiple shooters can be stagered.
*/
//----------------------------------------------------------------------
// class trap_shooter: base_hazard_shooter
// {
#ifdef SSQC
//--------------------------------------------------------------
void(entity e) trap_shooter_init =
{
e.classname = "trap_shooter";
e.classtype = CT_HAZARD_SHOOTER;
base_hazard_shooter_init (e);

if (e.wait == 0)
e.wait = 1;

// MED 11/01/96 added state capability
e.state = 1;
e.nextthink = e.nextthink + e.wait + e.ltime;
};

//--------------------------------------------------------------
void() trap_shooter =
{
// new spawnflags for all entities -- iw
if (SUB_Inhibit())
return;

trap_shooter_init (self);
};
#endif
// };

//MED 11/01/96 added new function
/*QUAKED trap_switched_shooter (0 .5 .8) (-8 -8 -8) (8 8 8) superspike laser lavaball rocket silent X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
Continuously fires spikes.
"wait" time between spike (1.0 default)
"nextthink" delay before firing first spike, so multiple shooters can be stagered.
"state" 0 initially off, 1 initially on. (0 default)
*/
//----------------------------------------------------------------------
// class trap_switched_shooter: base_hazard_shooter
// {
#ifdef SSQC
//--------------------------------------------------------------
// trap_shooter_use -- MED 11/01/96 added new use function
//--------------------------------------------------------------
void() trap_switched_shooter_use =
{
self.state = 1 - self.state;
};

//--------------------------------------------------------------
void(entity e) trap_switched_shooter_init =
{
e.classname = "trap_switched_shooter";
e.classtype = CT_HAZARD_SWITCHED_SHOOTER;
base_hazard_shooter_init (e);
e.use = trap_switched_shooter_use;

if (e.wait == 0)
e.wait = 1;

// MED 11/01/96 added state capability
e.nextthink = e.nextthink + e.wait + e.ltime;
};

//--------------------------------------------------------------
void() trap_switched_shooter =
{
// new spawnflags for all entities -- iw
if (SUB_Inhibit())
return;

trap_switched_shooter_init (self);
};
#endif
// };

Return to the top of this page or return to the overview of this repo.

Log shooter.qc

Return to the top of this page or return to the overview of this repo.