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MYBMRRYHYEB5IPIJRUVU5QC }static bool _slime_pit_enable_teleport_control(){return unset_level_flags(LFLAG_NO_TELE_CONTROL);}static void _fire_monster_death_event(monsters *monster,killer_type killer,int i){dungeon_events.fire_event(dgn_event(DET_MONSTER_DIED, monster->pos(), 0,monster_index(monster), killer));if (monster->type == MONS_ROYAL_JELLY)apply_to_level( level_id(BRANCH_SLIME_PITS, 6),true,_slime_pit_enable_teleport_control );
bool apply_to_all_dungeons(bool (*applicator)())
static void _restore_level(const level_id &original){// Reload the original level.you.where_are_you = original.branch;you.your_level = original.absdepth();you.level_type = original.level_type;load( DNGN_STONE_STAIRS_DOWN_I, LOAD_VISITOR,you.level_type, you.your_level, you.where_are_you );}// Given a level in the dungeon (i.e. level_type == LEVEL_DUNGEON),// returns true if the level has been created already in this game.// Asserts if the level_type is not LEVEL_DUNGEON.bool is_existing_level(const level_id &level){ASSERT(level.level_type == LEVEL_DUNGEON);return (tmp_file_pairs[level.absdepth()][level.branch]);}// Applies an operation (applicator) after switching to the specified level.// If preserve_current is true, will reload the original level after// modifying the target level.//// If the target level has not already been visited by the player, this// function will assert.//bool apply_to_level(const level_id &level, bool preserve_current,bool (*applicator)())
const branch_type original_branch = you.where_are_you;const int original_level = you.your_level;const level_area_type original_type = you.level_type;
ASSERT(is_existing_level(level));const level_id original = level_id::current();if (level != original){you.where_are_you = level.branch;you.your_level = level.absdepth();you.level_type = level.level_type;// Load the dungeon level...load( DNGN_STONE_STAIRS_DOWN_I, LOAD_VISITOR,LEVEL_DUNGEON, original.absdepth(),original.branch );}
branch_type last_visited_branch = original_branch;int last_visited_level = original_level;const coord_def old_pos(you.pos());
// Apply the change.const bool result = applicator();if (level != original){// And save it back.save_level(you.your_level, you.level_type, you.where_are_you);if (preserve_current)_restore_level(original);}return (result);}
// Don't apply to the original level - already done up top.if ( original_type == you.level_type &&original_level == you.your_level &&original_branch == you.where_are_you )continue;// Load the dungeon level...load( DNGN_STONE_STAIRS_DOWN_I, LOAD_VISITOR,LEVEL_DUNGEON, last_visited_level,last_visited_branch );// Modify it...if ( applicator() )success = true;// And save it back.save_level(you.your_level, LEVEL_DUNGEON, you.where_are_you);
if (!is_existing_level(thislevel))continue;// Don't apply to the original level - already done up top.if (original == thislevel)continue;
if not (pars.level_flags ~= "" or pars.branch_flags ~= "") thenerror("Must provide at least one of level_flags or branch_flags.")
if pars.level_flags == "" and pars.branch_flags == ""and not pars.triggerthenerror("Must provide at least one of level_flags, branch_flags, or trigger.")