.:: 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.

Rifleman 06-12-2004 16:17

Re: Angle offset bug
 
but I get that code from HPB_bot 4.0 , not the template

Pierre-Marie Baty 06-12-2004 18:11

Re: Angle offset bug
 
It's a well known bug in the HPB_bot, that needs to be fixed. But several years ago at his old forum botman said it wouldn't bother fixing it because it was mostly affecting Counter-Strike and his bot wasn't made to support Counter-Strike officially.

The correct code is the one in the template.

Rifleman 08-12-2004 17:41

Re: Angle offset bug
 
holy crap ! I fixed the offset bug , but now the problem is gettting weird ! The bot aim completely accurately at the center of their enemy , but when they fire their weapon , the bullet never hit the enemy except in very close range or when the bot is using knife ! Wow wow wow , my bot will be super-realistic ! :D

By the way , I changed the BotChangeYaw , BotChangePitch and my FaceVector function

Code:

void FaceVector ( bot_t *pBot, Vector vec )
{
  edict_t *pEdict = pBot->pEdict;
  Vector look_vec = UTIL_VecToAngles( vec ); 
  pEdict->v.ideal_yaw = look_vec.y; 
  BotFixIdealYaw(pEdict);
 
  pEdict->v.idealpitch = look_vec.x;
  BotFixIdealPitch(pEdict);
}


Pierre-Marie Baty 08-12-2004 19:28

Re: Angle offset bug
 
...which means that you did not fix anything but broke stuff instead. When you'll finally decide to listen to what people tell you, perhaps you'll make some progress.

In the meantime, please stop cluttering the HPB_bot support forum with your bot experiments.

Rifleman 09-12-2004 08:06

Re: Angle offset bug
 
sorry ...

but final question , I try to do this :

look_vec = look_vec - pEdict->v.punchangle;

Like you said one , but it still didn't work ...


All times are GMT +2. The time now is 03:41.

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