- fix a bunch of msvc warnings (mostly assigning double constants to float variables)
[supertux.git] / src / badguy / yeti.cpp
index 909fbe2..76f0faa 100644 (file)
@@ -1,5 +1,5 @@
 //  $Id$
-// 
+//
 //  SuperTux - Boss "Yeti"
 //  Copyright (C) 2005 Matthias Braun <matze@braunis.de>
 //  Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
@@ -13,7 +13,7 @@
 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 //  GNU General Public License for more details.
-// 
+//
 //  You should have received a copy of the GNU General Public License
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -42,7 +42,7 @@ namespace {
   const float STOMP_VY = -250; /** vertical speed while stomping on the dais */
 
   const float LEFT_STAND_X = 16; /**< x-coordinate of left dais' end position */
-  const float RIGHT_STAND_X = 800-60-16; /**< x-coordinate of right dais' end position */ 
+  const float RIGHT_STAND_X = 800-60-16; /**< x-coordinate of right dais' end position */
   const float LEFT_JUMP_X = LEFT_STAND_X+224; /**< x-coordinate of from where to jump on the left dais */
   const float RIGHT_JUMP_X = RIGHT_STAND_X-224; /**< x-coordinate of from where to jump on the right dais */
   const float STOMP_WAIT = .5; /**< time we stay on the dais before jumping again */
@@ -56,10 +56,10 @@ Yeti::Yeti(const lisp::Lisp& reader)
        : BadGuy(reader, "images/creatures/yeti/yeti.sprite")
 {
   hit_points = INITIAL_HITPOINTS;
-  reader.get("dead-script", dead_script);
   countMe = false;
   sound_manager->preload("sounds/yeti_gna.wav");
   sound_manager->preload("sounds/yeti_roar.wav");
+  draw_dead_script_hint = false;
 }
 
 Yeti::~Yeti()
@@ -164,18 +164,21 @@ Yeti::summon_snowball()
 }
 
 bool
-Yeti::collision_squished(Player& player)
+Yeti::collision_squished(GameObject& object)
 {
-  kill_squished(player);
+  kill_squished(object);
 
   return true;
 }
 
 void
-Yeti::kill_squished(Player& player)
+Yeti::kill_squished(GameObject& object)
 {
-    player.bounce(*this);
-    take_hit(player);
+  Player* player = dynamic_cast<Player*>(&object);
+  if (player) {
+    player->bounce(*this);
+    take_hit(*player);
+  }
 }
 
 void Yeti::take_hit(Player& )
@@ -191,7 +194,7 @@ void Yeti::take_hit(Player& )
     physic.enable_gravity(true);
     physic.set_velocity_x(0);
     physic.set_velocity_y(0);
-    
+
     state = SQUISHED;
     state_timer.start(SQUISH_TIME);
     set_group(COLGROUP_MOVING_ONLY_STATIC);
@@ -199,7 +202,6 @@ void Yeti::take_hit(Player& )
 
     if (countMe) Sector::current()->get_level()->stats.badguys++;
 
-    // start script
     if(dead_script != "") {
       std::istringstream stream(dead_script);
       Sector::current()->run_script(stream, "Yeti - dead-script");
@@ -225,10 +227,6 @@ Yeti::write(lisp::Writer& writer)
   writer.write_float("x", start_position.x);
   writer.write_float("y", start_position.y);
 
-  if(dead_script != "") {
-    writer.write_string("dead-script", dead_script);
-  }
-
   writer.end_list("yeti");
 }
 
@@ -236,7 +234,7 @@ void
 Yeti::drop_stalactite()
 {
   // make a stalactite falling down and shake camera a bit
-  Sector::current()->camera->shake(.1, 0, 10);
+  Sector::current()->camera->shake(.1f, 0, 10);
 
   YetiStalactite* nearest = 0;
   float dist = FLT_MAX;
@@ -249,7 +247,7 @@ Yeti::drop_stalactite()
       i != sector->gameobjects.end(); ++i) {
     YetiStalactite* stalactite = dynamic_cast<YetiStalactite*> (*i);
     if(stalactite && stalactite->is_hanging()) {
-      float sdist 
+      float sdist
         = fabsf(stalactite->get_pos().x - player->get_pos().x);
       if(sdist < dist) {
         nearest = stalactite;
@@ -265,7 +263,7 @@ Yeti::drop_stalactite()
 void
 Yeti::collision_solid(const CollisionHit& hit)
 {
-  if(hit.top || hit.bottom) { 
+  if(hit.top || hit.bottom) {
     // hit floor or roof
     physic.set_velocity_y(0);
     switch (state) {