FIxed hitting a banana when having a bomb

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7801 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2011-03-04 00:05:38 +00:00
parent 94015c38cd
commit 5fcccd6f32

View File

@ -111,10 +111,13 @@ void Attachment::hitBanana(Item *item, int new_attachment)
{ {
float leftover_time = 0.0f; float leftover_time = 0.0f;
bool add_a_new_item = true;
switch(getType()) // If there already is an attachment, make it worse :) switch(getType()) // If there already is an attachment, make it worse :)
{ {
case ATTACH_BOMB: case ATTACH_BOMB:
{ {
add_a_new_item = false;
projectile_manager->newExplosion(m_kart->getXYZ()); projectile_manager->newExplosion(m_kart->getXYZ());
m_kart->handleExplosion(m_kart->getXYZ(), /*direct_hit*/ true); m_kart->handleExplosion(m_kart->getXYZ(), /*direct_hit*/ true);
clear(); clear();
@ -133,11 +136,11 @@ void Attachment::hitBanana(Item *item, int new_attachment)
// if the kart already has an anvil, attach a new anvil, // if the kart already has an anvil, attach a new anvil,
// and increase the overall time // and increase the overall time
new_attachment = 2; new_attachment = 2;
leftover_time = m_time_left; leftover_time = m_time_left;
break; break;
case ATTACH_PARACHUTE: case ATTACH_PARACHUTE:
new_attachment = 2; // anvil new_attachment = 2;
leftover_time = m_time_left; leftover_time = m_time_left;
break; break;
default: default:
// There is no attachment currently, but there will be one // There is no attachment currently, but there will be one
@ -157,30 +160,33 @@ void Attachment::hitBanana(Item *item, int new_attachment)
new_attachment); new_attachment);
} }
switch (new_attachment) if (add_a_new_item)
{ {
case 0: switch (new_attachment)
set( ATTACH_PARACHUTE,stk_config->m_parachute_time+leftover_time); {
m_initial_speed = m_kart->getSpeed(); case 0:
if(m_initial_speed <= 1.5) m_initial_speed = 1.5; // if going very slowly or backwards, braking won't remove parachute set( ATTACH_PARACHUTE,stk_config->m_parachute_time+leftover_time);
// if ( m_kart == m_kart[0] ) m_initial_speed = m_kart->getSpeed();
// sound -> playSfx ( SOUND_SHOOMF ) ; if(m_initial_speed <= 1.5) m_initial_speed = 1.5; // if going very slowly or backwards, braking won't remove parachute
break ; // if ( m_kart == m_kart[0] )
case 1: // sound -> playSfx ( SOUND_SHOOMF ) ;
set( ATTACH_BOMB, stk_config->m_bomb_time+leftover_time); break ;
// if ( m_kart == m_kart[0] ) case 1:
// sound -> playSfx ( SOUND_SHOOMF ) ; set( ATTACH_BOMB, stk_config->m_bomb_time+leftover_time);
break ; // if ( m_kart == m_kart[0] )
case 2: // sound -> playSfx ( SOUND_SHOOMF ) ;
set( ATTACH_ANVIL, stk_config->m_anvil_time+leftover_time); break ;
// if ( m_kart == m_kart[0] ) case 2:
// sound -> playSfx ( SOUND_SHOOMF ) ; set( ATTACH_ANVIL, stk_config->m_anvil_time+leftover_time);
// Reduce speed once (see description above), all other changes are // if ( m_kart == m_kart[0] )
// handled in Kart::updatePhysics // sound -> playSfx ( SOUND_SHOOMF ) ;
m_kart->adjustSpeed(stk_config->m_anvil_speed_factor); // Reduce speed once (see description above), all other changes are
m_kart->updatedWeight(); // handled in Kart::updatePhysics
break ; m_kart->adjustSpeed(stk_config->m_anvil_speed_factor);
} // switch m_kart->updatedWeight();
break ;
} // switch
}
} // hitBanana } // hitBanana
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------