diff --git a/include/corelib.h b/include/corelib.h index badce0f..dbfb4c5 100644 --- a/include/corelib.h +++ b/include/corelib.h @@ -3488,23 +3488,6 @@ public: return fgets (buffer, count, m_handle); } - // - // Function: GetBuffer - // Gets the line from file stream, and stores it inside string class. - // - // Parameters: - // buffer - String buffer, that should receive line. - // count - Max. size of buffer. - // - // Returns: - // True if operation succeeded, false otherwise. - // - bool GetBuffer (String &buffer, int count) - { - assert (m_handle != NULL); - return !String (fgets (buffer, count, m_handle)).IsEmpty (); - } - // // Function: Printf // Puts formatted buffer, into stream. @@ -3834,7 +3817,10 @@ public: return NULL; int lineStartOffset = m_filePos; - int lineEndOffset = (m_fileSize - m_filePos > count - 1) ? (lineEndOffset = m_filePos + count - 1) : lineEndOffset = m_fileSize - 1; + int lineEndOffset = m_fileSize - 1; + + if (m_fileSize - m_filePos > count - 1) + lineEndOffset = m_filePos + count - 1; while (m_filePos < lineEndOffset) { @@ -3866,22 +3852,6 @@ public: return buffer; } - // - // Function: GetBuffer - // Gets the line from file stream, and stores it inside string class. - // - // Parameters: - // buffer - String buffer, that should receive line. - // count - Max. size of buffer. - // - // Returns: - // True if operation succeeded, false otherwise. - // - bool GetBuffer (String &buffer, int count) - { - return !String (GetBuffer (buffer, count)).IsEmpty (); - } - // // Function: Read // Reads buffer from file stream in binary format. diff --git a/include/engine/extdll.h b/include/engine/extdll.h index e5e086e..450ec1b 100644 --- a/include/engine/extdll.h +++ b/include/engine/extdll.h @@ -20,7 +20,7 @@ #define DEBUG 1 #endif -#ifdef _WIN32 +#ifdef _MSC_VER #pragma warning (disable : 4244) // int or float down-conversion #pragma warning (disable : 4305) // int or float data truncation #pragma warning (disable : 4201) // nameless struct/union @@ -31,7 +31,7 @@ #pragma warning (disable : 4702) // unreachable code #pragma warning (disable : 4706) // assignment within conditional expression - /* (dz): disable deprecation warnings concerning unsafe CRT functions */ + /* disable deprecation warnings concerning unsafe CRT functions */ #if !defined _CRT_SECURE_NO_DEPRECATE #define _CRT_SECURE_NO_DEPRECATE #endif diff --git a/source/basecode.cpp b/source/basecode.cpp index 6a5e15e..7d46a97 100644 --- a/source/basecode.cpp +++ b/source/basecode.cpp @@ -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 (); + + } + } } } diff --git a/source/combat.cpp b/source/combat.cpp index c1ee1ed..4b3335d 100644 --- a/source/combat.cpp +++ b/source/combat.cpp @@ -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; } } diff --git a/source/interface.cpp b/source/interface.cpp index 38fd6a8..7ac643f 100644 --- a/source/interface.cpp +++ b/source/interface.cpp @@ -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. diff --git a/source/manager.cpp b/source/manager.cpp index 32e713c..5959458 100644 --- a/source/manager.cpp +++ b/source/manager.cpp @@ -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; diff --git a/source/navigate.cpp b/source/navigate.cpp index c039be8..a1ed225 100644 --- a/source/navigate.cpp +++ b/source/navigate.cpp @@ -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; diff --git a/source/netmsg.cpp b/source/netmsg.cpp index 1c6bcb2..63b3b2f 100644 --- a/source/netmsg.cpp +++ b/source/netmsg.cpp @@ -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;