This commit is contained in:
Alayan 2024-05-21 15:31:46 +02:00
parent 5bfb9aa054
commit e165a5680b
No known key found for this signature in database
2 changed files with 13 additions and 4 deletions

View File

@ -47,6 +47,7 @@ FollowTheLeaderRace::FollowTheLeaderRace() : LinearWorld()
m_use_highscores = false; // disable high scores m_use_highscores = false; // disable high scores
setClockMode(WorldStatus::CLOCK_COUNTDOWN, m_leader_intervals[0]); setClockMode(WorldStatus::CLOCK_COUNTDOWN, m_leader_intervals[0]);
m_is_over_delay = 5.0f; m_is_over_delay = 5.0f;
m_leader_hit_count = 0;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -89,6 +90,7 @@ void FollowTheLeaderRace::reset(bool restart)
m_leader_intervals[0]); m_leader_intervals[0]);
m_is_over_delay = 2.0f; m_is_over_delay = 2.0f;
m_leader_hit_count = 0;
} // reset } // reset
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -122,7 +124,8 @@ const btTransform &FollowTheLeaderRace::getStartTransform(int index)
*/ */
void FollowTheLeaderRace::countdownReachedZero() void FollowTheLeaderRace::countdownReachedZero()
{ {
m_last_eliminated_time += m_leader_intervals[0]; m_last_eliminated_time += m_leader_intervals[0] + m_leader_hit_count * LEADER_HIT_TIME;
m_leader_hit_count = 0; // Reset the hit counter
if(m_leader_intervals.size()>1) if(m_leader_intervals.size()>1)
m_leader_intervals.erase(m_leader_intervals.begin()); m_leader_intervals.erase(m_leader_intervals.begin());
WorldStatus::setTime(m_leader_intervals[0]); WorldStatus::setTime(m_leader_intervals[0]);
@ -146,7 +149,7 @@ void FollowTheLeaderRace::countdownReachedZero()
{ {
if(UserConfigParams::m_ftl_debug) if(UserConfigParams::m_ftl_debug)
{ {
Log::debug("[FTL", "Eliminiating kart '%s' at position %d.", Log::debug("[FTL", "Eliminating kart '%s' at position %d.",
kart->getIdent().c_str(), position_to_remove); kart->getIdent().c_str(), position_to_remove);
} }
eliminateKart(kart->getWorldKartId()); eliminateKart(kart->getWorldKartId());
@ -227,8 +230,9 @@ bool FollowTheLeaderRace::isRaceOver()
void FollowTheLeaderRace::leaderHit() void FollowTheLeaderRace::leaderHit()
{ {
int countdown = getTimeTicks(); int countdown = getTimeTicks();
countdown += stk_config->time2Ticks(5.0f); countdown += stk_config->time2Ticks(LEADER_HIT_TIME);
setTicks(countdown); setTicks(countdown);
m_leader_hit_count++;
} // leaderHit } // leaderHit
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@ -18,6 +18,8 @@
#ifndef _follow_the_leader_hpp_ #ifndef _follow_the_leader_hpp_
#define _follow_the_leader_hpp_ #define _follow_the_leader_hpp_
#define LEADER_HIT_TIME 5.0f
#include "modes/linear_world.hpp" #include "modes/linear_world.hpp"
/** /**
@ -30,6 +32,9 @@ private:
// time till elimination in follow leader // time till elimination in follow leader
std::vector<float> m_leader_intervals; std::vector<float> m_leader_intervals;
// Number of rescue/hit endured by the leader since the previous kart elimination
unsigned int m_leader_hit_count;
/** A timer used before terminating the race. */ /** A timer used before terminating the race. */
float m_is_over_delay; float m_is_over_delay;