Don't do the upscaling animation if already upscaled

This commit is contained in:
Alayan 2018-09-22 23:13:54 +02:00
parent 9c6352c867
commit abbee26708
2 changed files with 10 additions and 7 deletions

View File

@ -1862,6 +1862,7 @@ void Kart::unsetSquash()
* other perks. */
void Kart::setSuper()
{
if (isSquashed())
unsetSquash();
float max_speed_increase = m_kart_properties->getSuperMaxSpeedIncrease();
@ -1874,10 +1875,11 @@ void Kart::setSuper()
engine_force,
stk_config->time2Ticks(duration),
stk_config->time2Ticks(fade_out_time));
// Kart small or downscaling and not currently upscaling
if (m_scale_change_ticks <= 0 && m_super_time == std::numeric_limits<float>::max())
m_scale_change_ticks = stk_config->time2Ticks(SUPER_TRANSITION_TIME) +
m_scale_change_ticks;
//FIXME : Use something based on config/Time2Ticks
//FIXME : check current scaling status before upscaling
m_scale_change_ticks = 40;
m_super_time = duration;
} // setSuper
@ -1886,22 +1888,22 @@ void Kart::setSuper()
*/
void Kart::updateScale(int ticks)
{
//TODO update physics model too
if (m_scale_change_ticks == 0) return;
float scale_by_tick = 0.5/(float)stk_config->time2Ticks(SUPER_TRANSITION_TIME);
float scale_factor;
if (m_scale_change_ticks > 0)
{
m_scale_change_ticks -= ticks;
if (m_scale_change_ticks < 0) m_scale_change_ticks = 0;
scale_factor = 1.4 - (m_scale_change_ticks*0.01);
scale_factor = 1.5 - (m_scale_change_ticks*scale_by_tick);
}
else
{
m_scale_change_ticks += ticks;
if (m_scale_change_ticks > 0) m_scale_change_ticks = 0;
scale_factor = 1.0 - (m_scale_change_ticks*0.01);
scale_factor = 1.0 - (m_scale_change_ticks*scale_by_tick);
}
#ifndef SERVER_ONLY

View File

@ -257,6 +257,7 @@ protected:
// Set to positive to upscale, to negative to downscale
int8_t m_scale_change_ticks;
float m_super_time;
const float SUPER_TRANSITION_TIME = 0.5;//TODO : move to config
/** To prevent using nitro in too short bursts */
int8_t m_min_nitro_ticks;