Beispiel #1
0
bool CCSBot::IsWellPastSafe() const
{
	CCSBotManager *ctrl = TheCSBots();

	if (ctrl->GetElapsedRoundTime() > 1.25f * m_safeTime)
		return true;

	return false;
}
Beispiel #2
0
void CCSBot::AdjustSafeTime()
{
	CCSBotManager *ctrl = TheCSBots();

	// if we spotted an enemy sooner than we thought possible, adjust our notion of "safe" time
	if (m_safeTime > ctrl->GetElapsedRoundTime())
	{
		// since right now is not safe, adjust safe time to be a few seconds ago
		m_safeTime = ctrl->GetElapsedRoundTime() - 2.0f;
	}
}
Beispiel #3
0
CBasePlayer *CCSBot::GetImportantEnemy(bool checkVisibility) const
{
	CCSBotManager *ctrl = TheCSBots();
	CBasePlayer *nearEnemy = NULL;
	float nearDist = 999999999.9f;

	for (int i = 1; i <= gpGlobals->maxClients; ++i)
	{
		CBaseEntity *entity = UTIL_PlayerByIndex(i);

		if (entity == NULL)
			continue;

		if (FNullEnt(entity->pev))
			continue;

		if (FStrEq(STRING(entity->pev->netname), ""))
			continue;

		// is it a player?
		if (!entity->IsPlayer())
			continue;

		CBasePlayer *player = static_cast<CBasePlayer *>(entity);

		// is it alive?
		if (!player->IsAlive())
			continue;

		// skip friends
		if (player->m_iTeam == m_iTeam)
			continue;

		// is it "important"
		if (!ctrl->IsImportantPlayer(player))
			continue;

		// is it closest?
		Vector d = pev->origin - player->pev->origin;

		float distSq = d.x * d.x + d.y * d.y + d.z * d.z;
		if (distSq < nearDist)
		{
			if (checkVisibility && !IsVisible(player, CHECK_FOV))
				continue;

			nearEnemy = player;
			nearDist = distSq;
		}
	}

	return nearEnemy;
}
/* <3fd284> ../cstrike/dlls/bot/cs_gamestate.cpp:225 */
bool CSGameState::IsAtPlantedBombsite(void) const
{
	if (m_bombState != PLANTED)
		return false;

	CCSBotManager *ctrl = TheCSBots();
	const CCSBotManager::Zone *zone = ctrl->GetClosestZone(&m_owner->pev->origin);

	if (zone != NULL)
	{
		return (m_plantedBombsite == zone->m_index);
	}

	return false;
}
/* <41fb6b> ../cstrike/dlls/hostage/states/hostage_escape.cpp:145 */
void HostageEscapeState::__MAKE_VHOOK(OnEnter)(CHostageImprov *improv)
{
	CCSBotManager *ctrl = TheCSBots();
	const CCSBotManager::Zone *zone = ctrl->GetRandomZone();

	if (zone != NULL)
	{
		m_toCoverState.SetRescueGoal(zone->m_center);

		m_behavior.Reset(improv);
		m_behavior.SetState(&m_toCoverState);
	}

	m_canEscape = true;
}
Beispiel #6
0
bool CCSBot::GuardRandomZone(float range)
{
	CCSBotManager *ctrl = TheCSBots();
	const CCSBotManager::Zone *zone = ctrl->GetRandomZone();

	if (zone != NULL)
	{
		CNavArea *rescueArea = ctrl->GetRandomAreaInZone(zone);
		if (rescueArea != NULL)
		{
			Hide(rescueArea, -1.0f, range);
			return true;
		}
	}

	return false;
}
Beispiel #7
0
bool CCSBot::CanSeePlantedBomb() const
{
	CCSBotManager *ctrl = TheCSBots();

	if (ctrl->GetScenario() != CCSBotManager::SCENARIO_DEFUSE_BOMB)
		return false;

	if (!GetGameState()->IsBombPlanted())
		return false;

	const Vector *bombPos = GetGameState()->GetBombPosition();

	if (bombPos != NULL && IsVisible(bombPos, CHECK_FOV))
		return true;

	return false;
}
Beispiel #8
0
bool CCSBot::CanSeeLooseBomb() const
{
	CCSBotManager *ctrl = TheCSBots();

	if (ctrl->GetScenario() != CCSBotManager::SCENARIO_DEFUSE_BOMB)
		return false;

	CBaseEntity *bomb = ctrl->GetLooseBomb();

	if (bomb != NULL)
	{
		if (IsVisible(&bomb->pev->origin, CHECK_FOV))
			return true;
	}

	return false;
}
Beispiel #9
0
bool CCSBot::NoticeLooseBomb() const
{
	CCSBotManager *ctrl = TheCSBots();

	if (ctrl->GetScenario() != CCSBotManager::SCENARIO_DEFUSE_BOMB)
		return false;

	CBaseEntity *bomb = ctrl->GetLooseBomb();

	if (bomb != NULL)
	{
		// T's can always see bomb on their radar
		return true;
	}

	return false;
}
Beispiel #10
0
void CCSBot::SpawnBot()
{
	CCSBotManager *ctrl = TheCSBots();

	ctrl->ValidateMapData();
	ResetValues();

	Q_strcpy(m_name, STRING(pev->netname));

	SetState(&m_buyState);
	SetTouch(&CCSBot::BotTouch);

	if (!TheNavAreaList.Count () && !ctrl->IsLearningMap())
	{
		ctrl->SetLearningMapFlag();
		StartLearnProcess();
	}
}
Beispiel #11
0
bool CCSBot::IsHurrying() const
{
	if (!m_hurryTimer.IsElapsed())
		return true;

	CCSBotManager *ctrl = TheCSBots();

	// if the bomb has been planted, we are in a hurry, CT or T (they could be defusing it!)
	if (ctrl->GetScenario() == CCSBotManager::SCENARIO_DEFUSE_BOMB && ctrl->IsBombPlanted())
		return true;

	// if we are a T and hostages are being rescued, we are in a hurry
	if (ctrl->GetScenario() == CCSBotManager::SCENARIO_RESCUE_HOSTAGES
		&& m_iTeam == TERRORIST
		&& GetGameState()->AreAllHostagesBeingRescued())
		return true;

	return false;
}
/* <3fd373> ../cstrike/dlls/bot/cs_gamestate.cpp:313 */
void CSGameState::UpdatePlantedBomb(const Vector *pos)
{
	CCSBotManager *ctrl = TheCSBots();
	const CCSBotManager::Zone *zone = ctrl->GetClosestZone(pos);

	if (zone == NULL)
	{
		CONSOLE_ECHO("ERROR: Bomb planted outside of a zone!\n");
		m_plantedBombsite = UNKNOWN;
	}
	else
	{
		m_plantedBombsite = zone->m_index;
	}

	m_plantedBombPos = *pos;
	m_isPlantedBombPosKnown = true;
	SetBombState(PLANTED);
}
Beispiel #13
0
bool CCSBot::IsRogue() const
{
	CCSBotManager *ctrl = TheCSBots();

	if (!ctrl->AllowRogues())
		return false;

	// periodically re-evaluate our rogue status
	if (m_rogueTimer.IsElapsed())
	{
		m_rogueTimer.Start(RANDOM_FLOAT(10, 30));

		// our chance of going rogue is inversely proportional to our teamwork attribute
		const float rogueChance = 100.0f * (1.0f - GetProfile()->GetTeamwork());

		m_isRogue = (RANDOM_FLOAT(0, 100) < rogueChance);
	}

	return m_isRogue; 
}
Beispiel #14
0
BOOL CGameRules::CanHavePlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon)
{
	// only living players can have items
	if (pPlayer->pev->deadflag != DEAD_NO)
	{
		return FALSE;
	}

	CCSBotManager *ctrl = TheCSBots();

	if (pPlayer->IsBot() && ctrl != NULL && !ctrl->IsWeaponUseable(pWeapon))
	{
		return FALSE;
	}

	if (pWeapon->pszAmmo1())
	{
		if (!CanHaveAmmo(pPlayer, pWeapon->pszAmmo1(), pWeapon->iMaxAmmo1()))
		{
			// we can't carry anymore ammo for this gun. We can only
			// have the gun if we aren't already carrying one of this type
			if (pPlayer->HasPlayerItem(pWeapon))
			{
				return FALSE;
			}
		}
	}
	else
	{
		// weapon doesn't use ammo, don't take another if you already have it.
		if (pPlayer->HasPlayerItem(pWeapon))
		{
			return FALSE;
		}
	}

	// note: will fall through to here if GetItemInfo doesn't fill the struct!
	return TRUE;
}
/* <3fd4f4> ../cstrike/dlls/bot/cs_gamestate.cpp:55 */
void CSGameState::Reset(void)
{
	int i;
	CCSBotManager *ctrl = TheCSBots();

	m_isRoundOver = false;

	// bomb
	m_bombState = MOVING;
	m_lastSawBomber.Invalidate();
	m_lastSawLooseBomb.Invalidate();
	m_bombsiteCount = ctrl->GetZoneCount();

	m_isPlantedBombPosKnown = false;
	m_plantedBombsite = UNKNOWN;

	for (i = 0; i < m_bombsiteCount; ++i)
	{
		m_isBombsiteClear[i] = false;
		m_bombsiteSearchOrder[i] = i;
	}

	// shuffle the bombsite search order
	// allows T's to plant at random site, and TEAM_CT's to search in a random order
	// NOTE: VS6 std::random_shuffle() doesn't work well with an array of two elements (most maps)
	for (i = 0; i < m_bombsiteCount; ++i)
	{
		int swap = m_bombsiteSearchOrder[i];
		int rnd = RANDOM_LONG(i, m_bombsiteCount - 1);

		m_bombsiteSearchOrder[i] = m_bombsiteSearchOrder[rnd];
		m_bombsiteSearchOrder[rnd] = swap;
	}

	m_bombsiteSearchIndex = 0;
	InitializeHostageInfo();
}
Beispiel #16
0
float CCSBot::GetSafeTimeRemaining() const
{
	CCSBotManager *ctrl = TheCSBots();

	return m_safeTime - ctrl->GetElapsedRoundTime();
}