diff options
author | DracoOmega <draco_omega@live.com> | 2014-02-25 07:35:15 -0330 |
---|---|---|
committer | Steve Melenchuk <smelenchuk@gmail.com> | 2014-03-06 09:58:10 -0700 |
commit | 760ea11527efb8d90367cbcc6d747789651cd3a5 (patch) | |
tree | 6d695c3f52225d4d1cf037fe06e49242bf02c089 /crawl-ref/source/mon-act.cc | |
parent | 2a0814e80e4265e48f4a64bdc9eff03199f80c2f (diff) | |
download | crawl-ref-760ea11527efb8d90367cbcc6d747789651cd3a5.tar.gz crawl-ref-760ea11527efb8d90367cbcc6d747789651cd3a5.zip |
An attempt at some AI improvements for spellforged servitors
There are two main changes here:
Firstly, given that this summon is more likely to be used by conjurers
than a typical summon, the tendency for them to walk into your line of
fire is more problematic than usual. I have added some fairly 'dumb'
code to try and reduce their chances of doing this. All it does is
refuse to let the servitor step anywhere in the direct line between the
player and the servitor's current enemy target, unless it's already
there (either you stepped behind it, or it acquired this target while
already interposed). This target is not guaranteed to be what the player
wants to fire at themselves, of course, but there's probably a
reasonable chance that it often is.
Secondly, make the servitor likely to hold position once its target is
within range for all of its spells, rather than close further into
melee. It has no melee attack in the first place, and I think that
keeping its distance will help it avoid blocking the player's line of
fire in other cases (as well as help the servitor's own survival).
It will not actually retreat, however - simply not advance.
My hope is that neither of these behaviors will obtrusively apparent
(produce visibly strange behavior) and simply result in it causing
fewer visible problems in actual games.
Diffstat (limited to 'crawl-ref/source/mon-act.cc')
-rw-r--r-- | crawl-ref/source/mon-act.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/crawl-ref/source/mon-act.cc b/crawl-ref/source/mon-act.cc index a5ef9ac9b3..fa9946b37a 100644 --- a/crawl-ref/source/mon-act.cc +++ b/crawl-ref/source/mon-act.cc @@ -30,6 +30,7 @@ #include "items.h" #include "item_use.h" #include "libutil.h" +#include "los.h" #include "mapmark.h" #include "message.h" #include "misc.h" @@ -3329,6 +3330,31 @@ bool mon_can_move_to_pos(const monster* mons, const coord_def& delta, if (mons->type == MONS_FIRE_ELEMENTAL && feat_is_watery(target_grid)) return false; + // Try to avoid deliberately blocking the player's line of fire. + if (mons->type == MONS_SPELLFORGED_SERVITOR) + { + // Only check if our target is something the player could theoretically + // be aiming at. + if (mons->get_foe() && mons->target != you.pos() + && you.see_cell_no_trans(mons->target)) + { + ray_def ray; + if (find_ray(you.pos(), mons->target, ray, opc_immob)) + { + while (ray.advance()) + { + // Either we've reached the end of the ray, or we're already + // (maybe) in the player's way and shouldn't care if our + // next step also is. + if (ray.pos() == mons->target || ray.pos() == mons->pos()) + break; + else if (ray.pos() == targ) + return false; + } + } + } + } + // Submerged water creatures avoid the shallows where // they would be forced to surface. -- bwr // [dshaligram] Monsters now prefer to head for deep water only if |