diff options
author | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-07-02 06:27:57 +0000 |
---|---|---|
committer | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-07-02 06:27:57 +0000 |
commit | efc837897078fce5beb9f4bb45b511b84e1ce7a8 (patch) | |
tree | fe63cc6c8b304b66cda5c0f04fa2fdde380e0137 /crawl-ref/source/spl-cast.cc | |
parent | 592a6c88a467f707864336f0ac06367b99ff8fe7 (diff) | |
download | crawl-ref-efc837897078fce5beb9f4bb45b511b84e1ce7a8.tar.gz crawl-ref-efc837897078fce5beb9f4bb45b511b84e1ce7a8.zip |
Make your_spells() only give the "Invalid spell!" message if the spell type
is truly invalid. If it's a valid but monster-only spell:
1) If the user is in wizard mode then temporarily place a dummy monster
on the same square as the player and use it to cast the monster spell
(this lets monster spells be cast via wizard commands for testing
purposes).
2) If the user isn't in wizard mode then give the message
"Spell '[spellname]' is not a player castable spell.", which provides more
useful debugging info than just "Invalid spell!"
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6325 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/spl-cast.cc')
-rw-r--r-- | crawl-ref/source/spl-cast.cc | 77 |
1 files changed, 76 insertions, 1 deletions
diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index 5d60865592..237b1e1c53 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -41,6 +41,7 @@ #include "misc.h" #include "monplace.h" #include "monstuff.h" +#include "mstuff2.h" #include "mutation.h" #include "ouch.h" #include "player.h" @@ -909,6 +910,67 @@ static bool _spell_is_uncastable(spell_type spell) return (false); } +#ifdef WIZARD +static void _try_monster_cast(spell_type spell, int powc, + dist &spd, bolt &beam) +{ + if (mgrd(you.pos()) != NON_MONSTER) + { + mpr("Couldn't try casting monster spell because you're " + "on top of a monster."); + return; + } + + int midx; + + for (midx = 0; midx < MAX_MONSTERS; midx++) + if (menv[midx].type == -1) + break; + + if (midx == MAX_MONSTERS) + { + mpr("Couldn't try casting monster spell because there is " + "no empty monster slot."); + return; + } + + mpr("Invalid player spell, attemtping to cast it as monster spell."); + + monsters* mon = &menv[midx]; + + mon->mname = "Dummy Monster"; + mon->type = MONS_HUMAN; + mon->behaviour = BEH_SEEK; + mon->attitude = ATT_FRIENDLY; + mon->flags = (MF_CREATED_FRIENDLY | MF_JUST_SUMMONED | MF_SEEN + | MF_WAS_IN_VIEW | MF_HARD_RESET); + mon->hit_points = you.hp; + mon->hit_dice = you.experience_level; + mon->x = you.x_pos; + mon->y = you.y_pos; + mon->target_x = spd.tx; + mon->target_y = spd.ty; + + if (!spd.isTarget) + mon->foe = MHITNOT; + else if (mgrd[spd.tx][spd.ty] == NON_MONSTER) + { + if (spd.isMe) + mon->foe = MHITYOU; + else + mon->foe = MHITNOT; + } + else + mon->foe = mgrd[spd.tx][spd.ty]; + + mgrd(you.pos()) = midx; + + mons_cast(mon, beam, spell); + + mon->reset(); +} +#endif // WIZARD + // Returns SPRET_SUCCESS if spell is successfully cast for purposes of // exercising, SPRET_FAIL otherwise, or SPRET_ABORT if the player canceled // the casting. @@ -2032,7 +2094,20 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail) break; default: - mpr("Invalid spell!"); +#ifdef WIZARD + if (you.wizard && !allow_fail && is_valid_spell(spell)) + { + _try_monster_cast(spell, powc, spd, beam); + return (SPRET_SUCCESS); + } +#endif + + if (is_valid_spell(spell)) + mprf(MSGCH_ERROR, "Spell '%s' is not a player castable spell.", + spell_title(spell)); + else + mpr("Invalid spell!", MSGCH_ERROR); + break; } // end switch |