Bowling balls will only affect karts that are

directly hit now.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11860 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk
2012-11-04 12:57:03 +00:00
parent 381412322e
commit a65147cad5
7 changed files with 31 additions and 11 deletions

View File

@@ -209,6 +209,6 @@ bool Bowling::hit(AbstractKart* kart, PhysicalObject* obj)
{
bool was_real_hit = Flyable::hit(kart, obj);
if(was_real_hit)
explode(kart, obj);
explode(kart, obj, /*hit_secondary*/false);
return was_real_hit;
} // hit

View File

@@ -469,8 +469,13 @@ bool Flyable::hit(AbstractKart *kart_hit, PhysicalObject* object)
// ----------------------------------------------------------------------------
/** Creates the explosion physical effect, i.e. pushes the karts and ph
* appropriately. The corresponding visual/sfx needs to be added manually!
* \param kart_hit If non-NULL a kart that was directly hit.
* \param object If non-NULL a physical item that was hit directly.
* \param secondary_hits True if items that are not directly hit should
* also be affected.
*/
void Flyable::explode(AbstractKart *kart_hit, PhysicalObject *object)
void Flyable::explode(AbstractKart *kart_hit, PhysicalObject *object,
bool secondary_hits)
{
// Apply explosion effect
// ----------------------
@@ -478,6 +483,12 @@ void Flyable::explode(AbstractKart *kart_hit, PhysicalObject *object)
for ( unsigned int i = 0 ; i < world->getNumKarts() ; i++ )
{
AbstractKart *kart = world->getKart(i);
// If no secondary hits should be done, only hit the
// direct hit kart.
if(!secondary_hits && kart!=kart_hit)
continue;
// Handle the actual explosion. The kart that fired a flyable will
// only be affected if it's a direct hit. This allows karts to use
// rockets on short distance.
@@ -492,7 +503,7 @@ void Flyable::explode(AbstractKart *kart_hit, PhysicalObject *object)
}
}
}
world->getTrack()->handleExplosion(getXYZ(), object);
world->getTrack()->handleExplosion(getXYZ(), object, secondary_hits);
} // explode
// ----------------------------------------------------------------------------

View File

@@ -172,7 +172,8 @@ public:
void updateFromServer(const FlyableInfo &f, float dt);
bool isOwnerImmunity(const AbstractKart *kart_hit) const;
virtual bool hit(AbstractKart* kart, PhysicalObject* obj=NULL);
void explode(AbstractKart* kart, PhysicalObject* obj=NULL);
void explode(AbstractKart* kart, PhysicalObject* obj=NULL,
bool secondary_hits=true);
// ------------------------------------------------------------------------
/** If true the up velocity of the flyable will be adjust so that the
* flyable stays at a height close to the average height.

View File

@@ -1101,10 +1101,12 @@ void Track::update(float dt)
* \param pos Position of the explosion.
* \param obj If the hit was a physical object, this object will be affected
* more. Otherwise this is NULL.
*/
void Track::handleExplosion(const Vec3 &pos, const PhysicalObject *obj) const
* \param secondary_hits True if items that are not directly hit should
* also be affected. */
void Track::handleExplosion(const Vec3 &pos, const PhysicalObject *obj,
bool secondary_hits) const
{
m_track_object_manager->handleExplosion(pos, obj);
m_track_object_manager->handleExplosion(pos, obj, secondary_hits);
} // handleExplosion
// ----------------------------------------------------------------------------

View File

@@ -377,7 +377,8 @@ public:
void setAmbientColor(const video::SColor &color,
unsigned int k);
void handleExplosion(const Vec3 &pos,
const PhysicalObject *mp) const;
const PhysicalObject *mp,
bool secondary_hits=true) const;
std::vector< std::vector<float> >
buildHeightMap();
// ------------------------------------------------------------------------

View File

@@ -143,14 +143,18 @@ void TrackObjectManager::reset()
* \param pos Position of the explosion.
* \param obj If the hit was a physical object, this object will be affected
* more. Otherwise this is NULL.
* \param secondary_hits True if items that are not directly hit should
* also be affected.
*/
void TrackObjectManager::handleExplosion(const Vec3 &pos, const PhysicalObject *mp)
void TrackObjectManager::handleExplosion(const Vec3 &pos, const PhysicalObject *mp,
bool secondary_hits)
{
TrackObject* curr;
for_in (curr, m_all_objects)
{
curr->handleExplosion(pos, mp == curr);
if(secondary_hits || mp==curr)
curr->handleExplosion(pos, mp == curr);
}
} // handleExplosion

View File

@@ -56,7 +56,8 @@ public:
~TrackObjectManager();
void add(const XMLNode &xml_node);
void update(float dt);
void handleExplosion(const Vec3 &pos, const PhysicalObject *mp);
void handleExplosion(const Vec3 &pos, const PhysicalObject *mp,
bool secondary_hits=true);
void reset();
void init();