reduced lag, when killing bots all together
a little housekeeping
This commit is contained in:
parent
b159d3c7f9
commit
533cd8a93c
5 changed files with 63 additions and 43 deletions
|
|
@ -1242,10 +1242,10 @@ public:
|
|||
inline Vector EyePosition (void) { return pev->origin + pev->view_ofs; };
|
||||
|
||||
// the main function that decides intervals of running bot ai
|
||||
void ThinkMain (void);
|
||||
void Think (void);
|
||||
|
||||
/// the things that can be executed while skipping frames
|
||||
void Think (void);
|
||||
void ThinkDelayed (void);
|
||||
|
||||
void NewRound (void);
|
||||
void EquipInBuyzone (int buyCount);
|
||||
|
|
@ -1319,6 +1319,7 @@ private:
|
|||
|
||||
// holds currently active grenades in the map
|
||||
Array <entity_t> m_activeGrenades;
|
||||
edict_t *m_killerEntity; // killer entity for bots
|
||||
|
||||
protected:
|
||||
int CreateBot (const String &name, int difficulty, int personality, int team, int member);
|
||||
|
|
@ -1346,6 +1347,10 @@ public:
|
|||
void Think (void);
|
||||
void PeriodicThink (void);
|
||||
|
||||
void CreateKillerEntity (void);
|
||||
void DestroyKillerEntity (void);
|
||||
void TouchWithKillerEntity (Bot *bot);
|
||||
|
||||
void Free (void);
|
||||
void Free (int index);
|
||||
void CheckAutoVacate (void);
|
||||
|
|
|
|||
|
|
@ -182,16 +182,13 @@
|
|||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>false</OmitFramePointers>
|
||||
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
|
||||
<AdditionalIncludeDirectories>..\mmgr;..\include\engine;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>NDEBUG;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<StructMemberAlignment>16Bytes</StructMemberAlignment>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
|
|
@ -205,7 +202,6 @@
|
|||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<CompileAs>CompileAsCpp</CompileAs>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<InterproceduralOptimization>SingleFile</InterproceduralOptimization>
|
||||
<FlushDenormalResultsToZero>true</FlushDenormalResultsToZero>
|
||||
<Parallelization>false</Parallelization>
|
||||
|
|
@ -215,6 +211,7 @@
|
|||
<UseProcessorExtensions>AVXI</UseProcessorExtensions>
|
||||
<DisableLanguageExtensions>false</DisableLanguageExtensions>
|
||||
<ForceConformanceInForLoopScope>false</ForceConformanceInForLoopScope>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
|
|
|||
|
|
@ -2869,12 +2869,12 @@ void Bot::ChooseAimDirection (void)
|
|||
m_lookAt = m_destOrigin;
|
||||
}
|
||||
|
||||
void Bot::ThinkMain (void)
|
||||
void Bot::Think (void)
|
||||
{
|
||||
if (m_thinkFps <= GetWorldTime ())
|
||||
{
|
||||
// execute delayed think
|
||||
Think ();
|
||||
ThinkDelayed ();
|
||||
|
||||
// skip some frames
|
||||
m_thinkFps = GetWorldTime () + m_thinkInterval;
|
||||
|
|
@ -2883,7 +2883,7 @@ void Bot::ThinkMain (void)
|
|||
UpdateLookAngles ();
|
||||
}
|
||||
|
||||
void Bot::Think (void)
|
||||
void Bot::ThinkDelayed (void)
|
||||
{
|
||||
pev->button = 0;
|
||||
pev->flags |= FL_FAKECLIENT; // restore fake client bit, if it were removed by some evil action =)
|
||||
|
|
@ -2907,7 +2907,7 @@ void Bot::Think (void)
|
|||
else if (!m_notKilled)
|
||||
{
|
||||
// no movement allowed in
|
||||
if (m_voteKickIndex != m_lastVoteKick && yb_tkpunish.GetBool ()) // We got a Teamkiller? Vote him away...
|
||||
if (m_voteKickIndex != m_lastVoteKick && yb_tkpunish.GetBool ()) // we got a teamkiller? vote him away...
|
||||
{
|
||||
FakeClientCommand (GetEntity (), "vote %d", m_voteKickIndex);
|
||||
m_lastVoteKick = m_voteKickIndex;
|
||||
|
|
@ -2961,7 +2961,7 @@ void Bot::Think (void)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (m_buyingFinished)
|
||||
else if (m_notKilled && m_buyingFinished && !(pev->maxspeed < 10 && GetTaskId () != TASK_PLANTBOMB && GetTaskId () != TASK_DEFUSEBOMB) && !yb_freeze_bots.GetBool ())
|
||||
botMovement = true;
|
||||
|
||||
CheckMessageQueue (); // check for pending messages
|
||||
|
|
@ -2970,10 +2970,7 @@ void Bot::Think (void)
|
|||
if (g_lastRadioTime[g_clients[IndexOfEntity (GetEntity ()) - 1].realTeam] + Random.Float (0.8f, 2.1f) < GetWorldTime ())
|
||||
SwitchChatterIcon (false); // hide icon
|
||||
|
||||
if (pev->maxspeed < 10 && GetTaskId () != TASK_PLANTBOMB && GetTaskId () != TASK_DEFUSEBOMB)
|
||||
botMovement = false;
|
||||
|
||||
if (m_notKilled && botMovement && !yb_freeze_bots.GetBool ())
|
||||
if (botMovement)
|
||||
BotAI (); // execute main code
|
||||
|
||||
RunPlayerMovement (); // run the player movement
|
||||
|
|
|
|||
|
|
@ -2055,6 +2055,9 @@ void ServerActivate (edict_t *pentEdictList, int edictCount, int clientMax)
|
|||
waypoints.Init ();
|
||||
waypoints.Load ();
|
||||
|
||||
// create global killer entity
|
||||
bots.CreateKillerEntity ();
|
||||
|
||||
// execute main config
|
||||
ServerCommand ("exec addons/yapb/conf/yapb.cfg");
|
||||
|
||||
|
|
@ -2089,6 +2092,9 @@ void ServerDeactivate (void)
|
|||
waypoints.SaveExperienceTab ();
|
||||
waypoints.SaveVisibilityTab ();
|
||||
|
||||
// destroy global killer entity
|
||||
bots.DestroyKillerEntity ();
|
||||
|
||||
FreeLibraryMemory ();
|
||||
|
||||
if (g_isMetamod)
|
||||
|
|
|
|||
|
|
@ -43,10 +43,50 @@ BotManager::BotManager (void)
|
|||
BotManager::~BotManager (void)
|
||||
{
|
||||
// this is a bot manager class destructor, do not use GetMaxClients () here !!
|
||||
|
||||
Free ();
|
||||
}
|
||||
|
||||
void BotManager::CreateKillerEntity (void)
|
||||
{
|
||||
// this function creates single trigger_hurt for using in Bot::Kill, to reduce lags, when killing all the bots
|
||||
|
||||
m_killerEntity = g_engfuncs.pfnCreateNamedEntity (MAKE_STRING ("trigger_hurt"));
|
||||
|
||||
m_killerEntity->v.dmg = 9999.0f;
|
||||
m_killerEntity->v.dmg_take = 1.0f;
|
||||
m_killerEntity->v.dmgtime = 2.0f;
|
||||
m_killerEntity->v.effects |= EF_NODRAW;
|
||||
|
||||
g_engfuncs.pfnSetOrigin (m_killerEntity, Vector (-99999.0f, -99999.0f, -99999.0f));
|
||||
MDLL_Spawn (m_killerEntity);
|
||||
}
|
||||
|
||||
void BotManager::DestroyKillerEntity (void)
|
||||
{
|
||||
if (!IsEntityNull (m_killerEntity))
|
||||
g_engfuncs.pfnRemoveEntity (m_killerEntity);
|
||||
}
|
||||
|
||||
void BotManager::TouchWithKillerEntity (Bot *bot)
|
||||
{
|
||||
if (IsEntityNull (m_killerEntity))
|
||||
{
|
||||
MDLL_ClientKill (bot->GetEntity ());
|
||||
return;
|
||||
}
|
||||
m_killerEntity->v.classname = MAKE_STRING (g_weaponDefs[bot->m_currentWeapon].className);
|
||||
m_killerEntity->v.dmg_inflictor = bot->GetEntity ();
|
||||
|
||||
KeyValueData kv;
|
||||
kv.szClassName = const_cast <char *> (g_weaponDefs[bot->m_currentWeapon].className);
|
||||
kv.szKeyName = "damagetype";
|
||||
kv.szValue = const_cast <char *> (FormatBuffer ("%d", (1 << 4)));
|
||||
kv.fHandled = FALSE;
|
||||
|
||||
MDLL_KeyValue (m_killerEntity, &kv);
|
||||
MDLL_Touch (m_killerEntity, bot->GetEntity ());
|
||||
}
|
||||
|
||||
void BotManager::CallGameEntity (entvars_t *vars)
|
||||
{
|
||||
// this function calls gamedll player() function, in case to create player entity in game
|
||||
|
|
@ -240,7 +280,7 @@ void BotManager::Think (void)
|
|||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
{
|
||||
if (m_bots[i] != NULL)
|
||||
m_bots[i]->ThinkMain ();
|
||||
m_bots[i]->Think ();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1130,32 +1170,7 @@ void Bot::Kill (void)
|
|||
// this function kills a bot (not just using ClientKill, but like the CSBot does)
|
||||
// base code courtesy of Lazy (from bots-united forums!)
|
||||
|
||||
edict_t *hurtEntity = (*g_engfuncs.pfnCreateNamedEntity) (MAKE_STRING ("trigger_hurt"));
|
||||
|
||||
if (IsEntityNull (hurtEntity))
|
||||
return;
|
||||
|
||||
hurtEntity->v.classname = MAKE_STRING (g_weaponDefs[m_currentWeapon].className);
|
||||
hurtEntity->v.dmg_inflictor = GetEntity ();
|
||||
hurtEntity->v.dmg = 9999.0;
|
||||
hurtEntity->v.dmg_take = 1.0;
|
||||
hurtEntity->v.dmgtime = 2.0;
|
||||
hurtEntity->v.effects |= EF_NODRAW;
|
||||
|
||||
(*g_engfuncs.pfnSetOrigin) (hurtEntity, Vector (-4000, -4000, -4000));
|
||||
|
||||
KeyValueData kv;
|
||||
kv.szClassName = const_cast <char *> (g_weaponDefs[m_currentWeapon].className);
|
||||
kv.szKeyName = "damagetype";
|
||||
kv.szValue = const_cast <char *> (FormatBuffer ("%d", (1 << 4)));
|
||||
kv.fHandled = FALSE;
|
||||
|
||||
MDLL_KeyValue (hurtEntity, &kv);
|
||||
|
||||
MDLL_Spawn (hurtEntity);
|
||||
MDLL_Touch (hurtEntity, GetEntity ());
|
||||
|
||||
(*g_engfuncs.pfnRemoveEntity) (hurtEntity);
|
||||
bots.TouchWithKillerEntity (this);
|
||||
}
|
||||
|
||||
void Bot::Kick (void)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue