.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   Where to put it ??? (http://forums.bots-united.com/showthread.php?t=816)

slash-evil 20-02-2004 03:43

Where to put it ???
 
//STEVE: instantly adjust aim if reticle near enemy target
if(pBot->STEVE_fire_pattern==1 && (pBot->pBotEnemy != NULL) &&pBot->iAimFlags & AIM_ENEMY)
{
pBot->vecEnemy= BotBodyTarget( pBot->pBotEnemy, pBot);

//old aiming algorithm
Vector vecDirection;
vecDirection = UTIL_VecToAngles(pBot->vecEnemy - GetGunPosition(pBot->pEdict));
vecDirection = vecDirection - pBot->pEdict->v.punchangle;
vecDirection.x = -vecDirection.x;

//new aiming algorithm
Vector vecDirection2;
float hypotenuse = (pBot->vecEnemy - GetGunPosition(pBot->pEdict)).Length();
float opposite = (pBot->vecEnemy.z - GetGunPosition(pBot->pEdict).z);
//arcsin (opposite / hypotenuse)
vecDirection2.x = (180/M_PI) * asin(opposite / hypotenuse);

opposite = (pBot->vecEnemy.y - GetGunPosition(pBot->pEdict).y);
float adjacent = (pBot->vecEnemy.x - GetGunPosition(pBot->pEdict).x);
//arctan (y/x)?
vecDirection2.y = (180/M_PI) * atan(opposite / adjacent);
//hypotenuse not used
// (pBot->vecEnemy - GetGunPosition(pBot->pEdict)).Length2D

float flDot = GetShootingConeDeviation(pBot->pEdict,&pBot->vecEnemy);
if(flDot > 0.90)
{
pBot->pEdict->v.ideal_yaw = vecDirection2.y;
pBot->pEdict->v.idealpitch = vecDirection2.x;
pEdict->v.v_angle.y = pEdict->v.ideal_yaw;
pEdict->v.v_angle.x = pEdict->v.idealpitch;
}
if (vecDirection2 != vecDirection)
SERVER_COMMAND("Old and new aiming algorith disagree!");
}

I found this code at the nuclearbox forum by steve++ , I wonder where I have to put it ?

slash-evil 20-02-2004 03:51

Re: Where to put it ???
 
I think I found one more bugs in my code , but I don't know which part of the code is the problem , so I explain it here : when I start a lan game , I have to wait about 20-30 seconds before I can add a bot , if I add a bot when I just get into the game , the game will crash

@$3.1415rin 20-02-2004 10:47

Re: Where to put it ???
 
you cannot search for bugs without understanding what the code actually does. so my advice is to read the sources carefully and then start debugging it. the other way around won't work :)

Pierre-Marie Baty 20-02-2004 14:09

Re: Where to put it ???
 
@slash-evil: the 2nd bug you're talking about is a well-known bug in the HL engine. Creating a fakeclient (a bot) triggers the sending of a lot of network messages. If you attempt to create several of them during the same frame time, the engine will eventually hit its maximal buffer size for network messages about to be sent, and hence crash. It is safe to wait at least 0.5 second between each creation of a bot.


All times are GMT +2. The time now is 08:25.

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