summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/directn.cc
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-24 09:59:53 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-24 11:05:13 +0100
commit0c9cba8792edc5ef6eb52dc0a51393c169c4a6b7 (patch)
tree7c55f061a53abc572eb025904eba4985b15f8680 /crawl-ref/source/directn.cc
parente022aaa532c3c4b5cd43b1ea7d43e1e2e4e7aa91 (diff)
downloadcrawl-ref-0c9cba8792edc5ef6eb52dc0a51393c169c4a6b7.tar.gz
crawl-ref-0c9cba8792edc5ef6eb52dc0a51393c169c4a6b7.zip
Allow overriding of monster target selection through Lua.
_find_monster now calls ch_target_monster with coordinates of a possible target. Currently ch_target_monster is only passed the relative coordinates of the possible target. It could easily be passed flags like need_path. Eventually, it should be able to check what the targetting is about (which spell, etc.), but that's not so easy to do currently.
Diffstat (limited to 'crawl-ref/source/directn.cc')
-rw-r--r--crawl-ref/source/directn.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc
index 405078316b..07736e93ce 100644
--- a/crawl-ref/source/directn.cc
+++ b/crawl-ref/source/directn.cc
@@ -2020,6 +2020,17 @@ static bool _find_mlist(const coord_def& where, int idx, bool need_path,
static bool _find_monster( const coord_def& where, int mode, bool need_path,
int range = -1)
{
+#ifdef CLUA_BINDINGS
+ {
+ coord_def dp = grid2player(where);
+ // We could pass more info here.
+ maybe_bool x = clua.callmbooleanfn("ch_target_monster", "dd",
+ dp.x, dp.y);
+ if (x != B_MAYBE)
+ return (tobool(x));
+ }
+#endif
+
// Target the player for friendly and general spells.
if ((mode == TARG_FRIEND || mode == TARG_ANY) && where == you.pos())
return (true);