fixed variable collisions

fixed active grenade timer running too fast
fixed reacting on sound function setting pvs instead of pas
This commit is contained in:
jeefo 2016-03-25 14:56:40 +03:00
commit da1b5c2ff9
7 changed files with 42 additions and 32 deletions

2
.gitignore vendored
View file

@ -59,3 +59,5 @@ project/yapb.vcxproj.user
*.aps *.aps
*.db *.db
*.enc *.enc
*.xml
/project/#Verone/incremental_index

View file

@ -1231,6 +1231,8 @@ private:
float m_maintainTime; // time to maintain bot creation float m_maintainTime; // time to maintain bot creation
float m_quotaMaintainTime; // time to maintain bot quota 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_lastWinner; // the team who won previous round
int m_balanceCount; // limit of bots to add int m_balanceCount; // limit of bots to add

View file

@ -55,14 +55,14 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v120_xp</PlatformToolset> <PlatformToolset>v140_xp</PlatformToolset>
<UseOfMfc>false</UseOfMfc> <UseOfMfc>false</UseOfMfc>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc> <UseOfMfc>false</UseOfMfc>
<PlatformToolset>v120_xp</PlatformToolset> <PlatformToolset>v140_xp</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">
@ -187,7 +187,7 @@
<AdditionalIncludeDirectories>..\mmgr;..\include\engine;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\mmgr;..\include\engine;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NDEBUG;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>false</ExceptionHandling> <ExceptionHandling>false</ExceptionHandling>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet> <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<PrecompiledHeaderFile> <PrecompiledHeaderFile>
</PrecompiledHeaderFile> </PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>.\release\inf\yapb.pch</PrecompiledHeaderOutputFile> <PrecompiledHeaderOutputFile>.\release\inf\yapb.pch</PrecompiledHeaderOutputFile>

View file

@ -5910,7 +5910,7 @@ void Bot::ReactOnSound (void)
if (pev->flags & FL_DUCKING) if (pev->flags & FL_DUCKING)
pasOrg = pasOrg + (VEC_HULL_MIN - VEC_DUCK_HULL_MIN); pasOrg = pasOrg + (VEC_HULL_MIN - VEC_DUCK_HULL_MIN);
byte *pas = ENGINE_SET_PVS (reinterpret_cast <float *> (&pasOrg)); byte *pas = ENGINE_SET_PAS (reinterpret_cast <float *> (&pasOrg));
float minDistance = 99999.0f; float minDistance = 99999.0f;

View file

@ -836,14 +836,14 @@ void Engine::ProcessMessageCapture (void *ptr)
// need to send congrats on well placed shot // need to send congrats on well placed shot
for (int i = 0; i < MaxClients (); i++) 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) if (killer == g_hostEntity)
bot->HandleChatterMessage ("#Bot_NiceShotCommander"); notify->HandleChatterMessage ("#Bot_NiceShotCommander");
else else
bot->HandleChatterMessage ("#Bot_NiceShotPall"); notify->HandleChatterMessage ("#Bot_NiceShotPall");
break; break;
} }
@ -853,23 +853,23 @@ void Engine::ProcessMessageCapture (void *ptr)
// notice nearby to victim teammates, that attacker is near // notice nearby to victim teammates, that attacker is near
for (int i = 0; i < MaxClients (); i++) 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; notify->m_actualReactionTime = 0.0f;
bot->m_seeEnemyTime = Time (); notify->m_seeEnemyTime = Time ();
bot->m_enemy = killer; notify->m_enemy = killer;
bot->m_lastEnemy = killer; notify->m_lastEnemy = killer;
bot->m_lastEnemyOrigin = killer->v.origin; 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? // is this message about a bot who killed somebody?
if (bot != NULL) if (notify != NULL)
bot->m_lastVictim = victim; notify->m_lastVictim = victim;
else // did a human kill a bot on his team? 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) if (yb_communication_type.GetInt () == 2)
{ {
Bot *bot = bots.FindOneValidAliveBot (); Bot *notify = bots.FindOneValidAliveBot ();
if (bot != NULL && bot->m_notKilled) if (notify != NULL && notify->m_notKilled)
bot->HandleChatterMessage (strVal); notify->HandleChatterMessage (strVal);
} }
} }
@ -975,10 +975,10 @@ void Engine::ProcessMessageCapture (void *ptr)
if (yb_communication_type.GetInt () == 2) if (yb_communication_type.GetInt () == 2)
{ {
Bot *bot = bots.FindOneValidAliveBot (); Bot *notify = bots.FindOneValidAliveBot ();
if (bot != NULL && bot->m_notKilled) if (notify != NULL && notify->m_notKilled)
bot->HandleChatterMessage (strVal); notify->HandleChatterMessage (strVal);
} }
} }
waypoints.SetBombPosition (true); waypoints.SetBombPosition (true);
@ -990,15 +990,15 @@ void Engine::ProcessMessageCapture (void *ptr)
for (int i = 0; i < MaxClients (); i++) 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 (); notify->DeleteSearchNodes ();
bot->ResetTasks (); notify->ResetTasks ();
if (yb_communication_type.GetInt () == 2 && Random.Long (0, 100) < 75 && bot->m_team == CT) if (yb_communication_type.GetInt () == 2 && Random.Long (0, 100) < 75 && notify->m_team == CT)
bot->ChatterMessage (Chatter_WhereIsTheBomb); notify->ChatterMessage (Chatter_WhereIsTheBomb);
} }
} }
waypoints.SetBombPosition (); waypoints.SetBombPosition ();

View file

@ -2257,8 +2257,9 @@ void StartFrame (void)
} }
g_timePerSecondUpdate = engine.Time () + 1.0f; 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 // keep bot number up to date
bots.MaintainBotQuota (); bots.MaintainBotQuota ();

View file

@ -38,6 +38,7 @@ BotManager::BotManager (void)
m_maintainTime = 0.0f; m_maintainTime = 0.0f;
m_quotaMaintainTime = 0.0f; m_quotaMaintainTime = 0.0f;
m_grenadeUpdateTime = 0.0f;
m_creationTab.RemoveAll (); m_creationTab.RemoveAll ();
m_killerEntity = NULL; m_killerEntity = NULL;
@ -1472,6 +1473,9 @@ void BotManager::SendDeathMsgFix (void)
void BotManager::UpdateActiveGrenades (void) void BotManager::UpdateActiveGrenades (void)
{ {
if (m_grenadeUpdateTime > engine.Time ())
return;
edict_t *grenade = NULL; edict_t *grenade = NULL;
// clear previously stored grenades // clear previously stored grenades
@ -1486,6 +1490,7 @@ void BotManager::UpdateActiveGrenades (void)
m_activeGrenades.Push (grenade); m_activeGrenades.Push (grenade);
} }
m_grenadeUpdateTime = 0.213f + engine.Time ();
} }
const Array <edict_t *> &BotManager::GetActiveGrenades (void) const Array <edict_t *> &BotManager::GetActiveGrenades (void)