fixes clang warnings

fixed bad combat strafe dir direction selection
added more 'shoot thru wall' code as reaction on sound
This commit is contained in:
jeefo 2016-03-09 22:34:24 +03:00
commit 4b0188222f
8 changed files with 68 additions and 86 deletions

View file

@ -989,7 +989,7 @@ void Bot::InstantChatterMessage (int type)
SwitchChatterIcon (true);
// delay only reportteam
if (type == Radio_ReportTeam && m_timeRepotingInDelay < engine.Time ())
if (type == Radio_ReportTeam)
{
if (m_timeRepotingInDelay < engine.Time ())
return;
@ -2607,45 +2607,44 @@ void Bot::CheckRadioCommands (void)
case Radio_SectorClear:
// is bomb planted and it's a ct
if (g_bombPlanted)
if (!g_bombPlanted)
break;
// check if it's a ct command
if (engine.GetTeam (m_radioEntity) == CT && m_team == CT && IsValidBot (m_radioEntity) && g_timeNextBombUpdate < engine.Time ())
{
float minDistance = 99999.0f;
int bombPoint = -1;
// check if it's a ct command
if (engine.GetTeam (m_radioEntity) == CT && m_team == CT && IsValidBot (m_radioEntity) && g_timeNextBombUpdate < engine.Time ())
// find nearest bomb waypoint to player
FOR_EACH_AE (waypoints.m_goalPoints, i)
{
float minDistance = 99999.0f;
distance = (waypoints.GetPath (waypoints.m_goalPoints[i])->origin - m_radioEntity->v.origin).GetLengthSquared ();
// find nearest bomb waypoint to player
FOR_EACH_AE (waypoints.m_goalPoints, i)
if (distance < minDistance)
{
distance = (waypoints.GetPath (waypoints.m_goalPoints[i])->origin - m_radioEntity->v.origin).GetLengthSquared ();
if (distance < minDistance)
{
minDistance = distance;
bombPoint = waypoints.m_goalPoints[i];
}
minDistance = distance;
bombPoint = waypoints.m_goalPoints[i];
}
// mark this waypoint as restricted point
if (bombPoint != -1 && !waypoints.IsGoalVisited (bombPoint))
{
// does this bot want to defuse?
if (GetTaskId () == TASK_NORMAL)
{
// is he approaching this goal?
if (GetTask ()->data == bombPoint)
{
GetTask ()->data = -1;
RadioMessage (Radio_Affirmative);
}
}
waypoints.SetGoalVisited (bombPoint);
}
g_timeNextBombUpdate = engine.Time () + 0.5f;
}
// mark this waypoint as restricted point
if (bombPoint != -1 && !waypoints.IsGoalVisited (bombPoint))
{
// does this bot want to defuse?
if (GetTaskId () == TASK_NORMAL)
{
// is he approaching this goal?
if (GetTask ()->data == bombPoint)
{
GetTask ()->data = -1;
RadioMessage (Radio_Affirmative);
}
}
waypoints.SetGoalVisited (bombPoint);
}
g_timeNextBombUpdate = engine.Time () + 0.5f;
}
break;
@ -3108,7 +3107,7 @@ void Bot::RunTask_Normal (void)
}
// don't allow vip on as_ maps to camp + don't allow terrorist carrying c4 to camp
if (campingAllowed && IsPlayerVIP (GetEntity ()) || ((g_mapType & MAP_DE) && m_team == TERRORIST && !g_bombPlanted && m_hasC4))
if (campingAllowed && (IsPlayerVIP (GetEntity ()) || ((g_mapType & MAP_DE) && m_team == TERRORIST && !g_bombPlanted && m_hasC4)))
campingAllowed = false;
// check if another bot is already camping here
@ -5995,6 +5994,20 @@ void Bot::ReactOnSound (void)
m_states |= STATE_SEEING_ENEMY;
m_seeEnemyTime = engine.Time ();
}
else // check if heard enemy can be shoot through some obstacle
{
if (m_difficulty > 2 && m_lastEnemy == player && m_seeEnemyTime + 3.0 > engine.Time () && yb_shoots_thru_walls.GetBool () && IsShootableThruObstacle (player->v.origin + player->v.view_ofs))
{
m_enemy = player;
m_lastEnemy = player;
m_enemyOrigin = player->v.origin;
m_lastEnemyOrigin = player->v.origin;
m_states |= (STATE_SEEING_ENEMY | STATE_SUSPECT_ENEMY);
m_seeEnemyTime = engine.Time ();
}
}
}
}

View file

@ -1112,18 +1112,18 @@ void Bot::CombatFight (void)
m_combatStrafeDir = STRAFE_DIR_RIGHT;
if (Random.Long (1, 100) < 30)
m_combatStrafeDir == STRAFE_DIR_LEFT ? STRAFE_DIR_RIGHT : STRAFE_DIR_LEFT;
m_combatStrafeDir = (m_combatStrafeDir == STRAFE_DIR_LEFT ? STRAFE_DIR_RIGHT : STRAFE_DIR_LEFT);
m_strafeSetTime = engine.Time () + Random.Float (1.5f, 3.0f);
m_strafeSetTime = engine.Time () + Random.Float (0.5f, 3.0f);
}
if (m_combatStrafeDir == STRAFE_DIR_LEFT)
if (m_combatStrafeDir == STRAFE_DIR_RIGHT)
{
if (!CheckWallOnLeft ())
m_strafeSpeed = -pev->maxspeed;
else
{
m_combatStrafeDir == STRAFE_DIR_LEFT ? STRAFE_DIR_RIGHT : STRAFE_DIR_LEFT;
m_combatStrafeDir = STRAFE_DIR_LEFT;
m_strafeSetTime = engine.Time () + 1.5f;
}
}
@ -1133,7 +1133,7 @@ void Bot::CombatFight (void)
m_strafeSpeed = pev->maxspeed;
else
{
m_combatStrafeDir == STRAFE_DIR_LEFT ? STRAFE_DIR_RIGHT : STRAFE_DIR_LEFT;
m_combatStrafeDir = STRAFE_DIR_RIGHT;
m_strafeSetTime = engine.Time () + 1.5f;
}
}

