djcev.com

//

Git Repos / fte_dogmode / qc / projectiles / bullet.qc

Last update to this file was on 2024-06-15 at 19:50.

Show bullet.qc

//==============================================================================
// Bullets - shotguns & enemy soldiers
//==============================================================================

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

const float BULLET_DIRECT_DAMAGE = 5; // id1 is 4
// bullets don't splash
const float BULLET_SPEED = 2500.0f; // AD is 2000 units per for player

const vector BULLET_MINS = '0 0 0'; // let's not change this -- CEV
const vector BULLET_MAXS = '0 0 0'; //

//======================================================================
// fields
//======================================================================

.float bulletcount; // based on BDW's Flak Ogre code -- CEV

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

// projectile_bullet
void() projectile_bullet_think_damage;
void() projectile_bullet_touch;
entity(entity src, vector org, vector vel) spawn_projectile_bullet;
void(entity e) projectile_bullet_init;
strip void() projectile_bullet;

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

//----------------------------------------------------------------------
// class projectile_bullet: base_projectile
// {
//--------------------------------------------------------------
void() projectile_bullet_think_damage =
{
// get correct gib direction
self.origin = self.oldenemy.origin + self.oldorigin;
t_damage2 (self.oldenemy, self, self.owner,
self.oldenemy.bulletcount);
self.oldenemy.bulletcount = 0;
remove (self);
};

//--------------------------------------------------------------
void() projectile_bullet_touch =
{
if (base_projectile_check_touch())
return;

// hit something that bleeds
if (other.takedamage)
{
spawn_touchblood (self.direct_damage);

if (other.bulletcount)
{
// not the first one
other.bulletcount += self.direct_damage;
remove (self);
return;
}

// the first one...
other.bulletcount = self.direct_damage;

// stick around for a little while...
self.velocity = '0 0 0';
self.solid = SOLID_NOT;
self.touch = sub_null;
self.model = __NULL__;
// displacement from enemy origin (its gonna
// move next frame)
self.oldorigin = self.origin - other.origin;
self.oldenemy = other;
self.think = projectile_bullet_think_damage;
self.nextthink = time + 0.05;
return;
}

WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_GUNSHOT);
WriteCoord (MSG_BROADCAST, self.origin_x);
WriteCoord (MSG_BROADCAST, self.origin_y);
WriteCoord (MSG_BROADCAST, self.origin_z);

remove (self);
};

//--------------------------------------------------------------
entity(entity src, vector org, vector vel) spawn_projectile_bullet =
{
local entity e = spawn();
e.owner = src;
e.origin = org;
e.velocity = vel;
projectile_bullet_init (e);
return e;
};

//--------------------------------------------------------------
void(entity e) projectile_bullet_init =
{
base_projectile_init (e);

e.classname = "projectile_bullet";
e.classtype = CT_PROJECTILE_BULLET;
e.movetype = MOVETYPE_FLY;
e.solid = SOLID_BBOX;
e.touch = projectile_bullet_touch;
e.angles = vectoangles (e.velocity);

if (!e.avelocity)
// avelocity from AD is randomized; fixed for now
e.avelocity = '100 200 0';

if (!e.proj_basespeed)
e.proj_basespeed = BULLET_SPEED;

if (!e.direct_damage)
e.direct_damage = BULLET_DIRECT_DAMAGE;

// dumptruck_ds
if (e.mdl_proj && e.mdl_proj != "")
{
setmodel (e, e.mdl_proj);
}
else
{
// AD projectile diamond model
setmodel (e, "progs/ad/proj_diam2.mdl");

// full range of sizes -- Sock (comment from AD)
e.frame = random () * 15;

// Bright colours -- Sock (comment from AD)
e.skin = 16 + random () * 7;
}

if (e.skin_proj)
e.skin = e.skin_proj;

setsize (e, BULLET_MINS, BULLET_MAXS);
setorigin (e, e.origin);
e.think = sub_remove;
e.nextthink = time + 6;
};

//--------------------------------------------------------------
strip void() projectile_bullet =
{
projectile_bullet_init (self);
};
// };

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

Log bullet.qc

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