1 .float shot_speed_max;
\r
2 .float shot_speed_gain;
\r
4 void spawnfunc_turret_hellion();
\r
5 void turret_hellion_dinit();
\r
6 void turret_hellion_attack();
\r
7 void turret_hellion_missile_explode();
\r
8 void turret_hellion_missile_think();
\r
9 void turret_hellion_missile_damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector vforce)
\r
11 void turret_hellion_postthink()
\r
13 if (cvar("g_turrets_reloadcvars"))
\r
15 if (!self.shot_speed_max) self.shot_speed_max = cvar("g_turrets_unit_hellion_std_shot_speed_max");
\r
16 if (!self.shot_speed_gain) self.shot_speed_gain = cvar("g_turrets_unit_hellion_std_shot_speed_gain");
\r
19 if (self.tur_head.frame != 0)
\r
20 self.tur_head.frame = self.tur_head.frame + 1;
\r
22 if (self.tur_head.frame > 7)
\r
23 self.tur_head.frame = 0;
\r
26 void turret_hellion_attack()
\r
28 local entity missile;
\r
30 sound (self, CHAN_WEAPON, "weapons/hagar_fire.wav", VOL_BASE, ATTN_NORM);
\r
33 setorigin(missile, self.tur_shotorg_updated);
\r
34 setmodel (missile, "models/turrets/mlrs_rocket.md3"); // precision set below
\r
35 setsize (missile, '-3 -3 -3', '3 3 3'); // give it some size so it can be shot
\r
37 missile.classname = "hellion_missile";
\r
38 missile.owner = self;
\r
39 missile.bot_dodge = TRUE;
\r
40 missile.bot_dodgerating = self.shot_dmg;
\r
41 missile.takedamage = DAMAGE_YES;
\r
42 missile.damageforcescale = 2;
\r
43 missile.health = 50;
\r
44 missile.enemy = self.enemy;
\r
45 missile.think = turret_hellion_missile_think;
\r
46 missile.nextthink = time + 0.2;
\r
47 missile.solid = SOLID_BBOX;
\r
48 missile.movetype = MOVETYPE_FLYMISSILE;
\r
49 missile.effects = EF_LOWPRECISION;
\r
50 missile.velocity = (self.tur_shotdir_updated + randomvec() * self.shot_spread) * self.shot_speed; // + ('0 0 1' * self.shot_speed * 0.15);
\r
51 missile.angles = vectoangles(missile.velocity);
\r
52 missile.touch = turret_hellion_missile_explode;
\r
53 missile.flags = FL_PROJECTILE;
\r
54 missile.solid = SOLID_BBOX;
\r
55 missile.tur_health = time + 9;
\r
56 missile.tur_aimpos = randomvec() * 128;
\r
57 te_explosion (missile.origin);
\r
59 CSQCProjectile(missile, FALSE, PROJECTILE_ROCKET);
\r
62 self.tur_shotorg_y = self.tur_shotorg_y * -1;
\r
64 if (self.tur_head.frame == 0)
\r
65 self.tur_head.frame = self.tur_head.frame + 1;
\r
69 void turret_hellion_missile_damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector vforce)
\r
71 self.health = self.health - damage;
\r
72 self.velocity = self.velocity + vforce;
\r
73 if (self.health <= 0) turret_hellion_missile_explode();
\r
76 void turret_hellion_missile_think()
\r
78 vector olddir,newdir;
\r
82 self.nextthink = time + 0.1;
\r
85 if (vlen(self.origin - self.enemy.origin) < self.owner.shot_radius * 0.25)
\r
86 turret_hellion_missile_explode();
\r
88 olddir = normalize(self.velocity);
\r
90 if (self.tur_health < time) turret_hellion_missile_explode();
\r
92 // Enemy dead? just keep on the current heading then.
\r
93 if ((self.enemy == world) || (self.enemy.deadflag != DEAD_NO))
\r
96 // Make sure we dont return to tracking a respawned player
\r
100 self.velocity = olddir * min(vlen(self.velocity) * self.owner.shot_speed_gain,self.owner.shot_speed_max);
\r
103 self.angles = vectoangles(self.velocity);
\r
105 //if ( (vlen(self.origin - self.owner.origin)) > (self.owner.shot_radius * 10) )
\r
106 // turret_hellion_missile_explode();
\r
111 olddir = normalize(self.velocity);
\r
115 // Predict enemy position
\r
116 itime = vlen(self.enemy.origin - self.origin) / vlen(self.velocity);
\r
117 pre_pos = self.enemy.origin + self.enemy.velocity * itime;
\r
121 pre_pos = self.origin + olddir * 1024;
\r
124 pre_pos = (pre_pos + self.enemy.origin) * 0.5;
\r
126 //pre_pos += randomvec() * 128; //self.tur_aimpos * (sin(32) * time) ;
\r
129 // Find out the direction to that place
\r
130 newdir = normalize(pre_pos - self.origin);
\r
133 newdir = normalize(olddir + newdir * 0.5);
\r
136 self.velocity = newdir * min(vlen(self.velocity) * self.owner.shot_speed_gain,self.owner.shot_speed_max);
\r
139 self.angles = vectoangles(self.velocity);
\r
141 if (time+itime < time+0.1)
\r
143 self.think = turret_hellion_missile_explode;
\r
144 self.nextthink = time + itime;
\r
147 UpdateCSQCProjectile(self);
\r
150 void turret_hellion_missile_explode()
\r
155 if(self.event_damage != SUB_Null)
\r
157 self.event_damage = SUB_Null;
\r
158 self.think = turret_hellion_missile_explode;
\r
159 self.nextthink = time;
\r
163 sound (self, CHAN_PROJECTILE, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
\r
164 org2 = findbetterlocation (self.origin, 16);
\r
166 // LordHavoc: TE_TEI_BIGEXPLOSION
\r
167 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
\r
168 WriteByte (MSG_BROADCAST, 78);
\r
169 WriteCoord (MSG_BROADCAST, org2_x);
\r
170 WriteCoord (MSG_BROADCAST, org2_y);
\r
171 WriteCoord (MSG_BROADCAST, org2_z);
\r
173 self.event_damage = SUB_Null;
\r
174 d = RadiusDamage (self, self.owner, self.owner.shot_dmg, 0, self.owner.shot_radius, world, self.owner.shot_force, DEATH_TURRET, world);
\r
176 #ifdef TURRET_DEBUG
\r
177 self.owner.tur_dbg_dmg_t_h = self.owner.tur_dbg_dmg_t_h + d; //self.owner.shot_dmg;
\r
178 self.owner.tur_dbg_dmg_t_f = self.owner.tur_dbg_dmg_t_f + self.owner.shot_dmg;
\r
181 // Target dead, get another is still targeting the same.
\r
182 if ((self.enemy.deadflag != DEAD_NO) && (self.enemy == self.owner.enemy))
\r
183 self.owner.enemy = world;
\r
188 void turret_hellion_dinit()
\r
190 if (self.netname == "") self.netname = "Hellion Missile Turret";
\r
192 if (!self.shot_speed_max) self.shot_speed_max = cvar("g_turrets_unit_hellion_std_shot_speed_max");
\r
193 if (!self.shot_speed_gain) self.shot_speed_gain = cvar("g_turrets_unit_hellion_std_shot_speed_gain");
\r
195 self.turrcaps_flags = TFL_TURRCAPS_RADIUSDMG | TFL_TURRCAPS_FASTPROJ | TFL_TURRCAPS_PLAYERKILL | TFL_TURRCAPS_MISSILEKILL;
\r
196 self.aim_flags = TFL_AIM_SIMPLE;
\r
197 self.target_select_flags = TFL_TARGETSELECT_LOS | TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_TRIGGERTARGET | TFL_TARGETSELECT_RANGELIMTS | TFL_TARGETSELECT_TEAMCHECK ;
\r
198 self.firecheck_flags = TFL_FIRECHECK_WORLD | TFL_FIRECHECK_DEAD | TFL_FIRECHECK_DISTANCES | TFL_FIRECHECK_TEAMCECK | TFL_FIRECHECK_REFIRE | TFL_FIRECHECK_AFF | TFL_FIRECHECK_OWM_AMMO;
\r
199 self.ammo_flags = TFL_AMMO_ROCKETS | TFL_AMMO_RECHARGE;
\r
201 if (turret_stdproc_init("hellion_std") == 0)
\r
207 setmodel(self,"models/turrets/base.md3");
\r
208 setmodel(self.tur_head,"models/turrets/hellion.md3");
\r
210 if (!turret_tag_setup(0))
\r
211 dprint("Warning: Turret ",self.classname, " faild to initialize md3 tags\n");
\r
213 // Our fire routine
\r
214 self.turret_firefunc = turret_hellion_attack;
\r
216 // Custom animations and sutch
\r
217 self.turret_postthink = turret_hellion_postthink;
\r
220 /*QUAKED turret_hellion (0 .5 .8) ?
\r
222 void spawnfunc_turret_hellion()
\r
224 //precache_model ( "models/turrets/mlrs_rocket.md3");
\r
225 //precache_model ("models/turrets/hellion.md3");
\r
226 //precache_model ("models/turrets/base.md3");
\r
228 self.think = turret_hellion_dinit;
\r
229 self.nextthink = time + 0.5;
\r