View Single Post
JoeBot/RACC aiming
Old
  (#1)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default JoeBot/RACC aiming - 30-07-2004

I have found a problem when trying to use the JoeBot/RACC aiming code here...
Code:
      Vector v_deviation = vecDirection - pev->v_angle;
      ClampAngles(v_deviation);

      float turn_skill = 0.3 * m_iSkill / 100;

      // if bot is aiming at something, aim fast, else take our time...
      if (m_iAimFlags >= AIM_LASTENEMY)
         speed = 0.7 + turn_skill; // fast aim
      else if (m_iAimFlags <= AIM_CAMP && (m_iAimFlags & AIM_CAMP))
         speed = 0.1 + turn_skill / 4; // very slow aim if camping
      else
         speed = 0.2 + turn_skill / 2; // slow aim

      float da_deadly_math = exp(log(speed / 2) * g_iMsecval / 50);

      // Thanks Tobias Heimann and Johannes Lampel for this one
      pev->yaw_speed = (pev->yaw_speed * da_deadly_math + speed * v_deviation.y * (1 - da_deadly_math)) * g_iMsecval / 50;
      pev->pitch_speed = (pev->pitch_speed * da_deadly_math + speed * v_deviation.x * (1 - da_deadly_math)) * g_iMsecval / 50;

      // influence of y movement on x axis and vice versa (less influence than x on y since it's
      // easier and more natural for the bot to "move its mouse" horizontally than vertically)
      pev->pitch_speed += pev->yaw_speed / (1.5 * (1 + turn_skill));
      pev->yaw_speed += pev->pitch_speed / (1 + turn_skill);

+// If the fps is very low (e.g. when I'm running RealBot WIP and
+// bot with this code at the same time on my slow computer), the msec
+// value will be too large and the angle may exceed the deviation value. So
+// I've added a check here to prevent bots aiming from being messed up.
+// This seems to be "patching" but it works, also I have no clue about
+// the theory of the aiming algorithm :(
+      if (fabs(pev->pitch_speed) > fabs(v_deviation.x))
+         pev->pitch_speed = v_deviation.x;
+
+      if (fabs(pev->yaw_speed) > fabs(v_deviation.y))
+         pev->yaw_speed = v_deviation.y;

      pev->v_angle.y += pev->yaw_speed;
      pev->v_angle.x += pev->pitch_speed;
  
Reply With Quote