diff --git a/src/karts/explosion_animation.cpp b/src/karts/explosion_animation.cpp index 7ad9fddb2..564b366af 100644 --- a/src/karts/explosion_animation.cpp +++ b/src/karts/explosion_animation.cpp @@ -23,8 +23,10 @@ #include "items/attachment.hpp" #include "karts/abstract_kart.hpp" #include "karts/kart_properties.hpp" +#include "modes/follow_the_leader.hpp" #include "modes/world.hpp" #include "network/network_config.hpp" +#include "race/race_manager.hpp" #include "tracks/track.hpp" /** A static create function that does only create an explosion if @@ -51,6 +53,14 @@ ExplosionAnimation *ExplosionAnimation::create(AbstractKart *kart, return NULL; } + if (race_manager->isFollowMode()) + { + FollowTheLeaderRace *ftl_world = + dynamic_cast(World::getWorld()); + if(ftl_world->isLeader(kart->getWorldKartId())) + ftl_world->leaderHit(); + } + return new ExplosionAnimation(kart, pos, direct_hit); } // create diff --git a/src/modes/follow_the_leader.cpp b/src/modes/follow_the_leader.cpp index c938e6ff7..2b00f1b2d 100644 --- a/src/modes/follow_the_leader.cpp +++ b/src/modes/follow_the_leader.cpp @@ -223,17 +223,12 @@ bool FollowTheLeaderRace::isRaceOver() //----------------------------------------------------------------------------- /** If the leader kart is hit, increase the delay to the next elimination */ -bool FollowTheLeaderRace::kartHit(int kart_id, int hitter) +void FollowTheLeaderRace::leaderHit() { - if (kart_id == 0) - { - int countdown = getTimeTicks(); - countdown += stk_config->time2Ticks(5.0f); - setTicks(countdown); - } - - return false; -} + int countdown = getTimeTicks(); + countdown += stk_config->time2Ticks(5.0f); + setTicks(countdown); +} // leaderHit //----------------------------------------------------------------------------- /** Called at the end of a race. Updates highscores, pauses the game, and diff --git a/src/modes/follow_the_leader.hpp b/src/modes/follow_the_leader.hpp index b116a0153..d80a6c265 100644 --- a/src/modes/follow_the_leader.hpp +++ b/src/modes/follow_the_leader.hpp @@ -54,13 +54,15 @@ public: virtual void init() OVERRIDE; virtual void terminateRace() OVERRIDE; virtual bool isRaceOver() OVERRIDE; - virtual bool kartHit(int kart_id, int hitter = -1) OVERRIDE; // ------------------------------------------------------------------------ /** Returns if this type of race has laps. */ virtual bool raceHasLaps() OVERRIDE { return false; } // ------------------------------------------------------------------------ /** Returns if faster music should be used at the end. */ virtual bool useFastMusicNearEnd() const OVERRIDE { return false; } + + bool isLeader(int kart_id) { return (kart_id == 0); } + void leaderHit(); }; // FollowTheLeader