save point for tomorrow, good night

This commit is contained in:
Dmitry 2015-06-11 00:18:49 +03:00
commit 02823791c0
5 changed files with 69 additions and 17 deletions

View file

@ -1284,6 +1284,9 @@ private:
bool m_economicsGood[2]; // is team able to buy anything
bool m_deathMsgSent; // for fakeping
// holds currently active grenades in the map
Array <entity_t> m_activeGrenades;
protected:
int CreateBot (String name, int difficulty, int personality, int team, int member);
@ -1330,9 +1333,23 @@ public:
void CheckTeamEconomics (int team);
static void CallGameEntity (entvars_t *vars);
inline void SetDeathMsgState (bool sent)
{
m_deathMsgSent = sent;
}
inline void SetDeathMsgState (bool sent) { m_deathMsgSent = sent; }
inline bool GetDeathMsgState (void) { return m_deathMsgSent; }
inline bool GetDeathMsgState (void)
{
return m_deathMsgSent;
}
// grenades
void UpdateActiveGrenades (void);
const Array <entity_t> GetActiveGrenades (void);
inline bool HasActiveGrenades (void)
{
return !m_activeGrenades.IsEmpty ();
}
public:
void CalculatePingOffsets (void);

View file

@ -243,6 +243,9 @@ void Bot::AvoidGrenades (void)
{
// checks if bot 'sees' a grenade, and avoid it
if (!g_botManager->HasActiveGrenades ())
return;
edict_t *ent = m_avoidGrenade;
// check if old pointers to grenade is invalid
@ -272,12 +275,12 @@ void Bot::AvoidGrenades (void)
// TODO: should be done once for grenade, instead of checking several times
if (m_difficulty == 4 && strcmp (STRING (ent->v.model) + 9, "flashbang.mdl") == 0)
{
Vector position = (GetEntityOrigin (ent) - EyePosition ()).ToAngles ();
const Vector &position = (GetEntityOrigin (ent) - EyePosition ()).ToAngles ();
// don't look at flashbang
if (!(m_states & STATE_SEEING_ENEMY))
{
pev->v_angle.y = AngleNormalize (position.y + 180.0);
pev->v_angle.y = AngleNormalize (position.y + 180.0f);
m_canChooseAimDirection = false;
}
}
@ -315,6 +318,9 @@ void Bot::AvoidGrenades (void)
bool Bot::IsBehindSmokeClouds (edict_t *ent)
{
if (!g_botManager->HasActiveGrenades ())
return false;
edict_t *pentGrenade = NULL;
Vector betweenUs = (ent->v.origin - pev->origin).Normalize ();

View file

@ -2216,7 +2216,7 @@ void StartFrame (void)
}
g_botManager->SetDeathMsgState (false);
if (g_timePerSecondUpdate <= GetWorldTime ())
if (g_timePerSecondUpdate < GetWorldTime ())
{
g_botManager->CalculatePingOffsets ();
@ -2246,20 +2246,28 @@ void StartFrame (void)
}
}
}
if (g_isMetamod)
{
cvar_t *csdm_active = CVAR_GET_POINTER ("csdm_active");
cvar_t *mp_freeforall = CVAR_GET_POINTER ("mp_freeforall");
if (csdm_active != NULL && csdm_active->value > 0)
yb_csdm_mode.SetInt (mp_freeforall != NULL && mp_freeforall->value > 0 ? 2 : 1);
}
g_timePerSecondUpdate = GetWorldTime () + 1.0f;
}
if (g_bombPlanted)
g_waypoint->SetBombPosition ();
if (g_isMetamod)
{
static cvar_t *csdm_active;
static cvar_t *mp_freeforall;
if (csdm_active == NULL)
csdm_active = CVAR_GET_POINTER ("csdm_active");
if (mp_freeforall == NULL)
mp_freeforall = CVAR_GET_POINTER ("mp_freeforall");
if (csdm_active != NULL && csdm_active->value > 0)
yb_csdm_mode.SetInt (mp_freeforall != NULL && mp_freeforall->value > 0 ? 2 : 1);
}
g_timePerSecondUpdate = GetWorldTime () + 1.0f;
}
else if (g_timePerSecondUpdate * 0.5f < GetWorldTime ())
g_botManager->UpdateActiveGrenades ();
// keep bot number up to date
g_botManager->MaintainBotQuota ();

View file

@ -1347,4 +1347,26 @@ void BotManager::SendDeathMsgFix (void)
for (int i = 0; i < GetMaxClients (); i++)
SendPingDataOffsets (g_clients[i].ent);
}
}
void BotManager::UpdateActiveGrenades (void)
{
edict_t *grenade = NULL;
// clear previously stored grenades
m_activeGrenades.RemoveAll ();
// search the map for any type of grenade
while (!IsEntityNull (grenade = FIND_ENTITY_BY_CLASSNAME (grenade, "grenade")))
{
if (grenade->v.effects & EF_NODRAW)
continue;
m_activeGrenades.Push (grenade);
}
}
const Array <entity_t> BotManager::GetActiveGrenades (void)
{
return m_activeGrenades;
}

View file

@ -2323,7 +2323,6 @@ bool Bot::HeadTowardWaypoint (void)
m_navNode = m_navNode->next; // advance in list
m_currentTravelFlags = 0; // reset travel flags (jumping etc)
// we're not at the end of the list?
// we're not at the end of the list?
if (m_navNode != NULL)
{
@ -2347,7 +2346,7 @@ bool Bot::HeadTowardWaypoint (void)
kills = (g_experienceData + (waypoint * g_numWaypoints) + waypoint)->team1Damage / g_highestDamageCT;
// if damage done higher than one
if (kills > 0.15f && g_timeRoundMid > GetWorldTime ())
if (kills > 0.15f && g_timeRoundMid + 15.0f > GetWorldTime ())
{
switch (m_personality)
{