Fix swatter on bubblegum shield decreasing a life in battle mode

Also let the AIs be able to protect itself using bubblegum shield
when a kart nearby is using a swatter
This commit is contained in:
Benau 2016-04-30 11:13:28 +08:00
parent 56549f68d4
commit c096503860
2 changed files with 14 additions and 4 deletions
src
items
karts/controller

@ -318,7 +318,11 @@ void Swatter::squashThingsAround()
projectile_manager->addHitEffect(he);
ExplosionAnimation::create(m_closest_kart);
} // if kart has bomb attached
World::getWorld()->kartHit(m_closest_kart->getWorldKartId());
if (m_closest_kart->isSquashed())
{
// The kart may not be squashed if it was protected by a bubblegum shield
World::getWorld()->kartHit(m_closest_kart->getWorldKartId());
}
// TODO: squash items
} // squashThingsAround

@ -600,11 +600,17 @@ void ArenaAI::handleArenaItems(const float dt)
type == Attachment::ATTACH_NOLOKS_SWATTER)
break;
// Check if a flyable (cake, ...) is close. If so, use bubblegum
// Check if a flyable (cake, ...) is close or a kart nearby
// has a swatter attachment. If so, use bubblegum
// as shield
if (!m_kart->isShielded() &&
if ((!m_kart->isShielded() &&
projectile_manager->projectileIsClose(m_kart,
m_ai_properties->m_shield_incoming_radius))
m_ai_properties->m_shield_incoming_radius)) ||
(m_closest_kart_pos_data.distance < 15.0f &&
((m_closest_kart->getAttachment()->
getType() == Attachment::ATTACH_SWATTER) ||
(m_closest_kart->getAttachment()->
getType() == Attachment::ATTACH_NOLOKS_SWATTER))))
{
m_controls->m_fire = true;
m_controls->m_look_back = false;