New option: prompt to abandon spells/abilities

This commit is contained in:
Rob Pearce 2016-06-07 20:12:22 +10:00
parent fd450ba0c3
commit d98ba870ca
5 changed files with 17 additions and 7 deletions

1
data.c
View File

@ -10340,6 +10340,7 @@ void initoptions(void) {
addoption(OPT_STOPRUNONNOISE, "stop running if sound heard", B_TRUE); addoption(OPT_STOPRUNONNOISE, "stop running if sound heard", B_TRUE);
addoption(OPT_TIMEDEBUG, "enable performance debugging", B_FALSE); addoption(OPT_TIMEDEBUG, "enable performance debugging", B_FALSE);
addoption(OPT_ABSORBNOTIFY, "liquid absorption notifications", B_FALSE); addoption(OPT_ABSORBNOTIFY, "liquid absorption notifications", B_FALSE);
addoption(OPT_CONFIRM_SPELLCANCEL, "confirm spell/ability cancellation", B_FALSE);
} }
void initrace(void) { void initrace(void) {

1
defs.h
View File

@ -4823,6 +4823,7 @@ enum OPTION {
OPT_STOPRUNONNOISE, OPT_STOPRUNONNOISE,
OPT_TIMEDEBUG, OPT_TIMEDEBUG,
OPT_ABSORBNOTIFY, OPT_ABSORBNOTIFY,
OPT_CONFIRM_SPELLCANCEL,
}; };
typedef struct option_s { typedef struct option_s {

5
io.c
View File

@ -8476,7 +8476,12 @@ char *makedesc_spell(objecttype_t *ot, char *retbuf) {
strncat(retbuf, buf, BUFLEN); strncat(retbuf, buf, BUFLEN);
if (range != UNLIMITED) { if (range != UNLIMITED) {
if (getspellmaxpower(ot->id) == 1) {
sprintf(buf, "It has a range of %d cell%s",range, (range == 1) ? "" : "s");
} else {
sprintf(buf, "At this power, it has a range of %d cell%s",range, (range == 1) ? "" : "s"); sprintf(buf, "At this power, it has a range of %d cell%s",range, (range == 1) ? "" : "s");
}
if (minrange != 0) { if (minrange != 0) {
char buf2[BUFLEN]; char buf2[BUFLEN];
sprintf(buf2, " (minimum %d)", minrange); sprintf(buf2, " (minimum %d)", minrange);

5
lf.c
View File

@ -6023,12 +6023,13 @@ void enhanceskills(lifeform_t *lf) {
enum SPELLSCHOOL school; enum SPELLSCHOOL school;
school = getspellschoolknown(lf, o->type->id); school = getspellschoolknown(lf, o->type->id);
if (school == ch) { if (school == ch) {
char buf[BUFLEN]; char buf[BUFLEN],descbuf[HUGEBUFLEN];
snprintf(buf, BUFLEN, "%s (%s) [%d points]", o->type->name, snprintf(buf, BUFLEN, "%s (%s) [%d points]", o->type->name,
getschoolname(school), getschoolname(school),
getspelllevel(o->type->id) ); getspelllevel(o->type->id) );
makedesc_spell(o->type, descbuf);
addchoice(&prompt, o->type->id, o->type->name, buf, o, NULL); addchoice(&prompt, o->type->id, o->type->name, buf, o, descbuf);
} }
} }
addchoice(&prompt, '-', "(none)", NULL, NULL, NULL); addchoice(&prompt, '-', "(none)", NULL, NULL, NULL);

View File

@ -16032,11 +16032,13 @@ cell_t *validatespellcell(lifeform_t *caster, cell_t **targcell, int targtype, e
if (!where) { if (!where) {
char ques[BUFLEN]; char ques[BUFLEN];
int ch; int ch;
if (getoption(OPT_CONFIRM_SPELLCANCEL)) {
snprintf(ques, BUFLEN, "Abandon your %s?", (sp->obclass->id == OC_SPELL) ? "spell" : "ability"); snprintf(ques, BUFLEN, "Abandon your %s?", (sp->obclass->id == OC_SPELL) ? "spell" : "ability");
ch = askchar(ques,"yn","n", B_TRUE, B_FALSE); ch = askchar(ques,"yn","n", B_TRUE, B_FALSE);
if (ch == 'y') { } else {
return NULL; ch = 'y';
} }
if (ch == 'y') return NULL;
} }
} else { } else {
// TODO: fill in monster code? // TODO: fill in monster code?