Rewrite some code for updated kart characteristics

This commit is contained in:
Benau 2020-03-16 11:48:02 +08:00
parent a589ab4a10
commit 4170628d23
7 changed files with 15 additions and 12 deletions

View File

@ -916,7 +916,7 @@ void SlipStream::updateSpeedIncrease()
const KartProperties* kp = m_kart->getKartProperties();
float speed_increase = kp->getSlipstreamMaxSpeedIncrease();
float add_power = kp->getSlipstreamAddPower();
int fade_out = kp->getSlipstreamFadeOutTicks();
int fade_out = stk_config->time2Ticks(kp->getSlipstreamFadeOutTime());
m_kart->instantSpeedIncrease(
MaxSpeed::MS_INCREASE_SLIPSTREAM, speed_increase,
speed_increase, add_power, m_speed_increase_duration, fade_out);

View File

@ -354,7 +354,9 @@ void Attachment::hitBanana(ItemState *item_state)
{
case ATTACH_PARACHUTE:
{
set(ATTACH_PARACHUTE, kp->getParachuteDuration() + leftover_ticks);
int parachute_ticks = stk_config->time2Ticks(
kp->getParachuteDuration()) + leftover_ticks;
set(ATTACH_PARACHUTE, parachute_ticks);
int initial_speed_round = (int)(m_kart->getSpeed() * 100.0f);
initial_speed_round =
irr::core::clamp(initial_speed_round, -32768, 32767);

View File

@ -449,7 +449,7 @@ void Powerup::use()
kart->getAttachment()
->set(Attachment::ATTACH_PARACHUTE,
int(kp->getParachuteDurationOther()*rank_mult) );
stk_config->time2Ticks(kp->getParachuteDurationOther()*rank_mult) );
if(kart->getController()->isLocalPlayerController())
player_kart = kart;

View File

@ -204,10 +204,10 @@ void RubberBand::update(int ticks)
diff.normalize(); // diff can't be zero here
m_owner->getBody()->applyCentralForce(diff*force);
m_owner->increaseMaxSpeed(MaxSpeed::MS_INCREASE_RUBBER,
kp->getPlungerBandSpeedIncrease(),
/*engine_force*/ 0.0f,
/*duration*/stk_config->time2Ticks(0.1f),
kp->getPlungerBandFadeOutTicks() );
kp->getPlungerBandSpeedIncrease(),
/*engine_force*/ 0.0f,
/*duration*/stk_config->time2Ticks(0.1f),
stk_config->time2Ticks(kp->getPlungerBandFadeOutTime()));
if(m_attached_state==RB_TO_KART)
m_hit_kart->getBody()->applyCentralForce(diff*(-force));
}

View File

@ -1246,7 +1246,7 @@ void SkiddingAI::handleItems(const float dt, const Vec3 *aim_point, int last_nod
case PowerupManager::POWERUP_PARACHUTE:
{
// Wait one second more than a previous parachute
if(m_time_since_last_shot > stk_config->ticks2Time(m_kart->getKartProperties()->getParachuteDurationOther()) + 1.0f)
if(m_time_since_last_shot > m_kart->getKartProperties()->getParachuteDurationOther() + 1.0f)
m_controls->setFire(true);
break;
}// POWERUP_PARACHUTE

View File

@ -1150,9 +1150,9 @@ void Kart::collectedItem(ItemState *item_state)
((World::getWorld()->getTicksSinceStart() / 10) % 2 == 0) ?
true : false;
m_max_speed->setSlowdown(MaxSpeed::MS_DECREASE_BUBBLE,
m_kart_properties->getBubblegumSpeedFraction() ,
m_kart_properties->getBubblegumFadeInTicks(),
m_bubblegum_ticks);
m_kart_properties->getBubblegumSpeedFraction() ,
stk_config->time2Ticks(m_kart_properties->getBubblegumFadeInTime()),
m_bubblegum_ticks);
if (!RewindManager::get()->isRewinding())
getNextEmitter()->play(getXYZ(), m_goo_sound);

View File

@ -182,7 +182,8 @@ void addAttachment(Attachment::AttachmentType type)
else if (type == Attachment::ATTACH_PARACHUTE)
{
kart->getAttachment()
->set(type, kart->getKartProperties()->getParachuteDuration() );
->set(type, stk_config->time2Ticks(
kart->getKartProperties()->getParachuteDuration()));
}
else if (type == Attachment::ATTACH_BOMB)
{