From 22c316437e8177b1296151171d641b3faf3c68a3 Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Tue, 7 Feb 2012 04:26:29 +0000 Subject: [PATCH] - [+] hiscores - show "Killed by xxx on level 5 of the dungeons." - [+] extra suffix text. - [+] use two lines for each entry. - [+] have to use modified version of wrapprint for this. - [+] wrapprint needs a "wrapped_lines_indent_amt" option. - [+] this should give exactly 24 lines. --- attack.c | 8 +++ data/hiscores.db | Bin 13312 -> 13312 bytes defs.h | 10 +++- doc/glyphs.txt | 2 +- io.c | 139 +++++++++++++++++++++++++---------------------- io.h | 2 +- lf.c | 92 ++++++++++++++++--------------- map.c | 4 +- objects.c | 8 +-- save.c | 2 +- spell.c | 2 +- text.c | 59 +++++++++++++++----- text.h | 4 +- 13 files changed, 197 insertions(+), 135 deletions(-) diff --git a/attack.c b/attack.c index 7d3a508..3e78401 100644 --- a/attack.c +++ b/attack.c @@ -1980,6 +1980,14 @@ int getextradamwep(object_t *wep, int *dam, enum DAMTYPE *damtype, int *ndam) { } *(damtype + *ndam) = DT_FIRE; (*ndam)++; + } else if (f->id == F_HOT) { + if (strlen(f->text)) { + *(dam + *ndam) = roll(f->text); + } else { + *(dam + *ndam) = rolldie(1,2); + } + *(damtype + *ndam) = DT_HEAT; + (*ndam)++; } else if (f->id == F_FROZEN) { *(dam + *ndam) = rolldie(1,4); *(damtype + *ndam) = DT_COLD; diff --git a/data/hiscores.db b/data/hiscores.db index ca6388b6e1b56bf52df10293a9159c48f87fd02a..3623db90934ed04e4d8d351812b0ad956bbd33f8 100644 GIT binary patch delta 655 zcmZq3Xvml#&6~;q0USVzYoo>uW(i&(i-U1F1M_C)OlCQz%S1X70 z=U`)C6xPhPnXD)!JNb_;N4-LRoU_gU6cxCnz-l0}a-~)lqCF4yicFwl)nQkqFgm_09Id*P(V}PgPn}(a|Ree74 zkE=z~D7(aASv^X}v96>dyr^xomD;$G9<^(VuJ|N7POot@y}+`fhXc~`M>=Jnq=6HS zUzQ35eXw71+#Xf>Bu-LUOfS_odZx;;J{%Cuf9N2ch&9qvRZ%j)dB?;EozW6IWl|^? zoMMIKEMv{hOp1PTts(dwnK!o#CqHFcRv}Mv72?|KOC_^hBnDZwj8*O&+jUK-A=TSv zGYsv;*$6{kmTA;mVJdm`Oz|ue*;_;?#*E@ka)wY6se3|1sG+>DkKhNs;Db&54W8g0 z?y8CK4Ro=lSOO#p5(Xp;a~a~&&83C4kz&=Ks9L8B%t!bZ&&3xYFb^m2z~T^YgFs_w KtlFP^ZvF+SNOcGR diff --git a/defs.h b/defs.h index c29766f..5c46b84 100644 --- a/defs.h +++ b/defs.h @@ -285,6 +285,13 @@ enum RELATIVEDIR { RD_SIDEWAYS, }; +enum REGIONNAMEFORMAT { + RF_SHORT, // %s + RF_WITHLEVEL, // %s (L%d) + RF_LONG, // on level %d of %s + +}; + enum TURNDIR { TD_RIGHT, TD_LEFT @@ -315,7 +322,7 @@ enum SHOPACTION { #define SAVEDIR "data" #define VAULTDIR "data/vaults" // rank, score, name, job, killer -#define HISCOREFORMAT "%-5s%-7s%-10s%-23s%s" +#define HISCOREFORMAT "%-4s%-7s%-10s%-23s" // game strings #define MORESTRING "--More--" @@ -2370,6 +2377,7 @@ enum FLAG { // weapons. F_HOT, // object is very hot to the touch. // v0 = amt of damage to deal if touched while gloveless + // text = amt of extra damage for weapons to deal F_ENCHANTED, // weapon also deals 'text' extra fire damage F_HEADLESS, // for corpses. can go on LFs too. F_MASTERWORK, // weps do higher damager, armour protects better diff --git a/doc/glyphs.txt b/doc/glyphs.txt index c93d1f5..92e63e0 100644 --- a/doc/glyphs.txt +++ b/doc/glyphs.txt @@ -29,7 +29,7 @@ m = mutant n = small humanoid / nymph / sprite N = necron o = orc -O = ogre +O = monstrous humanoid (ie. ogre) p = sPirit P = gastroPod q = quadraped diff --git a/io.c b/io.c index 74f3c87..491fe4b 100644 --- a/io.c +++ b/io.c @@ -3620,7 +3620,7 @@ void describeob(object_t *o) { //textwithcol(mainwin, buf2); x = 0; y = 2; getyx(mainwin, y, x); - wrapprint(mainwin, &y, &x, "%s", buf2); + wrapprint(mainwin, &y, &x, 0, "%s", buf2); free(buf2); wrefresh(mainwin); @@ -3652,7 +3652,7 @@ void describerace(enum RACE rid) { makedesc_race(rid, buf2, B_TRUE, B_FALSE); //textwithcol(mainwin, buf2); getyx(mainwin,y,x); - ch = wrapprint(mainwin, &y, &x, "%s", buf2); + ch = wrapprint(mainwin, &y, &x, 0, "%s", buf2); free(buf2); wrefresh(mainwin); @@ -5320,6 +5320,11 @@ char *makedesc_ob(object_t *o, char *retbuf) { sprintf(buf,"@It also inflicts %s extra burning damage.\n", strlen(f->text) ? f->text : "1-4"); strncat(retbuf, buf, HUGEBUFLEN); } + f = hasflag(o->flags, F_HOT); + if (f) { + sprintf(buf,"@It also inflicts %s extra burning damage.\n", strlen(f->text) ? f->text : "1-2"); + strncat(retbuf, buf, HUGEBUFLEN); + } f = hasflag(o->flags, F_FROZEN); if (f) { sprintf(buf,"@It also inflicts %s extra cold damage.\n", strlen(f->text) ? f->text : "1-4"); @@ -8773,7 +8778,7 @@ char getchoicestr(prompt_t *prompt, int useshortcuts, int showallatstart) { if (showall) y++; wmove(mainwin, y, 0); //textwithcol(mainwin, prompt->choice[validchoice].longdesc); - wrapprint(mainwin, &y, &x, "%s", prompt->choice[validchoice].longdesc); + wrapprint(mainwin, &y, &x, 0, "%s", prompt->choice[validchoice].longdesc); getyx(mainwin, descendy, dummy); // remember bottom of description } } else if (descendy != -1) { @@ -10068,7 +10073,7 @@ void drawstatus(void) { //wprintw(statwin, "DLev:%d", player->cell->map->depth); setcol(statwin, C_BROWN); - getregionname(buf, player->cell->map, NULL, B_TRUE); + getregionname(buf, player->cell->map, NULL, RF_WITHLEVEL); capitalise(buf); wprintw(statwin, "%s", buf); unsetcol(statwin, C_BROWN); @@ -10212,7 +10217,7 @@ void setobcolour(WINDOW *win, object_t *o, int set) { // dump out a single hiscore line int showhiscoreline(void *hilitescore, int ncols, char **argv, char **colname) { - int i; + int i,x,y,origy; char *rank = NULL, *score = NULL, *name = NULL, *job = NULL, *killer = NULL; for (i = 0; i < ncols; i++) { if (streq(colname[i], "rank")) rank = strdup(argv[i]); @@ -10222,10 +10227,20 @@ int showhiscoreline(void *hilitescore, int ncols, char **argv, char **colname) { else if (streq(colname[i], "killedby")) killer = strdup(argv[i]); } if (streq(score, (char *)hilitescore)) setcol(mainwin, C_BOLDGREEN); - wprintw(mainwin, HISCOREFORMAT, rank, score, name, job, killer); + wprintw(mainwin, HISCOREFORMAT, rank, score, name, job); + + // last field should be wrapped with lines 2+ indented + getyx(mainwin, y, x); + origy = y; + wrapprint(mainwin, &y, &x, x, "%s", killer); + if (streq(score, (char *)hilitescore)) unsetcol(mainwin, C_BOLDGREEN); - wprintw(mainwin, "\n"); + if (y == origy) { + wprintw(mainwin, "\n\n"); + } else { + wprintw(mainwin, "\n"); + } free(score); free(name); free(job); @@ -10898,7 +10913,7 @@ void showlfstats(lifeform_t *lf, int showall) { descbuf = malloc(HUGEBUFLEN * sizeof(char)); makedesc_race(lf->race->id, descbuf, B_FALSE ); //mvwprintw(mainwin, y, 0, "%s", descbuf); - wrapprint(mainwin, &y, &x, "%s", descbuf); + wrapprint(mainwin, &y, &x, 0, "%s", descbuf); free(descbuf); getyx(mainwin, y, x); @@ -10951,33 +10966,33 @@ void showlfstats(lifeform_t *lf, int showall) { if (hitstokillit == hitstokillyou) { if (hitstokillit) { setcol(mainwin, lorecol); - wrapprint(mainwin, &y, &x, "You could both kill each other in %d hit%s. ", hitstokillit, + wrapprint(mainwin, &y, &x, 0, "You could both kill each other in %d hit%s. ", hitstokillit, (hitstokillit == 1) ? "" : "s"); unsetcol(mainwin, lorecol); } else { setcol(mainwin, lorecol); - wrapprint(mainwin, &y, &x, "Neither of you would be able to kill the other. "); + wrapprint(mainwin, &y, &x, 0, "Neither of you would be able to kill the other. "); unsetcol(mainwin, lorecol); } } else { if (hitstokillit) { setcol(mainwin, lorecol); - wrapprint(mainwin, &y, &x, "You could kill it in %d hit%s. ", hitstokillit, + wrapprint(mainwin, &y, &x, 0, "You could kill it in %d hit%s. ", hitstokillit, (hitstokillit == 1) ? "" : "s"); unsetcol(mainwin, lorecol); } else { setcol(mainwin, lorecol); - wrapprint(mainwin, &y, &x, "You probably couldn't kill it. "); + wrapprint(mainwin, &y, &x, 0, "You probably couldn't kill it. "); unsetcol(mainwin, lorecol); } if (hitstokillyou) { setcol(mainwin, lorecol); - wrapprint(mainwin, &y, &x, "It could kill you in %d hit%s. ", hitstokillyou, + wrapprint(mainwin, &y, &x, 0, "It could kill you in %d hit%s. ", hitstokillyou, (hitstokillyou == 1) ? "" : "s"); unsetcol(mainwin, lorecol); } else { setcol(mainwin, lorecol); - wrapprint(mainwin, &y, &x, "It probably couldn't kill you. "); + wrapprint(mainwin, &y, &x, 0, "It probably couldn't kill you. "); unsetcol(mainwin, lorecol); } } @@ -11005,7 +11020,7 @@ void showlfstats(lifeform_t *lf, int showall) { snprintf(buf, BUFLEN, "It is EXTREMELY dangerous to you."); } //mvwprintw(mainwin, y, 0, "Threat rating: %0.1f",comparelfs(player, lf)); - wrapprint(mainwin, &y, &x, "%s ", buf); + wrapprint(mainwin, &y, &x, 0, "%s ", buf); unsetcol(mainwin, lorecol); y++; x = 0; } @@ -11024,7 +11039,7 @@ void showlfstats(lifeform_t *lf, int showall) { case ST_KO: strcpy(sleepname, "unconscious"); break; } - wrapprint(mainwin, &y, &x, "%s %s %s. ", you(lf), is(lf), sleepname); + wrapprint(mainwin, &y, &x, 0, "%s %s %s. ", you(lf), is(lf), sleepname); } f = lfhasknownflag(lf, F_ATTACHEDTO); if (f && (f->known)) { @@ -11037,40 +11052,40 @@ void showlfstats(lifeform_t *lf, int showall) { strcpy(grabeename, "something"); } snprintf(buf, BUFLEN,"%s %s attached to %s.",you(lf), is(lf), grabeename); - wrapprint(mainwin, &y, &x, "%s ", buf); + wrapprint(mainwin, &y, &x, 0, "%s ", buf); } if (isbleeding(lf)) { - wrapprint(mainwin, &y, &x, "%s %s bleeding. ", you(lf), is(lf)); + wrapprint(mainwin, &y, &x, 0, "%s %s bleeding. ", you(lf), is(lf)); } f = lfhasknownflag(lf, F_CLIMBING); if (f && (f->known)) { - wrapprint(mainwin, &y, &x, "%s %s climbing on a wall. ", you(lf), is(lf)); + wrapprint(mainwin, &y, &x, 0, "%s %s climbing on a wall. ", you(lf), is(lf)); } f = lfhasknownflag(lf, F_FASTMETAB); if (f && (f->known)) { - wrapprint(mainwin, &y, &x, "%s metabolic rate has been increased. ", your(lf), getpossessive(you(lf))); + wrapprint(mainwin, &y, &x, 0, "%s metabolic rate has been increased. ", your(lf), getpossessive(you(lf))); } f = lfhasknownflag(lf, F_FEIGNINGDEATH); if (f && (f->known)) { - wrapprint(mainwin, &y, &x, "%s %s pretending to be dead. ", you(lf), is(lf)); + wrapprint(mainwin, &y, &x, 0, "%s %s pretending to be dead. ", you(lf), is(lf)); } f = lfhasknownflag(lf, F_FLYING); if (f && (f->known)) { - wrapprint(mainwin, &y, &x, "%s %s flying. ", you(lf), is(lf)); + wrapprint(mainwin, &y, &x, 0, "%s %s flying. ", you(lf), is(lf)); } if (isswimming(lf)) { - wrapprint(mainwin, &y, &x, "%s %s swimming. ", you(lf), is(lf)); + wrapprint(mainwin, &y, &x, 0, "%s %s swimming. ", you(lf), is(lf)); } if (isclimbing(lf)) { - wrapprint(mainwin, &y, &x, "%s %s currently climbing. ", you(lf), is(lf)); + wrapprint(mainwin, &y, &x, 0, "%s %s currently climbing. ", you(lf), is(lf)); } f = lfhasknownflag(lf, F_PRONE); if (f && (f->known)) { - wrapprint(mainwin, &y, &x, "%s %s lying on the ground. ", you(lf), is(lf)); + wrapprint(mainwin, &y, &x, 0, "%s %s lying on the ground. ", you(lf), is(lf)); } f = lfhasflag(lf, F_FROZEN); if (f && (f->known)) { - wrapprint(mainwin, &y, &x, "%s %s been turned to ice, and %s slowly melting. ", you(lf), isplayer(lf) ? "have" : "has", + wrapprint(mainwin, &y, &x, 0, "%s %s been turned to ice, and %s slowly melting. ", you(lf), isplayer(lf) ? "have" : "has", is(lf)); } f = lfhasknownflag(lf, F_GRABBEDBY); @@ -11084,7 +11099,7 @@ void showlfstats(lifeform_t *lf, int showall) { strcpy(grabbername, "something"); } snprintf(buf, BUFLEN,"%s %s being held by %s.",you(lf), is(lf), grabbername); - wrapprint(mainwin, &y, &x, "%s ",buf); + wrapprint(mainwin, &y, &x, 0, "%s ",buf); } f = lfhasknownflag(lf, F_GRABBING); if (f && (f->known)) { @@ -11097,11 +11112,11 @@ void showlfstats(lifeform_t *lf, int showall) { strcpy(grabeename, "something"); } snprintf(buf, BUFLEN,"%s %s holding on to %s.",you(lf), is(lf), grabeename); - wrapprint(mainwin, &y, &x, "%s ", buf); + wrapprint(mainwin, &y, &x, 0, "%s ", buf); } f = lfhasknownflag(lf, F_HIDING); if (f && (f->known)) { - wrapprint(mainwin, &y, &x, "%s %s hiding. ", you(lf), is(lf)); + wrapprint(mainwin, &y, &x, 0, "%s %s hiding. ", you(lf), is(lf)); } getflags(lf->flags, retflag, &nretflags, F_INJURY, F_NONE); for (i = 0; i < nretflags; i++) { @@ -11110,40 +11125,40 @@ void showlfstats(lifeform_t *lf, int showall) { f = retflag[i]; p = readuntil(injname, f->text, '^'); readuntil(injdesc, p, '^'); - wrapprint(mainwin, &y, &x, "^%c%s %s (%s). ", getlfcol(lf, CC_VBAD), your(lf), injname, injdesc); + wrapprint(mainwin, &y, &x, 0, "^%c%s %s (%s). ", getlfcol(lf, CC_VBAD), your(lf), injname, injdesc); } f = lfhasknownflag(lf, F_INVISIBLE); if (f && (f->known)) { - wrapprint(mainwin, &y, &x, "%s %s invisible. ", you(lf), is(lf)); + wrapprint(mainwin, &y, &x, 0, "%s %s invisible. ", you(lf), is(lf)); } f = lfhasknownflag(lf, F_LEVITATING); if (f && (f->known)) { - wrapprint(mainwin, &y, &x, "%s %s levitating. ", you(lf), is(lf)); + wrapprint(mainwin, &y, &x, 0, "%s %s levitating. ", you(lf), is(lf)); } f = lfhasflag(lf, F_NONCORPOREAL); if (f && (f->known)) { - wrapprint(mainwin, &y, &x, "%s %s noncorporeal and can walk through walls. ", you(lf), is(lf)); + wrapprint(mainwin, &y, &x, 0, "%s %s noncorporeal and can walk through walls. ", you(lf), is(lf)); } f = lfhasflag(lf, F_PRODUCESLIGHT); if (f && (f->known)) { - wrapprint(mainwin, &y, &x, "%s produce%s light. ", you(lf), isplayer(lf) ? "" : "s"); + wrapprint(mainwin, &y, &x, 0, "%s produce%s light. ", you(lf), isplayer(lf) ? "" : "s"); } f = lfhasknownflag(lf, F_SLOWMETAB); if (f && (f->known)) { - wrapprint(mainwin, &y, &x, "%s metabolic rate has been decreased. ", your(lf), getpossessive(you(lf))); + wrapprint(mainwin, &y, &x, 0, "%s metabolic rate has been decreased. ", your(lf), getpossessive(you(lf))); } f = lfhasknownflag(lf, F_SPRINTING); if (f) { - wrapprint(mainwin, &y, &x, "%s %s sprinting. ", you(lf), is(lf)); + wrapprint(mainwin, &y, &x, 0, "%s %s sprinting. ", you(lf), is(lf)); } if (!getstamina(lf)) { - wrapprint(mainwin, &y, &x, "%s %s exhausted. ", you(lf), is(lf)); + wrapprint(mainwin, &y, &x, 0, "%s %s exhausted. ", you(lf), is(lf)); } f = lfhasknownflag(lf, F_UNDEAD); if (f) { - wrapprint(mainwin, &y, &x, "%s %s undead. ", you(lf), is(lf)); + wrapprint(mainwin, &y, &x, 0, "%s %s undead. ", you(lf), is(lf)); } // non-intrinsic effecst like polymorph, eye shading @@ -11154,11 +11169,11 @@ void showlfstats(lifeform_t *lf, int showall) { snprintf(buf2, BUFLEN, " [%d left]", f->lifetime); strcat(buf, buf2); // } - wrapprint(mainwin, &y, &x, "%s ", buf); + wrapprint(mainwin, &y, &x, 0, "%s ", buf); } if (!canuseweapons(lf)) { - wrapprint(mainwin, &y, &x, "%s cannot use weapons. ", you(lf)); + wrapprint(mainwin, &y, &x, 0, "%s cannot use weapons. ", you(lf)); } nmissingbp = 0; @@ -11203,20 +11218,20 @@ void showlfstats(lifeform_t *lf, int showall) { } } strcat(buf, "."); - wrapprint(mainwin, &y, &x, "%s ", buf); + wrapprint(mainwin, &y, &x, 0, "%s ", buf); } f = lfhasflag(lf, F_REFLECTION); if (f && (f->known)) { - wrapprint(mainwin, &y, &x, "%s %s surrounded by a negative gravity field.", you(lf), is(lf)); + wrapprint(mainwin, &y, &x, 0, "%s %s surrounded by a negative gravity field.", you(lf), is(lf)); } f = lfhasflag(lf, F_RETALIATE); if (f && (f->known)) { if (showall || (lorelev >= PR_BEGINNER)) { - wrapprint(mainwin, &y, &x, "%s %s covered by %s (%dd%d %s dmg to attackers). ", you(lf), is(lf), f->text, + wrapprint(mainwin, &y, &x, 0, "%s %s covered by %s (%dd%d %s dmg to attackers). ", you(lf), is(lf), f->text, f->val[0], f->val[1], getdamname(f->val[2])); } else { - wrapprint(mainwin, &y, &x, "%s %s covered by %s ", you(lf), is(lf), f->text); + wrapprint(mainwin, &y, &x, 0, "%s %s covered by %s ", you(lf), is(lf), f->text); } } @@ -11228,7 +11243,7 @@ void showlfstats(lifeform_t *lf, int showall) { lf2 = findlf(NULL, f->val[0]); if (lf2) { getlfname(lf2, buf); - wrapprint(mainwin, &y, &x, "%s %s fleeing from %s. ", you(lf), is(lf), buf); + wrapprint(mainwin, &y, &x, 0, "%s %s fleeing from %s. ", you(lf), is(lf), buf); } } } @@ -11238,7 +11253,7 @@ void showlfstats(lifeform_t *lf, int showall) { if (getlfmaterial(lf) != MT_FLESH) { material_t *mt; mt = findmaterial(getlfmaterial(lf)); - wrapprint(mainwin, &y, &x, "%s %s made out of %s. ",you(lf), is(lf), mt->name); + wrapprint(mainwin, &y, &x, 0, "%s %s made out of %s. ",you(lf), is(lf), mt->name); } } else if (mode == 'a') { centre(mainwin, C_WHITE, 0, "ABILITIES"); @@ -11823,7 +11838,7 @@ void showlfstats(lifeform_t *lf, int showall) { } if (strlen(buf) > 0) { strcat(buf, ".\n"); - wrapprint(mainwin, &y, &x, buf); + wrapprint(mainwin, &y, &x, 0, buf); } // immunities strcpy(buf, ""); @@ -11849,7 +11864,7 @@ void showlfstats(lifeform_t *lf, int showall) { if (strlen(buf) > 0) { strcat(buf, ".\n"); - wrapprint(mainwin, &y, &x, buf); + wrapprint(mainwin, &y, &x, 0, buf); } // vulnerabilities strcpy(buf, ""); @@ -11883,7 +11898,7 @@ void showlfstats(lifeform_t *lf, int showall) { } if (strlen(buf) > 0) { strcat(buf, ".\n"); - wrapprint(mainwin, &y, &x, buf); + wrapprint(mainwin, &y, &x, 0, buf); } // wants/desires @@ -11896,7 +11911,7 @@ void showlfstats(lifeform_t *lf, int showall) { objecttype_t *ot; ot = findot(f->val[0]); pname = makeplural(ot->name); - mvwprintw(mainwin, y, 0, "It %s %s.", (f->val[1] == B_COVETS) ? "covets" : "wants", pname); + mvwprintw(mainwin, y, 0, 0, "It %s %s.", (f->val[1] == B_COVETS) ? "covets" : "wants", pname); y++; free(pname); } else if (f->id == F_WANTSOBFLAG) { @@ -12521,15 +12536,10 @@ void tombstone(lifeform_t *lf) { //printf("%s\n",lf->name); centre(mainwin, C_GREY, y, "%s (%ld points)",pname, playerscore); y++; - if (player->cell->map->region->rtype->id == RG_WORLDMAP) { - getregionname(buf, player->cell->map, NULL, B_TRUE); - centre(mainwin, C_GREY, y, "Died on %s.", buf); y++; - } else { - getregionname(buf, player->cell->map, NULL, B_FALSE); - centre(mainwin, C_GREY, y, "Died on level %d of %s.", player->cell->map->depth, buf); y++; - } + getregionname(buf, player->cell->map, NULL, RF_LONG); + centre(mainwin, C_GREY, y, "Died %s.", buf); y++; // ie. "Died on level 1 of the dungeon" - makekillertext(killer, lf->killverb, lf->lastdam, B_TRUE); + makekillertext(killer, lf->killverb, lf->lastdam, lf->cell->map, B_TRUE, B_FALSE); p = readuntil(buf, killer, '\n'); while (strlen(buf)) { @@ -12567,9 +12577,10 @@ void tombstone(lifeform_t *lf) { limit(&maxrank, NA, 100); } - centre(mainwin, C_GREY, y, "High Scores"); y += 2; + centre(mainwin, C_GREY, y, "High Scores"); y++; wattron(mainwin, A_BOLD); - mvwprintw(mainwin, y, 0, HISCOREFORMAT, "Rank", "Score", "Name", "Job", "Method of death"); y++; + mvwprintw(mainwin, y, 0, HISCOREFORMAT, "Pos", "Score", "Name", "Job"); + wprintw(mainwin, "Method of death"); y++; wmove(mainwin, y, 0); wattroff(mainwin, A_BOLD); @@ -12622,7 +12633,7 @@ int real_warnabout(char *what, int lifetime, int doquestion) { } // @ = tab -char wrapprint(WINDOW *win, int *y, int *x, char *format, ... ) { +char wrapprint(WINDOW *win, int *y, int *x, int newlineindent, char *format, ... ) { char word[HUGEBUFLEN],buf[HUGEBUFLEN]; char *p; va_list args; @@ -12659,9 +12670,9 @@ char wrapprint(WINDOW *win, int *y, int *x, char *format, ... ) { } // if this word won't fit, put it on the next line. if (*x != 0) { - if (*x + strlen(repword) >= w) { + if (*x + strlen(repword) >= (w-1)) { (*y)++; - *x = 0; + *x = newlineindent; } } @@ -12685,7 +12696,7 @@ char wrapprint(WINDOW *win, int *y, int *x, char *format, ... ) { if (first) { first = B_FALSE; - } else if (*x != 0) { + } else if (*x != newlineindent) { textwithcol_real(win, " ", B_FALSE); } textwithcol_real(win, repword, B_FALSE); diff --git a/io.h b/io.h index ce0e065..f89628a 100644 --- a/io.h +++ b/io.h @@ -137,4 +137,4 @@ void updatestatus(void); int updateviewfor(cell_t *cell); int warnabout(char *what); int real_warnabout(char *what, int lifetime, int doquestion); -char wrapprint(WINDOW *win, int *y, int *x, char *format, ... ); +char wrapprint(WINDOW *win, int *y, int *x, int newlineindent, char *format, ... ); diff --git a/lf.c b/lf.c index 0060b5a..e78b047 100644 --- a/lf.c +++ b/lf.c @@ -17357,7 +17357,7 @@ void startlfturn(lifeform_t *lf) { if (!movedlastturn) { getflags(lf->flags, retflag, &nretflags, F_HOTFEET, F_NONE); - if (nretflags && !hasobofmaterial(lf->cell->obpile, MT_WATER) && !isimmuneto(lf->flags, DT_FIRE)) { + if (nretflags && !hasobofmaterial(lf->cell->obpile, MT_WATER) && !isimmuneto(lf->flags, DT_FIRE, B_FALSE)) { for (i = 0; i < nretflags; i++) { int dam; enum DAMTYPE dt; @@ -17462,7 +17462,7 @@ void startlfturn(lifeform_t *lf) { // effects from pack objects for (o = lf->pack->first ; o ; o = o->next) { // hot equipped objects? - if (isequipped(o) && !isweapon(o) && !isimmuneto(lf->flags, DT_FIRE)) { + if (isequipped(o) && !isweapon(o) && !isimmuneto(lf->flags, DT_FIRE, B_FALSE)) { f = hasflag(o->flags, F_HOT); if (f) { f->known = B_TRUE; @@ -18466,53 +18466,55 @@ int touch(lifeform_t *lf, object_t *o) { } // flaming or red-hot objects? - getflags(o->flags, retflag, &nretflags, F_ONFIRE, F_HOT, F_NONE); // IMPORTANT - check ONFIRE first! - for (i = 0; i < nretflags; i++) { - f = retflag[i]; - // flaming weapons are ok - only the blade is burning - if ((f->id == F_ONFIRE) && isweapon(o)) { - } else { - // wearing gloves? they get damaged. - if (gloves) { - if (f->id == F_ONFIRE) { - takedamage(gloves, 2, DT_FIRE); - if (hasflag(gloves->flags, F_DEAD)) { - gloves = NULL; - } else { - // if your gloves weren't destroyed the fire - // will go out. - killflagsofid(o->flags, F_ONFIRE); - } - } + if (!isimmuneto(lf->flags, DT_FIRE, B_FALSE)) { + getflags(o->flags, retflag, &nretflags, F_ONFIRE, F_HOT, F_NONE); // IMPORTANT - check ONFIRE first! + for (i = 0; i < nretflags; i++) { + f = retflag[i]; + // flaming weapons are ok - only the blade is burning + if ((f->id == F_ONFIRE) && isweapon(o)) { } else { - enum DAMTYPE dt; - int dam = 3; - // otherwise YOU get damaged. - f->known = B_TRUE; - getobname(o, obname, o->amt); // get name again after making flag known - if (isplayer(lf)) { - msg("^bOw! You burn your hands on %s.",obname); - } else if (cansee(player, lf)) { - msg("%s burns itself on %s.",lfname, obname); + // wearing gloves? they get damaged. + if (gloves) { + if (f->id == F_ONFIRE) { + takedamage(gloves, 2, DT_FIRE); + if (hasflag(gloves->flags, F_DEAD)) { + gloves = NULL; + } else { + // if your gloves weren't destroyed the fire + // will go out. + killflagsofid(o->flags, F_ONFIRE); + } + } + } else { + enum DAMTYPE dt; + int dam = 3; + // otherwise YOU get damaged. + f->known = B_TRUE; + getobname(o, obname, o->amt); // get name again after making flag known + if (isplayer(lf)) { + msg("^bOw! You burn your hands on %s.",obname); + } else if (cansee(player, lf)) { + msg("%s burns itself on %s.",lfname, obname); + } + snprintf(buf, BUFLEN, "touching %s",obname); + if (f->id == F_ONFIRE) { + dt = DT_FIRE; + dam = rnd(2,4); + } else if (f->id == F_HOT) { + dt = DT_HEAT; + dam = f->val[0]; + } + losehp(lf, dam, dt, NULL, buf); + // drop the object if we're holding it + if ((o->pile->owner == lf) && !isequipped(o)) { + drop(o, ALL); + } + return B_TRUE; } - snprintf(buf, BUFLEN, "touching %s",obname); - if (f->id == F_ONFIRE) { - dt = DT_FIRE; - dam = rnd(2,4); - } else if (f->id == F_HOT) { - dt = DT_HEAT; - dam = f->val[0]; - } - losehp(lf, dam, dt, NULL, buf); - // drop the object if we're holding it - if ((o->pile->owner == lf) && !isequipped(o)) { - drop(o, ALL); - } - return B_TRUE; + } - } - } + } // end if !immune to fire return B_FALSE; } diff --git a/map.c b/map.c index 9a5a9b9..ee7825c 100644 --- a/map.c +++ b/map.c @@ -2941,7 +2941,7 @@ void createmap(map_t *map, int depth, region_t *region, map_t *parentmap, int ex map->region = region; if (db) { - getregionname(buf, map, NULL, B_FALSE); + getregionname(buf, map, NULL, RF_SHORT); dblog("Creating new map of region '%s'",buf); } map->habitat = findhabitat(habitat); @@ -3079,7 +3079,7 @@ void createmap(map_t *map, int depth, region_t *region, map_t *parentmap, int ex //if (gamemode == GM_GAMESTARTED) checkallflags(player->cell->map); // debugging // we now have the map name! - getregionname(buf2, map, NULL, B_TRUE); + getregionname(buf2, map, NULL, RF_WITHLEVEL); snprintf(buf, BUFLEN, "%s (id #%d)",buf2, map->id); map->name = strdup(buf); diff --git a/objects.c b/objects.c index 3e11259..91761cb 100644 --- a/objects.c +++ b/objects.c @@ -5340,7 +5340,7 @@ char *real_getobname(object_t *o, char *buf, int count, int wantpremods, int wan } else { char buf2[BUFLEN]; strcat(localbuf, " to "); - getregionname(buf2, newmap, NULL, B_FALSE); + getregionname(buf2, newmap, NULL, RF_SHORT); strcat(localbuf, buf2); } } @@ -7638,7 +7638,7 @@ int makeduller(object_t *o, int howmuch) { void makehot(object_t *o, int howmuch, int howlong) { flag_t *f; int seen = B_FALSE; - f = addtempflag(o->flags, F_HOT, howmuch, NA, NA, NULL, howlong); + f = addtempflag(o->flags, F_HOT, howmuch, NA, NA, "1d2", howlong); if (isequipped(o) && o->pile->owner) { if (isplayer(o->pile->owner) || cansee(player, o->pile->owner)) { seen = B_TRUE; @@ -10797,13 +10797,13 @@ int readsomething(lifeform_t *lf, object_t *o) { case PR_ADEPT: case PR_SKILLED: // tell which area it is in (without level) - getregionname(buf, NULL, srcregion, B_FALSE); + getregionname(buf, NULL, srcregion, RF_SHORT); msg("%s %s somewhere within %s.", f->text, isare, buf); break; case PR_EXPERT: case PR_MASTER: // which area it is in, plus which floor - getregionname(buf, NULL, srcregion, B_TRUE); + getregionname(buf, NULL, srcregion, RF_WITHLEVEL); msg("%s %s in %s.", f->text, isare, buf); break; } diff --git a/save.c b/save.c index bf23d19..2ff8865 100644 --- a/save.c +++ b/save.c @@ -1156,7 +1156,7 @@ int writehiscore(lifeform_t *lf, int *rank) { capitalise(racename); snprintf(jobname, BUFLEN, "Lv%d %s %s", player->level, racename, j->name); - makekillertext(killedby, lf->killverb, lf->lastdam, B_FALSE); + makekillertext(killedby, lf->killverb, lf->lastdam, lf->cell->map, B_FALSE, B_TRUE); // add escapes escaped = strdup(killedby); diff --git a/spell.c b/spell.c index fc5d7f9..8d7b79e 100644 --- a/spell.c +++ b/spell.c @@ -8169,7 +8169,7 @@ int dospelleffects(lifeform_t *caster, enum OBTYPE spellid, int power, lifeform_ char ch = 'a'; char mapname[BUFLEN]; - getregionname(mapname, m, NULL, B_TRUE); + getregionname(mapname, m, NULL, RF_WITHLEVEL); capitalise(mapname); if (m->habitat->id == H_HEAVEN) continue; diff --git a/text.c b/text.c index fc2829c..f0c90cd 100644 --- a/text.c +++ b/text.c @@ -1100,23 +1100,23 @@ char *getrarityname(enum RARITY rr) { // pass in EITHER m or r, not both. // -// if withlevel is TRUE, "m" should be passed. -char *getregionname(char *buf, map_t *m, region_t *r, int withlevel) { +// if how is anything other than RF_SHORT, "m" should be passed. +char *getregionname(char *buf, map_t *m, region_t *r, enum REGIONNAMEFORMAT how) { + int x = NA,y = NA; if (!r) { r = m->region; } - if (withlevel && m) { + if (m) { flag_t *f; - int x,y; f = hasflag(m->flags, F_MAPCOORDS); if (f) { x = f->val[0]; y = f->val[1]; - } else { - x = NA; - y = NA; - } + } + } + + if ((how == RF_WITHLEVEL) && m) { switch (r->rtype->id) { case RG_CAVE: snprintf(buf, BUFLEN, "goblin caves L%d", m->depth); @@ -1140,7 +1140,31 @@ char *getregionname(char *buf, map_t *m, region_t *r, int withlevel) { snprintf(buf, BUFLEN, "a stomach"); break; } - } else { + } else if ((how == RF_LONG) && m) { + switch (r->rtype->id) { + case RG_CAVE: + snprintf(buf, BUFLEN, "on level %d of the goblin caves", m->depth); + break; + case RG_WORLDMAP: + snprintf(buf, BUFLEN, "on the surface(%d,%d)",x,y); + break; + case RG_MAINDUNGEON: + snprintf(buf, BUFLEN, "on level %d of the dungeon", m->depth); + break; + case RG_HEAVEN: + snprintf(buf, BUFLEN, "in the realm of gods"); + break; + case RG_PIT: + snprintf(buf, BUFLEN, "in a pit"); + break; + case RG_SEWER: + snprintf(buf, BUFLEN, "in a sewer"); + break; + case RG_STOMACH: + snprintf(buf, BUFLEN, "inside a worm's stomach"); // TODO: " in a stomach of of xxx" + break; + } + } else { // ie. RF_SHORT switch (r->rtype->id) { case RG_CAVE: strcpy(buf, "the goblin caves"); @@ -1337,14 +1361,15 @@ void makegunaimstring(lifeform_t *lf, int lfid, char *retbuf) { sprintf(retbuf, "%s%s", noprefix(targname), accbuf); } -char *makekillertext(char *retbuf, char *killverb, char *lastdam, int wantextra) { +char *makekillertext(char *retbuf, char *killverb, char *lastdam, map_t *where, int wantextra, int wantlocation) { char *p, *dummy; + char regionbuf[BUFLEN]; p = strtok_r(lastdam,"^", &dummy); if (p) { if (!strcmp(p, "you")) { - strcpy(retbuf, "Committed suicide."); + strcpy(retbuf, "Committed suicide"); } else { - snprintf(retbuf, BUFLEN, "%s %s %s.",killverb, + snprintf(retbuf, BUFLEN, "%s %s %s",killverb, streq(killverb, "Drowned") ? "in" : "by", p); } @@ -1358,8 +1383,16 @@ char *makekillertext(char *retbuf, char *killverb, char *lastdam, int wantextra) } } } else { - sprintf(retbuf, "%s by something unknown.", killverb); + sprintf(retbuf, "%s by something unknown", killverb); } + + if (wantlocation) { + // now include WHERE they died. + getregionname(regionbuf, where, NULL, RF_LONG); + strcat(retbuf, " "); + strcat(retbuf, regionbuf); + } + strcat(retbuf, "."); return retbuf; } diff --git a/text.h b/text.h index 9e3a495..51e3d85 100644 --- a/text.h +++ b/text.h @@ -29,7 +29,7 @@ char *getinjuryname(enum DAMTYPE dt); char *getinjurydesc(enum BODYPART bp, enum DAMTYPE dt); char *getobmodprefix(object_t *o, obmod_t *om); char *getrarityname(enum RARITY rr); -char *getregionname(char *buf, map_t *m, region_t *r, int withlevel); +char *getregionname(char *buf, map_t *m, region_t *r, enum REGIONNAMEFORMAT how); char *getreldirname(int reldir); char *getsizetext(enum LFSIZE sz); char *gettimetext(char *retbuf); @@ -39,7 +39,7 @@ char *getweighttext(float weight, char *buf, int shortfmt); char *is(lifeform_t *lf); int isvowel(char c); void makegunaimstring(lifeform_t *lf, int lfid, char *retbuf); -char *makekillertext(char *retbuf, char *killverb, char *lastdam, int wantextra); +char *makekillertext(char *retbuf, char *killverb, char *lastdam, map_t *where, int wantextra, int wantlocation); char *makelowercase(char *text); char *makeplural(char *text); char *makethrowaccstring(lifeform_t *lf, cell_t *c, flag_t *throwflag, char *retbuf);