Merge branch 'skiddingAI' of https://github.com/gupascal/stk-code into gupascal-skiddingAI

This commit is contained in:
hiker 2014-04-22 14:29:35 +10:00
commit ef341344e7

View File

@ -1242,17 +1242,24 @@ void SkiddingAI::handleItems(const float dt)
case PowerupManager::POWERUP_CAKE: case PowerupManager::POWERUP_CAKE:
{ {
// Do not destroy your own shield // Do not destroy your own shield
if(m_kart->getShieldTime() > min_bubble_time) // if the kart has a shield, do not break it by using a swatter. if(m_kart->getShieldTime() > min_bubble_time) // if the kart has a shield, do not break it by using a cake.
break; break;
// Leave some time between shots // Leave some time between shots
if(m_time_since_last_shot<3.0f) break; if(m_time_since_last_shot<3.0f) break;
//TODO: do not fire if the kart is driving too slow
// Do not fire if the kart is driving too slow
bool kart_behind_is_slow = (m_kart_behind && m_kart_behind->getSpeed() < m_kart->getSpeed());
bool kart_ahead_is_slow = (m_kart_ahead && m_kart_ahead->getSpeed() < m_kart->getSpeed());
// Since cakes can be fired all around, just use a sane distance // 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 // with a bit of extra for backwards, as enemy will go towards cake
bool fire_backwards = (m_kart_behind && m_kart_ahead && bool fire_backwards = !m_kart_ahead ||
m_distance_behind < m_distance_ahead) || (m_kart_behind && m_kart_ahead &&
!m_kart_ahead; (m_distance_behind < m_distance_ahead || kart_ahead_is_slow) &&
!kart_behind_is_slow
);
if ((fire_backwards && kart_behind_is_slow) || (!fire_backwards && kart_ahead_is_slow))
break;
float distance = fire_backwards ? m_distance_behind float distance = fire_backwards ? m_distance_behind
: m_distance_ahead; : m_distance_ahead;
m_controls->m_fire = (fire_backwards && distance < 25.0f) || m_controls->m_fire = (fire_backwards && distance < 25.0f) ||
@ -1265,7 +1272,7 @@ void SkiddingAI::handleItems(const float dt)
case PowerupManager::POWERUP_BOWLING: case PowerupManager::POWERUP_BOWLING:
{ {
// Do not destroy your own shield // Do not destroy your own shield
if(m_kart->getShieldTime() > min_bubble_time) // if the kart has a shield, do not break it by using a swatter. if(m_kart->getShieldTime() > min_bubble_time) // if the kart has a shield, do not break it by using a bowling ball.
break; break;
// Leave more time between bowling balls, since they are // Leave more time between bowling balls, since they are
// slower, so it should take longer to hit something which // slower, so it should take longer to hit something which
@ -1295,7 +1302,7 @@ void SkiddingAI::handleItems(const float dt)
case PowerupManager::POWERUP_PLUNGER: case PowerupManager::POWERUP_PLUNGER:
{ {
// Do not destroy your own shield // Do not destroy your own shield
if(m_kart->getShieldTime() > min_bubble_time) // if the kart has a shield, do not break it by using a swatter. if(m_kart->getShieldTime() > min_bubble_time) // if the kart has a shield, do not break it by using a plunger.
break; break;
// Leave more time after a plunger, since it will take some // Leave more time after a plunger, since it will take some