summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2009-12-27 16:37:34 +0100
committerAdam Borowski <kilobyte@angband.pl>2009-12-27 16:44:05 +0100
commit2be5d5f08528b99817be0cf6fe8c04bab40842ec (patch)
tree6a5b556620e5a599c6f79f3053c4f927d903a215 /crawl-ref
parentfa0307d3451bef981c807759f956b0de01d5485f (diff)
downloadcrawl-ref-2be5d5f08528b99817be0cf6fe8c04bab40842ec.tar.gz
crawl-ref-2be5d5f08528b99817be0cf6fe8c04bab40842ec.zip
Untie disarm confirmations from autotravel settings (Mantis 254).
Since it is done only on an explicit request, copious safety margins are not needed. I didn't provide an alternate way to disable the confirmation, but since the danger is now always real, I don't think that's needed.
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/trap_def.h1
-rw-r--r--crawl-ref/source/traps.cc37
2 files changed, 27 insertions, 11 deletions
diff --git a/crawl-ref/source/trap_def.h b/crawl-ref/source/trap_def.h
index 90c2cc4372..2ec924d3b4 100644
--- a/crawl-ref/source/trap_def.h
+++ b/crawl-ref/source/trap_def.h
@@ -18,6 +18,7 @@ struct trap_def
void prepare_ammo();
bool type_has_ammo() const;
bool active() const;
+ int max_damage(const actor& act);
private:
void message_trap_entry();
diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc
index e2dcd625ea..9083576b6e 100644
--- a/crawl-ref/source/traps.cc
+++ b/crawl-ref/source/traps.cc
@@ -677,7 +677,7 @@ void trap_def::trigger(actor& triggerer, bool flat_footed)
this->destroy();
}
-int trap_def::shot_damage(actor& act)
+int trap_def::max_damage(const actor& act)
{
int level = you.your_level;
@@ -691,17 +691,27 @@ int trap_def::shot_damage(actor& act)
switch (this->type)
{
case TRAP_NEEDLE: return 0;
- case TRAP_DART: return random2( 4 + level/2) + 1;
- case TRAP_ARROW: return random2( 7 + level) + 1;
- case TRAP_SPEAR: return random2(10 + level) + 1;
- case TRAP_BOLT: return random2(13 + level) + 1;
- case TRAP_AXE: return random2(15 + level) + 1;
+ case TRAP_DART: return 4 + level/2;
+ case TRAP_ARROW: return 7 + level;
+ case TRAP_SPEAR: return 10 + level;
+ case TRAP_BOLT: return 13 + level;
+ case TRAP_AXE: return 15 + level;
default: return 0;
+ case TRAP_BLADE: return (level ? level*2 : 10) + 28;
}
return (0);
}
+int trap_def::shot_damage(actor& act)
+{
+ const int dam = max_damage(act);
+
+ if (!dam)
+ return 0;
+ return random2(dam) + 1;
+}
+
int reveal_traps(const int range)
{
int traps_found = 0;
@@ -746,6 +756,15 @@ trap_type get_trap_type(const coord_def& pos)
return (TRAP_UNASSIGNED);
}
+static bool _disarm_is_deadly(trap_def& trap)
+{
+ int dam = trap.max_damage(you);
+ if (trap.type == TRAP_NEEDLE && you.res_poison() <= 0)
+ dam += 15; // arbitrary
+
+ return you.hp <= dam;
+}
+
// where *must* point to a valid, discovered trap.
void disarm_trap(const coord_def& where)
{
@@ -770,11 +789,8 @@ void disarm_trap(const coord_def& where)
break;
}
-#ifdef CLUA_BINDINGS
// Prompt for any trap for which you might not survive setting it off.
- // (See trapwalk.lua)
- if (Options.trap_prompt
- && !clua.callbooleanfn(false, "ch_cross_trap", "s", trap_name(where)))
+ if (_disarm_is_deadly(trap))
{
std::string prompt = make_stringf(
"Really try disarming that %s?",
@@ -789,7 +805,6 @@ void disarm_trap(const coord_def& where)
return;
}
}
-#endif
// Make the actual attempt
you.turn_is_over = true;