From 9b64fa1406add5c9bd2f2505faea4915bc4a92ee Mon Sep 17 00:00:00 2001 From: hikerstk Date: Sat, 4 Jun 2011 13:29:35 +0000 Subject: [PATCH] 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 --- src/graphics/stars.cpp | 4 ++-- src/graphics/stars.hpp | 3 --- src/items/flyable.cpp | 2 +- src/karts/emergency_animation.cpp | 3 +++ src/karts/kart.cpp | 8 +++++++- src/karts/kart.hpp | 24 ++++++++++++++++++------ src/physics/physics.cpp | 4 ++-- 7 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/graphics/stars.cpp b/src/graphics/stars.cpp index 4ede5014a..10c5eec68 100644 --- a/src/graphics/stars.cpp +++ b/src/graphics/stars.cpp @@ -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; nisEliminated() || kart == m_owner || - kart->getStarEffect()->isEnabled() || + kart->isInvulnerable() || kart->playingEmergencyAnimation() ) continue; btTransform t=kart->getTrans(); diff --git a/src/karts/emergency_animation.cpp b/src/karts/emergency_animation.cpp index 39b87b87b..522bbdccc 100644 --- a/src/karts/emergency_animation.cpp +++ b/src/karts/emergency_animation.cpp @@ -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 diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index dc08ad9a7..8f991dbd0 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -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 diff --git a/src/karts/kart.hpp b/src/karts/kart.hpp index 15daeba57..abba9d703 100644 --- a/src/karts/kart.hpp +++ b/src/karts/kart.hpp @@ -109,10 +109,16 @@ private: /** For skidding smoke */ int m_wheel_toggle; - - float m_max_gear_rpm; /** 0; } + // ------------------------------------------------------------------------ + /** Sets the energy the kart has collected. */ + void setEnergy(float val) { m_collected_energy = val; } }; diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp index 00ff2718c..3c23b1c7d 100644 --- a/src/physics/physics.cpp +++ b/src/physics/physics.cpp @@ -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