Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
blaster.qc File Reference
#include "blaster.qh"
Include dependency graph for blaster.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void W_Blaster_Attack (entity actor,.entity weaponentity)
void W_Blaster_Think (entity this)
void W_Blaster_Touch (entity this, entity toucher)

Function Documentation

◆ W_Blaster_Attack()

void W_Blaster_Attack ( entity actor,
.entity weaponentity )

Definition at line 54 of file blaster.qc.

55{
56 float atk_shotangle = WEP_CVAR_PRI(WEP_BLASTER, shotangle) * DEG2RAD;
57 float atk_damage = WEP_CVAR_PRI(WEP_BLASTER, damage);
58 vector s_forward = v_forward * cos(atk_shotangle) + v_up * sin(atk_shotangle);
59 int atk_deathtype = WEP_BLASTER.m_id;
60
61 W_SetupShot_Dir(actor, weaponentity, s_forward, false, 3, SND_BLASTER_FIRE, CH_WEAPON_B, atk_damage, atk_deathtype);
62 W_MuzzleFlash(WEP_BLASTER, actor, weaponentity, w_shotorg, w_shotdir);
63
64 entity missile = new(blasterbolt);
65 missile.owner = missile.realowner = actor;
66 missile.bot_dodge = true;
67 missile.bot_dodgerating = atk_damage;
69
70 setorigin(missile, w_shotorg);
71 setsize(missile, '0 0 0', '0 0 0');
72
73 float atk_speed = WEP_CVAR_PRI(WEP_BLASTER, speed);
74 float atk_spread = WEP_CVAR_PRI(WEP_BLASTER, spread);
75 W_SetupProjVelocity_Explicit(missile, w_shotdir, v_up, atk_speed, 0, 0, atk_spread, false);
76
77 missile.angles = vectoangles(missile.velocity);
78
79 //missile.glow_color = 250; // 244, 250
80 //missile.glow_size = 120;
81
82 settouch(missile, W_Blaster_Touch);
83 missile.flags = FL_PROJECTILE;
84 IL_PUSH(g_projectiles, missile);
85 IL_PUSH(g_bot_dodge, missile);
86 missile.missile_flags = MIF_SPLASH;
87 missile.projectiledeathtype = atk_deathtype;
88 missile.weaponentity_fld = weaponentity;
89 setthink(missile, W_Blaster_Think);
90 missile.nextthink = time + WEP_CVAR_PRI(WEP_BLASTER, delay);
91
92 MUTATOR_CALLHOOK(EditProjectile, actor, missile);
93
94 if (time >= missile.nextthink)
95 {
96 getthink(missile)(missile);
97 }
98}
IntrusiveList g_bot_dodge
Definition api.qh:150
#define MUTATOR_CALLHOOK(id,...)
Definition base.qh:143
void W_Blaster_Think(entity this)
Definition blaster.qc:46
void W_Blaster_Touch(entity this, entity toucher)
Definition blaster.qc:5
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float delay
Definition items.qc:17
const int FL_PROJECTILE
Definition constants.qh:85
vector v_up
float DEG2RAD
float time
vector v_forward
float speed
Definition dynlight.qc:9
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
float cos(float f)
vector vectoangles(vector v)
float sin(float f)
#define setthink(e, f)
#define getthink(e)
vector
Definition self.qh:92
#define settouch(e, f)
Definition self.qh:73
const int MIF_SPLASH
Definition common.qh:46
IntrusiveList g_projectiles
Definition common.qh:58
#define PROJECTILE_MAKETRIGGER(e)
Definition common.qh:34
const int CH_WEAPON_B
Definition sound.qh:8
void W_SetupProjVelocity_Explicit(entity proj, vector dir, vector upDir, float pSpeed, float pUpSpeed, float pZSpeed, float spread, float forceAbsolute)
Definition tracing.qc:192
vector w_shotdir
Definition tracing.qh:20
vector w_shotorg
Definition tracing.qh:19
#define W_SetupShot_Dir(ent, wepent, s_forward, antilag, recoil, snd, chan, maxdamage, deathtype)
Definition tracing.qh:32
void W_MuzzleFlash(Weapon thiswep, entity actor,.entity weaponentity, vector shotorg, vector shotdir)
Definition all.qc:728
#define WEP_CVAR_PRI(wep, name)
Definition all.qh:322

