diff --git a/src/karts/abstract_kart.hpp b/src/karts/abstract_kart.hpp index dafd3c70a6d..cd6cada0ccc 100644 --- a/src/karts/abstract_kart.hpp +++ b/src/karts/abstract_kart.hpp @@ -310,20 +310,20 @@ class AbstractKart : public Moveable * category. * \param category Which category to report on. */ virtual int getSpeedIncreaseTicksLeft(unsigned int category) const = 0; - + // ------------------------------------------------------------------------ /** Sets the kart AI boost state. * Not pure abstract, since there is no need to implement this e.g. in Ghost. * \param boosted True if a boost should be applied. */ virtual void setBoostAI(bool boosted) = 0; - + // ------------------------------------------------------------------------ /** Returns the kart AI boost state. * Not pure abstract, since there is no need to implement this e.g. in Ghost. */ virtual bool getBoostAI() const = 0; - + // ------------------------------------------------------------------------ - + /** Sets an increased maximum speed for a category. * \param category The category for which to set the higher maximum speed. * \param add_speed How much speed (in m/s) is added to the maximum speed. @@ -461,6 +461,8 @@ class AbstractKart : public Moveable /** This is used on the client side only to set the speed of the kart * from the server information. */ virtual void setSpeed(float s) = 0; + /** Removes all status effects */ + virtual void removeStatusEffects() = 0; // ------------------------------------------------------------------------ /** Returns if the kart is invulnerable. */ virtual bool isInvulnerable() const = 0; diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index 1efa7fe2e58..d0659767ce7 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -423,14 +423,14 @@ void Kart::reset() m_controls.reset(); m_slipstream->reset(); - + if(m_vehicle) { for (unsigned int i = 0; i < 4; i++) { m_vehicle->getWheelInfo(i).m_steering = 0; } - + m_vehicle->reset(); } @@ -599,6 +599,18 @@ void Kart::setPosition(int p) m_race_position = p; } // setPosition +// ----------------------------------------------------------------------------- +/** +* Remove all status effects: +*/ +void Kart::removeStatusEffects() +{ + + setInvulnerableTicks(0); + unsetSquash(); + m_attachment->reset(); +} + // ----------------------------------------------------------------------------- /** Sets that the view is blocked by a plunger. The duration depends on * the difficulty, see KartPorperties getPlungerInFaceTime. @@ -642,7 +654,7 @@ btTransform Kart::getAlignedTransform(const float custom_pitch) trans2.setIdentity(); trans2.setRotation(btQuaternion(m_skidding->getVisualSkidRotation(), 0, 0)); trans *= trans2; - + return trans; } // getAlignedTransform @@ -711,7 +723,7 @@ void Kart::createPhysics() } // The y position of the wheels (i.e. the points where // the suspension is attached to) is just at the - // bottom of the kart (independent of collision shape). + // bottom of the kart (independent of collision shape). // That is half the kart height down. wheel_pos[index].setY(-0.5f*kart_height); } // if y==-1 @@ -952,7 +964,7 @@ void Kart::finishedRace(float time, bool from_server) RaceEventManager::get()->kartFinishedRace(this, time); } // isServer - // Ignore local detection of a kart finishing a race in a + // Ignore local detection of a kart finishing a race in a // network game. else if (NetworkConfig::get()->isClient()) { @@ -1155,7 +1167,7 @@ void Kart::collectedItem(ItemState *item_state) break; } case Item::ITEM_BUBBLEGUM: - m_has_caught_nolok_bubblegum = + m_has_caught_nolok_bubblegum = (item_state->getPreviousOwner()&& item_state->getPreviousOwner()->getIdent() == "nolok"); @@ -1439,7 +1451,7 @@ void Kart::update(int ticks) m_invulnerable_ticks = stk_config->time2Ticks(time); } - // Update the locally maintained speed of the kart (m_speed), which + // Update the locally maintained speed of the kart (m_speed), which // is used furthermore for engine power, camera distance etc updateSpeed(); // Make the restitution depend on speed: this avoids collision issues, @@ -1823,7 +1835,7 @@ void Kart::updateSpeed() // In theory <0 should be sufficient, but floating point errors can cause // flipping from +eps to -eps and back, resulting in animation flickering // if the kart has backpedal animations. - if (forwardW.dot(getVehicle()->getRigidBody()->getLinearVelocity()) + if (forwardW.dot(getVehicle()->getRigidBody()->getLinearVelocity()) < btScalar(-0.01f)) { m_speed = -m_speed; @@ -1872,7 +1884,7 @@ bool Kart::setSquash(float time, float slowdown) } m_max_speed->setSlowdown(MaxSpeed::MS_DECREASE_SQUASH, slowdown, - stk_config->time2Ticks(0.1f), + stk_config->time2Ticks(0.1f), stk_config->time2Ticks(time)); return true; } // setSquash @@ -1950,7 +1962,7 @@ void Kart::handleMaterialSFX() // entered), the oldest (previous) sfx is stopped and deleted. // FIXME: if there are already two sfx playing, don't add another - // one. This should reduce the performance impact when driving + // one. This should reduce the performance impact when driving // on the bridge in Cocoa. const Material* material = isOnGround() ? m_terrain_info->getMaterial() : NULL; @@ -2012,7 +2024,7 @@ void Kart::handleMaterialSFX() // terrain sound is not necessarily a looping sound so check its status before // setting its speed, to avoid 'ressuscitating' sounds that had already stopped - if(m_terrain_sound && + if(m_terrain_sound && (m_terrain_sound->getStatus()==SFXBase::SFX_PLAYING || m_terrain_sound->getStatus()==SFXBase::SFX_PAUSED) ) { @@ -2478,11 +2490,11 @@ void Kart::playCrashSFX(const Material* m, AbstractKart *k) if (getVelocity().length()> 0.555f) { const float speed_for_max_volume = 15; //The speed at which the sound plays at maximum volume - const float max_volume = 1; //The maximum volume a sound is played at - const float min_volume = 0.2f; //The minimum volume a sound is played at - + const float max_volume = 1; //The maximum volume a sound is played at + const float min_volume = 0.2f; //The minimum volume a sound is played at + float volume; //The volume the crash sound will be played at - + if (k == NULL) //Collision with wall { volume = sqrt( abs(m_speed / speed_for_max_volume)); @@ -2493,16 +2505,16 @@ void Kart::playCrashSFX(const Material* m, AbstractKart *k) const Vec3 OtherKartVelocity = k->getVelocity(); const Vec3 VelocityDifference = ThisKartVelocity - OtherKartVelocity; const float LengthOfDifference = VelocityDifference.length(); - + volume = sqrt( abs(LengthOfDifference / speed_for_max_volume)); } - + if (volume > max_volume) { volume = max_volume; } else if (volume < min_volume) { volume = min_volume; } SFXBase* crash_sound_emitter = getNextEmitter(); crash_sound_emitter->setVolume(volume); - + // In case that the sfx is longer than 0.5 seconds, only play it if // it's not already playing. if (isShielded() || (k != NULL && k->isShielded())) @@ -2671,7 +2683,7 @@ void Kart::updatePhysics(int ticks) } // updatephysics //----------------------------------------------------------------------------- -/** Adjust the engine sound effect depending on the speed of the kart. This +/** Adjust the engine sound effect depending on the speed of the kart. This * is called during updateGraphics, i.e. once per rendered frame only. * \param dt Time step size. */ @@ -2716,7 +2728,7 @@ void Kart::updateEngineSFX(float dt) //----------------------------------------------------------------------------- /** Reduces the engine power according to speed - * + * * TODO : find where the physics already apply a linear force decrease * TODO : While this work fine, it should ideally be in physics * However, the function use some kart properties and parachute @@ -2821,7 +2833,7 @@ void Kart::updateEnginePowerAndBrakes(int ticks) // This also applies parachute physics if relevant engine_power = applyAirFriction(engine_power); - + if(m_controls.getBrake()) { // check if the player is currently only slowing down // or moving backwards @@ -3331,7 +3343,7 @@ void Kart::updateGraphics(float dt) int max_lean_sign = extract_sign(max_lean); m_current_lean += max_lean_sign * dt* roll_speed; if( (max_lean > 0 && m_current_lean > max_lean) - ||(max_lean < 0 && m_current_lean < max_lean)) + ||(max_lean < 0 && m_current_lean < max_lean)) m_current_lean = max_lean; } else if(m_current_lean!=0.0f) @@ -3417,7 +3429,7 @@ void Kart::setOnScreenText(const core::stringw& text) #ifndef SERVER_ONLY if (GUIEngine::isNoGraphics()) return; - + BoldFace* bold_face = font_manager->getFont(); STKTextBillboard* tb = new STKTextBillboard( diff --git a/src/karts/kart.hpp b/src/karts/kart.hpp index 0fe118c1058..870dae1cd94 100644 --- a/src/karts/kart.hpp +++ b/src/karts/kart.hpp @@ -356,7 +356,7 @@ class Kart : public AbstractKart int fade_out_time) OVERRIDE; // ---------------------------------------------------------------------------------------- virtual void instantSpeedIncrease(unsigned int category, float add_max_speed, - float speed_boost, float engine_force, + float speed_boost, float engine_force, int duration, int fade_out_time) OVERRIDE; // ---------------------------------------------------------------------------------------- virtual void setSlowdown(unsigned int category, float max_speed_fraction, @@ -438,6 +438,10 @@ class Kart : public AbstractKart // ======================================================================================== // SPECIAL-STATUS related functions (plunger, squash, shield, immunity). // ---------------------------------------------------------------------------------------- + + /** Removes all status effects */ + virtual void removeStatusEffects() OVERRIDE; + /** Makes a kart invulnerable for a certain amount of time. */ virtual void setInvulnerableTicks(int ticks) OVERRIDE { diff --git a/src/modes/soccer_world.cpp b/src/modes/soccer_world.cpp index 89ee81fe2ef..56d422833d8 100644 --- a/src/modes/soccer_world.cpp +++ b/src/modes/soccer_world.cpp @@ -726,6 +726,7 @@ void SoccerWorld::resetKartsToSelfGoals() unsigned index = m_kart_position_map.at(kart->getWorldKartId()); btTransform t = Track::getCurrentTrack()->getStartTransform(index); moveKartTo(kart.get(), t); + kart->removeStatusEffects(); } } // resetKartsToSelfGoals