diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-08-28 19:41:00 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-08-28 19:41:00 +0000 |
commit | 1a5a0bf7895f13de0e85719c00e6bc95a5a0798d (patch) | |
tree | 33297179c03960e37903240b044abd26ee47c13f /crawl-ref/source | |
parent | 717609abcaa13c7e83ea5300e0a73897d3166b54 (diff) | |
download | crawl-ref-1a5a0bf7895f13de0e85719c00e6bc95a5a0798d.tar.gz crawl-ref-1a5a0bf7895f13de0e85719c00e6bc95a5a0798d.zip |
Apply patch by (?) to make Apportation autotarget the nearest object.
Thanks!
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10608 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/directn.cc | 44 | ||||
-rw-r--r-- | crawl-ref/source/enum.h | 3 | ||||
-rw-r--r-- | crawl-ref/source/spl-cast.cc | 9 |
3 files changed, 37 insertions, 19 deletions
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index 242befcd6e..58b2bae261 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -1054,24 +1054,32 @@ void direction(dist& moves, targeting_type restricts, bool target_unshifted = Options.target_unshifted_dirs; // Find a default target. - if (Options.default_target && (mode == TARG_ENEMY || mode == TARG_HOSTILE)) + if (Options.default_target) { - skip_iter = true; // Skip first iteration...XXX mega-hack - if (you.prev_targ != MHITNOT && you.prev_targ != MHITYOU) + if (restricts == DIR_TARGET_OBJECT) { - const monsters *montarget = &menv[you.prev_targ]; - if (you.can_see(montarget) - // not made friendly since then - && (mons_attitude(montarget) == ATT_HOSTILE - || mode == TARG_ENEMY && !mons_friendly(montarget)) - && _is_target_in_range(montarget->pos(), range)) + skip_iter = true; + found_autotarget = true; + } + else if (Options.default_target && (mode == TARG_ENEMY || mode == TARG_HOSTILE)) + { + skip_iter = true; // Skip first iteration...XXX mega-hack + if (you.prev_targ != MHITNOT && you.prev_targ != MHITYOU) { - found_autotarget = true; - moves.target = montarget->pos(); + const monsters *montarget = &menv[you.prev_targ]; + if (you.can_see(montarget) + // not made friendly since then + && (mons_attitude(montarget) == ATT_HOSTILE + || mode == TARG_ENEMY && !mons_friendly(montarget)) + && _is_target_in_range(montarget->pos(), range)) + { + found_autotarget = true; + moves.target = montarget->pos(); + } } } } - + bool show_prompt = true; bool moved_with_keys = true; @@ -1124,14 +1132,22 @@ void direction(dist& moves, targeting_type restricts, if (skip_iter) { - if (found_autotarget) + if (restricts == DIR_TARGET_OBJECT) + { + key_command = CMD_TARGET_OBJ_CYCLE_FORWARD; + } + else if (found_autotarget) + { key_command = CMD_NO_CMD; + } else + { key_command = CMD_TARGET_CYCLE_FORWARD; // Find closest target. + } } else { - key_command = beh->get_command(); + key_command = beh->get_command(); } #ifdef USE_TILE diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index e3021b85eb..550c677fab 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -2896,7 +2896,8 @@ enum targeting_type { DIR_NONE, DIR_TARGET, - DIR_DIR + DIR_DIR, + DIR_TARGET_OBJECT // New as of 27-August-2009, for item-targeting spells }; enum torment_source_type diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index 381ddf95d8..79a6c369cf 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -1171,10 +1171,11 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail) targ = TARG_ANY; targeting_type dir = - (testbits( flags, SPFLAG_TARGET ) ? DIR_TARGET : - testbits( flags, SPFLAG_GRID ) ? DIR_TARGET : - testbits( flags, SPFLAG_DIR ) ? DIR_DIR - : DIR_NONE); + ( (spell == SPELL_APPORTATION) ? DIR_TARGET_OBJECT : + testbits(flags, SPFLAG_TARGET) ? DIR_TARGET : + testbits(flags, SPFLAG_GRID) ? DIR_TARGET : + testbits(flags, SPFLAG_DIR) ? DIR_DIR : + DIR_NONE ); const char *prompt = get_spell_target_prompt(spell); if (spell == SPELL_EVAPORATE) |