Thread: Waypointing
View Single Post
Re: Waypointing
Old
  (#62)
Ghoul
Moderator
 
Status: Offline
Posts: 56
Join Date: Jul 2004
Location: Michigan
Default Re: Waypointing - 22-01-2005

Okay, found and fixed the problem. Let me explain...

The contact evasion code used some math to determine the current direction the bot was headed. One function used was the asin function, which takes one parameter. This parameter is a float between -1 and 1. The bot inputs its current strafe speed divided by the max speed to get the value which asin takes. This all works fine normally under the correct conditions.

S&I however changes the maximum speed of players quite often. Something like switching weapons will increase or decrease the max speed. If a bot is currently on a weapon with high max speed, then switches to a weapon of low max speed, there is a fraction of a second where the bot is actually traveling faster than the max speed.

So, in the code, the obtained value will be either > 1 or < -1 (depending on the direction of travel) and that value will be passed on to asin. asin doesn't work correctly with values out of its range, and so it returns an invalid jumbled float. This value is passed on into the function (BotAvoidContact), corrupting the angular vector caluclated, and the direction vector calculated. The bad direction vector is used in an initial TraceLine function to see if anything is in the way of the bot.

The TraceLine function is where the looping begins. Apparently it is unable to correctly handle the corrupt vector, and somehow hits an infinite loop. Since the function is within the engine, there's no way to really know.

The first fix I tried was to limit the value of the variable passed into the asin function. This worked fine, as it should, but then I realized that the whole asin function itself, along with many other calculations, were pointless. I simply created a new vector in the bot called v_curr_direction. Everytime the bot calculates the direction it wishes to travel, that vector is updated with the calculated direction.

The avoid function has been updated to use this new vector, rather than performing tons of unneeded math, and all is well.

What's going to happen today? A release of 0.3 with the S&I crash fixed and hopefully the min_bot and max_bot crash fixed (along with a couple other misc adjustments). Version 0.3 will be released under the following:

- Windows standard hooking DLL
- Windows metamod DLL
- Linux standard hooking .so
- Linux metamod .so

See ya guys!

Last edited by Ghoul; 23-01-2005 at 07:44..
  
Reply With Quote