Enable backwards firing of cakes (based in ball code).

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5372 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
mbjornstk
2010-05-04 00:29:41 +00:00
parent 16e3988ddd
commit 7a23f394fc

View File

@@ -515,9 +515,21 @@ void DefaultAIController::handleItems( const float DELTA, const int STEPS )
// towards m_kart_ahead. And some of them can fire backwards, too - which
// isn't yet supported for AI karts.
case PowerupManager::POWERUP_CAKE:
m_controls->m_fire = (m_kart_ahead && m_distance_ahead < 20.0f) ||
m_time_since_last_shot > 10.0f;
break;
{
// Since cakes can be fired all around, just use a sane distance
// with a bit of extra for backwards, as enemy will go towards cake
bool fire_backwards = (m_kart_behind && m_kart_ahead &&
m_distance_behind < m_distance_ahead) ||
!m_kart_ahead;
float distance = fire_backwards ? m_distance_behind
: m_distance_ahead;
m_controls->m_fire = (fire_backwards && distance < 25.0f) ||
(!fire_backwards && distance < 20.0f) ||
m_time_since_last_shot > 10.0f;
if(m_controls->m_fire)
m_controls->m_look_back = fire_backwards;
break;
}
case PowerupManager::POWERUP_BOWLING:
{
// Bowling balls slower, so only fire on closer karts - but when