From: Mathnerd314 Date: Tue, 19 Jan 2010 03:06:25 +0000 (+0000) Subject: MrBomb, MrIceBlock, and Snail now die on invincibility rather than just being kicked... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=6e9a46ef5f9d2877b0bb41e574ed468e72262f56;p=supertux.git MrBomb, MrIceBlock, and Snail now die on invincibility rather than just being kicked. (Also incorporates Matt's patch for bug 468) SVN-Revision: 6262 --- diff --git a/src/badguy/mrbomb.cpp b/src/badguy/mrbomb.cpp index 9614e742f..8b411892c 100644 --- a/src/badguy/mrbomb.cpp +++ b/src/badguy/mrbomb.cpp @@ -18,6 +18,7 @@ #include "badguy/bomb.hpp" #include "badguy/mrbomb.hpp" #include "object/explosion.hpp" +#include "object/player.hpp" #include "sprite/sprite.hpp" #include "sprite/sprite_manager.hpp" #include "supertux/object_factory.hpp" @@ -77,6 +78,12 @@ MrBomb::collision_player(Player& player, const CollisionHit& hit) bool MrBomb::collision_squished(GameObject& object) { + Player* player = dynamic_cast(&object); + if(player && player->is_invincible()) { + player->bounce(*this); + kill_fall(); + return true; + } if(is_valid()) { remove_me(); Sector::current()->add_object(new Bomb(get_pos(), dir, sprite_name )); diff --git a/src/badguy/mriceblock.cpp b/src/badguy/mriceblock.cpp index 9cc320ab5..4b8d6e332 100644 --- a/src/badguy/mriceblock.cpp +++ b/src/badguy/mriceblock.cpp @@ -177,6 +177,13 @@ MrIceBlock::collision_badguy(BadGuy& badguy, const CollisionHit& hit) bool MrIceBlock::collision_squished(GameObject& object) { + Player* player = dynamic_cast(&object); + if(player && (player->does_buttjump || player->is_invincible())) { + player->bounce(*this); + kill_fall(); + return true; + } + switch(ice_state) { case ICESTATE_KICKED: { @@ -190,9 +197,8 @@ MrIceBlock::collision_squished(GameObject& object) // fall through case ICESTATE_NORMAL: { - Player* player = dynamic_cast(&object); squishcount++; - if ((squishcount >= MAXSQUISHES) || (player && player->does_buttjump)) { + if (squishcount >= MAXSQUISHES) { kill_fall(); return true; } @@ -217,7 +223,6 @@ MrIceBlock::collision_squished(GameObject& object) break; } - Player* player = dynamic_cast(&object); if (player) player->bounce(*this); return true; } diff --git a/src/badguy/snail.cpp b/src/badguy/snail.cpp index cff4b6304..c441b0158 100644 --- a/src/badguy/snail.cpp +++ b/src/badguy/snail.cpp @@ -185,14 +185,20 @@ Snail::collision_badguy(BadGuy& badguy, const CollisionHit& hit) bool Snail::collision_squished(GameObject& object) { + Player* player = dynamic_cast(&object); + if(player && (player->does_buttjump || player->is_invincible())) { + kill_fall(); + player->bounce(*this); + return true; + } + switch(state) { case STATE_KICKED: case STATE_NORMAL: { - Player* player = dynamic_cast(&object); squishcount++; - if ((squishcount >= MAX_SNAIL_SQUISHES) || (player && player->does_buttjump)) { + if (squishcount >= MAX_SNAIL_SQUISHES) { kill_fall(); return true; } @@ -220,7 +226,6 @@ Snail::collision_squished(GameObject& object) } - Player* player = dynamic_cast(&object); if (player) player->bounce(*this); return true; }