.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   HPB_bot (http://forums.bots-united.com/forumdisplay.php?f=35)
-   -   Angle offset bug (http://forums.bots-united.com/showthread.php?t=3126)

Rifleman 03-12-2004 12:15

Angle offset bug
 
I think this is an aged old error but I still cant figured out how to fix it

we assume we define a vector "vec"

Code:

  Vector look_vec = UTIL_VecToAngles( vec );
 
  pEdict->v.ideal_yaw = look_vec.y;
  BotFixIdealYaw(pEdict);
 
  pEdict->v.v_angle.x = look_vec.x;
 
  if (pBot->pEdict->v.v_angle.x > 180)
        pBot->pEdict->v.v_angle.x -=360;
 
  pEdict->v.angles.x = pEdict->v.v_angle.x / 3;
  pEdict->v.v_angle.x = -pEdict->v.v_angle.x;

The bot's aiming seems to be a bit off to the right side , how can this happen ?

Pierre-Marie Baty 03-12-2004 13:54

Re: Angle offset bug
 
This ain't making the bot aim to the right side. The only thing that could cause the effect you're witnessing may be the weapon recoil. Especially if you use the bots in realistic mods such as Counter-Strike (which I bet that's what you're trying to do).

This behaviour is not a bug in the HPB_bot, but rather a lack of a functionality, which is recoil compensation.

To compensate for the recoil, most bot authors compute their aiming vector by taking in account the "punchangle" variable in the bot's entvars structure.

Rifleman 04-12-2004 04:20

Re: Angle offset bug
 
thats not the problem , because that happen although in freezetime , but when I change the code to

Code:

  pEdict->v.v_angle = UTIL_VecToAngles( vec );
  if (pEdict->v.v_angle.y > 180)
          pEdict->v.v_angle.y -=360;
  // Paulo-La-Frite - START bot aiming bug fix
  if (pEdict->v.v_angle.x > 180)
          pEdict->v.v_angle.x -=360;
  // set the body angles to point the gun correctly
  pEdict->v.angles.x = pEdict->v.v_angle.x / 3;
  pEdict->v.angles.y = pEdict->v.v_angle.y;
  pEdict->v.angles.z = 0;
                 
  // adjust the view angle pitch to aim correctly (MUST be after body v.angles stuff)
  pEdict->v.v_angle.x = -pEdict->v.v_angle.x;
  // Paulo-La-Frite - END
  pEdict->v.ideal_yaw = pEdict->v.v_angle.y;
 
  BotFixIdealYaw(pEdict);

The problem will go away ! But it was unrealistic anyway ...

Pierre-Marie Baty 04-12-2004 07:19

Re: Angle offset bug
 
It IS the problem. If you make your bot lock on the target immediately, absolutely each frame, the punch angle has no effect, neither has the weapon recoil. But since bots feature random offset variations to simulate human-like aim, this variation gets multiplied by the punch angle. Simple as that.

Rifleman 04-12-2004 10:06

Re: Angle offset bug
 
no , I just force the bot to aim at the enemy head

Code:

  Vector v_enemy = v_enemy = (pBot->pBotEnemy->v.origin + pBot->pBotEnemy->v.view_ofs) -
                                GetGunPosition(pEdict);


Pierre-Marie Baty 04-12-2004 10:59

Re: Angle offset bug
 
yes, this is just what I'm saying. So what ?

Rifleman 04-12-2004 11:16

Re: Angle offset bug
 
lol , I missed the word "punch angle" :)

And why , it only happen sometimes and always to the yaw angle ? It never happen at "x" and "z" , I dont think it is because of the punch angle

Pierre-Marie Baty 04-12-2004 13:58

Re: Angle offset bug
 
It depends on how the mod DLL implements it.

Rifleman 06-12-2004 09:37

Re: Angle offset bug
 
finally I figured it out , it is caused by the function BotFixIdealYaw()

The HPB_Bot template one is :

Code:

void BotFixIdealYaw(edict_t *pEdict)
{
  // check for wrap around of angle...
  if (pEdict->v.ideal_yaw >= 180)
          pEdict->v.ideal_yaw -= 360 * ((int) (pEdict->v.ideal_yaw / 360) + 1);
  if (pEdict->v.ideal_yaw < -180)
          pEdict->v.ideal_yaw += 360 * ((int) (-pEdict->v.ideal_yaw / 360) + 1);
}

It should rather be :

Code:

void BotFixIdealYaw(edict_t *pEdict)
{
  // check for wrap around of angle...
  if (pEdict->v.ideal_yaw > 180)
          pEdict->v.ideal_yaw -= 360;
  if (pEdict->v.ideal_yaw < -180)
          pEdict->v.ideal_yaw += 360;
}

Dont know wherever its the solution , havent test it out yet , but I think that is the solution since no other code are related to aiming and angle

Pierre-Marie Baty 06-12-2004 13:03

Re: Angle offset bug
 
No, this is NOT the cause. Are you listening to what we tell you ?????

By doing this you introduced a new bug that will make the engine crash if ever an angle greater than 540 is passed to it through BotFixIdealYaw.


All times are GMT +2. The time now is 07:21.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.