diff options
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/spells2.cc | 21 | ||||
-rw-r--r-- | crawl-ref/source/traps.cc | 23 | ||||
-rw-r--r-- | crawl-ref/source/traps.h | 1 |
3 files changed, 26 insertions, 19 deletions
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index 58f66d2bae..ab3c2d378f 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -55,27 +55,10 @@ int detect_traps(int pow) { pow = std::min(50, pow); - int traps_found = 0; + // Trap detection moved to traps.cc. -am const int range = 8 + random2(8) + pow; - - for (int i = 0; i < MAX_TRAPS; i++) - { - trap_def& trap = env.trap[i]; - - if (!trap.active()) - continue; - - if (grid_distance(you.pos(), trap.pos) < range && !trap.is_known()) - { - traps_found++; - trap.reveal(); - set_map_knowledge_obj(trap.pos, show_type(grd(trap.pos))); - set_terrain_mapped(trap.pos); - } - } - - return (traps_found); + return reveal_traps(range); } int detect_items(int pow) diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc index 53313da1d5..3ac701c57a 100644 --- a/crawl-ref/source/traps.cc +++ b/crawl-ref/source/traps.cc @@ -733,6 +733,29 @@ int trap_def::shot_damage(actor& act) return (0); } +int reveal_traps(const int range) +{ + int traps_found = 0; + + for (int i = 0; i < MAX_TRAPS; i++) + { + trap_def& trap = env.trap[i]; + + if (!trap.active()) + continue; + + if (grid_distance(you.pos(), trap.pos) < range && !trap.is_known()) + { + traps_found++; + trap.reveal(); + set_map_knowledge_obj(trap.pos, show_type(grd(trap.pos))); + set_terrain_mapped(trap.pos); + } + } + + return (traps_found); +} + void destroy_trap( const coord_def& pos ) { if (trap_def* ptrap = find_trap(pos)) diff --git a/crawl-ref/source/traps.h b/crawl-ref/source/traps.h index 7f49e2bcca..bd25c0c9a8 100644 --- a/crawl-ref/source/traps.h +++ b/crawl-ref/source/traps.h @@ -27,6 +27,7 @@ void check_net_will_hold_monster(monsters *mon); dungeon_feature_type trap_category(trap_type type); +int reveal_traps(const int range); void destroy_trap(const coord_def& pos); trap_def* find_trap(const coord_def& where); trap_type get_trap_type(const coord_def& where); |