this.bot_canfire = 1;
}
+// this function should be called after bot_aim so the aim is reset the next frame
void bot_aim_reset(entity this)
{
+ this.bot_mouseaim = this.v_angle;
+ this.bot_olddesiredang = this.v_angle;
this.bot_aimdir_executed = true;
- makevectors(this.v_angle);
this.bot_badaimtime = 0;
this.bot_aimthinktime = time;
this.bot_prevaimtime = time;
- this.bot_mouseaim = v_forward;
- this.bot_olddesiredang = v_forward;
this.bot_1st_order_aimfilter = '0 0 0';
this.bot_2nd_order_aimfilter = '0 0 0';
this.bot_3th_order_aimfilter = '0 0 0';
this.v_angle_y = this.v_angle.y - floor(this.v_angle.y / 360) * 360;
this.v_angle_z = 0;
+ // make work bot_aim_reset even if called before this function
+ if (this.bot_prevaimtime == time)
+ return;
+
// invalid aim dir (can happen when bot overlaps target)
if(!v) return;
blendrate = autocvar_bot_ai_aimskill_blendrate;
r = max(fixedrate, blendrate);
//this.v_angle = this.v_angle + diffang * bound(frametime, r * frametime * (2+skill*skill*0.05-random()*0.05*(10-skill)), 1);
- this.v_angle = this.v_angle + diffang * bound(delta_t, r * delta_t * (2 + ((skill + this.bot_mouseskill) ** 3) * 0.005 - random()), 1);
- this.v_angle = this.v_angle * bound(0,autocvar_bot_ai_aimskill_mouse,1) + desiredang * bound(0,(1-autocvar_bot_ai_aimskill_mouse),1);
- //this.v_angle = this.v_angle + diffang * bound(0, r * frametime * (skill * 0.5 + 2), 1);
- //this.v_angle = this.v_angle + diffang * (1/ blendrate);
+ r = bound(delta_t, r * delta_t * (2 + ((skill + this.bot_mouseskill) ** 3) * 0.005 - random()), 1);
+ this.v_angle += diffang * (r + (1 - r) * bound(0, 1 - autocvar_bot_ai_aimskill_mouse, 1));
+
this.v_angle_z = 0;
this.v_angle_y = this.v_angle.y - floor(this.v_angle.y / 360) * 360;
//dprint(" turn:", vtos(this.v_angle));
{
float r, hf, distanceratio;
vector v;
- /*
- eprint(this);
- dprint("bot_aim(", ftos(shotspeed));
- dprint(", ", ftos(shotspeedupward));
- dprint(", ", ftos(maxshottime));
- dprint(", ", ftos(applygravity));
- dprint(");\n");
- */
-
hf = this.dphitcontentsmask;
this.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
- shotspeed *= W_WeaponSpeedFactor(this);
- shotspeedupward *= W_WeaponSpeedFactor(this);
+ float speed_factor = W_WeaponSpeedFactor(this);
+ shotspeed *= speed_factor;
+ shotspeedupward *= speed_factor;
if (!shotspeed)
{
LOG_TRACE("bot_aim: WARNING: weapon ", this.(weaponentity).m_weapon.m_name, " shotspeed is zero!");