18 float c, savesolid, shottime;
28 savesolid = targ.solid;
30 o = (targ.absmin + targ.absmax) * 0.5;
31 shottime = ((
vlen(o -
org) / shotspeed) + shotdelay);
32 v = targ.velocity * shottime + o;
33 tracebox(o, targ.mins, targ.maxs, v,
false, targ);
35 end = v + (targ.mins + targ.maxs) * 0.5;
36 float shotdistance =
max(0.001,
vlen(end -
org));
37 if ((shotdistance / shotspeed + 0.2) > maxtime)
40 targ.solid = savesolid;
56 dir = (end -
org) * (1 / shotdistance);
66 targ.solid = savesolid;
79 test_dir_normalized =
normalize(test_dir);
82 targ.solid = savesolid;
99 if (targ.team ==
this.team)
116 if (!targ.takedamage)
124 if(targ.alpha <= 0.1 && targ.alpha != 0)
152 float dist, delta_t, blend;
153 vector desiredang, diffang;
185 float skill_save =
skill;
201 float enemy_factor = ((this.
enemy) ? 5 : 2);
205 if (desiredang.x >= 180)
206 desiredang.x = desiredang.x - 360;
207 desiredang.x =
bound(-90, 0 - desiredang.x, 90);
221 diffang.y = diffang.y -
floor(diffang.y / 360) * 360;
222 if (diffang.y >= 180)
223 diffang.y = diffang.y - 360;
228 this.bot_prevaimtime =
time;
243 desiredang = desiredang + blend *
251 desiredang.x =
bound(-90, desiredang.x, 90);
256 diffang.y = diffang.y -
floor(diffang.y / 360) * 360;
257 if (diffang.y >= 180)
258 diffang.y = diffang.y - 360;
269 diffang = this.bot_mouseaim - desiredang;
271 diffang.y = diffang.y -
floor(diffang.y / 360) * 360;
272 if (diffang.y >= 180)
273 diffang.y = diffang.y - 360;
277 diffang = desiredang - this.
v_angle;
279 diffang.y = diffang.y -
floor(diffang.y / 360) * 360;
280 if (diffang.y >= 180)
281 diffang.y = diffang.y - 360;
285 dist =
vlen(diffang);
289 float r, fixedrate, blendrate;
292 r =
max(fixedrate, blendrate);
297 this.v_angle_y = this.v_angle.y -
floor(this.v_angle.y / 360) * 360;
302 if (maxfiredeviation <= 0)
320 while (deviation.x < -180) deviation.x += 360;
while (deviation.x > 180) deviation.x -= 360;
321 while (deviation.y < -180) deviation.y += 360;
while (deviation.y > 180) deviation.y -= 360;
322 if (
fabs(deviation.x) < maxfiredeviation &&
fabs(deviation.y) < maxfiredeviation)
336 return targorigin + targvelocity * (shotdelay +
vlen(targorigin -
shotorg) / shotspeed);
339bool bot_aim(
entity this, .
entity weaponentity,
float shotspeed,
float shotspeedupward,
float maxshottime,
bool applygravity,
bool shot_accurate)
341 float hf, distanceratio;
347 shotspeed *= speed_factor;
348 shotspeedupward *= speed_factor;
351 LOG_TRACE(
"bot_aim: WARNING: weapon ", this.(weaponentity).
m_weapon.m_name,
" shotspeed is zero!");
356 LOG_TRACE(
"bot_aim: WARNING: weapon ", this.(weaponentity).
m_weapon.m_name,
" maxshottime is zero!");
363 v =
bot_shotlead(enemy_org, this.
enemy.velocity, shotspeed,
this.bot_aimlatency);
370 float maxfiredeviation = 1000 / (dist - 9) - 0.35;
372 float f = (shot_accurate) ? 1 : 1.6;
374 maxfiredeviation =
min(90, maxfiredeviation * f);
376 if (applygravity && this.
enemy)
395 traceline(
shotorg, enemy_org,
false,
this);
bool bot_shouldattack(entity this, entity targ)
vector bot_shotlead(vector targorigin, vector targvelocity, float shotspeed, float shotdelay)
float findtrajectorywithleading(vector org, vector m1, vector m2, entity targ, float shotspeed, float shotspeedupward, float maxtime, float shotdelay, entity ignore)
void bot_aim_reset(entity this)
void bot_aimdir(entity this, vector v, float maxfiredeviation)
bool bot_aim(entity this,.entity weaponentity, float shotspeed, float shotspeedupward, float maxshottime, bool applygravity, bool shot_accurate)
vector bot_4th_order_aimfilter
vector bot_3th_order_aimfilter
vector bot_1st_order_aimfilter
vector findtrajectory_velocity
entity tracetossfaketarget
vector bot_5th_order_aimfilter
vector bot_2nd_order_aimfilter
#define MUTATOR_CALLHOOK(id,...)
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define PHYS_INPUT_BUTTON_CHAT(s)
float autocvar_bot_ai_aimskill_order_mix_5th
float autocvar_bot_ai_aimskill_order_mix_1st
int autocvar_bot_ai_aimskill_firetolerance
float autocvar_bot_ai_aimskill_order_filter_5th
float autocvar_bot_ai_aimskill_order_mix_2nd
float autocvar_bot_ai_aimskill_think
float autocvar_bot_ai_aimskill_order_mix_4th
bool autocvar_bot_typefrag
float autocvar_bot_ai_aimskill_order_filter_3th
float autocvar_bot_ai_aimskill_order_filter_4th
float autocvar_bot_ai_aimskill_order_filter_2nd
float autocvar_bot_ai_aimskill_order_filter_1st
float autocvar_bot_ai_aimskill_mouse
float autocvar_bot_ai_aimskill_offset
float autocvar_bot_ai_aimskill_order_mix_3th
bool autocvar_bot_ignore_bots
float autocvar_bot_ai_aimskill_blendrate
float autocvar_bot_ai_aimskill_fixedrate
void set_movetype(entity this, int mt)
#define IS_BOT_CLIENT(v)
want: (IS_CLIENT(v) && !IS_REAL_CLIENT(v))
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
float W_WeaponSpeedFactor(entity this)