]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/tturrets/units/unit_hellion.qc
Merge branch 'master' into terencehill/clear_button
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / tturrets / units / unit_hellion.qc
1 void spawnfunc_turret_hellion();
2 void turret_hellion_dinit();
3 void turret_hellion_attack();
4
5 void turret_hellion_missile_think()
6 {
7     vector olddir,newdir;
8     vector pre_pos;
9     float itime;
10
11     self.nextthink = time + 0.05;
12
13     olddir = normalize(self.velocity);
14
15     if(self.tur_health < time)
16         turret_projectile_explode();
17
18     // Enemy dead? just keep on the current heading then.
19     if ((self.enemy == world) || (self.enemy.deadflag != DEAD_NO))
20     {
21
22         // Make sure we dont return to tracking a respawned player
23         self.enemy = world;
24
25         // Turn model
26         self.angles = vectoangles(self.velocity);
27
28         if ( (vlen(self.origin - self.owner.origin)) > (self.owner.shot_radius * 5) )
29             turret_projectile_explode();
30
31         // Accelerate
32         self.velocity = olddir * min(vlen(self.velocity) * autocvar_g_turrets_unit_hellion_std_shot_speed_gain, autocvar_g_turrets_unit_hellion_std_shot_speed_max);
33
34         UpdateCSQCProjectile(self);
35
36         return;
37     }
38
39     // Enemy in range?
40     if (vlen(self.origin - self.enemy.origin) < self.owner.shot_radius * 0.2)
41         turret_projectile_explode();
42
43     // Predict enemy position
44     itime = vlen(self.enemy.origin - self.origin) / vlen(self.velocity);
45     pre_pos = self.enemy.origin + self.enemy.velocity * itime;
46
47     pre_pos = (pre_pos + self.enemy.origin) * 0.5;
48
49     // Find out the direction to that place
50     newdir = normalize(pre_pos - self.origin);
51
52     // Turn
53     newdir = normalize(olddir + newdir * 0.35);
54
55     // Turn model
56     self.angles = vectoangles(self.velocity);
57
58     // Accelerate
59     self.velocity = newdir * min(vlen(self.velocity) * autocvar_g_turrets_unit_hellion_std_shot_speed_gain, autocvar_g_turrets_unit_hellion_std_shot_speed_max);
60
61     if (itime < 0.05)
62         self.think = turret_projectile_explode;
63
64     UpdateCSQCProjectile(self);
65 }
66 void turret_hellion_attack()
67 {
68     entity missile;
69                 
70         if(self.tur_head.frame != 0)
71                 self.tur_shotorg = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_fire"));
72         else
73                 self.tur_shotorg = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_fire2"));
74     
75     missile = turret_projectile("weapons/rocket_fire.wav", 6, 10, DEATH_TURRET_HELLION, PROJECTILE_ROCKET, FALSE, FALSE);
76     te_explosion (missile.origin);
77     missile.think        = turret_hellion_missile_think;
78     missile.nextthink    = time;
79     missile.flags        = FL_PROJECTILE;
80     missile.tur_health   = time + 9;
81     missile.tur_aimpos   = randomvec() * 128;
82         self.tur_head.frame += 1;
83 }
84
85 void turret_hellion_postthink()
86 {
87     if (self.tur_head.frame != 0)
88         self.tur_head.frame += 1;
89
90     if (self.tur_head.frame >= 7)
91         self.tur_head.frame = 0;
92 }
93
94 void turret_hellion_dinit()
95 {
96     if (self.netname == "")      self.netname  = "Hellion Missile Turret";
97
98     self.turrcaps_flags = TFL_TURRCAPS_RADIUSDMG | TFL_TURRCAPS_FASTPROJ | TFL_TURRCAPS_PLAYERKILL | TFL_TURRCAPS_MISSILEKILL;
99     self.aim_flags = TFL_AIM_SIMPLE;
100     self.target_select_flags = TFL_TARGETSELECT_LOS | TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMTS | TFL_TARGETSELECT_TEAMCHECK ;
101     self.firecheck_flags = TFL_FIRECHECK_DEAD | TFL_FIRECHECK_DISTANCES | TFL_FIRECHECK_TEAMCECK | TFL_FIRECHECK_REFIRE | TFL_FIRECHECK_AFF | TFL_FIRECHECK_OWM_AMMO;
102     self.ammo_flags = TFL_AMMO_ROCKETS | TFL_AMMO_RECHARGE;
103
104     if (turret_stdproc_init("hellion_std", "models/turrets/base.md3", "models/turrets/hellion.md3", TID_HELLION) == 0)
105     {
106         remove(self);
107         return;
108     }
109
110     self.turret_firefunc  = turret_hellion_attack;
111     self.turret_postthink = turret_hellion_postthink;
112 }
113
114 /*QUAKED turret_hellion (0 .5 .8) ?
115 */
116 void spawnfunc_turret_hellion()
117 {
118     precache_model ("models/turrets/hellion.md3");
119     precache_model ("models/turrets/base.md3");
120
121     self.think = turret_hellion_dinit;
122     self.nextthink = time + 0.5;
123 }
124
125