From f18bad8e43ddfd0fc58ed6dc37a206e16e5f933d Mon Sep 17 00:00:00 2001 From: Erik Lunna Date: Fri, 22 Sep 2023 07:14:28 +0200 Subject: [PATCH] Fix: a couple bugs with wizmode command #wizspell. From EvilHack commit 68be09ac32 --- src/cmd.c | 13 +++++++++---- src/spell.c | 5 +++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/cmd.c b/src/cmd.c index ab8c0953e..3b0fbf827 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -980,19 +980,24 @@ wiz_map(VOID_ARGS) return 0; } -/* ^S command - cast any spell. */ +/* ^S command - cast any spell, does not require energy to use */ STATIC_PTR int wiz_spell(VOID_ARGS) { char buf[BUFSZ] = DUMMY; int last_spbook, i; + while (buf[0] == '\0' || buf[0] == '\033') { - getlin("What spell do you successfully cast without energy use?", buf); + getlin("Which spell to cast?", buf); (void) mungspaces(buf); } - last_spbook = (SPBOOK_CLASS + 1 < MAXOCLASSES ? bases[SPBOOK_CLASS + 1] : NUM_OBJECTS) - 1; + + last_spbook = (SPBOOK_CLASS + 1 < MAXOCLASSES + ? bases[SPBOOK_CLASS + 1] : NUM_OBJECTS) - 1; + for (i = bases[SPBOOK_CLASS]; i <= last_spbook; ++i) { - if (objects[i].oc_skill < P_FIRST_SPELL || objects[i].oc_skill > P_LAST_SPELL) + if (objects[i].oc_skill < P_FIRST_SPELL + || objects[i].oc_skill > P_LAST_SPELL) continue; if (!strcmpi(buf, OBJ_NAME(objects[i]))) { /* pline("Casting [%d] %s", i, buf); */ diff --git a/src/spell.c b/src/spell.c index e919841bc..b14faffde 100644 --- a/src/spell.c +++ b/src/spell.c @@ -1241,7 +1241,7 @@ boolean wiz_cast; added per cast. the players intelligence must be greater than 6 to be able to help remember spells as they're cast. cavepersons are the one role that do not have this benefit */ - if (!Role_if(PM_CAVEMAN) && ACURR(A_INT) > 6) { + if (!wiz_cast && !Role_if(PM_CAVEMAN) && ACURR(A_INT) > 6) { spl_book[spell].sp_know += rn1(ACURR(A_INT) * 5, ACURR(A_INT) * 2); if (spl_book[spell].sp_know >= KEEN) spl_book[spell].sp_know = KEEN; @@ -1314,7 +1314,8 @@ boolean wiz_cast; } else if (role_skill >= P_SKILLED) { /* player said not to cast advanced spell; return up to half of the * magical energy */ - u.uen += rnd(energy / 2); + if (!wiz_cast) + u.uen += rnd(energy / 2); } /*FALLTHRU*/