From a04e11a6d9dd82506a2f0cbf1d4100f609ea2f15 Mon Sep 17 00:00:00 2001 From: mathnerd314 Date: Tue, 19 Jan 2010 03:06:25 +0000 Subject: [PATCH] MrBomb, MrIceBlock, and Snail now die on invincibility rather than just being kicked. (Also incorporates Matt's patch for bug 468) git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6262 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- src/badguy/mrbomb.cpp | 7 +++++++ src/badguy/mriceblock.cpp | 11 ++++++++--- src/badguy/snail.cpp | 11 ++++++++--- 3 files changed, 23 insertions(+), 6 deletions(-) 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; } -- 2.11.0