View file

@ -1,4 +1,4 @@
//
//
// Yet Another POD-Bot, based on PODBot by Markus Klinge ("CountFloyd").
// Copyright (c) YaPB Development Team.
//
@ -2939,7 +2939,7 @@ export int Server_GetBlendingInterface (int version, void **ppinterface, void *p
return (*g_serverBlendingAPI) (version, ppinterface, pstudio, rotationmatrix, bonetransform);
}
export int Meta_Query (char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_t *pMetaUtilFuncs)
export int Meta_Query (char *, plugin_info_t **pPlugInfo, mutil_funcs_t *pMetaUtilFuncs)
{
// this function is the first function ever called by metamod in the plugin DLL. Its purpose
// is for metamod to retrieve basic information about the plugin, such as its meta-interface
@ -2951,7 +2951,7 @@ export int Meta_Query (char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_t *p
return TRUE; // tell metamod this plugin looks safe
}
export int Meta_Attach (PLUG_LOADTIME now, metamod_funcs_t *functionTable, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs)
export int Meta_Attach (PLUG_LOADTIME, metamod_funcs_t *functionTable, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs)
{
// this function is called when metamod attempts to load the plugin. Since it's the place
// where we can tell if the plugin will be allowed to run or not, we wait until here to make
@ -2965,7 +2965,7 @@ export int Meta_Attach (PLUG_LOADTIME now, metamod_funcs_t *functionTable, meta_
return TRUE; // returning true enables metamod to attach this plugin
}
export int Meta_Detach (PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
export int Meta_Detach (PLUG_LOADTIME, PL_UNLOAD_REASON)
{
// this function is called when metamod unloads the plugin. A basic check is made in order
// to prevent unloading the plugin if its processing should not be interrupted.

View file

@ -41,6 +41,7 @@ BotManager::BotManager (void)
m_creationTab.RemoveAll ();
m_killerEntity = NULL;
m_balanceCount = 0;
}
BotManager::~BotManager (void)
@ -1095,7 +1096,7 @@ void Bot::NewRound (void)
m_maxThrowTimer = 0.0f;
m_timeTeamOrder = 0.0f;
m_timeRepotingInDelay = 0.0f;
m_timeRepotingInDelay = Random.Float (40.0f, 240.0f);
m_askCheckTime = 0.0f;
m_minSpeed = 260.0f;
m_prevSpeed = 0.0f;
@ -1399,7 +1400,7 @@ void BotManager::CalculatePingOffsets (void)
void BotManager::SendPingDataOffsets (edict_t *to)
{
if ((g_gameFlags & GAME_LEGACY) || yb_latency_display.GetInt () != 2 || engine.IsNullEntity (to))
if ((g_gameFlags & GAME_LEGACY) || yb_latency_display.GetInt () != 2 || engine.IsNullEntity (to) || (to->v.flags & FL_FAKECLIENT))
return;
if (!(to->v.flags & FL_CLIENT) && !(((to->v.button & IN_SCORE) || !(to->v.oldbuttons & IN_SCORE))))
@ -1413,7 +1414,7 @@ void BotManager::SendPingDataOffsets (edict_t *to)
for (int i = 0; i < engine.MaxClients (); i++)
{
Bot *bot = GetBot (i);
Bot *bot = m_bots[i];
if (bot == NULL)
continue;

View file

@ -1,4 +1,4 @@
//
//
// Yet Another POD-Bot, based on PODBot by Markus Klinge ("CountFloyd").
// Copyright (c) YaPB Development Team.
//
@ -374,8 +374,6 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal)
// FIXME: doesn't care for ladder movement (handled separately) should be included in some way
if ((m_moveSpeed >= 10.0f || m_strafeSpeed >= 10.0f) && m_lastCollTime < engine.Time () && m_seeEnemyTime + 0.8f < engine.Time () && GetTaskId () != TASK_ATTACK)
{
bool cantMoveForward = false;
if (movedDistance < 2.0f && m_prevSpeed >= 20.0f) // didn't we move enough previously?
{
// Then consider being stuck
@ -388,7 +386,7 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal)
else // not stuck yet
{
// test if there's something ahead blocking the way
if ((cantMoveForward = CantMoveForward (dirNormal, &tr)) && !IsOnLadder ())
if (CantMoveForward (dirNormal, &tr) && !IsOnLadder ())
{
if (m_firstCollideTime == 0.0f)
m_firstCollideTime = engine.Time () + 0.2f;

View file

@ -475,7 +475,7 @@ void NetworkMsg::Execute (void *p)
if (yb_csdm_mode.GetInt () == 2)
cl.team = playerIndex;
else
cl.team = g_clients[playerIndex - 1].realTeam;
cl.team = cl.realTeam;
#endif
}
break;