From 1f9e38751c81744f2e8d4ffb1aea7f3870ba9d5b Mon Sep 17 00:00:00 2001 From: haranp Date: Thu, 25 Sep 2008 17:13:23 +0000 Subject: Ranges redone. bolt no longer has a rangeMax, just a range. Almost all ranges are now capped by LOS. There are still some things missing, most noticeably randomizing ranges for the range-1-to-2 spells (e.g. Flame Tongue.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6984 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/spl-cast.cc | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) (limited to 'crawl-ref/source/spl-cast.cc') diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index 8dde8f6add..c72b4cffe2 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -944,6 +944,27 @@ beam_type _spell_to_beam_type(spell_type spell) return BEAM_NONE; } +int _setup_evaporate_cast() +{ + int rc = prompt_invent_item("Throw which potion?", MT_INVLIST, OBJ_POTIONS); + + if (prompt_failed(rc)) + { + rc = -1; + } + else if (you.inv[rc].base_type != OBJ_POTIONS) + { + mpr("This spell works only on potions!"); + rc = -1; + } + else + { + mprf(MSGCH_PROMPT, "Where do you want to aim %s?", + you.inv[rc].name(DESC_NOCAP_YOUR).c_str()); + } + return rc; +} + // Returns SPRET_SUCCESS if spell is successfully cast for purposes of // exercising, SPRET_FAIL otherwise, or SPRET_ABORT if the player canceled // the casting. @@ -986,19 +1007,9 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail) const char *prompt = get_spell_target_prompt(spell); if (spell == SPELL_EVAPORATE) { - potion = prompt_invent_item("Throw which potion?", - MT_INVLIST, OBJ_POTIONS); - - if (prompt_failed(potion)) - return (SPRET_ABORT); - - if (you.inv[potion].base_type != OBJ_POTIONS) - { - mpr("This spell works only on potions!"); + potion = _setup_evaporate_cast(); + if (potion == -1) return (SPRET_ABORT); - } - mprf(MSGCH_PROMPT, "Where do you want to aim %s?", - you.inv[potion].name(DESC_NOCAP_YOUR).c_str()); } else if (dir == DIR_DIR) mpr(prompt ? prompt : "Which direction?", MSGCH_PROMPT); @@ -1008,13 +1019,17 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail) const bool dont_cancel_me = testbits(flags, SPFLAG_AREA); - if (!spell_direction(spd, beam, dir, targ, needs_path, true, - dont_cancel_me, prompt, + const int range = spell_range(spell, powc, false); + + if (!spell_direction(spd, beam, dir, targ, range, + needs_path, true, dont_cancel_me, prompt, testbits(flags, SPFLAG_NOT_SELF))) { return (SPRET_ABORT); } + beam.range = spell_range(spell, powc, true); + if (testbits(flags, SPFLAG_NOT_SELF) && spd.isMe) { if (spell == SPELL_TELEPORT_OTHER || spell == SPELL_HEAL_OTHER -- cgit v1.2.3-54-g00ecf