- In THREAT ASSESSMENT, don't show both "your <limb> is destroyed" and "you have no <limb>".

- Make '0' work as a shortcut slot.
- Change default shortcuts
        Sixth sense -> 6 ("SIXth" -> "6th" -> 6)
        Tiptoe -> 0 ("tOE" -> "oh" -> 0)
        Training -> 9
This commit is contained in:
Rob Pearce 2016-06-03 15:28:05 +10:00
parent f3030981fa
commit e1edc8e14b
5 changed files with 74 additions and 30 deletions

2
defs.h
View File

@ -266,6 +266,8 @@
// >= MAXFLAGS
#define MAXCANDIDATES 2048
#define LASTSHORTCUT 9
#define MAXCHOICES 400
#define MAXDEPTH 25 // max dungeon depth
#define MAXDIR_ORTH 4

2
io.c
View File

@ -13255,6 +13255,7 @@ void showlfstats(lifeform_t *lf, int showall) {
getflags(lf->flags, retflag, &nretflags, F_NOBODYPART, F_NONE);
for (i = 0; i < nretflags; i++) {
bp = retflag[i]->val[0];
if (retflag[i]->lifetime != FROMINJURY) {
if (bp == BP_RIGHTFINGER) {
if (!lfhasflagval(lf, F_NOBODYPART, BP_HANDS, NA, NA, NULL)) {
missingbp[nmissingbp] = bp;
@ -13277,6 +13278,7 @@ void showlfstats(lifeform_t *lf, int showall) {
nmissingbp++;
}
}
}
if (nmissingbp) {
snprintf(buf, BUFLEN, "%s %s no %s",you(lf), isplayer(lf) ? "have" : "has", getbodypartname(lf, missingbp[0]));

53
lf.c
View File

@ -9401,16 +9401,34 @@ int getnaturalflightheight(lifeform_t *lf) {
return 0;
}
// returns a number from 1 - LASTSHORTCUT containing the first avilaable shortcut slot.
//
// if none available, return NA.
//
int getnextshortcut(lifeform_t *lf) {
flag_t *retflag[MAXCANDIDATES];
int nretflags,i,min = 0;
int nretflags,i,slotnum = 0;
// get all currently assigned shortcuts
getflags(lf->flags, retflag, &nretflags, F_SHORTCUT, F_NONE);
// use 1=10 instead of 0=9, so that '0' is last.
for (slotnum = 1; slotnum <= (LASTSHORTCUT+1); slotnum++) {
int found = B_FALSE;
// technically this is faster than using hasflagval()
for (i = 0; i < nretflags; i++) {
if (retflag[i]->val[0] > min) {
min = retflag[i]->val[0];
if (retflag[i]->val[0] == slotnum) {
found = B_TRUE;
break;
}
}
return min + 1;
if (!found) {
// this slot is available
if (slotnum == 10) slotnum = 0;
return slotnum;
}
}
return NA;
}
int getnightvisrange(lifeform_t *lf) {
@ -16758,18 +16776,36 @@ void autolearnspellsfrombook(lifeform_t *lf, object_t *book) {
}
}
void autoshortcut(lifeform_t *lf, enum OBTYPE spellid) {
// If spellid = OT_NONE, automatically assign slots for all job/race/skill abilities,
// starting at 'startslot'
//
// If spellid = <specific spell>, auto assign a shortcut just for that one. Use 'startslot'
// if given, otherwise pick the next available one.
//
void autoshortcut(lifeform_t *lf, enum OBTYPE spellid, int startslot) {
flag_t *retflag[MAXCANDIDATES],*f;
int nretflags,i;
int min = 1;
int min = 0;
objecttype_t *ot = NULL;
if (startslot == NA) {
min = getnextshortcut(lf);
if (min == NA) return;
} else {
min = startslot;
}
if (min == 10) min = 0;
limit(&min, 0, LASTSHORTCUT);
getflags(lf->flags, retflag, &nretflags, F_CANCAST, F_CANWILL, F_NONE);
min = getnextshortcut(lf);
for (i = 0; (i < nretflags) && (min < 10); i++) {
for (i = 0; (i < nretflags) && (min <= LASTSHORTCUT); i++) {
f = retflag[i];
ot = findot(f->val[0]);
if (!ot) continue;
// already have a shortcut for this?
if (lfhasflagval(lf, F_SHORTCUT, NA, NA, NA, ot->name)) continue;
if (spellid == OT_NONE) {
// autoshortcut everything from your job/race
@ -16779,6 +16815,7 @@ void autoshortcut(lifeform_t *lf, enum OBTYPE spellid) {
if (!lfhasflagval(lf, F_SHORTCUT, NA, NA, NA, ot->name)) {
addflag(lf->flags, F_SHORTCUT, min, NA, NA, ot->name);
min = getnextshortcut(lf);
if (min == NA) return;
}
}
} else {

2
lf.h
View File

@ -30,7 +30,7 @@ int askforinfo(lifeform_t *lf, int diffmod);
char *assignnpcname(flagpile_t *fp);
int attrincreasable(enum ATTRIB a);
void autolearnspellsfrombook(lifeform_t *lf, object_t *book);
void autoshortcut(lifeform_t *lf, enum OBTYPE spellid);
void autoshortcut(lifeform_t *lf, enum OBTYPE spellid, int startslot);
void autoskill(lifeform_t *lf);
void autospells(lifeform_t *lf, int howmany);
void autotarget(lifeform_t *lf);

View File

@ -496,10 +496,13 @@ int main(int argc, char **argv) {
}
// we always want 'cook' to be shortcut number one.
autoshortcut(player, OT_A_COOK);
// some abilities should always use certain shortcut numbers
autoshortcut(player, OT_A_TRAIN, 9);
autoshortcut(player, OT_A_TIPTOE, 0);
autoshortcut(player, OT_A_COOK, 1);
autoshortcut(player, OT_S_SIXTHSENSE, 6);
// populate the remainder with our other abilities
autoshortcut(player, OT_NONE);
autoshortcut(player, OT_NONE, NA);
getplayernamefull(pname);
snprintf(welcomemsg, BUFLEN, "Greetings %s, welcome to nexus!", pname);