]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/turrets/unit/hellion.qc
596b95fa08c6bb5d1461bbd1082999d70bfd757c
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / unit / hellion.qc
1 #ifdef REGISTER_TURRET
2 REGISTER_TURRET(
3 /* TUR_##id   */ HELLION,
4 /* function   */ t_hellion,
5 /* spawnflags */ TUR_FLAG_SPLASH | TUR_FLAG_FASTPROJ | TUR_FLAG_PLAYER | TUR_FLAG_MISSILE,
6 /* mins,maxs  */ '-32 -32 0', '32 32 64',
7 /* model          */ "base.md3",
8 /* head_model */ "hellion.md3",
9 /* netname        */ "hellion",
10 /* fullname   */ _("Hellion Missile Turret")
11 );
12 #else
13 #ifdef SVQC
14 float autocvar_g_turrets_unit_hellion_shot_speed_gain;
15 float autocvar_g_turrets_unit_hellion_shot_speed_max;
16
17 void turret_hellion_missile_think()
18 {SELFPARAM();
19     vector olddir,newdir;
20     vector pre_pos;
21     float itime;
22
23     self.nextthink = time + 0.05;
24
25     olddir = normalize(self.velocity);
26
27     if(self.max_health < time)
28         turret_projectile_explode();
29
30     // Enemy dead? just keep on the current heading then.
31     if ((self.enemy == world) || (self.enemy.deadflag != DEAD_NO))
32     {
33
34         // Make sure we dont return to tracking a respawned player
35         self.enemy = world;
36
37         // Turn model
38         self.angles = vectoangles(self.velocity);
39
40         if ( (vlen(self.origin - self.owner.origin)) > (self.owner.shot_radius * 5) )
41             turret_projectile_explode();
42
43         // Accelerate
44         self.velocity = olddir * min(vlen(self.velocity) * (autocvar_g_turrets_unit_hellion_shot_speed_gain), (autocvar_g_turrets_unit_hellion_shot_speed_max));
45
46         UpdateCSQCProjectile(self);
47
48         return;
49     }
50
51     // Enemy in range?
52     if (vlen(self.origin - self.enemy.origin) < self.owner.shot_radius * 0.2)
53         turret_projectile_explode();
54
55     // Predict enemy position
56     itime = vlen(self.enemy.origin - self.origin) / vlen(self.velocity);
57     pre_pos = self.enemy.origin + self.enemy.velocity * itime;
58
59     pre_pos = (pre_pos + self.enemy.origin) * 0.5;
60
61     // Find out the direction to that place
62     newdir = normalize(pre_pos - self.origin);
63
64     // Turn
65     newdir = normalize(olddir + newdir * 0.35);
66
67     // Turn model
68     self.angles = vectoangles(self.velocity);
69
70     // Accelerate
71     self.velocity = newdir * min(vlen(self.velocity) * (autocvar_g_turrets_unit_hellion_shot_speed_gain), (autocvar_g_turrets_unit_hellion_shot_speed_max));
72
73     if (itime < 0.05)
74         self.think = turret_projectile_explode;
75
76     UpdateCSQCProjectile(self);
77 }
78
79 void spawnfunc_turret_hellion() { SELFPARAM(); if(!turret_initialize(TUR_HELLION)) remove(self); }
80
81 float t_hellion(float req)
82 {SELFPARAM();
83     switch(req)
84     {
85         case TR_ATTACK:
86         {
87             entity missile;
88
89             if(self.tur_head.frame != 0)
90                 self.tur_shotorg = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_fire"));
91             else
92                 self.tur_shotorg = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_fire2"));
93
94             missile = turret_projectile(SND(ROCKET_FIRE), 6, 10, DEATH_TURRET_HELLION, PROJECTILE_ROCKET, FALSE, FALSE);
95             te_explosion (missile.origin);
96             missile.think               = turret_hellion_missile_think;
97             missile.nextthink   = time;
98             missile.flags               = FL_PROJECTILE;
99             missile.max_health   = time + 9;
100             missile.tur_aimpos   = randomvec() * 128;
101             missile.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_GUIDED_HEAT;
102             self.tur_head.frame += 1;
103
104             return true;
105         }
106         case TR_THINK:
107         {
108             if (self.tur_head.frame != 0)
109                 self.tur_head.frame += 1;
110
111             if (self.tur_head.frame >= 7)
112                 self.tur_head.frame = 0;
113
114             return true;
115         }
116         case TR_DEATH:
117         {
118             return true;
119         }
120         case TR_SETUP:
121         {
122             self.aim_flags = TFL_AIM_SIMPLE;
123             self.target_select_flags = TFL_TARGETSELECT_LOS | TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK ;
124             self.firecheck_flags = TFL_FIRECHECK_DEAD | TFL_FIRECHECK_DISTANCES | TFL_FIRECHECK_TEAMCHECK | TFL_FIRECHECK_REFIRE | TFL_FIRECHECK_AFF | TFL_FIRECHECK_AMMO_OWN;
125             self.ammo_flags = TFL_AMMO_ROCKETS | TFL_AMMO_RECHARGE;
126
127             return true;
128         }
129         case TR_PRECACHE:
130         {
131             return true;
132         }
133     }
134
135     return true;
136 }
137
138 #endif // SVQC
139 #ifdef CSQC
140 float t_hellion(float req)
141 {
142     switch(req)
143     {
144         case TR_SETUP:
145         {
146             return true;
147         }
148         case TR_PRECACHE:
149         {
150             return true;
151         }
152     }
153
154     return true;
155 }
156
157 #endif // CSQC
158 #endif // REGISTER_TURRET