Description |
Currently if you tab with a rod equipped, it moves you towards the enemy, and only asks if you're sure you want to attack with it once you're in range. The attached patch exposes wielded_weapon_check to lua (as crawl.weapon_check), and calls that before moving towards an enemy with tab, so that you get the warning instead of moving towards the enemy.
Maybe there are people who prefer the old behavior, although dumping you into melee range with a useless weapon seems cruel to me, so perhaps a new rcfile option to enable/disable this change is warranted? |
Attached Files |
autofight_rods.patch [^] (2,168 bytes) 2015-04-19 22:55 [Show Content] [Hide Content]From 96397635529509edebea8de84a379dbfaed1079b Mon Sep 17 00:00:00 2001
From: Alan Malloy <alan@malloys.org>
Date: Sun, 19 Apr 2015 13:50:26 -0700
Subject: [PATCH] Warn the player when tabbing with a bad weapon.
It already warns you once you're in melee rangs with, say, a rod;
this patch gives you a warning even when you're not yet in melee
range, instead of moving you toward the enemy while wielding
a stupid weapon.
---
crawl-ref/source/dat/clua/autofight.lua | 2 +-
crawl-ref/source/l_crawl.cc | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/crawl-ref/source/dat/clua/autofight.lua b/crawl-ref/source/dat/clua/autofight.lua
index 2afa6b6..a74ae05 100644
--- a/crawl-ref/source/dat/clua/autofight.lua
+++ b/crawl-ref/source/dat/clua/autofight.lua
@@ -298,7 +298,7 @@ function attack(allow_movement)
attack_melee(x,y)
elseif info.attack_type == 1 then
attack_reach(x,y)
- elseif allow_movement then
+ elseif allow_movement and crawl.weapon_check() then
move_towards(x,y)
elseif AUTOFIGHT_WAIT then
crawl.process_keys('s')
diff --git a/crawl-ref/source/l_crawl.cc b/crawl-ref/source/l_crawl.cc
index 253e0b3..3bcb3ac 100644
--- a/crawl-ref/source/l_crawl.cc
+++ b/crawl-ref/source/l_crawl.cc
@@ -20,6 +20,7 @@ module "crawl"
#include "dlua.h"
#include "end.h"
#include "english.h"
+#include "fight.h"
#include "hints.h"
#include "initfile.h"
#include "itemname.h"
@@ -680,6 +681,7 @@ LUARET1(crawl_x_chance_in_y, boolean, x_chance_in_y(luaL_checkint(ls, 1),
LUARET1(crawl_div_rand_round, number, div_rand_round(luaL_checkint(ls, 1),
luaL_checkint(ls, 2)))
LUARET1(crawl_random_real, number, random_real())
+LUARET1(crawl_weapon_check, boolean, wielded_weapon_check(you.weapon()))
// Get the full worley noise datum for a given point
static int crawl_worley(lua_State *ls)
@@ -1098,6 +1100,7 @@ static const struct luaL_reg crawl_clib[] =
{ "call_dlua", crawl_call_dlua },
#endif
{ "version", crawl_version },
+ { "weapon_check", crawl_weapon_check},
{ nullptr, nullptr },
};
--
1.9.1
|