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 bool isPlayer = IS_PLAYER(actor);
12 if (fire & 1)
13 if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, 1)) {
14 if (isPlayer) {
15 turret_initparams(actor);
16 W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_HellionAttack_FIRE, CH_WEAPON_B, 0, DEATH_TURRET_HELLION.m_id);
17 actor.tur_shotdir_updated = w_shotdir;
18 actor.tur_shotorg = w_shotorg;
19 actor.tur_head = actor;
20 actor.shot_radius = 500;
21 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0.5, w_ready);
22 }
23 if (!isPlayer) {
24 if (actor.tur_head.frame != 0)
25 actor.tur_shotorg = gettaginfo(actor.tur_head, gettagindex(actor.tur_head, "tag_fire"));
26 else
27 actor.tur_shotorg = gettaginfo(actor.tur_head, gettagindex(actor.tur_head, "tag_fire2"));
28 }
29
30 entity missile = turret_projectile(actor, SND_HellionAttack_FIRE, 6, 10, DEATH_TURRET_HELLION.m_id, PROJECTILE_ROCKET, false, false);
31 te_explosion (missile.origin);
33 missile.nextthink = time;
34 missile.max_health = time + 9;
35 missile.tur_aimpos = randomvec() * 128;
36 missile.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_GUIDED_HEAT;
37 if (!isPlayer) actor.tur_head.frame += 1;
38 }
39}
40
42{
43 vector olddir,newdir;
44 vector pre_pos;
45 float itime;
46
47 this.nextthink = time + 0.05;
48
49 olddir = normalize(this.velocity);
50
51 if(this.max_health < time)
53
54 // Enemy dead? just keep on the current heading then.
55 if ((this.enemy == NULL) || (IS_DEAD(this.enemy)))
56 {
57
58 // Make sure we dont return to tracking a respawned player
59 this.enemy = NULL;
60
61 // Turn model
62 this.angles = vectoangles(this.velocity);
63
64 if(vdist(this.origin - this.owner.origin, >, (this.owner.shot_radius * 5)))
66
67 // Accelerate
69
71
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 itime = vlen(this.enemy.origin - this.origin) / vlen(this.velocity);
81 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
88 // Turn
89 newdir = normalize(olddir + newdir * 0.35);
90
91 // Turn model
92 this.angles = vectoangles(this.velocity);
93
94 // Accelerate
96
97 if (itime < 0.05)
99
101}
102
103#endif
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:245
#define IS_PLAYER(s)
Definition player.qh:243
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:225
#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)