]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/turrets/turret/hellion_weapon.qc
Hide the MOTD when going spec
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / turret / hellion_weapon.qc
1 #ifndef TURRET_HELLION_WEAPON_H
2 #define TURRET_HELLION_WEAPON_H
3
4 CLASS(HellionAttack, PortoLaunch)
5 /* flags     */ ATTRIB(HellionAttack, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_HIDDEN | WEP_FLAG_MUTATORBLOCKED);
6 /* impulse   */ ATTRIB(HellionAttack, impulse, int, 9);
7 /* refname   */ ATTRIB(HellionAttack, netname, string, "turret_hellion");
8 /* wepname   */ ATTRIB(HellionAttack, message, string, _("Hellion"));
9 ENDCLASS(HellionAttack)
10 REGISTER_WEAPON(HELLION, NEW(HellionAttack));
11
12 #endif
13
14 #ifdef IMPLEMENTATION
15
16 #ifdef SVQC
17
18 float autocvar_g_turrets_unit_hellion_shot_speed_gain;
19 float autocvar_g_turrets_unit_hellion_shot_speed_max;
20
21 void turret_hellion_missile_think();
22 METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) {
23     bool isPlayer = IS_PLAYER(actor);
24     if (fire1)
25     if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) {
26         if (isPlayer) {
27             turret_initparams(actor);
28             W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
29             actor.tur_shotdir_updated = w_shotdir;
30             actor.tur_shotorg = w_shotorg;
31             actor.tur_head = actor;
32             actor.shot_radius = 500;
33             weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
34         }
35         if (!isPlayer) {
36             if (actor.tur_head.frame != 0)
37                 actor.tur_shotorg = gettaginfo(actor.tur_head, gettagindex(actor.tur_head, "tag_fire"));
38             else
39                 actor.tur_shotorg = gettaginfo(actor.tur_head, gettagindex(actor.tur_head, "tag_fire2"));
40         }
41
42         entity missile = turret_projectile(SND(ROCKET_FIRE), 6, 10, DEATH_TURRET_HELLION.m_id, PROJECTILE_ROCKET, FALSE, FALSE);
43         te_explosion (missile.origin);
44         missile.think           = turret_hellion_missile_think;
45         missile.nextthink       = time;
46         missile.flags           = FL_PROJECTILE;
47         missile.max_health   = time + 9;
48         missile.tur_aimpos   = randomvec() * 128;
49         missile.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_GUIDED_HEAT;
50         if (!isPlayer) actor.tur_head.frame += 1;
51     }
52 }
53
54 void turret_hellion_missile_think()
55 {SELFPARAM();
56     vector olddir,newdir;
57     vector pre_pos;
58     float itime;
59
60     self.nextthink = time + 0.05;
61
62     olddir = normalize(self.velocity);
63
64     if(self.max_health < time)
65         turret_projectile_explode();
66
67     // Enemy dead? just keep on the current heading then.
68     if ((self.enemy == world) || (self.enemy.deadflag != DEAD_NO))
69     {
70
71         // Make sure we dont return to tracking a respawned player
72         self.enemy = world;
73
74         // Turn model
75         self.angles = vectoangles(self.velocity);
76
77         if ( (vlen(self.origin - self.owner.origin)) > (self.owner.shot_radius * 5) )
78             turret_projectile_explode();
79
80         // Accelerate
81         self.velocity = olddir * min(vlen(self.velocity) * (autocvar_g_turrets_unit_hellion_shot_speed_gain), (autocvar_g_turrets_unit_hellion_shot_speed_max));
82
83         UpdateCSQCProjectile(self);
84
85         return;
86     }
87
88     // Enemy in range?
89     if (vlen(self.origin - self.enemy.origin) < self.owner.shot_radius * 0.2)
90         turret_projectile_explode();
91
92     // Predict enemy position
93     itime = vlen(self.enemy.origin - self.origin) / vlen(self.velocity);
94     pre_pos = self.enemy.origin + self.enemy.velocity * itime;
95
96     pre_pos = (pre_pos + self.enemy.origin) * 0.5;
97
98     // Find out the direction to that place
99     newdir = normalize(pre_pos - self.origin);
100
101     // Turn
102     newdir = normalize(olddir + newdir * 0.35);
103
104     // Turn model
105     self.angles = vectoangles(self.velocity);
106
107     // Accelerate
108     self.velocity = newdir * min(vlen(self.velocity) * (autocvar_g_turrets_unit_hellion_shot_speed_gain), (autocvar_g_turrets_unit_hellion_shot_speed_max));
109
110     if (itime < 0.05)
111         self.think = turret_projectile_explode;
112
113     UpdateCSQCProjectile(self);
114 }
115
116 #endif
117
118 #endif