8 TFL_AIM_SHOTTIMECOMPENSATE
\r
16 vector turret_stdproc_aim_generic()
\r
19 vector pre_pos,prep;
\r
20 float distance,impact_time,i,mintime;
\r
22 turret_tag_fire_update();
\r
24 if(self.aim_flags & TFL_AIM_SIMPLE)
\r
25 return real_origin(self.enemy);
\r
27 // Keep track of when we can shoot the next time and
\r
28 // try to predict where the target will be then, so we can put our aimpoint there.
\r
29 // + sys_frametime, becouse spawned REMOVE THIS IF sv_gameplayfix_delayprojectiles are 0!
\r
30 // projectiles dont move during the first tic of their life.
\r
31 //if (self.turrcaps_flags & TFL_TURRCAPS_HITSCAN)
\r
32 // mintime = max(self.attack_finished_single - time,0) + sys_frametime;
\r
35 mintime = max(self.attack_finished_single - time,0) + sys_frametime;
\r
38 pre_pos = real_origin(self.enemy);
\r
40 if (self.aim_flags & TFL_AIM_INFRONT) // Aim a bit in front of the target
\r
41 pre_pos = pre_pos + (normalize(self.enemy.velocity) * 64);
\r
43 if (self.aim_flags & TFL_AIM_BEHIND) // Aim a bit behind the target
\r
44 pre_pos = pre_pos - (normalize(self.enemy.velocity) * 32);
\r
47 if (self.aim_flags & TFL_AIM_LEAD)
\r
48 if (self.aim_flags & TFL_AIM_SHOTTIMECOMPENSATE) // Need to conpensate for shot traveltime
\r
50 // FIXME: this cant be the best way to do this..
\r
52 for(i = 0; i < 4; ++i)
\r
54 distance = vlen(prep - self.tur_shotorg);
\r
55 impact_time = distance / self.shot_speed;
\r
56 prep = pre_pos + self.enemy.velocity * impact_time;
\r
60 // tnx to Rudolf "div0" Polzer for this solution.
\r
61 // hmm tobad it dont work.
\r
64 q = solve_quadratic(self.enemy.velocity*self.enemy.velocity - self.shot_speed*self.shot_speed, 2*(pre_pos*self.enemy.velocity), pre_pos * pre_pos);
\r
71 prep = pre_pos + (self.enemy.velocity * (impact_time + mintime));
\r
73 if(self.aim_flags & TFL_AIM_ZPREDICT)
\r
74 if not(self.enemy.flags & FL_ONGROUND)
\r
75 if(self.enemy.movetype == MOVETYPE_WALK || self.enemy.movetype == MOVETYPE_TOSS || self.enemy.movetype == MOVETYPE_BOUNCE)
\r
79 vz = self.enemy.velocity_z;
\r
80 for(i = 0; i < impact_time; i += sys_frametime)
\r
82 vz = vz - (sv_gravity * sys_frametime);
\r
83 prep_z = prep_z + vz * sys_frametime;
\r
89 pre_pos = pre_pos + self.enemy.velocity * mintime;
\r
91 // Smooth out predict-Z?
\r
93 if (self.aim_flags & TFL_AIM_ZEASE)
\r
94 if (self.enemy.flags & FL_CLIENT)
\r
97 v = real_origin(self.enemy);
\r
98 pre_pos_z = (pre_pos_z + v_z) * 0.5;
\r
102 if(self.aim_flags & TFL_AIM_GROUND2)
\r
104 //tracebox(pre_pos + '0 0 32',self.enemy.mins,self.enemy.maxs,pre_pos -'0 0 64',MOVE_WORLDONLY,self.enemy);
\r
105 traceline(pre_pos + '0 0 32',pre_pos -'0 0 64',MOVE_WORLDONLY,self.enemy);
\r
106 if(trace_fraction != 1.0)
\r
107 pre_pos = trace_endpos;
\r
111 // This turret should hit the ground neer a target rather the do a direct hit
\r
112 if (self.aim_flags & TFL_AIM_GROUND)
\r
114 traceline(pre_pos + '0 0 8',pre_pos - '0 0 10000',MOVE_WORLDONLY,self.enemy);
\r
115 pre_pos = trace_endpos;
\r