Skip to content

Update soccer_world.cpp #5294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/karts/abstract_kart.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down
58 changes: 35 additions & 23 deletions src/karts/kart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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())
{
Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) )
{
Expand Down Expand Up @@ -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));
Expand All @@ -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()))
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -3417,7 +3429,7 @@ void Kart::setOnScreenText(const core::stringw& text)
#ifndef SERVER_ONLY
if (GUIEngine::isNoGraphics())
return;

BoldFace* bold_face = font_manager->getFont<BoldFace>();
STKTextBillboard* tb =
new STKTextBillboard(
Expand Down
6 changes: 5 additions & 1 deletion src/karts/kart.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
{
Expand Down
1 change: 1 addition & 0 deletions src/modes/soccer_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading