summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mon-movetarget.cc
diff options
context:
space:
mode:
authorDracoOmega <draco_omega@live.com>2014-03-07 13:22:32 -0330
committerDracoOmega <draco_omega@live.com>2014-03-11 20:07:32 -0230
commitbb6088fec99f460e3e42ac86610d8cb552bdf78b (patch)
treebccf57accf56a6fddab1da29a7e2aeb09424b9ff /crawl-ref/source/mon-movetarget.cc
parent1a18c9ac3d99df1ecaa57289612e5ba601de365b (diff)
downloadcrawl-ref-bb6088fec99f460e3e42ac86610d8cb552bdf78b.tar.gz
crawl-ref-bb6088fec99f460e3e42ac86610d8cb552bdf78b.zip
Adjust siren movement behavior
This changes the metric for how sirens select their movement destination in a couple ways. They no longer try to surround themselves completely with deep water, but instead prefer at least one neighbouring tile be shallow water or land. The presence of a single tile of deep water is valued more highly, but multiples more lowly. Moreover, they will no longer always reposition if a more optimal spot is visible to them, so long as their current location is 'okay enough', which should reduce the distances they move while still trying to give them sufficient terrain advantage. In general, this should cause them to make themselves inaccessible far less often, as well as move away less often, period.
Diffstat (limited to 'crawl-ref/source/mon-movetarget.cc')
-rw-r--r--crawl-ref/source/mon-movetarget.cc39
1 files changed, 30 insertions, 9 deletions
diff --git a/crawl-ref/source/mon-movetarget.cc b/crawl-ref/source/mon-movetarget.cc
index 736e4dc8f5..2ed6374e9b 100644
--- a/crawl-ref/source/mon-movetarget.cc
+++ b/crawl-ref/source/mon-movetarget.cc
@@ -307,21 +307,40 @@ bool pacified_leave_level(monster* mon, vector<level_exit> e, int e_index)
return false;
}
-// Counts deep water twice (and reports if any is found).
-static int _count_water_neighbours(coord_def p, bool& deep)
+// Assesses how desirable a spot is to a siren (preferring spaces surrounded
+// by water, at least one of which is deep, and with at least one neighbour
+// which is inhabitable without swimming or flight)
+static int _siren_water_score(coord_def p, bool& deep)
{
- int water_count = 0;
+ int score = 0;
+ bool near_floor = false;
+ deep = false;
+
for (adjacent_iterator ai(p); ai; ++ai)
{
if (grd(*ai) == DNGN_SHALLOW_WATER)
- water_count++;
+ {
+ score++;
+ near_floor = true;
+ }
else if (grd(*ai) == DNGN_DEEP_WATER)
{
- water_count += 2;
+ score++;
deep = true;
}
+ else if (feat_has_solid_floor(grd(*ai)))
+ near_floor = true;
}
- return water_count;
+
+ // Greatly prefer at least one tile of neighbouring deep water
+ if (deep)
+ score += 6;
+
+ // Slightly prefer standing in deep water, if possible
+ if (grd(p) == DNGN_DEEP_WATER)
+ score++;
+
+ return score;
}
// Pick the nearest water grid that is surrounded by the most
@@ -339,8 +358,10 @@ bool find_siren_water_target(monster* mon)
bool deep;
- // Already completely surrounded by deep water.
- if (_count_water_neighbours(mon->pos(), deep) >= 16)
+ // If our current location is good enough, don't bother moving towards
+ // some other spot which might be somewhat better
+ if (_siren_water_score(mon->pos(), deep) >= 12 && deep
+ && grd(mon->pos()) == DNGN_DEEP_WATER)
{
mon->firing_pos = mon->pos();
return true;
@@ -378,7 +399,7 @@ bool find_siren_water_target(monster* mon)
continue;
// Counts deep water twice.
- const int water_count = _count_water_neighbours(*ri, deep);
+ const int water_count = _siren_water_score(*ri, deep);
if (water_count < best_water_count)
continue;