References CH_WEAPON_B, cos(), DEG2RAD, delay, entity(), FL_PROJECTILE, g_bot_dodge, g_projectiles, getthink, IL_PUSH(), MIF_SPLASH, MUTATOR_CALLHOOK, PROJECTILE_MAKETRIGGER, setthink, settouch, sin(), speed, time, v_forward, v_up, vectoangles(), vector, W_Blaster_Think(), W_Blaster_Touch(), W_MuzzleFlash(), W_SetupProjVelocity_Explicit(), W_SetupShot_Dir, w_shotdir, w_shotorg, and WEP_CVAR_PRI.

◆ W_Blaster_Think()

void W_Blaster_Think ( entity this)

Definition at line 46 of file blaster.qc.

47{
49 setthink(this, SUB_Remove);
50 this.nextthink = time + WEP_CVAR_PRI(WEP_BLASTER, lifetime);
51 CSQCProjectile(this, true, PROJECTILE_BLASTER, true);
52}
float lifetime
Definition powerups.qc:23
float nextthink
void CSQCProjectile(entity e, float clientanimate, int type, float docull)
void SUB_Remove(entity this)
Remove entity.
Definition defer.qh:13
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_FLY
Definition movetypes.qh:134
const int PROJECTILE_BLASTER

References CSQCProjectile(), entity(), lifetime, MOVETYPE_FLY, nextthink, PROJECTILE_BLASTER, set_movetype(), setthink, SUB_Remove(), time, and WEP_CVAR_PRI.

Referenced by W_Blaster_Attack().

◆ W_Blaster_Touch()

void W_Blaster_Touch ( entity this,
entity toucher )

Definition at line 5 of file blaster.qc.

6{
8
9 this.event_damage = func_null;
10
11 vector force_xyzscale = '1 1 1';
12 force_xyzscale.z = WEP_CVAR_PRI(WEP_BLASTER, force_zscale);
13
14 // slightly hacky but probably not worth adding a parameter for this special case
15 bool zero_damageforcescale = false;
16 if (autocvar_g_projectiles_interact == 1 && (toucher.flags & FL_PROJECTILE) && !toucher.damageforcescale)
17 {
18 toucher.damageforcescale = 1;
19 zero_damageforcescale = true;
20 }
21
23 this,
24 (this.origin + (this.mins + this.maxs) * 0.5),
25 this.velocity,
26 this.realowner,
27 WEP_CVAR_PRI(WEP_BLASTER, damage),
28 WEP_CVAR_PRI(WEP_BLASTER, edgedamage),
29 WEP_CVAR_PRI(WEP_BLASTER, radius),
30 NULL,
31 NULL,
32 false,
33 WEP_CVAR_PRI(WEP_BLASTER, force),
34 force_xyzscale,
38 );
39
40 if (zero_damageforcescale)
41 toucher.damageforcescale = 0;
42
43 delete(this);
44}
float radius
Definition impulse.qh:11
vector mins
vector velocity
vector maxs
vector origin
float RadiusDamageForSource(entity inflictor, vector inflictororigin, vector inflictorvelocity, entity attacker, float coredamage, float edgedamage, float rad, entity cantbe, entity mustbe, float inflictorselfdamage, float forceintensity, vector forcexyzscale, int deathtype,.entity weaponentity, entity directhitentity)
Definition damage.qc:741
var void func_null()
#define NULL
Definition post.qh:14
entity entity toucher
Definition self.qh:72
int projectiledeathtype
Definition common.qh:21
#define PROJECTILE_TOUCH(e, t)
Definition common.qh:28
int autocvar_g_projectiles_interact
Definition common.qh:4
entity realowner
entity weaponentity_fld

References autocvar_g_projectiles_interact, entity(), FL_PROJECTILE, func_null(), maxs, mins, NULL, origin, PROJECTILE_TOUCH, projectiledeathtype, radius, RadiusDamageForSource(), realowner, toucher, vector, velocity, weaponentity_fld, and WEP_CVAR_PRI.

Referenced by W_Blaster_Attack().