djcev.com

//

Git Repos / fte_dogmode / qc / projectiles / wizardspell.qc

Last update to this file was on 2024-04-08 at 15:40.

Show wizardspell.qc

//==============================================================================
// Wizard (Scrag) Magic Missile
//==============================================================================

//======================================================================
// This is a weird one. The Wizard spawns an entity with a think
// function that then spawns the actual missile. So we're dealing with
// two temporary entities: the projectile (wizardmissile), and the thing
// that creates it (wizardspell). -- CEV
//======================================================================

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

const float WIZMIS_DIRECT_DAMAGE = 9; // direct damage; 9 is id1
const float WIZMIS_SPLASH_DAMAGE = 9; // splash damage
const float WIZMIS_EXPLOD_DAMAGE = 50; // big damage. explody scrag should
// be beefy. dmg for direct & splash
const float WIZMIS_SPEED = 600; // id1 magic missile speed 600ups

const vector WIZMIS_MINS = '0 0 0'; // let's not change this -- CEV
const vector WIZMIS_MAXS = '0 0 0'; //

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

// projectile_wizardmissile
void() base_wizardmissile_touch;
entity(entity src, vector org, vector vel) spawn_projectile_wizardmissile;
void(entity e) projectile_wizardmissile_init;
strip void() projectile_wizardmissile;

// projectile_wizardspell
void() projectile_wizardspell_think;
entity(entity src, vector org, vector mdir, float nt)
spawn_projectile_wizardspell;
void(entity e) projectile_wizardspell_init;
strip void() projectile_wizardspell;

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

//----------------------------------------------------------------------
// class projectile_wizardmissile: base_projectile
// {
//--------------------------------------------------------------
// adapted from spike_touch -- CEV
//--------------------------------------------------------------
void() base_wizardmissile_touch =
{
if (other.takedamage)
{
spawn_touchblood (self.direct_damage);
t_damage2 (other, self, self.owner, self.direct_damage);
}
else
{
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
if (self.owner.snd_hit != __NULL__ &&
self.owner.snd_hit != "")
{
// dumptruck_ds
sound (self, CHAN_WEAPON, self.owner.snd_hit,
1, ATTN_STATIC);
WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
}
else
{
WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
}
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_wizardmissile =
{
local entity e = spawn ();
e.owner = src;
e.enemy = src.enemy;
e.origin = org;
e.velocity = vel;
e.avelocity = src.cust_avelocity;
e.proj_basespeed = src.proj_basespeed;
e.proj_speed_mod = src.proj_speed_mod;
e.projexpl = src.projexpl;
// damage
// e.direct_damage = direct;
// e.splash_damage = splash;
// model, skin, & sounds
e.mdl_proj = src.mdl_proj;
e.skin_proj = src.skin_proj;
e.snd_hit = src.snd_hit;

projectile_wizardmissile_init (e);
return e;
};

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

e.classname = "wizspike";
e.classtype = CT_PROJECTILE_WIZARDMISSILE;
e.movetype = MOVETYPE_FLYMISSILE;
e.solid = SOLID_BBOX;
if (base_projectile_parse_projexpl(e.projexpl, 0))
e.aflag |= PROJECTILE_EXPLOSIVE;
e.angles = vectoangles (e.velocity);

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

if (!e.direct_damage)
if (e.aflag & PROJECTILE_EXPLOSIVE)
e.direct_damage = WIZMIS_EXPLOD_DAMAGE;
else
e.direct_damage = WIZMIS_DIRECT_DAMAGE;

if (!e.splash_damage)
if (e.aflag & PROJECTILE_EXPLOSIVE)
e.splash_damage = WIZMIS_EXPLOD_DAMAGE;
else
e.splash_damage = WIZMIS_SPLASH_DAMAGE;

// dumptruck_ds custom_mdls
if (e.mdl_proj != "")
setmodel (e, e.mdl_proj);
else
setmodel (e, "progs/w_spike.mdl");

// dumptruck_ds
if (e.skin_proj)
e.skin = e.skin_proj;
else
e.skin = 0;

if (e.homing > 0 || e.owner.homing > 0)
{
base_projectile_setup_homing (e,
self.proj_basespeed * self.proj_speed_mod);
}
else
{
// SetSpeed
e.think = sub_remove;
e.nextthink = time + 5;
}

setsize (e, WIZMIS_MINS, WIZMIS_MAXS);
setorigin (e, e.origin);
};

//--------------------------------------------------------------
strip void() projectile_wizardmissile =
{
projectile_wizardmissile_init (self);
};
// };

//----------------------------------------------------------------------
// class projectile_wizardspell: base_tempentity
// {
//==============================================================
// If the player moves behind cover before the missile is launched,
// launch it at the last visible spot with no velocity leading,
// in hopes that the player will duck back out and catch it.
//==============================================================

//--------------------------------------------------------------
// Wizard missile think function
//--------------------------------------------------------------
void() projectile_wizardspell_think =
{
// make sure owner still exists -- CEV
if (!self.owner)
{
remove (self);
return;
}

// make sure owner is still alive
if (self.owner.health > 0)
{
self.owner.effects |= EF_MUZZLEFLASH;

makevectors (self.enemy.angles);
local vector dir = normalize ((self.enemy.origin - 13 *
self.movedir) - self.origin);

// SetSpeed (newmis, vec, projspeed);
dir *= min (self.proj_basespeed * (self.proj_speed_mod ?
self.proj_speed_mod : 1), world_maxvelocity);

spawn_projectile_wizardmissile (
self.owner, self.origin, dir);
}

remove (self);
};

//--------------------------------------------------------------
entity(entity src, vector org, vector mdir, float nt)
spawn_projectile_wizardspell =
{
local entity e = spawn ();
e.owner = src;
e.enemy = src.enemy;
e.origin = org;
e.movedir = mdir;
e.proj_basespeed = src.proj_basespeed;
e.proj_speed_mod = src.proj_speed_mod;
e.projexpl = src.projexpl;

projectile_wizardspell_init (e);

e.nextthink = nt;
return e;
};

//--------------------------------------------------------------
void(entity e) projectile_wizardspell_init =
{
base_tempentity_init (e);

e.classname = "projectile_wizardspell";
e.classtype = CT_TEMP_WIZARDSPELL;
e.think = projectile_wizardspell_think;

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

setsize (e, '0 0 0', '0 0 0');
setorigin (e, e.origin);
};

//--------------------------------------------------------------
strip void() projectile_wizardspell =
{
projectile_wizardspell_init (self);

};
// };

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

Log wizardspell.qc

Date Commit Message Author + -
2024-04-08 Registered monsters, projectile bugfixes cev +1  
2024-04-05 Player footsteps, shareware monsters, misc? cev +7 -7
2024-03-24 2nd pass refactor, rework QC class structure cev +158 -77
2024-02-18 Client/player, projectiles, entrypoints refactor cev +168  

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