From da1b5c2ff92624a64aad19c9101852eb16e6b176 Mon Sep 17 00:00:00 2001 From: jeefo Date: Fri, 25 Mar 2016 14:56:40 +0300 Subject: [PATCH] fixed variable collisions fixed active grenade timer running too fast fixed reacting on sound function setting pvs instead of pas --- .gitignore | 2 ++ include/core.h | 2 ++ project/yapb.vcxproj | 6 ++--- source/basecode.cpp | 2 +- source/engine.cpp | 52 ++++++++++++++++++++++---------------------- source/interface.cpp | 5 +++-- source/manager.cpp | 5 +++++ 7 files changed, 42 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index 59e6f29..62c4af6 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,5 @@ project/yapb.vcxproj.user *.aps *.db *.enc +*.xml +/project/#Verone/incremental_index diff --git a/include/core.h b/include/core.h index 2b6fdfa..630e96e 100644 --- a/include/core.h +++ b/include/core.h @@ -1231,6 +1231,8 @@ private: float m_maintainTime; // time to maintain bot creation float m_quotaMaintainTime; // time to maintain bot quota + float m_grenadeUpdateTime; // time to update active grenades + int m_lastWinner; // the team who won previous round int m_balanceCount; // limit of bots to add diff --git a/project/yapb.vcxproj b/project/yapb.vcxproj index 9f08cd2..3d9d590 100644 --- a/project/yapb.vcxproj +++ b/project/yapb.vcxproj @@ -55,14 +55,14 @@ DynamicLibrary - v120_xp + v140_xp false true DynamicLibrary false - v120_xp + v140_xp @@ -187,7 +187,7 @@ ..\mmgr;..\include\engine;..\include;%(AdditionalIncludeDirectories) NDEBUG;WIN32;%(PreprocessorDefinitions) false - AdvancedVectorExtensions + StreamingSIMDExtensions2 .\release\inf\yapb.pch diff --git a/source/basecode.cpp b/source/basecode.cpp index 5acf1a3..5fe4a75 100644 --- a/source/basecode.cpp +++ b/source/basecode.cpp @@ -5910,7 +5910,7 @@ void Bot::ReactOnSound (void) if (pev->flags & FL_DUCKING) pasOrg = pasOrg + (VEC_HULL_MIN - VEC_DUCK_HULL_MIN); - byte *pas = ENGINE_SET_PVS (reinterpret_cast (&pasOrg)); + byte *pas = ENGINE_SET_PAS (reinterpret_cast (&pasOrg)); float minDistance = 99999.0f; diff --git a/source/engine.cpp b/source/engine.cpp index 83fb0f4..38ec4cc 100644 --- a/source/engine.cpp +++ b/source/engine.cpp @@ -836,14 +836,14 @@ void Engine::ProcessMessageCapture (void *ptr) // need to send congrats on well placed shot for (int i = 0; i < MaxClients (); i++) { - Bot *bot = bots.GetBot (i); + Bot *notify = bots.GetBot (i); - if (bot != NULL && bot->m_notKilled && killer != bot->GetEntity () && bot->EntityIsVisible (victim->v.origin) && GetTeam (killer) == bot->m_team && GetTeam (killer) != GetTeam (victim)) + if (notify != NULL && notify->m_notKilled && killer != notify->GetEntity () && notify->EntityIsVisible (victim->v.origin) && GetTeam (killer) == notify->m_team && GetTeam (killer) != GetTeam (victim)) { if (killer == g_hostEntity) - bot->HandleChatterMessage ("#Bot_NiceShotCommander"); + notify->HandleChatterMessage ("#Bot_NiceShotCommander"); else - bot->HandleChatterMessage ("#Bot_NiceShotPall"); + notify->HandleChatterMessage ("#Bot_NiceShotPall"); break; } @@ -853,23 +853,23 @@ void Engine::ProcessMessageCapture (void *ptr) // notice nearby to victim teammates, that attacker is near for (int i = 0; i < MaxClients (); i++) { - Bot *bot = bots.GetBot (i); + Bot *notify = bots.GetBot (i); - if (bot != NULL && bot->m_seeEnemyTime + 2.0f < Time () && bot->m_notKilled && bot->m_team == GetTeam (victim) && IsVisible (killer->v.origin, bot->GetEntity ()) && IsNullEntity (bot->m_enemy) && GetTeam (killer) != GetTeam (victim)) + if (notify != NULL && notify->m_seeEnemyTime + 2.0f < Time () && notify->m_notKilled && notify->m_team == GetTeam (victim) && IsVisible (killer->v.origin, notify->GetEntity ()) && IsNullEntity (notify->m_enemy) && GetTeam (killer) != GetTeam (victim)) { - bot->m_actualReactionTime = 0.0f; - bot->m_seeEnemyTime = Time (); - bot->m_enemy = killer; - bot->m_lastEnemy = killer; - bot->m_lastEnemyOrigin = killer->v.origin; + notify->m_actualReactionTime = 0.0f; + notify->m_seeEnemyTime = Time (); + notify->m_enemy = killer; + notify->m_lastEnemy = killer; + notify->m_lastEnemyOrigin = killer->v.origin; } } - Bot *bot = bots.GetBot (killer); + Bot *notify = bots.GetBot (killer); // is this message about a bot who killed somebody? - if (bot != NULL) - bot->m_lastVictim = victim; + if (notify != NULL) + notify->m_lastVictim = victim; else // did a human kill a bot on his team? { @@ -956,10 +956,10 @@ void Engine::ProcessMessageCapture (void *ptr) if (yb_communication_type.GetInt () == 2) { - Bot *bot = bots.FindOneValidAliveBot (); + Bot *notify = bots.FindOneValidAliveBot (); - if (bot != NULL && bot->m_notKilled) - bot->HandleChatterMessage (strVal); + if (notify != NULL && notify->m_notKilled) + notify->HandleChatterMessage (strVal); } } @@ -975,10 +975,10 @@ void Engine::ProcessMessageCapture (void *ptr) if (yb_communication_type.GetInt () == 2) { - Bot *bot = bots.FindOneValidAliveBot (); + Bot *notify = bots.FindOneValidAliveBot (); - if (bot != NULL && bot->m_notKilled) - bot->HandleChatterMessage (strVal); + if (notify != NULL && notify->m_notKilled) + notify->HandleChatterMessage (strVal); } } waypoints.SetBombPosition (true); @@ -990,15 +990,15 @@ void Engine::ProcessMessageCapture (void *ptr) for (int i = 0; i < MaxClients (); i++) { - Bot *bot = bots.GetBot (i); + Bot *notify = bots.GetBot (i); - if (bot != NULL && bot->m_notKilled) + if (notify != NULL && notify->m_notKilled) { - bot->DeleteSearchNodes (); - bot->ResetTasks (); + notify->DeleteSearchNodes (); + notify->ResetTasks (); - if (yb_communication_type.GetInt () == 2 && Random.Long (0, 100) < 75 && bot->m_team == CT) - bot->ChatterMessage (Chatter_WhereIsTheBomb); + if (yb_communication_type.GetInt () == 2 && Random.Long (0, 100) < 75 && notify->m_team == CT) + notify->ChatterMessage (Chatter_WhereIsTheBomb); } } waypoints.SetBombPosition (); diff --git a/source/interface.cpp b/source/interface.cpp index 75671b4..2911690 100644 --- a/source/interface.cpp +++ b/source/interface.cpp @@ -2257,8 +2257,9 @@ void StartFrame (void) } g_timePerSecondUpdate = engine.Time () + 1.0f; } - else if (g_timePerSecondUpdate * 0.5f < engine.Time ()) - bots.UpdateActiveGrenades (); + + // keep track of grenades on map + bots.UpdateActiveGrenades (); // keep bot number up to date bots.MaintainBotQuota (); diff --git a/source/manager.cpp b/source/manager.cpp index 131bcf9..fad393b 100644 --- a/source/manager.cpp +++ b/source/manager.cpp @@ -38,6 +38,7 @@ BotManager::BotManager (void) m_maintainTime = 0.0f; m_quotaMaintainTime = 0.0f; + m_grenadeUpdateTime = 0.0f; m_creationTab.RemoveAll (); m_killerEntity = NULL; @@ -1472,6 +1473,9 @@ void BotManager::SendDeathMsgFix (void) void BotManager::UpdateActiveGrenades (void) { + if (m_grenadeUpdateTime > engine.Time ()) + return; + edict_t *grenade = NULL; // clear previously stored grenades @@ -1486,6 +1490,7 @@ void BotManager::UpdateActiveGrenades (void) m_activeGrenades.Push (grenade); } + m_grenadeUpdateTime = 0.213f + engine.Time (); } const Array &BotManager::GetActiveGrenades (void)