summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/traps.cc
diff options
context:
space:
mode:
authorNicholas Feinberg <pleasingfung@gmail.com>2014-07-02 07:54:30 -0700
committerNicholas Feinberg <pleasingfung@gmail.com>2014-07-02 07:54:30 -0700
commit981af8bb92e8360cca9ec788720c04f06900da93 (patch)
tree21daf5473ada8d6eef2249dbafc649e19837fc22 /crawl-ref/source/traps.cc
parent886d980933ff95be25921ebadfea48feb1f37d17 (diff)
downloadcrawl-ref-981af8bb92e8360cca9ec788720c04f06900da93.tar.gz
crawl-ref-981af8bb92e8360cca9ec788720c04f06900da93.zip
Move a little more code out of misc.cc
Diffstat (limited to 'crawl-ref/source/traps.cc')
-rw-r--r--crawl-ref/source/traps.cc60
1 files changed, 55 insertions, 5 deletions
diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc
index 58e0d420cf..853c7d2998 100644
--- a/crawl-ref/source/traps.cc
+++ b/crawl-ref/source/traps.cc
@@ -11,6 +11,7 @@
#include <algorithm>
#include <math.h>
+#include "areas.h"
#include "artefact.h"
#include "beam.h"
#include "bloodspatter.h"
@@ -23,13 +24,15 @@
#include "describe.h"
#include "directn.h"
#include "dungeon.h"
+#include "env.h"
#include "exercise.h"
-#include "map_knowledge.h"
+#include "hints.h"
#include "itemname.h"
#include "itemprop.h"
#include "items.h"
#include "libutil.h"
#include "makeitem.h"
+#include "map_knowledge.h"
#include "mapmark.h"
#include "message.h"
#include "misc.h"
@@ -38,6 +41,8 @@
#include "mon-util.h"
#include "ouch.h"
#include "player.h"
+#include "religion.h"
+#include "shout.h"
#include "skills.h"
#include "spl-miscast.h"
#include "spl-util.h"
@@ -45,13 +50,9 @@
#include "state.h"
#include "stuff.h"
#include "travel.h"
-#include "env.h"
-#include "areas.h"
#include "terrain.h"
#include "transform.h"
-#include "hints.h"
#include "view.h"
-#include "shout.h"
#include "xom.h"
bool trap_def::active() const
@@ -1150,6 +1151,55 @@ static bool _disarm_is_deadly(trap_def& trap)
return you.hp <= dam;
}
+void search_around()
+{
+ ASSERT(!crawl_state.game_is_arena());
+
+ int base_skill = you.experience_level * 100 / 3;
+ int skill = (2/(1+exp(-(base_skill+120)/325.0))-1) * 225
+ + (base_skill/200.0) + 15;
+
+ if (you_worship(GOD_ASHENZARI) && !player_under_penance())
+ skill += you.piety * 2;
+
+ int max_dist = div_rand_round(skill, 32);
+ if (max_dist > 5)
+ max_dist = 5;
+ if (max_dist < 1)
+ max_dist = 1;
+
+ for (radius_iterator ri(you.pos(), max_dist, C_ROUND, LOS_NO_TRANS); ri; ++ri)
+ {
+ if (grd(*ri) != DNGN_UNDISCOVERED_TRAP)
+ continue;
+
+ int dist = ri->range(you.pos());
+
+ // Own square is not excluded; may be flying.
+ // XXX: Currently, flying over a trap will always detect it.
+
+ int effective = (dist <= 1) ? skill : skill / (dist * 2 - 1);
+
+ trap_def* ptrap = find_trap(*ri);
+ if (!ptrap)
+ {
+ // Maybe we shouldn't kill the trap for debugging
+ // purposes - oh well.
+ grd(*ri) = DNGN_FLOOR;
+ dprf("You found a buggy trap! It vanishes!");
+ continue;
+ }
+
+ if (effective > ptrap->skill_rnd)
+ {
+ ptrap->reveal();
+ mprf("You found %s!",
+ ptrap->name(DESC_A).c_str());
+ learned_something_new(HINT_SEEN_TRAP, *ri);
+ }
+ }
+}
+
// where *must* point to a valid, discovered trap.
void disarm_trap(const coord_def& where)
{