Skip to content

Commit

Permalink
Fix: a couple bugs with wizmode command #wizspell.
Browse files Browse the repository at this point in the history
From EvilHack commit 68be09ac32
  • Loading branch information
elunna committed Sep 22, 2023
1 parent e4bc2f4 commit f18bad8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
13 changes: 9 additions & 4 deletions src/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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); */
Expand Down
5 changes: 3 additions & 2 deletions src/spell.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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*/

Expand Down

0 comments on commit f18bad8

Please sign in to comment.