/** * @brief Creates a door. * @param game The game. * @param name Name identifying this entity. * @param layer Layer of the entity to create. * @param x X coordinate of the entity to create. * @param y Y coordinate of the entity to create. * @param direction Direction of the door. * @param sprite_name Name of the animation set of the * sprite to create for the door. * The sprite must have an animation \c "closed", that will be shown while * the door is closed. Optionally, they sprite can also have animations * \c "opening" and \c "closing", that will be shown (if they exist) * while the door is being opened or closed, respectively. * If they don't exist, the door will get opened or closed instantly. * @param savegame_variable Boolean variable where the door's state is saved * (an empty string lets the door unsaved). */ Door::Door(Game& game, const std::string& name, Layer layer, int x, int y, int direction, const std::string& sprite_name, const std::string& savegame_variable): Detector(COLLISION_FACING_POINT | COLLISION_SPRITE, name, layer, x, y, 16, 16), savegame_variable(savegame_variable), opening_method(OPENING_NONE), opening_condition(), opening_condition_consumed(false), cannot_open_dialog_id(), state(OPEN), initialized(false), next_hint_sound_date(0) { Sprite& sprite = create_sprite(sprite_name, true); sprite.set_ignore_suspend(true); // Continue the animation while the camera is moving. set_direction(direction); if (is_saved()) { set_open(game.get_savegame().get_boolean(savegame_variable)); } else { set_open(false); } sprite.set_current_direction(direction); }
/** * \copydoc Detector::notify_action_command_pressed */ bool Chest::notify_action_command_pressed() { if (is_enabled() && get_hero().is_free() && get_keys_effect().get_action_key_effect() != KeysEffect::ACTION_KEY_NONE ) { if (can_open()) { Sound::play("chest_open"); set_open(true); treasure_date = System::now() + 300; get_keys_effect().set_action_key_effect(KeysEffect::ACTION_KEY_NONE); get_hero().start_freezed(); } else if (!get_cannot_open_dialog_id().empty()) { Sound::play("wrong"); get_game().start_dialog(get_cannot_open_dialog_id(), ScopedLuaRef(), ScopedLuaRef()); } return true; } return false; }
void reset() { ::reset(); set_open("door", 0); set_locked("door", 1); MJUNGLE "tomb20.c"->set_open("door", 0); MJUNGLE "tomb20.c"->set_locked("door", 1); }
void reset() { ::reset(); set_open("door", 1); set_locked("door", 0); "/d/shadow/rooms/palace27.c"->set_open("door", 1); "/d/shadow/rooms/palace27.c"->set_locked("door", 0); }
/** * @brief Updates the entity. */ void Door::update() { Detector::update(); if (!initialized) { update_dynamic_tiles(); initialized = true; } if (is_closed() && get_opening_method() == OPENING_BY_EXPLOSION && get_equipment().has_ability("detect_weak_walls") && Geometry::get_distance(get_center_point(), get_hero().get_center_point()) < 40 && !is_suspended() && System::now() >= next_hint_sound_date) { Sound::play("cane"); next_hint_sound_date = System::now() + 500; } if (is_changing() && get_sprite().is_animation_finished()) { // Toggle door_open when the changing animation finishes. set_open(is_opening()); } if (is_saved() && !is_changing()) { bool open_in_savegame = get_savegame().get_boolean(savegame_variable); if (open_in_savegame && is_closed()) { set_opening(); } else if (!open_in_savegame && is_open()) { set_closing(); } } }
/** * @brief Makes the door being closed. */ void Door::set_closing() { if (get_sprite().has_animation("closing")) { state = CLOSING; get_sprite().set_current_animation("closing"); } else { set_open(false); } }
/** * @brief Makes the door being opened. */ void Door::set_opening() { if (get_sprite().has_animation("opening")) { state = OPENING; get_sprite().set_current_animation("opening"); } else { set_open(true); } }
/** * @brief This function is called when the player interacts with this chest. * * This function is called when the player presses the action key * when the hero is facing this detector, and the action icon lets him do this. * The hero opens the chest if possible. */ void Chest::action_key_pressed() { if (is_visible() && get_hero().is_free()) { if (!big_chest || get_equipment().has_ability("open_dungeon_big_locks")) { Sound::play("chest_open"); set_open(true); treasure_date = System::now() + 300; get_keys_effect().set_action_key_effect(KeysEffect::ACTION_KEY_NONE); get_hero().start_freezed(); } else { Sound::play("wrong"); get_dialog_box().start_dialog("_big_key_required"); } } }
void create() { ::create(); set_property("indoors",1); set_property("light",1); set("short","Palace"); set("long","This room explains why this hall is well kept, yet mostly " "unused. On the east wall is a large set of double doors, engraved with intricate " "symbols. The decorations abruptly end here, while the hall continues north. " "The red carpet leads right up to the doors. This room must belong to royalty."); set_smell("default","There is a fresh breeze in this part of the palace."); set_listen("default","It is fairly quiet here."); set_items((["wall":"The wall is quite plain here on the second floor.", "doors":"The immense doors have been carved with great care.", "decorations":"They stop abruptly after the room to the east.", "carpet":"The %^RED%^crimson carpet%^RESET%^ covers the ground."])); set_door("door", ROOMS "palace27.c", "enter", "bedroom key"); set_open("door", 1); set_locked("door", 0); set_exits((["north":ROOMS "palace26.c","south":ROOMS "palace24.c","enter":ROOMS "palace27.c"])); }
varargs void vault_open(status from_twin) { set_open(True); if(!from_twin) query_twin()->vault_open(True); }