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:
parent
8d2ac03837
commit
9b64fa1406
@ -78,9 +78,9 @@ Stars::~Stars()
|
|||||||
|
|
||||||
void Stars::showFor(float time)
|
void Stars::showFor(float time)
|
||||||
{
|
{
|
||||||
m_enabled = true;
|
m_enabled = true;
|
||||||
m_remaining_time = time;
|
m_remaining_time = time;
|
||||||
m_fade_in_time = 1.0f;
|
m_fade_in_time = 1.0f;
|
||||||
|
|
||||||
const int nodeAmount = m_nodes.size();
|
const int nodeAmount = m_nodes.size();
|
||||||
for (int n=0; n<nodeAmount; n++)
|
for (int n=0; n<nodeAmount; n++)
|
||||||
|
@ -57,9 +57,6 @@ private:
|
|||||||
void showFor(float time);
|
void showFor(float time);
|
||||||
void reset();
|
void reset();
|
||||||
void update (float delta_t);
|
void update (float delta_t);
|
||||||
/** Returns true if the stars are currently shown. */
|
|
||||||
bool isEnabled() const { return m_enabled; }
|
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ void Flyable::getClosestKart(const Kart **minKart, float *minDistSquared,
|
|||||||
// If a kart has star effect shown, the kart is immune, so
|
// If a kart has star effect shown, the kart is immune, so
|
||||||
// it is not considered a target anymore.
|
// it is not considered a target anymore.
|
||||||
if(kart->isEliminated() || kart == m_owner ||
|
if(kart->isEliminated() || kart == m_owner ||
|
||||||
kart->getStarEffect()->isEnabled() ||
|
kart->isInvulnerable() ||
|
||||||
kart->playingEmergencyAnimation() ) continue;
|
kart->playingEmergencyAnimation() ) continue;
|
||||||
btTransform t=kart->getTrans();
|
btTransform t=kart->getTrans();
|
||||||
|
|
||||||
|
@ -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.
|
// Avoid doing another explosion while a kart is thrown around in the air.
|
||||||
if(playingEmergencyAnimation()) return;
|
if(playingEmergencyAnimation()) return;
|
||||||
|
if(m_kart->isInvulnerable())
|
||||||
|
return;
|
||||||
|
|
||||||
m_xyz = m_kart->getXYZ();
|
m_xyz = m_kart->getXYZ();
|
||||||
// Ignore explosion that are too far away.
|
// 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 )
|
if ( UserConfigParams::m_graphical_effects )
|
||||||
{
|
{
|
||||||
m_stars_effect->showFor(6.0f);
|
m_stars_effect->showFor(6.0f);
|
||||||
|
m_kart->setInvulnerableTime(6.0f);
|
||||||
}
|
}
|
||||||
m_kart->getAttachment()->clear();
|
m_kart->getAttachment()->clear();
|
||||||
} // handleExplosion
|
} // handleExplosion
|
||||||
|
@ -96,6 +96,7 @@ Kart::Kart (const std::string& ident, Track* track, int position, bool is_first_
|
|||||||
m_finished_race = false;
|
m_finished_race = false;
|
||||||
m_wheel_toggle = 1;
|
m_wheel_toggle = 1;
|
||||||
m_finish_time = 0.0f;
|
m_finish_time = 0.0f;
|
||||||
|
m_invulnerable_time = 0.0f;
|
||||||
m_shadow_enabled = false;
|
m_shadow_enabled = false;
|
||||||
m_shadow = NULL;
|
m_shadow = NULL;
|
||||||
m_terrain_particles = NULL;
|
m_terrain_particles = NULL;
|
||||||
@ -499,6 +500,7 @@ void Kart::reset()
|
|||||||
m_race_position = m_initial_position;
|
m_race_position = m_initial_position;
|
||||||
m_finished_race = false;
|
m_finished_race = false;
|
||||||
m_finish_time = 0.0f;
|
m_finish_time = 0.0f;
|
||||||
|
m_invulnerable_time = 0.0f;
|
||||||
m_collected_energy = 0;
|
m_collected_energy = 0;
|
||||||
m_has_started = false;
|
m_has_started = false;
|
||||||
m_wheel_rotation = 0;
|
m_wheel_rotation = 0;
|
||||||
@ -739,7 +741,7 @@ void Kart::update(float dt)
|
|||||||
getNode()->setVisible(false);
|
getNode()->setVisible(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the position and other data taken from the physics
|
// Update the position and other data taken from the physics
|
||||||
Moveable::update(dt);
|
Moveable::update(dt);
|
||||||
|
|
||||||
@ -747,9 +749,13 @@ void Kart::update(float dt)
|
|||||||
m_controller->update(dt);
|
m_controller->update(dt);
|
||||||
if(m_camera)
|
if(m_camera)
|
||||||
m_camera->update(dt);
|
m_camera->update(dt);
|
||||||
|
|
||||||
// if its view is blocked by plunger, decrease remaining time
|
// if its view is blocked by plunger, decrease remaining time
|
||||||
if(m_view_blocked_by_plunger > 0) m_view_blocked_by_plunger -= dt;
|
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);
|
m_slipstream->update(dt);
|
||||||
|
|
||||||
// Store the actual kart controls at the start of update in the server
|
// Store the actual kart controls at the start of update in the server
|
||||||
|
@ -109,10 +109,16 @@ private:
|
|||||||
|
|
||||||
/** For skidding smoke */
|
/** For skidding smoke */
|
||||||
int m_wheel_toggle;
|
int m_wheel_toggle;
|
||||||
|
|
||||||
float m_max_gear_rpm; /**<Maximum engine rpm's for the current gear*/
|
/**<Maximum engine rpm's for the current gear*/
|
||||||
float m_bounce_back_time; /**<A short time after a collision acceleration
|
float m_max_gear_rpm;
|
||||||
* is disabled to allow the karts to bounce back*/
|
|
||||||
|
/** 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
|
// Bullet physics parameters
|
||||||
// -------------------------
|
// -------------------------
|
||||||
@ -406,8 +412,14 @@ public:
|
|||||||
* the upright constraint to allow for more realistic explosions. */
|
* the upright constraint to allow for more realistic explosions. */
|
||||||
bool isNearGround () const;
|
bool isNearGround () const;
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
/** Makes a kart invulnerable for a certain amount of time. */
|
||||||
void setEnergy (float val) { m_collected_energy = val; }
|
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; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -140,8 +140,8 @@ void Physics::update(float dt)
|
|||||||
// Only explode a bowling ball if the target does not
|
// Only explode a bowling ball if the target does not
|
||||||
// the stars shown
|
// the stars shown
|
||||||
if(p->a->getPointerFlyable()->getType()
|
if(p->a->getPointerFlyable()->getType()
|
||||||
!=PowerupManager::POWERUP_BOWLING ||
|
!=PowerupManager::POWERUP_BOWLING ||
|
||||||
!p->b->getPointerKart()->getStarEffect()->isEnabled() )
|
!p->b->getPointerKart()->isInvulnerable() )
|
||||||
p->a->getPointerFlyable()->hit(p->b->getPointerKart());
|
p->a->getPointerFlyable()->hit(p->b->getPointerKart());
|
||||||
}
|
}
|
||||||
else // projectile hits projectile
|
else // projectile hits projectile
|
||||||
|
Loading…
x
Reference in New Issue
Block a user