fixed crash in lift usage
optimized walkspeed function
This commit is contained in:
parent
ad6db4109b
commit
60e4802640
3 changed files with 61 additions and 16 deletions
|
|
@ -1037,7 +1037,7 @@ private:
|
||||||
inline bool IsOnFloor (void) { return (pev->flags & (FL_ONGROUND | FL_PARTIALGROUND)) != 0; }
|
inline bool IsOnFloor (void) { return (pev->flags & (FL_ONGROUND | FL_PARTIALGROUND)) != 0; }
|
||||||
inline bool IsInWater (void) { return pev->waterlevel >= 2; }
|
inline bool IsInWater (void) { return pev->waterlevel >= 2; }
|
||||||
|
|
||||||
inline float GetWalkSpeed (void) { return static_cast <float> ((static_cast <int> (pev->maxspeed) * 0.5) + (static_cast <int> (pev->maxspeed) / 50)) - 18; }
|
float GetWalkSpeed (void);
|
||||||
|
|
||||||
bool ItemIsVisible (const Vector &dest, char *itemName);
|
bool ItemIsVisible (const Vector &dest, char *itemName);
|
||||||
bool LastEnemyShootable (void);
|
bool LastEnemyShootable (void);
|
||||||
|
|
|
||||||
|
|
@ -3392,7 +3392,7 @@ void Bot::RunTask (void)
|
||||||
m_moveSpeed = m_minSpeed;
|
m_moveSpeed = m_minSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((yb_walking_allowed.GetBool () && mp_footsteps.GetBool ()) && m_difficulty >= 2 && !(m_aimFlags & AIM_ENEMY) && (m_heardSoundTime + 13.0 >= GetWorldTime () || (m_states & (STATE_HEARING_ENEMY | STATE_SUSPECT_ENEMY))) && GetNearbyEnemiesNearPosition (pev->origin, 1024) >= 1 && !(m_currentTravelFlags & PATHFLAG_JUMP) && !(pev->button & IN_DUCK) && !(pev->flags & FL_DUCKING) && !yb_jasonmode.GetBool () && !g_bombPlanted)
|
if ((yb_walking_allowed.GetBool () && mp_footsteps.GetBool ()) && m_difficulty >= 2 && !(m_aimFlags & AIM_ENEMY) && (m_heardSoundTime + 13.0 >= GetWorldTime () || (m_states & (STATE_HEARING_ENEMY | STATE_SUSPECT_ENEMY))) && GetNearbyEnemiesNearPosition (pev->origin, 1024) >= 1 && !yb_jasonmode.GetBool () && !g_bombPlanted)
|
||||||
m_moveSpeed = GetWalkSpeed ();
|
m_moveSpeed = GetWalkSpeed ();
|
||||||
|
|
||||||
// bot hasn't seen anything in a long time and is asking his teammates to report in
|
// bot hasn't seen anything in a long time and is asking his teammates to report in
|
||||||
|
|
@ -3508,7 +3508,7 @@ void Bot::RunTask (void)
|
||||||
pev->button |= IN_DUCK;
|
pev->button |= IN_DUCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((m_lastEnemyOrigin - pev->origin).GetLength () < 512.0 && !(pev->flags & FL_DUCKING))
|
if ((m_lastEnemyOrigin - pev->origin).GetLength () < 512.0)
|
||||||
m_moveSpeed = GetWalkSpeed ();
|
m_moveSpeed = GetWalkSpeed ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -6136,3 +6136,11 @@ bool Bot::IsBombDefusing (const Vector &bombOrigin)
|
||||||
}
|
}
|
||||||
return defusingInProgress;
|
return defusingInProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float Bot::GetWalkSpeed (void)
|
||||||
|
{
|
||||||
|
if ((pev->flags & FL_DUCKING) || (pev->button & IN_DUCK) || (pev->oldbuttons & IN_DUCK) || (m_currentTravelFlags & PATHFLAG_JUMP) || (m_currentPath != NULL && m_currentPath->flags & FLAG_LADDER) || IsOnLadder () || IsInWater ())
|
||||||
|
return pev->maxspeed;
|
||||||
|
|
||||||
|
return static_cast <float> ((static_cast <int> (pev->maxspeed) * 0.5f) + (static_cast <int> (pev->maxspeed) / 50.0f)) - 18.0f;
|
||||||
|
}
|
||||||
|
|
@ -313,6 +313,8 @@ void Bot::ResetCollideState (void)
|
||||||
m_collisionState = COLLISION_NOTDECICED;
|
m_collisionState = COLLISION_NOTDECICED;
|
||||||
m_collStateIndex = 0;
|
m_collStateIndex = 0;
|
||||||
|
|
||||||
|
m_isStuck = false;
|
||||||
|
|
||||||
for (int i = 0; i < MAX_COLLIDE_MOVES; i++)
|
for (int i = 0; i < MAX_COLLIDE_MOVES; i++)
|
||||||
m_collideMoves[i] = 0;
|
m_collideMoves[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -732,6 +734,7 @@ bool Bot::DoWaypointNav (void)
|
||||||
// special lift handling (code merged from podbotmm)
|
// special lift handling (code merged from podbotmm)
|
||||||
if (m_currentPath->flags & FLAG_LIFT)
|
if (m_currentPath->flags & FLAG_LIFT)
|
||||||
{
|
{
|
||||||
|
|
||||||
bool liftClosedDoorExists = false;
|
bool liftClosedDoorExists = false;
|
||||||
|
|
||||||
// update waypoint time set
|
// update waypoint time set
|
||||||
|
|
@ -796,8 +799,13 @@ bool Bot::DoWaypointNav (void)
|
||||||
// check if we enough to destination
|
// check if we enough to destination
|
||||||
if ((pev->origin - m_destOrigin).GetLengthSquared () < 225)
|
if ((pev->origin - m_destOrigin).GetLengthSquared () < 225)
|
||||||
{
|
{
|
||||||
m_moveSpeed = 0.0;
|
m_moveSpeed = 0.0f;
|
||||||
m_strafeSpeed = 0.0;
|
m_strafeSpeed = 0.0f;
|
||||||
|
|
||||||
|
m_navTimeset = GetWorldTime ();
|
||||||
|
m_aimFlags |= AIM_NAVPOINT;
|
||||||
|
|
||||||
|
ResetCollideState ();
|
||||||
|
|
||||||
// need to wait our following teammate ?
|
// need to wait our following teammate ?
|
||||||
bool needWaitForTeammate = false;
|
bool needWaitForTeammate = false;
|
||||||
|
|
@ -866,8 +874,13 @@ bool Bot::DoWaypointNav (void)
|
||||||
|
|
||||||
if ((pev->origin - m_destOrigin).GetLengthSquared () < 225)
|
if ((pev->origin - m_destOrigin).GetLengthSquared () < 225)
|
||||||
{
|
{
|
||||||
m_moveSpeed = 0.0;
|
m_moveSpeed = 0.0f;
|
||||||
m_strafeSpeed = 0.0;
|
m_strafeSpeed = 0.0f;
|
||||||
|
|
||||||
|
m_navTimeset = GetWorldTime ();
|
||||||
|
m_aimFlags |= AIM_NAVPOINT;
|
||||||
|
|
||||||
|
ResetCollideState ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -904,8 +917,13 @@ bool Bot::DoWaypointNav (void)
|
||||||
|
|
||||||
if ((pev->origin - m_destOrigin).GetLengthSquared () < 225)
|
if ((pev->origin - m_destOrigin).GetLengthSquared () < 225)
|
||||||
{
|
{
|
||||||
m_moveSpeed = 0.0;
|
m_moveSpeed = 0.0f;
|
||||||
m_strafeSpeed = 0.0;
|
m_strafeSpeed = 0.0f;
|
||||||
|
|
||||||
|
m_navTimeset = GetWorldTime ();
|
||||||
|
m_aimFlags |= AIM_NAVPOINT;
|
||||||
|
|
||||||
|
ResetCollideState ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -917,8 +935,13 @@ bool Bot::DoWaypointNav (void)
|
||||||
|
|
||||||
if ((pev->origin - m_destOrigin).GetLengthSquared () < 225)
|
if ((pev->origin - m_destOrigin).GetLengthSquared () < 225)
|
||||||
{
|
{
|
||||||
m_moveSpeed = 0.0;
|
m_moveSpeed = 0.0f;
|
||||||
m_strafeSpeed = 0.0;
|
m_strafeSpeed = 0.0f;
|
||||||
|
|
||||||
|
m_navTimeset = GetWorldTime ();
|
||||||
|
m_aimFlags |= AIM_NAVPOINT;
|
||||||
|
|
||||||
|
ResetCollideState ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -936,11 +959,16 @@ bool Bot::DoWaypointNav (void)
|
||||||
|
|
||||||
if ((pev->origin - m_destOrigin).GetLengthSquared () < 225)
|
if ((pev->origin - m_destOrigin).GetLengthSquared () < 225)
|
||||||
{
|
{
|
||||||
m_moveSpeed = 0.0;
|
m_moveSpeed = 0.0f;
|
||||||
m_strafeSpeed = 0.0;
|
m_strafeSpeed = 0.0f;
|
||||||
|
|
||||||
|
m_navTimeset = GetWorldTime ();
|
||||||
|
m_aimFlags |= AIM_NAVPOINT;
|
||||||
|
|
||||||
|
ResetCollideState ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (!IsEntityNull(m_liftEntity))
|
||||||
{
|
{
|
||||||
edict_t *button = FindNearestButton (STRING (m_liftEntity->v.targetname));
|
edict_t *button = FindNearestButton (STRING (m_liftEntity->v.targetname));
|
||||||
|
|
||||||
|
|
@ -1008,8 +1036,13 @@ bool Bot::DoWaypointNav (void)
|
||||||
|
|
||||||
if ((pev->origin - m_destOrigin).GetLengthSquared () < 100)
|
if ((pev->origin - m_destOrigin).GetLengthSquared () < 100)
|
||||||
{
|
{
|
||||||
m_moveSpeed = 0.0;
|
m_moveSpeed = 0.0f;
|
||||||
m_strafeSpeed = 0.0;
|
m_strafeSpeed = 0.0f;
|
||||||
|
|
||||||
|
m_navTimeset = GetWorldTime ();
|
||||||
|
m_aimFlags |= AIM_NAVPOINT;
|
||||||
|
|
||||||
|
ResetCollideState ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1851,7 +1884,11 @@ bool Bot::FindWaypoint (void)
|
||||||
for (i = 0; i < g_numWaypoints; i++)
|
for (i = 0; i < g_numWaypoints; i++)
|
||||||
{
|
{
|
||||||
// ignore current waypoint and previous recent waypoints...
|
// ignore current waypoint and previous recent waypoints...
|
||||||
|
#if 0
|
||||||
if (i == m_currentWaypointIndex || i == m_prevWptIndex[0] || i == m_prevWptIndex[1] || i == m_prevWptIndex[2] || i == m_prevWptIndex[3] || i == m_prevWptIndex[4])
|
if (i == m_currentWaypointIndex || i == m_prevWptIndex[0] || i == m_prevWptIndex[1] || i == m_prevWptIndex[2] || i == m_prevWptIndex[3] || i == m_prevWptIndex[4])
|
||||||
|
#else
|
||||||
|
if (i == m_currentWaypointIndex)
|
||||||
|
#endif
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((g_mapType & MAP_CS) && HasHostage () && (g_waypoint->GetPath (i)->flags & FLAG_NOHOSTAGE))
|
if ((g_mapType & MAP_CS) && HasHostage () && (g_waypoint->GetPath (i)->flags & FLAG_NOHOSTAGE))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue