PDA

View Full Version : bots stuck ?


Whistler
31-03-2004, 13:54
Why does the two bots just get stuck INTO each other sometimes ?

I know the problem may be because the msec calculation, but Tobias' method is l33t enough I think... (my computer is an old Celeron 466MHz with 64MB RAM, but Tobias' method should work well)

And also I'm running the bot in Metamod so the GetBlendingInterface shouldn't be a problem


static float msecdel = 0;
static float msecnum = 0;

if (msecdel + msecnum / 1000 < gpGlobals->time - 0.5 ||
msecdel > gpGlobals->time)
{
msecdel = gpGlobals->time - 0.05;
msecnum = 0;
}

g_iMsecval = (gpGlobals->time - msecdel) * 1000 - msecnum; // optimal msec value since start of 1 sec period
msecnum = (gpGlobals->time - msecdel) * 1000; // value we have to add to reach optimum

// do we have to start a new 1 sec period?
if (msecnum > 1000)
{
msecdel += msecnum / 1000;
msecnum = 0;
}

if (g_iMsecval < 5)
g_iMsecval = 5; // don't allow the msec delay to be too low
else if (g_iMsecval > 255)
g_iMsecval = 255; // don't allow it to last longer than 255 milliseconds either

botman
31-03-2004, 16:33
They get stuck because their collision bounding boxes intersect each other. The same kind of stuck condition will occur if you create a map and place a player spawn point too close to world geometry.

In order to keep guys from getting stuck, you should try to make them not get near each other. When the msec value passed into pfnRunPlayerMove() is wrong, bots will move further than they should during the next frame interval. If two bots are moving directly towards each other and they both move so far that their bounding boxes intersect each other, they will become stuck together like Siamese Twins.

I have always suspected that temporarily putting one of the bots in "noclip" mode would allow you to easily get them unstuck, but I haven't actually tried this myself.

botman

Pierre-Marie Baty
01-04-2004, 01:02
The noclip cheat works well, I already tried something like this, but the problem is that with it your bot won't collide with the world either. Thus for example if your bots get stuck together while climbing a slope, putting one into noclip mode and making it move away may bury the bot into the ground rather than doing anything useful...

botman
01-04-2004, 01:26
Yes, you would need to do some UTIL_TraceHull() calls in the direction that you plan to "unstuck" the bot in before moving it that way to make sure there is room to move the bot.

You should be able to determine which of the two bots has the most empty space around it (by tracing several hulls in different directions) and picking that bot as the one to put in "noclip" mode. Then move it away from the other one (moving it upwards slightly to keep it from intersecting the ground) and putting it back into normal "non-noclip" mode.

botman