Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
hellion_weapon.qc
Go to the documentation of this file.
1#include "hellion_weapon.qh"
2
3#ifdef SVQC
4
7
9SOUND(HellionAttack_FIRE, W_Sound("rocket_fire"));
10METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
11{
12 bool isPlayer = IS_PLAYER(actor);
13 if (fire & 1)
14 if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, 1))
15 {
16 if (isPlayer)
17 {
18 turret_initparams(actor);
19 W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_HellionAttack_FIRE, CH_WEAPON_B, 0, DEATH_TURRET_HELLION.m_id);
20 actor.tur_shotdir_updated = w_shotdir;
21 actor.tur_shotorg = w_shotorg;
22 actor.tur_head = actor;
23 actor.shot_radius = 500;
24 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0.5, w_ready);
25 }
26 else
27 {
28 if (actor.tur_head.frame != 0)
29 actor.tur_shotorg = gettaginfo(actor.tur_head, gettagindex(actor.tur_head, "tag_fire"));
30 else
31 actor.tur_shotorg = gettaginfo(actor.tur_head, gettagindex(actor.tur_head, "tag_fire2"));
32 }
33
34 entity missile = turret_projectile(actor, SND_HellionAttack_FIRE, 6, 10, DEATH_TURRET_HELLION.m_id, PROJECTILE_ROCKET, false, false);
35 te_explosion(missile.origin);
37 missile.nextthink = time;
38 missile.max_health = time + 9;
39 missile.tur_aimpos = randomvec() * 128;
40 missile.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_GUIDED_HEAT;
41 if (!isPlayer)
42 ++actor.tur_head.frame;
43 }
44}
45
47{
48 this.nextthink = time + 0.05;
49
50 vector newdir, olddir = normalize(this.velocity);
51
52 if (this.max_health < time)
54
55 // Enemy dead? just keep on the current heading then.
56 if (this.enemy == NULL || IS_DEAD(this.enemy))
57 {
58
59 // Make sure we dont return to tracking a respawned player
60 this.enemy = NULL;
61
62 // Turn model
63 this.angles = vectoangles(this.velocity);
64
65 if (vdist(this.origin - this.owner.origin, >, (this.owner.shot_radius * 5)))
67
68 // Accelerate
70
72 return;
73 }
74
75 // Enemy in range?
76 if (vdist(this.origin - this.enemy.origin, <, this.owner.shot_radius * 0.2))
78
79 // Predict enemy position
80 float itime = vlen(this.enemy.origin - this.origin) / vlen(this.velocity);
81 vector pre_pos = this.enemy.origin + this.enemy.velocity * itime;
82
83 pre_pos = (pre_pos + this.enemy.origin) * 0.5;
84
85 // Find out the direction to that place
86 newdir = normalize(pre_pos - this.origin);
87 // Turn
88 newdir = normalize(olddir + newdir * 0.35);
89 // Turn model
90 this.angles = vectoangles(this.velocity);
91
92 // Accelerate
94
95 if (itime < 0.05)
97
99}
100
101#endif // SVQC
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float max_health
entity owner
Definition main.qh:87
#define IS_DEAD(s)
Definition player.qh:244
#define IS_PLAYER(s)
Definition player.qh:242
vector velocity
float time
float nextthink
vector v_forward
vector origin
void UpdateCSQCProjectile(entity e)
#define gettagindex
ent angles
Definition ent_cs.qc:121
float autocvar_g_turrets_unit_hellion_shot_speed_gain
float autocvar_g_turrets_unit_hellion_shot_speed_max
void turret_hellion_missile_think(entity this)
float vlen(vector v)
vector vectoangles(vector v)
vector randomvec(void)
float min(float f,...)
vector normalize(vector v)
#define METHOD(cname, name, prototype)
Definition oo.qh:269
#define NULL
Definition post.qh:14
#define gettaginfo
Definition post.qh:32
const int PROJECTILE_ROCKET
Definition projectiles.qh:4
#define setthink(e, f)
vector
Definition self.qh:92
const int MIF_SPLASH
Definition common.qh:46
const int MIF_GUIDED_HEAT
Definition common.qh:50
const int MIF_PROXY
Definition common.qh:48
const int CH_WEAPON_B
Definition sound.qh:8
string W_Sound(string w_snd)
Definition all.qc:226
#define SOUND(name, path)
Definition all.qh:30
entity enemy
Definition sv_ctf.qh:153
entity turret_projectile(entity actor, Sound _snd, float _size, float _health, float _death, float _proj_type, float _cull, float _cli_anim)
void turret_initparams(entity tur)
void turret_projectile_explode(entity this)
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
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition vector.qh:8
void weapon_thinkf(entity actor,.entity weaponentity, WFRAME fr, float t, void(Weapon thiswep, entity actor,.entity weaponentity, int fire) func)
bool weapon_prepareattack(Weapon thiswep, entity actor,.entity weaponentity, bool secondary, float attacktime)
void w_ready(Weapon thiswep, entity actor,.entity weaponentity, int fire)