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
|
|
@ -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