Fix duplicated setsquash explosion animation creation
This commit is contained in:
parent
8058b74603
commit
2bbe2d5b79
@ -285,7 +285,7 @@ void Swatter::chooseTarget()
|
||||
{
|
||||
AbstractKart *kart = world->getKart(i);
|
||||
// TODO: isSwatterReady(), isSquashable()?
|
||||
if(kart->isEliminated() || kart==m_kart)
|
||||
if(kart->isEliminated() || kart==m_kart || kart->getKartAnimation())
|
||||
continue;
|
||||
// don't squash an already hurt kart
|
||||
if (kart->isInvulnerable() || kart->isSquashed())
|
||||
@ -348,10 +348,13 @@ void Swatter::squashThingsAround()
|
||||
// The squash attempt may fail because of invulnerability, shield, etc.
|
||||
// Making a bomb explode counts as a success
|
||||
bool success = closest_kart->setSquash(duration, slowdown);
|
||||
const bool has_created_explosion_animation =
|
||||
success && closest_kart->getKartAnimation() != NULL;
|
||||
|
||||
// Locally add a event to replay the squash during rewind
|
||||
if (NetworkConfig::get()->isNetworking() &&
|
||||
NetworkConfig::get()->isClient())
|
||||
NetworkConfig::get()->isClient() &&
|
||||
closest_kart->getKartAnimation() == NULL)
|
||||
{
|
||||
RewindManager::get()->addRewindInfoEventFunction(new
|
||||
RewindInfoEventFunction(World::getWorld()->getTicksSinceStart(),
|
||||
@ -378,15 +381,12 @@ void Swatter::squashThingsAround()
|
||||
}
|
||||
}
|
||||
|
||||
//FIXME : setSquash also do a bomb check
|
||||
if (m_closest_kart->getAttachment()->getType()==Attachment::ATTACH_BOMB)
|
||||
{ // make bomb explode
|
||||
m_closest_kart->getAttachment()->update(10000);
|
||||
if (has_created_explosion_animation)
|
||||
{
|
||||
HitEffect *he = new Explosion(m_kart->getXYZ(), "explosion", "explosion.xml");
|
||||
if(m_kart->getController()->isLocalPlayerController())
|
||||
he->setLocalPlayerKartHit();
|
||||
projectile_manager->addHitEffect(he);
|
||||
ExplosionAnimation::create(m_closest_kart);
|
||||
} // if kart has bomb attached
|
||||
|
||||
// TODO: squash items
|
||||
|
@ -1814,7 +1814,7 @@ void Kart::showZipperFire()
|
||||
*/
|
||||
bool Kart::setSquash(float time, float slowdown)
|
||||
{
|
||||
if (isInvulnerable()) return false;
|
||||
if (isInvulnerable() || getKartAnimation()) return false;
|
||||
|
||||
if (isShielded())
|
||||
{
|
||||
@ -1858,6 +1858,7 @@ bool Kart::setSquash(float time, float slowdown)
|
||||
return true;
|
||||
} // setSquash
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Kart::unsetSquash()
|
||||
{
|
||||
#ifndef SERVER_ONLY
|
||||
@ -1881,7 +1882,7 @@ void Kart::unsetSquash()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} // unsetSquash
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Returns if the kart is currently being squashed
|
||||
|
@ -243,8 +243,12 @@ void Physics::update(int ticks)
|
||||
else if (obj->isFlattenKartObject())
|
||||
{
|
||||
const KartProperties *kp = kart->getKartProperties();
|
||||
kart->setSquash(kp->getSwatterSquashDuration(),
|
||||
kp->getSwatterSquashSlowdown());
|
||||
if (kart->setSquash(kp->getSwatterSquashDuration(),
|
||||
kp->getSwatterSquashSlowdown()))
|
||||
{
|
||||
World::getWorld()->kartHit(kart->getWorldKartId(),
|
||||
kart->getWorldKartId());
|
||||
}
|
||||
}
|
||||
else if(obj->isSoccerBall() &&
|
||||
race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
|
||||
|
Loading…
Reference in New Issue
Block a user