示例#1
0
bool CSDKBot::ThinkFlag() {
	CFlag* pFlag = m_PlayerSearchInfo.CloseEnemyFlagVisible();

	if (IsCapturingEnemyFlagAttempt()) {
		if (!m_bLastThinkWasInFlag) {
			m_bLastThinkWasInFlag = true;
			if (bot_randfloat() < 0.4f && ShouldReload()) {
				m_curCmd.buttons |= IN_RELOAD;
			}
			m_flNextStrafeTime = gpGlobals->curtime;
		}

		CBasePlayer* pEnemy = m_PlayerSearchInfo.CloseEnemy();
		if (pEnemy) {
			LookAt(pEnemy->Weapon_ShootPosition(), 0.7f, 3);
			if (pFlag)
				DanceAround(pFlag->GetAbsOrigin(), pFlag->m_flCaptureRadius);
			if (bot_randfloat() < 0.3f)
				m_flNextFireTime = gpGlobals->curtime;
		}
		else {
			StopMoving();
		}
	} else {
		m_bLastThinkWasInFlag = false;

		if (pFlag) {
			m_curCmd.buttons |= IN_FORWARD;
			LookAt(pFlag->GetAbsOrigin() + g_vUpFromFlag, 0.8f, 5);
		}
		TeammateGoAround(true);
	}
	return true;
}
示例#2
0
//-------------------------------------------------------------------------------------------------
// Purpose: Checks if we should fight nearest enemy or run to flag, if we're already in a mid-range engagement
//-------------------------------------------------------------------------------------------------
bool CSDKBot::ThinkCheckFlagOrFight() {
	CFlag* pFlag = m_PlayerSearchInfo.CloseEnemyFlagVisible();
	CBasePlayer* pEnemy = m_PlayerSearchInfo.CloseEnemy();
	if (pFlag && pEnemy) {
		float enemyDistanceToFlag = (pEnemy->GetAbsOrigin() - pFlag->GetAbsOrigin()).Length();
		float ourDistanceToFlag = (m_PlayerSearchInfo.OwnerOrigin() - pFlag->GetAbsOrigin()).Length();
		if (m_pCurThinker != &BotThinkers::Flag /*No self-scheduling!*/ 
			&& enemyDistanceToFlag > 100 //don't bother if they're on the flag
			&& enemyDistanceToFlag > ourDistanceToFlag && m_PlayerSearchInfo.CloseEnemyDist() > MELEE_RANGE_START) {
			m_bTowardFlag = true;
			ScheduleThinker(&BotThinkers::Flag, 0.1f);
			return false;
		}

		//also check if we should exit flag to med-range
		if (m_pCurThinker == &BotThinkers::Flag && m_PlayerSearchInfo.CloseEnemyDist() < ourDistanceToFlag) {
			ScheduleThinker(&BotThinkers::MedRange, 0.1f);
			return false;
		}
	}
	return true;
}
示例#3
0
bool CSDKBot::ThinkLongRange() {
	m_curCmd.buttons |= IN_FORWARD;
	Vector lookTarget;
	CBasePlayer* pEnemy = m_PlayerSearchInfo.CloseEnemy();
	CFlag* pFlag = m_PlayerSearchInfo.CloseEnemyFlagVisible();
	//if there's a flag move towards the flag as well
	if (pEnemy && pFlag) {
		lookTarget = LerpVector(pFlag->GetAbsOrigin(), pEnemy->Weapon_ShootPosition(), 0.3f);
	} else if (pEnemy) {
		lookTarget = pEnemy->Weapon_ShootPosition();
	}
	LookAt(lookTarget, 0.6f, 5.f);
	TeammateGoAround(true);
	return true;
}