set_group(COLGROUP_MOVING_ONLY_STATIC);
Player* player = dynamic_cast<Player*>(&object);
if (player) {
- if (countMe) Sector::current()->get_level()->stats.badguys++;
player->bounce(*this);
}
// start dead-script
- if(dead_script != "") {
- std::istringstream stream(dead_script);
- Sector::current()->run_script(stream, "dead-script");
- }
+ run_dead_script();
}
void
BadGuy::kill_fall()
{
sound_manager->play("sounds/fall.wav", get_pos());
- if (countMe) Sector::current()->get_level()->stats.badguys++;
physic.set_velocity_y(0);
physic.set_acceleration_y(0);
physic.enable_gravity(true);
set_state(STATE_FALLING);
// start dead-script
- if(dead_script != "") {
- std::istringstream stream(dead_script);
- Sector::current()->run_script(stream, "dead-script");
- }
+ run_dead_script();
}
void
BadGuy::run_dead_script()
{
- if (countMe)
+ if (countMe)
Sector::current()->get_level()->stats.badguys++;
+
+ countMe = false;
// start dead-script
if(dead_script != "") {
player->stop_grabbing();
}
- remove_me();
- Explosion* explosion = new Explosion(get_bbox().get_middle());
- Sector::current()->add_object(explosion);
+ if(is_valid()) {
+ remove_me();
+ Explosion* explosion = new Explosion(get_bbox().get_middle());
+ Sector::current()->add_object(explosion);
+ }
run_dead_script();
}
physic.set_velocity_y(0);
physic.enable_gravity(true);
set_state(STATE_FALLING);
+
+ run_dead_script();
}
HitResponse
reader.get("x", start_position.x);
sprite->set_action("falling");
physic.enable_gravity(false);
+ countMe = false;
}
void
{
set_state(DEAD);
sound_manager->play("sounds/fall.wav", get_pos());
- if (countMe) Sector::current()->get_level()->stats.badguys++;
+ run_dead_script();
}
HitResponse
{
set_state(DEAD);
sound_manager->play("sounds/squish.wav", get_pos());
- if (countMe) Sector::current()->get_level()->stats.badguys++;
+ run_dead_script();
return true;
}
bool
MrBomb::collision_squished(GameObject& object)
{
- remove_me();
- Sector::current()->add_object(new Bomb(get_pos(), dir, sprite_name ));
+ if(is_valid()) {
+ remove_me();
+ Sector::current()->add_object(new Bomb(get_pos(), dir, sprite_name ));
+ }
kill_squished(object);
return true;
}
void
MrBomb::kill_fall()
{
- remove_me();
- Explosion* explosion = new Explosion(get_bbox().get_middle());
- Sector::current()->add_object(explosion);
+ if(is_valid()) {
+ remove_me();
+ Explosion* explosion = new Explosion(get_bbox().get_middle());
+ Sector::current()->add_object(explosion);
+ }
run_dead_script();
}
if (Sector::current()->is_free_of_movingstatics(leaf1_bbox, this)) {
PoisonIvy* leaf1 = new PoisonIvy(leaf1_bbox.p1, LEFT);
leaf1 = leaf1;
+ leaf1->countMe = false;
Sector::current()->add_object(leaf1);
}
if (Sector::current()->is_free_of_movingstatics(leaf2_bbox, this)) {
PoisonIvy* leaf2 = new PoisonIvy(leaf2_bbox.p1, RIGHT);
leaf2 = leaf2;
+ leaf2->countMe = false;
Sector::current()->add_object(leaf2);
}
void
Root::deactivate()
{
- remove_me();
+ remove_me();
+ //no dead script
}
void
set_colgroup_active(COLGROUP_MOVING_ONLY_STATIC);
sprite->set_action("dead");
- if (countMe) Sector::current()->get_level()->stats.badguys++;
-
- if(dead_script != "") {
- std::istringstream stream(dead_script);
- Sector::current()->run_script(stream, "Yeti - dead-script");
- }
+ run_dead_script();
}
else {
safe_timer.start(SAFE_TIME);