allow bots to crouch

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@7339 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lucas GAUTHERON
2013-03-10 15:52:30 +00:00
parent 5239106e66
commit ad2aa69d2d
3 changed files with 24 additions and 4 deletions
+1
View File
@@ -255,6 +255,7 @@ public:
void MainAI(void);
bool CheckStuck(void);
bool CheckJump(void);
bool CheckCrouch(void);
bool CheckStrafe(void);
void CheckFOV(void);
bool IsVisible(const vec &o, bool CheckPlayers = false) { return ::IsVisible(m_pMyEnt->o, o,
+21 -2
View File
@@ -778,6 +778,10 @@ void CBot::MainAI()
// Default bots won't strafe
m_pMyEnt->strafe = 0;
// Whatever the bot is doing, check for needed crouch
if(CheckCrouch()) m_pMyEnt->trycrouch = true;
else m_pMyEnt->trycrouch = false;
if (!BotManager.BotsShoot() && m_pMyEnt->enemy)
m_pMyEnt->enemy = NULL; // Clear enemy when bots may not shoot
@@ -1244,7 +1248,7 @@ void CBot::DoCombatNav()
bool CBot::CheckStuck()
{
if (m_iStuckCheckDelay >= lastmillis)
if (m_iStuckCheckDelay + (CheckCrouch() ? 2000 : 0) >= lastmillis)
return false;
if ((m_vGoal!=g_vecZero) && (GetDistance(m_vGoal) < 2.0f))
@@ -1403,10 +1407,25 @@ bool CBot::CheckJump()
return true;
}
}
return false; // Bot didn't had to jump(or couldn't)
}
bool CBot::CheckCrouch()
{
bool bHasGoal = m_vGoal!=g_vecZero;
float flGoalDist = (bHasGoal) ? GetDistance(m_vGoal) : 0.0f;
vec start = m_pMyEnt->o;
vec crouch = vec(0, 0, 2.0f);
float flTraceDist = 3.0f;
if (bHasGoal && (flGoalDist < flTraceDist))
flTraceDist = flGoalDist;
if (!IsVisible(vec(start).add(crouch), FORWARD, flTraceDist, false) && IsVisible(vec(start).sub(crouch), FORWARD, flTraceDist, false)) return true;
return false;
}
bool CBot::CheckStrafe()
{
if (m_iStrafeTime >= lastmillis)
+2 -2
View File
@@ -648,10 +648,10 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime)
}
// apply volume-resize when crouching
if(pl->type==ENT_PLAYER)
if(pl->type==ENT_PLAYER || pl->type==ENT_BOT)
{
// if(pl==player1 && !(intermission || player1->onladder || (pl->trycrouch && !player1->onfloor && player1->timeinair > 50))) updatecrouch(player1, player1->trycrouch);
if(pl==player1 && !intermission) updatecrouch(player1, player1->trycrouch);
if(!intermission) updatecrouch((playerent *)pl, pl->trycrouch);
const float croucheyeheight = pl->maxeyeheight*3.0f/4.0f;
resizephysent(pl, moveres, curtime, croucheyeheight, pl->maxeyeheight);
}