summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/actor.cc4
-rw-r--r--crawl-ref/source/actor.h2
-rw-r--r--crawl-ref/source/misc.cc6
-rw-r--r--crawl-ref/source/monster.cc2
-rw-r--r--crawl-ref/source/player.cc7
-rw-r--r--crawl-ref/source/traps.cc86
-rw-r--r--crawl-ref/source/traps.h2
7 files changed, 49 insertions, 60 deletions
diff --git a/crawl-ref/source/actor.cc b/crawl-ref/source/actor.cc
index 1a79413525..16e67aed3b 100644
--- a/crawl-ref/source/actor.cc
+++ b/crawl-ref/source/actor.cc
@@ -30,9 +30,9 @@ bool actor::will_trigger_shaft() const
return (!airborne() && total_weight() > 0 && is_valid_shaft_level());
}
-level_id actor::shaft_dest() const
+level_id actor::shaft_dest(bool known = false) const
{
- return generic_shaft_dest(pos());
+ return generic_shaft_dest(pos(), known);
}
bool actor::airborne() const
diff --git a/crawl-ref/source/actor.h b/crawl-ref/source/actor.h
index 97e65922cb..a4d76ef56e 100644
--- a/crawl-ref/source/actor.h
+++ b/crawl-ref/source/actor.h
@@ -248,7 +248,7 @@ public:
virtual bool has_spell(spell_type spell) const = 0;
virtual bool will_trigger_shaft() const;
- virtual level_id shaft_dest() const;
+ virtual level_id shaft_dest(bool known) const;
virtual bool do_shaft() = 0;
coord_def position;
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index 54456fc8a5..b5182b278b 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -2213,7 +2213,7 @@ void down_stairs( int old_level, dungeon_feature_type force_stair,
return;
}
- shaft_dest = you.shaft_dest();
+ shaft_dest = you.shaft_dest(known_trap);
if (shaft_dest == level_id::current())
{
if (known_trap)
@@ -2230,6 +2230,10 @@ void down_stairs( int old_level, dungeon_feature_type force_stair,
if (you.flight_mode() != FL_FLY || force_stair)
mpr("You fall through a shaft!");
+
+ // Shafts are one-time-use.
+ mpr("The shaft crumbles and collapses!");
+ find_trap(you.pos())->destroy();
}
if (stair_find == DNGN_ENTER_ZOT && !you.opened_zot)
diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc
index ad1d1b499c..abedfba501 100644
--- a/crawl-ref/source/monster.cc
+++ b/crawl-ref/source/monster.cc
@@ -5564,7 +5564,7 @@ bool monsters::do_shaft()
}
}
- level_id lev = shaft_dest();
+ level_id lev = shaft_dest(false);
if (lev == level_id::current())
return (false);
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index e36fd474e6..be27606499 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -203,10 +203,10 @@ bool move_player_to_grid( const coord_def& p, bool stepped, bool allow_shift,
#ifdef CLUA_BINDINGS
// Prompt for any trap where you might not have enough hp
// as defined in init.txt (see trapwalk.lua)
- if (new_grid != DNGN_TRAP_MECHANICAL
- && type != TRAP_SHAFT
+ if (type != TRAP_SHAFT // Known shafts aren't traps
+ && (new_grid != DNGN_TRAP_MECHANICAL
|| !clua.callbooleanfn(false, "ch_cross_trap",
- "s", trap_name(p)))
+ "s", trap_name(p))))
#endif
{
std::string prompt = make_stringf(
@@ -7309,7 +7309,6 @@ bool player::do_shaft()
return (false);
}
- mpr("A shaft briefly opens up underneath you!");
handle_items_on_shaft(this->pos(), false);
if (airborne() || total_weight() == 0)
diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc
index a8d47fa834..4251ffe78f 100644
--- a/crawl-ref/source/traps.cc
+++ b/crawl-ref/source/traps.cc
@@ -626,6 +626,9 @@ void trap_def::trigger(actor& triggerer, bool flat_footed)
break;
case TRAP_SHAFT:
+ // Unknown shafts are traps triggered by walking onto them.
+ // Known shafts are used as escape hatches
+
// Paranoia
if (!is_valid_shaft_level())
{
@@ -636,48 +639,19 @@ void trap_def::trigger(actor& triggerer, bool flat_footed)
break;
}
+ // If the shaft isn't triggered, don't reveal it.
+ if (!triggerer.will_trigger_shaft() && !you_know)
+ this->hide();
+
// Known shafts don't trigger as traps.
if (trig_knows)
- {
- if (you_trigger)
- {
- if (triggerer.airborne())
- {
- if (you.flight_mode() == FL_LEVITATE)
- mpr("You float over the shaft.");
- else
- mpr("You fly over the shaft.");
- }
- else
- mpr("You carefully avoid triggering the shaft.");
- }
break;
- }
-
- if (!triggerer.will_trigger_shaft())
- {
- if (!you_know)
- this->hide();
- else if (!triggerer.airborne())
- {
- if (you_trigger)
- {
- mpr("You don't fall through the shaft.");
- }
- else if (m)
- {
- simple_monster_message(m,
- " doesn't fall through the shaft.");
- }
- }
- }
// Fire away!
- {
- const bool revealed = triggerer.do_shaft();
- if (!revealed && !you_know)
- this->hide();
- }
+ triggerer.do_shaft();
+
+ // Shafts are destroyed
+ // after one use in down_stairs(), misc.cc
break;
default:
@@ -1341,10 +1315,10 @@ bool is_valid_shaft_level(const level_id &place)
return ((branch.depth - place.depth) >= min_delta);
}
-level_id generic_shaft_dest(level_pos lpos)
+level_id generic_shaft_dest(level_pos lpos, bool known = false)
{
- level_id lid = lpos.id;
- coord_def pos = lpos.pos;
+ level_id lid = lpos.id;
+ coord_def pos = lpos.pos;
if (lid.level_type != LEVEL_DUNGEON)
return lid;
@@ -1352,14 +1326,26 @@ level_id generic_shaft_dest(level_pos lpos)
int curr_depth = lid.depth;
Branch &branch = branches[lid.branch];
- // 25% drop one level
- // 50% drop two levels
- // 25% drop three levels
- lid.depth += 2;
- if (pos.x % 2)
- lid.depth--;
- if (pos.y % 2)
- lid.depth++;
+ // Shaft traps' behavior depends on whether it is entered intentionally.
+ // Knowingly entering one is more likely to drop you 1 level.
+ // Falling in unknowingly can drop you 1/2/3 levels with equal chance.
+
+ if (known)
+ {
+ // Chances are 5/8s for 1 level, 2/8s for 2 levels, 1/8 for 3 levels
+ int s = random2(8) + 1;
+ if (s == 1)
+ lid.depth += 3;
+ else if (s <= 3)
+ lid.depth += 2;
+ else
+ lid.depth += 1;
+ }
+ else
+ {
+ // 33.3% for 1, 2, 3
+ lid.depth += 1 + random2(3);
+ }
if (lid.depth > branch.depth)
lid.depth = branch.depth;
@@ -1382,7 +1368,7 @@ level_id generic_shaft_dest(level_pos lpos)
return lid;
}
-level_id generic_shaft_dest(coord_def pos)
+level_id generic_shaft_dest(coord_def pos, bool known = false)
{
return generic_shaft_dest(level_pos(level_id::current(), pos));
}
@@ -1392,7 +1378,7 @@ void handle_items_on_shaft(const coord_def& pos, bool open_shaft)
if (!is_valid_shaft_level())
return;
- level_id dest = generic_shaft_dest(pos);
+ level_id dest = generic_shaft_dest(pos);
if (dest == level_id::current())
return;
diff --git a/crawl-ref/source/traps.h b/crawl-ref/source/traps.h
index bd25c0c9a8..1fe167040f 100644
--- a/crawl-ref/source/traps.h
+++ b/crawl-ref/source/traps.h
@@ -33,7 +33,7 @@ trap_def* find_trap(const coord_def& where);
trap_type get_trap_type(const coord_def& where);
bool is_valid_shaft_level(const level_id &place = level_id::current());
-level_id generic_shaft_dest(coord_def pos);
+level_id generic_shaft_dest(coord_def pos, bool known);
void handle_items_on_shaft(const coord_def& where, bool open_shaft);
int num_traps_for_place(int level_number = -1,