1) Added new isInvulnerable function to kart, which is now

also used by emergency animation to make a kart invulnerable
   for a certain amount of time.
2) Karts are not not affected anymore by a explosion that
   just happens close by, see #258.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8814 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2011-06-04 13:29:35 +00:00
parent 8d2ac03837
commit 9b64fa1406
7 changed files with 33 additions and 15 deletions

View File

@ -78,9 +78,9 @@ Stars::~Stars()
void Stars::showFor(float time)
{
m_enabled = true;
m_enabled = true;
m_remaining_time = time;
m_fade_in_time = 1.0f;
m_fade_in_time = 1.0f;
const int nodeAmount = m_nodes.size();
for (int n=0; n<nodeAmount; n++)

View File

@ -57,9 +57,6 @@ private:
void showFor(float time);
void reset();
void update (float delta_t);
/** Returns true if the stars are currently shown. */
bool isEnabled() const { return m_enabled; }
};
#endif

View File

@ -256,7 +256,7 @@ void Flyable::getClosestKart(const Kart **minKart, float *minDistSquared,
// If a kart has star effect shown, the kart is immune, so
// it is not considered a target anymore.
if(kart->isEliminated() || kart == m_owner ||
kart->getStarEffect()->isEnabled() ||
kart->isInvulnerable() ||
kart->playingEmergencyAnimation() ) continue;
btTransform t=kart->getTrans();

View File

@ -135,6 +135,8 @@ void EmergencyAnimation::handleExplosion(const Vec3 &pos, bool direct_hit)
{
// Avoid doing another explosion while a kart is thrown around in the air.
if(playingEmergencyAnimation()) return;
if(m_kart->isInvulnerable())
return;
m_xyz = m_kart->getXYZ();
// Ignore explosion that are too far away.
@ -173,6 +175,7 @@ void EmergencyAnimation::handleExplosion(const Vec3 &pos, bool direct_hit)
if ( UserConfigParams::m_graphical_effects )
{
m_stars_effect->showFor(6.0f);
m_kart->setInvulnerableTime(6.0f);
}
m_kart->getAttachment()->clear();
} // handleExplosion

View File

@ -96,6 +96,7 @@ Kart::Kart (const std::string& ident, Track* track, int position, bool is_first_
m_finished_race = false;
m_wheel_toggle = 1;
m_finish_time = 0.0f;
m_invulnerable_time = 0.0f;
m_shadow_enabled = false;
m_shadow = NULL;
m_terrain_particles = NULL;
@ -499,6 +500,7 @@ void Kart::reset()
m_race_position = m_initial_position;
m_finished_race = false;
m_finish_time = 0.0f;
m_invulnerable_time = 0.0f;
m_collected_energy = 0;
m_has_started = false;
m_wheel_rotation = 0;
@ -739,7 +741,7 @@ void Kart::update(float dt)
getNode()->setVisible(false);
return;
}
// Update the position and other data taken from the physics
Moveable::update(dt);
@ -747,9 +749,13 @@ void Kart::update(float dt)
m_controller->update(dt);
if(m_camera)
m_camera->update(dt);
// if its view is blocked by plunger, decrease remaining time
if(m_view_blocked_by_plunger > 0) m_view_blocked_by_plunger -= dt;
// Decrease remaining invulnerability time
if(m_invulnerable_time>0) m_invulnerable_time-=dt;
m_slipstream->update(dt);
// Store the actual kart controls at the start of update in the server

View File

@ -109,10 +109,16 @@ private:
/** For skidding smoke */
int m_wheel_toggle;
float m_max_gear_rpm; /**<Maximum engine rpm's for the current gear*/
float m_bounce_back_time; /**<A short time after a collision acceleration
* is disabled to allow the karts to bounce back*/
/**<Maximum engine rpm's for the current gear*/
float m_max_gear_rpm;
/** A short time after a collision acceleration is disabled to allow
* the karts to bounce back*/
float m_bounce_back_time;
/** Time a kart is invulnerable. */
float m_invulnerable_time;
// Bullet physics parameters
// -------------------------
@ -406,8 +412,14 @@ public:
* the upright constraint to allow for more realistic explosions. */
bool isNearGround () const;
// ------------------------------------------------------------------------
void setEnergy (float val) { m_collected_energy = val; }
/** Makes a kart invulnerable for a certain amount of time. */
void setInvulnerableTime(float t) { m_invulnerable_time = t; };
// ------------------------------------------------------------------------
/** Returns if the kart is invulnerable. */
bool isInvulnerable() const { return m_invulnerable_time > 0; }
// ------------------------------------------------------------------------
/** Sets the energy the kart has collected. */
void setEnergy(float val) { m_collected_energy = val; }
};

View File

@ -140,8 +140,8 @@ void Physics::update(float dt)
// Only explode a bowling ball if the target does not
// the stars shown
if(p->a->getPointerFlyable()->getType()
!=PowerupManager::POWERUP_BOWLING ||
!p->b->getPointerKart()->getStarEffect()->isEnabled() )
!=PowerupManager::POWERUP_BOWLING ||
!p->b->getPointerKart()->isInvulnerable() )
p->a->getPointerFlyable()->hit(p->b->getPointerKart());
}
else // projectile hits projectile