From c30a1c4b94c85eaf7f4aaad49567f50870d11e1a Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Thu, 2 Jun 2016 14:50:03 +1000 Subject: [PATCH] - generate error if main screen is not at least 80x25 - showlfstats() - implement text wrap and scrolling on Effects screen - If a monster slips and IQ >= animal, tiptoe next turn. --- defs.h | 2 + io.c | 630 +++++++++++++++++++++++++++++---------------------------- io.h | 3 + lf.c | 7 + move.c | 14 +- 5 files changed, 341 insertions(+), 315 deletions(-) diff --git a/defs.h b/defs.h index 0c85f6a..f3c3969 100644 --- a/defs.h +++ b/defs.h @@ -3578,6 +3578,8 @@ enum FLAG { // v0 = max time allowed to rest before checkout // v1 = total time rested // text = obid of hotel + F_SLIPPEDLASTTURN, // this monster slipped the previous turn, and will try to tiptoe + // on its next move. F_SWARM, // this lf is a swarm, its maxattacks are reduced // based on its remaining hp pct. F_SWIMEVASION, // +v0 evasion if swimming diff --git a/io.c b/io.c index 3614f54..0040229 100644 --- a/io.c +++ b/io.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -9592,9 +9593,6 @@ int dothrow(obpile_t *op, object_t *o) { // returns TRUE if we hit the bottom of the screen. int downline(int *y, int h, int headinglines, int *nextoffset) { - int w; - w = getmaxx(mainwin); - /* // this is the heading we'll print after going past the 'MORE' strong snprintf(headbuf, w-1, "%s (continued)", heading); @@ -9926,19 +9924,32 @@ void initgfx(void) { int statwinh = 3; int i; short r,g,b; + struct winsize ws; + int w,h; + + ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws); + w = ws.ws_col; + h = ws.ws_row; + + if ((w < 80) || (h < 25)) { + printf("Error - Terminal size must be at least 80x25 (current: %d x %d).\n", w, h); + exit(1); + } setlocale(LC_CTYPE, ""); mainwin = initscr(); + // colour setup if (!has_colors()) { - wprintw(mainwin,"Terminal does not support colour.\n"); + endwin(); + printf("Error - Terminal does not support colour.\n"); hascolour = B_FALSE; exit(1); } if (!can_change_color()){ - wprintw(mainwin,"Terminal does not support changes to colours.\n"); + wprintw(mainwin,"Error - Terminal does not support changes to colours.\n"); exit(1); } start_color(); @@ -10251,6 +10262,35 @@ void dumpweps(void) { } +int effectline(int *stopnow, int *count, int offset, int *nextoffset, int headinglines, WINDOW *win, int *y, int *x, int newlineindent, char *format, ... ) { + char buf[HUGEBUFLEN]; + va_list args; + int h; + + if (*stopnow) return *stopnow; + + h = getmaxy(win); + + va_start(args, format); + vsnprintf( buf, HUGEBUFLEN, format, args ); + va_end(args); + + if (!strlen(buf)) return B_FALSE; + + if (*count >= offset) { + wrapprint_nomore(win, y, x, newlineindent, "%s", buf); + + if (downline(y, h, headinglines, nextoffset)) { + *nextoffset += offset; + *stopnow = B_TRUE; + } + *x = 0; + + } + (*count)++; + return *stopnow; +} + void forceredraw(void) { needredraw = B_TRUE; statdirty = B_TRUE; @@ -13039,8 +13079,8 @@ void showlfstats(lifeform_t *lf, int showall) { } + // TODO: move this to 'effects' ?? // obvious physical effects here. - f = lfhasknownflag(lf, F_SWARM); if (f) { wrapprint(mainwin, &y, &x, 0, "%s %s a swarm, gaining EV and losing strength as its health drops.", @@ -13369,7 +13409,6 @@ void showlfstats(lifeform_t *lf, int showall) { int count = 0; lfstatheading("SKILLS", offset); -//ooooooo start of skills y = headinglines; // construct headings @@ -13512,7 +13551,6 @@ void showlfstats(lifeform_t *lf, int showall) { } if (finished) break; } -//oooooooooooo end of skills oooooooooo } else if (mode == 'm') { char subheading[BUFLEN]; int lev; @@ -13606,16 +13644,18 @@ void showlfstats(lifeform_t *lf, int showall) { mvwprintw(mainwin, y, 0, "%s cannot cast any spells.", you(lf)); } } else if (mode == 'e') { + int count = 0,headinglines = 2; int nfound = 0,luckmod; enum LFSIZE racesize,cursize; + int stopnow = B_FALSE; char source[BUFLEN]; x = 0; // override // down a line. wattron(mainwin, A_UNDERLINE); centre(mainwin, C_WHITE, y, "EFFECTS"); wattroff(mainwin, A_UNDERLINE); - y += 2; - + y += headinglines; + count = 0; // gods angry? if (isplayer(lf)) { @@ -13623,76 +13663,71 @@ void showlfstats(lifeform_t *lf, int showall) { enum PIETYLEV plev; plev = getpietylev(R_GODLIFE, NULL, NULL); if (plev <= PL_ANGRY) { - mvwprintw(mainwin, y, 0, "You have been cut off from Life magic.", you(lf)); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "You have been cut off from Life magic.", you(lf)); + } if (plev == PL_ANGRY) { - mvwprintw(mainwin, y, 0, "The Goddess of Life has slowed your body's natural healing.", you(lf)); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "The Goddess of Life has slowed your body's natural healing.", you(lf)); + } else if ((plev == PL_FURIOUS) || (plev == PL_ENRAGED)) { - mvwprintw(mainwin, y, 0, "The Goddess of Life has nullified your body's natural healing.", you(lf)); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "The Goddess of Life has nullified your body's natural healing.", you(lf)); + } } if (godprayedto(R_GODNATURE) && godisangry(R_GODNATURE)) { - mvwprintw(mainwin, y, 0, "You have been cut off from Nature magic.", you(lf)); - y++; - mvwprintw(mainwin, y, 0, "The Goddess of Nature has cursed you with a rotting touch.", you(lf)); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "You have been cut off from Nature magic.", you(lf)); + + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "The Goddess of Nature has cursed you with a rotting touch.", you(lf)); + } } - // ready to gain a level? if (lfhasflag(lf, F_STATGAINREADY)) { - mvwprintw(mainwin, y, 0, "%s are ready to train your attributes.", you(lf)); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s are ready to train your attributes.", you(lf)); + } if (lf->skillpoints) { - mvwprintw(mainwin, y, 0, "%s are ready to learn a new skill.", you(lf)); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s are ready to learn a new skill.", you(lf)); + } if (levelabilityready(lf)) { - mvwprintw(mainwin, y, 0, "%s are ready to learn a new job-based ability.", you(lf)); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s are ready to learn a new job-based ability.", you(lf)); + } - - // temperature if (isplayer(lf) || (lorelev >= PR_BEGINNER)) { int temp; temp = getlftemp(lf); if (temp != T_NORMAL) { - mvwprintw(mainwin, y, 0, "%s %s feeling %s.", you(lf), is(lf), gettemperaturename(temp)); y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s feeling %s.", you(lf), is(lf), gettemperaturename(temp)); if (temp < T_NORMAL) { // cold int pen; pen = gettempaccpenalty(lf, temp); if (pen) { - mvwprintw(mainwin, y, 0, " %d accuracy due to exposed body parts.",pen); y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, " %d accuracy due to exposed body parts.",pen); } if (!isimmuneto(lf->flags, DT_COLD, B_FALSE) && !isresistantto(lf->flags, DT_COLD, B_FALSE)) { - mvwprintw(mainwin, y, 0, " Cannot sleep due to cold."); y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, " Cannot sleep due to cold."); } - mvwprintw(mainwin, y, 0, " Chance of shivering or getting sick due to cold."); y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, " Chance of shivering or getting sick due to cold."); } else { // hot int pen; if (!lfhasflag(lf, F_NOSTAM)) { pen = gettempstammod(lf, temp); if (pen != 100) { - mvwprintw(mainwin, y, 0, " %d%% stamina usage due to heat.",pen); y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, " %d%% stamina usage due to heat.",pen); } } if (!lfhasflag(lf, F_NOSLEEP) && (temp >= T_HOT)) { - mvwprintw(mainwin, y, 0, " Chance of waking from sleep due to heat."); y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, " Chance of waking from sleep due to heat."); } - if (temp >= T_HOT) { - mvwprintw(mainwin, y, 0, " Reduced healing rate due to heat."); y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, " Reduced healing rate due to heat."); } } } } - // spells nfound = 0; for (f = lf->flags->first ; f ; f = f->next) { @@ -13703,9 +13738,9 @@ void showlfstats(lifeform_t *lf, int showall) { char thisline[BUFLEN]; char desc[BUFLEN]; if (nfound == 0) { - mvwprintw(mainwin, y, 0, "%s %s the following spells active:", you(lf), + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s the following spells active:", you(lf), isplayer(lf) ? "have" : "has"); - y++; + } sprintf(thisline, " - %s %s (consuming %d MP", sp->name, roman(f->val[2]), f->val[1]); getspelldesc(f->val[0], f->val[2], desc); @@ -13715,35 +13750,31 @@ void showlfstats(lifeform_t *lf, int showall) { } strcat(thisline, ")"); - mvwprintw(mainwin, y, 0, "%s", thisline); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s", thisline); + nfound++; } } } - //if (nfound) y++; - + //if (nfound) // obvious physical effects first. f = lfhasknownflag(lf, F_BEINGSTONED); if (f) { getflagsourcetext(f, source); - mvwprintw(mainwin, y, 0, "%s %s being turning to stone.%s", you(lf), is(lf), source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s being turning to stone.%s", you(lf), is(lf), source); + } - if (eyesshaded(lf)) { getflagsourcetext(f, source); - mvwprintw(mainwin, y, 0, "%s eyes are shaded%s.", your(lf), buf, source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s eyes are shaded%s.", your(lf), buf, source); + } - f = lfhasflag(lf, F_FLAMMABLELF); if (f) { getflagsourcetext(f, source); - mvwprintw(mainwin, y, 0, "%s %s covered in %s.%s", you(lf), is(lf), f->text, source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s covered in %s.%s", you(lf), is(lf), f->text, source); + } - f = hasflag(lf->race->flags, F_SIZE); if (f) { getflagsourcetext(f, source); @@ -13754,75 +13785,66 @@ void showlfstats(lifeform_t *lf, int showall) { } cursize = getlfsize(lf); if (cursize != racesize) { - mvwprintw(mainwin, y, 0, "%s body has been magically %s.%s", your(lf), (cursize > racesize) ? "enlarged" : "shrunken", + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s body has been magically %s.%s", your(lf), (cursize > racesize) ? "enlarged" : "shrunken", source); - y++; + } - - // show racial effects if (hasjob(lf, J_PIRATE)) { - mvwprintw(mainwin, y, 0, "%s can hold %s liquor well. (%s)", you(lf), isplayer(lf) ? "Your" : "its", + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s can hold %s liquor well. (%s)", you(lf), isplayer(lf) ? "Your" : "its", getsourcetext(FROMJOB)); - y++; - mvwprintw(mainwin, y, 0, "%s %s missing one eye. (%s)", you(lf), is(lf), + + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s missing one eye. (%s)", you(lf), is(lf), getsourcetext(FROMJOB)); - y++; + } if (hasjob(lf, J_DRUID)) { - mvwprintw(mainwin, y, 0, "%s spell power is boosted by nearby plants. (%s)", isplayer(lf) ? "Your" : "Its", + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s spell power is boosted by nearby plants. (%s)", isplayer(lf) ? "Your" : "Its", getsourcetext(FROMJOB)); - y++; - mvwprintw(mainwin, y, 0, "%s regenerate mana when plants are nearby. (%s)", you(lf), + + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s regenerate mana when plants are nearby. (%s)", you(lf), getsourcetext(FROMJOB)); - y++; + } - // if the PLAYER knows the time... if (lfhasflag(player, F_KNOWSTIME)) { enum TIMEPHASE tp; tp = gettimephase(); if ((tp == TP_TWILIGHTMORN) || (tp == TP_SUNRISE)) { if (getskill(lf, SK_SS_LIFE)) { - mvwprintw(mainwin, y, 0, "The power of %s Life magic is currently boosted because it is %s.", + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "The power of %s Life magic is currently boosted because it is %s.", your(lf), gettimephasename(tp)); - y++; + } } else if (tp == TP_MIDNIGHT) { if (getskill(lf, SK_SS_DEATH)) { - mvwprintw(mainwin, y, 0, "The power of %s Death magic is currently boosted because it is %s.", + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "The power of %s Death magic is currently boosted because it is %s.", your(lf), gettimephasename(tp)); - y++; + } } } - if (lfhasflag(lf, F_CANCAST)) { int chance; chance = getmiscastchance(lf); if (chance) { - mvwprintw(mainwin, y, 0, "%s spells have a %d%% chance of failing due to cumbersome armour.", your(lf), chance); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s spells have a %d%% chance of failing due to cumbersome armour.", your(lf), chance); + } } - - // show boosts to spell power if (showall) { // note: same code as in getspellpower() enum SPELLSCHOOL school[5]; int nschools = 5; - school[0] = SS_WILD; school[1] = SS_MENTAL; school[2] = SS_NATURE; school[3] = SS_LIFE; school[4] = SS_ALLOMANCY; - for (i = 0; i < nschools; i++) { enum ATTRIB att = A_NONE; int n,found = B_FALSE; - // can you cast any spells from this school? getflags(lf->flags, retflag, &nretflags, F_CANCAST, F_CANWILL, F_NONE); for (n = 0; n < nretflags; n++) { @@ -13833,13 +13855,12 @@ void showlfstats(lifeform_t *lf, int showall) { break; } } - if (found) { int mod; enum RACE godid = R_NONE; mod = getspellpowerstatmod(lf, school[i], &att); if (mod) { - mvwprintw(mainwin, y, 0, "%s %s %s will %s the power of %s %s by %d.", + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s %s will %s the power of %s %s by %d.", your(lf), (mod > 0) ? "high" : "low", getattrname(att), (mod > 0) ? "boost" : "lower", @@ -13848,53 +13869,50 @@ void showlfstats(lifeform_t *lf, int showall) { getschoolname(school[i]), (school[i] == SS_MENTAL) ? "disciplines" : "spells", abs(mod) ); - y++; + } - // boosted by god? mod = getspellpowergodmod(lf, school[i], &godid); if (mod > 0) { lifeform_t *god; god = findgod(godid); if (god) { - mvwprintw(mainwin, y, 0, "%s is boosting the power of %s spells by %d.", + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s is boosting the power of %s spells by %d.", god->race->name, your(lf), mod); - y++; + } } } // end if found } // end foreach school } - // we DONT show traits based on the monster's racial characteristics // here. leave that to makedesc_race. // // This display is only for effects specific to this INDIVIDUAL lifeform. if (showall || (lorelev >= PR_NOVICE)) { if (isdeaf(lf)) { - mvwprintw(mainwin, y, 0, "%s %s deaf.", you(lf), is(lf)); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s deaf.", you(lf), is(lf)); + } f = hasflag_real(lf->flags, F_ENHANCESMELL, B_TRUE, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s an enhanced sense of smell.%s", you(lf), isplayer(lf) ? "have" : "has", + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s an enhanced sense of smell.%s", you(lf), isplayer(lf) ? "have" : "has", source); - y++; + } f = lfhasknownflag(lf, F_DISEASEIMMUNE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s immune to disease.%s", you(lf), is(lf), source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s immune to disease.%s", you(lf), is(lf), source); + } - f = hasflag_real(lf->flags, F_HEAVYBLOW, B_TRUE, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); snprintf(buf, BUFLEN,"%s%s attacks knock enemies back.%s", you(lf), getpossessive(you(lf)), source); - mvwprintw(mainwin, y, 0, buf); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, buf); + } f = lfhasknownflag(lf, F_REGENERATES); if (f) { @@ -13909,9 +13927,9 @@ void showlfstats(lifeform_t *lf, int showall) { strcpy(regenspeed, " extremely quickly"); } getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s regenerate%s health%s.%s", you(lf),isplayer(lf) ? "" : "s", regenspeed, + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s regenerate%s health%s.%s", you(lf),isplayer(lf) ? "" : "s", regenspeed, source); - y++; + } f = lfhasknownflag(lf, F_RESISTMAG); if (f) { @@ -13942,114 +13960,108 @@ void showlfstats(lifeform_t *lf, int showall) { strcpy(adjective, "completely"); } getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s %s resistant to magic.%s", you(lf), is(lf), adjective,source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s %s resistant to magic.%s", you(lf), is(lf), adjective,source); + } f = hasflag_real(lf->flags, F_FEARLESS, B_TRUE, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - wrapprint(mainwin, &y, &x, 0, "%s %s immune to the effects of fear.%s", you(lf), is(lf), source); + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s immune to the effects of fear.%s", you(lf), is(lf), source); } - f = hasflag_real(lf->flags, F_FASTMETAB, B_TRUE, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - wrapprint(mainwin, &y, &x, 0, "%s metabolic rate has been increased.%s", your(lf), getpossessive(you(lf)), + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s metabolic rate has been increased.%s", your(lf), getpossessive(you(lf)), source); } - f = hasflag_real(lf->flags, F_TREMORSENSE, B_TRUE, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s can 'see' by sensing vibrations around %s.%s", you(lf), you(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s can 'see' by sensing vibrations around %s.%s", you(lf), you(lf),source); + } f = hasflag_real(lf->flags, F_SEEINDARK, B_TRUE, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s can see in the dark.%s", you(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s can see in the dark.%s", you(lf),source); + if (f->val[1] == B_BLINDABLE) { - mvwprintw(mainwin, y, 0, "Bright lights will blind %s.%s", isplayer(lf) ? "you" : "it",source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "Bright lights will blind %s.%s", isplayer(lf) ? "you" : "it",source); + } } f = hasflag_real(lf->flags, F_SEEINVIS, B_TRUE, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s can see invisible things.%s", you(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s can see invisible things.%s", you(lf),source); + } f = hasflag_real(lf->flags, F_SHADOWED, B_TRUE, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s hidden from distant creatures.%s", you(lf), is(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s hidden from distant creatures.%s", you(lf), is(lf),source); + } f = hasflag_real(lf->flags, F_SPIDERCLIMB, B_TRUE, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s adhesive skin allows you to climb walls.%s", your(lf), isplayer(lf) ? "you" : "it", + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s adhesive skin allows you to climb walls.%s", your(lf), isplayer(lf) ? "you" : "it", source); - y++; + } f = hasflag_real(lf->flags, F_SIXTHSENSE, B_TRUE, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s will be warned about nearby enemies.%s", you(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s will be warned about nearby enemies.%s", you(lf),source); + } f = hasflag_real(lf->flags, F_STABILITY, B_TRUE, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s will not fall on slippery ground.%s", you(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s will not fall on slippery ground.%s", you(lf),source); + } - // only show eating habits if not inherited from race f = hasflag_real(lf->flags, F_CARNIVORE, B_TRUE, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s a carnivore (will not eat non-meat products).%s", you(lf), is(lf), + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s a carnivore (will not eat non-meat products).%s", you(lf), is(lf), source); - y++; + } f = hasflag_real(lf->flags, F_VEGETARIAN, B_TRUE, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s a vegetarian (will not eat meat).%s", you(lf), is(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s a vegetarian (will not eat meat).%s", you(lf), is(lf),source); + } f = hasflag_real(lf->flags, F_PARTVEGETARIAN, B_TRUE, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s a part vegetarian (will only eat meat when hungry).%s", you(lf), is(lf), + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s a part vegetarian (will only eat meat when hungry).%s", you(lf), is(lf), source); - y++; + } - f = hasflag_real(lf->flags, F_VISRANGEMOD, B_TRUE, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s vision range has been %s.%s", your(lf), + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s vision range has been %s.%s", your(lf), (f->val[0] > 0) ? "increased" : "decreased", source); - y++; + } f = hasflag_real(lf->flags, F_NIGHTVISRANGEMOD, B_TRUE, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s night vision range has been %s.%s", your(lf), + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s night vision range has been %s.%s", your(lf), (f->val[0] > 0) ? "increased" : "decreased", source); - y++; + } - f = hasflag_real(lf->flags, F_XRAYVIS, B_TRUE, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s can see through walls.%s", you(lf), source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s can see through walls.%s", you(lf), source); + } - getflags(lf->flags, retflag, &nretflags, F_CANSEETHROUGHMAT, F_NONE); for (i = 0; i < nretflags; i++) { material_t *m; @@ -14057,12 +14069,11 @@ void showlfstats(lifeform_t *lf, int showall) { m = findmaterial(f->val[0]); if (m) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s can see through %s.%s", you(lf), m->name,source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s can see through %s.%s", you(lf), m->name,source); + } } } - // traits based on the monster's bevaviour. // only known if you've studied this creature type a bit. if (showall || (lorelev >= PR_BEGINNER)) { @@ -14084,10 +14095,9 @@ void showlfstats(lifeform_t *lf, int showall) { } else { strcpy(moralebuf, "nervous"); } - mvwprintw(mainwin, y, 0, "It looks %s.", moralebuf); y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "It looks %s.", moralebuf); } - // damage desistances/vulnerabilities // resistances strcpy(buf, ""); @@ -14106,7 +14116,6 @@ void showlfstats(lifeform_t *lf, int showall) { } else { snprintf(buf2, BUFLEN, ", %s", getdamnamenoun(i)); } - if (lfhasknownflag(lf, F_EXTRAINFO) || lfhasflag(lf, F_OMNIPOTENT)) { if ((f->lifetime != PERMENANT) && (f->lifetime > 0)) { @@ -14121,7 +14130,7 @@ void showlfstats(lifeform_t *lf, int showall) { } if (strlen(buf) > 0) { strcat(buf, ".\n"); - wrapprint(mainwin, &y, &x, 0, buf); + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, buf); } // immunities strcpy(buf, ""); @@ -14144,10 +14153,9 @@ void showlfstats(lifeform_t *lf, int showall) { } } } - if (strlen(buf) > 0) { strcat(buf, ".\n"); - wrapprint(mainwin, &y, &x, 0, buf); + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, buf); } // vulnerabilities strcpy(buf, ""); @@ -14166,7 +14174,6 @@ void showlfstats(lifeform_t *lf, int showall) { } else { snprintf(buf2, BUFLEN, ", %s", getdamnamenoun(i)); } - if (lfhasknownflag(lf, F_EXTRAINFO) || lfhasflag(lf, F_OMNIPOTENT)) { if (f->lifetime > 0) { @@ -14181,9 +14188,8 @@ void showlfstats(lifeform_t *lf, int showall) { } if (strlen(buf) > 0) { strcat(buf, ".\n"); - wrapprint(mainwin, &y, &x, 0, buf); + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, buf); } - // material vulnerabilities getflags(lf->flags, retflag, &nretflags, F_MATVULN, F_NONE); for (i = 0; i < nretflags; i++) { @@ -14192,18 +14198,17 @@ void showlfstats(lifeform_t *lf, int showall) { mt = findmaterial(f->val[0]); if (mt) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s take%s %d%% damage from %s weapons.%s", you(lf), + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s take%s %d%% damage from %s weapons.%s", you(lf), isplayer(lf) ? "" : "s", f->val[1], mt->name,source); - y++; + if (f->val[2] > 0) { - mvwprintw(mainwin, y, 0, "Touching %s objects will hurt %s (%d dam).", + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "Touching %s objects will hurt %s (%d dam).", mt->name, you(lf), f->val[2]); - y++; + } } } } - if (showall || (lorelev >= PR_BEGINNER) || (getskill(player, SK_SPEECH) >= PR_ADEPT)) { // wants/desires if (!isplayer(lf)) { @@ -14216,8 +14221,8 @@ void showlfstats(lifeform_t *lf, int showall) { ot = findot(f->val[0]); pname = strdup(ot->name); makeplural(&pname); - mvwprintw(mainwin, y, 0, 0, "It %s %s.", (f->val[1] == B_COVETS) ? "covets" : "wants", pname); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, 0, "It %s %s.", (f->val[1] == B_COVETS) ? "covets" : "wants", pname); + free(pname); } else if (f->id == F_WANTSOBFLAG) { char what[BUFLEN]; @@ -14228,142 +14233,139 @@ void showlfstats(lifeform_t *lf, int showall) { default: strcpy(what, "some objects"); break; // shouldn't happen } - mvwprintw(mainwin, y, 0, "It %s %s.", (f->val[1] == B_COVETS) ? "covets" : "wants", what); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "It %s %s.", (f->val[1] == B_COVETS) ? "covets" : "wants", what); + } else if (f->id == F_WANTSBETTERWEP) { - mvwprintw(mainwin, y, 0, "It %s better weapons.", (f->val[1] == B_COVETS) ? "covets" : "wants"); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "It %s better weapons.", (f->val[1] == B_COVETS) ? "covets" : "wants"); + } else if (f->id == F_WANTSBETTERARM) { - mvwprintw(mainwin, y, 0, "It %s better armour.", (f->val[1] == B_COVETS) ? "covets" : "wants"); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "It %s better armour.", (f->val[1] == B_COVETS) ? "covets" : "wants"); + } } } } - // show intrinsics f = lfhasknownflag(lf, F_ARBOOST); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s Armour Rating is being magically %s.%s", + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s Armour Rating is being magically %s.%s", your(lf), (f->val[0] >= 0) ? "boosted" : "reduced",source); - y++; + } f = lfhasknownflag(lf, F_ATTRSET); if (f && (f->known)) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s has been modified.%s", your(lf), getattrname(f->val[0]),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s has been modified.%s", your(lf), getattrname(f->val[0]),source); + } else { f = lfhasknownflag(lf, F_ATTRMOD); if (f && (f->known)) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s has been %s.%s", your(lf), getattrname(f->val[0]), + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s has been %s.%s", your(lf), getattrname(f->val[0]), (f->val[1] > 0) ? "increased" : "decreased",source); - y++; + } } if (lfhasknownflag(lf, F_ANONYMOUS)) { - mvwprintw(mainwin, y, 0, "%s identity is obscured.%s", your(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s identity is obscured.%s", your(lf),source); + } f = hasflag_real(lf->flags, F_AUTOTANGLE, B_TRUE, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s a %d%% chance to automatically entangle enemies.%s", you(lf), + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s a %d%% chance to automatically entangle enemies.%s", you(lf), isplayer(lf) ? "have" : "has", f->val[0], source); - y++; + } f = hasflag_real(lf->flags, F_AWARENESS, B_TRUE, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s can see things which are behind %s.%s", you(lf), you(lf), + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s can see things which are behind %s.%s", you(lf), you(lf), source); - y++; + } f = hasflag_real(lf->flags, F_DODGES, B_TRUE, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s will automatically use %s remaining stamina to dodge fatal attacks.%s", you(lf), your(lf), + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s will automatically use %s remaining stamina to dodge fatal attacks.%s", you(lf), your(lf), source); - y++; + } getflags(lf->flags, retflag, &nretflags, F_LEARNBOOST, F_NONE); for (i = 0; i < nretflags; i++) { f = retflag[i]; if (f && f->known) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s have a %d%% %s to earned experience points.%s", you(lf), + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s have a %d%% %s to earned experience points.%s", you(lf), f->val[0], (f->val[0] > 0) ? "bonus" : "penalty",source); - y++; + } } - f = lfhasknownflag(lf, F_MAGICARMOUR); if (f && (f->known)) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s protected by %s %s", you(lf), is(lf), + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s protected by %s %s", you(lf), is(lf), needan(f->text) ? "an" : "a", f->text); if (isplayer(lf)) { wprintw(mainwin, " (+%d AR).%s",f->val[0],source); } else { wprintw(mainwin, ".%s",source); } - y++; + } f = lfhasknownflag(lf, F_MAGICBOOST); if (f && (f->known)) { int boost; getflagsourcetext(f,source); sumflags(lf->flags, F_MAGICBOOST, &boost, NULL, NULL); - mvwprintw(mainwin, y, 0, "The power of %s spells is boosted by %d.%s", + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "The power of %s spells is boosted by %d.%s", isplayer(lf) ? "your" : "its", boost,source); - y++; + } f = lfhasknownflag(lf, F_TEMPMAGICBOOST); if (f && (f->known)) { int boost; sumflags(lf->flags, F_TEMPMAGICBOOST, &boost, NULL, NULL); getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "The power of %s next spell will be boosted by %d.%s", + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "The power of %s next spell will be boosted by %d.%s", isplayer(lf) ? "your" : "its", boost,source); - y++; + } f = lfhasknownflag(lf, F_MINCRITCHANCE); if (f && (f->known)) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s attacks are guided by the gods, granting a minimum %d%% criticial hit chance.%s", + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s attacks are guided by the gods, granting a minimum %d%% criticial hit chance.%s", your(lf), f->val[0],source); - y++; + } f = lfhasknownflag(lf, F_MINDSHIELD); if (f && (f->known)) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s are protected from psionic attacks.%s", you(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s are protected from psionic attacks.%s", you(lf),source); + } f = lfhasknownflag(lf, F_MISCASTCHANCE); if (f && (f->known)) { int chance; getflagsourcetext(f,source); sumflags(lf->flags, F_MISCASTCHANCE, &chance, NULL, NULL); - mvwprintw(mainwin, y, 0, "%s spells have a %d%% chance of failure.%s", + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s spells have a %d%% chance of failure.%s", isplayer(lf) ? "Your" : "Its", chance, source); - y++; + } - f = lfhasflag(lf, F_OMNIPOTENT); if (f && (f->known)) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s are omnipotent.%s", you(lf), source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s are omnipotent.%s", you(lf), source); + } f = isblind(lf); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s cannot see.%s", you(lf), source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s cannot see.%s", you(lf), source); + } f = lfhasknownflag(lf, F_CHARMEDBY); if (f) { @@ -14376,81 +14378,79 @@ void showlfstats(lifeform_t *lf, int showall) { strcpy(charmername, "something"); } snprintf(buf, BUFLEN,"%s %s been charmed by %s.",you(lf), isplayer(lf) ? "have" : "has", charmername); - mvwprintw(mainwin, y, 0, buf); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, buf); + } f = lfhasknownflag(lf, F_BREATHWATER); if (!f) f = lfhasknownflag(lf, F_AQUATIC); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s can breath normally while underwater.%s", you(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s can breath normally while underwater.%s", you(lf),source); + } f = lfhasknownflag(lf, F_CONTROL); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s can control teleportation and polymorphic effects.%s", you(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s can control teleportation and polymorphic effects.%s", you(lf),source); + } f = lfhasknownflag(lf, F_CONFUSED); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s confused.%s", you(lf), is(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s confused.%s", you(lf), is(lf),source); + } f = lfhasknownflag(lf, F_CONSUMESOULS); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s can consume souls of those who die nearby.%s", you(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s can consume souls of those who die nearby.%s", you(lf),source); + } f = lfhasknownflag(lf, F_DETECTAURAS); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s automatically detect blessings or curses.%s", you(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s automatically detect blessings or curses.%s", you(lf),source); + } f = lfhasknownflag(lf, F_DETECTLIFE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s automatically detect %snearby lifeforms.%s", you(lf), + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s automatically detect %snearby lifeforms.%s", you(lf), (f->val[1] == B_TRUE) ? "" : "the size of ",source); - y++; + } f = lfhasknownflag(lf, F_DETECTMAGIC); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s automatically detect magical enchantments on objects.%s", you(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s automatically detect magical enchantments on objects.%s", you(lf),source); + } f = lfhasknownflag(lf, F_DETECTMETAL); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s automatically detect nearby metal.%s", you(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s automatically detect nearby metal.%s", you(lf),source); + } f = lfhasknownflag(lf, F_DETECTOBS); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s automatically detect nearby objects.%s", you(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s automatically detect nearby objects.%s", you(lf),source); + } f = lfhasknownflag(lf, F_ENHANCESEARCH); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s searching ability is enhanced.%s", you(lf), isplayer(lf) ? "Your" : "Its",source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s searching ability is enhanced.%s", you(lf), isplayer(lf) ? "Your" : "Its",source); + } - f = lfhasknownflag(lf, F_DRUNK); if (f) { char ddesc[BUFLEN]; getflagsourcetext(f,source); getdrunkdesc(lf, f, ddesc); - mvwprintw(mainwin, y, 0, "%s %s %s (%s).%s", you(lf), is(lf), getdrunktext(f), ddesc,source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s %s (%s).%s", you(lf), is(lf), getdrunktext(f), ddesc,source); + } - getflags(lf->flags, retflag, &nretflags, F_EXTRADAM, F_WOUNDING,F_NONE); for (i = 0; i < nretflags; i++) { if (showall || f->known) { @@ -14491,20 +14491,18 @@ void showlfstats(lifeform_t *lf, int showall) { strcpy(damtypebuf, "damage"); } - getflagsourcetext(f,source); dicetotext(ndice, nsides, bonus, &min, &max, dicebuf, mmbuf); if (strcmp(dicebuf, mmbuf)) { - mvwprintw(mainwin, y, 0, "%s deal%s %s (%s) extra %s each hit.%s", you(lf), + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s deal%s %s (%s) extra %s each hit.%s", you(lf), isplayer(lf) ? "" : "s", dicebuf, mmbuf, damtypebuf,source); } else { - mvwprintw(mainwin, y, 0, "%s deal%s %s extra %s each hit.%s", you(lf), + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s deal%s %s extra %s each hit.%s", you(lf), isplayer(lf) ? "" : "s", dicebuf, damtypebuf,source); } - y++; + } } - f = lfhasflag(lf, F_EXTRALUCK); if (f) { sumflags(lf->flags, F_EXTRALUCK, &luckmod, NULL, NULL); @@ -14520,36 +14518,32 @@ void showlfstats(lifeform_t *lf, int showall) { strcpy(luckamt, "incredibly "); break; } getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s %slucky.%s", you(lf), is(lf), luckamt,source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s %slucky.%s", you(lf), is(lf), luckamt,source); + } } - f = lfhasknownflag(lf, F_EXTRAMP); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "Your mana pool is being boosted.%s", you(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "Your mana pool is being boosted.%s", you(lf),source); + } - f = lfhasknownflag(lf, F_EXTRAINFO); if (f && (f->known)) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s receive enhanced knowledge about the world.%s", you(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s receive enhanced knowledge about the world.%s", you(lf),source); + } for (f = lf->flags->first ; f ; f = f->next ){ if (f->known && (f->id == F_POISONED)) { int knownfatal = B_FALSE; poisontype_t *pt; pt = findpoisontype(f->val[0]); - if (getskill(player, SK_FIRSTAID) >= PR_ADEPT) { if (poisonthreatenslife(lf, f)) { knownfatal = B_TRUE; } } - if (pt->id == P_LYCANTHROPY) { snprintf(buf, BUFLEN, "%s %s afflicted with %s.", you(lf), is(lf), pt->name); @@ -14565,10 +14559,9 @@ void showlfstats(lifeform_t *lf, int showall) { strcat(buf, buf2); } } - mvwprintw(mainwin, y, 0, buf); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, buf); + } - if (f->known && (f->id == F_INCUBATING)) { poisontype_t *pt; pt = findpoisontype(f->val[0]); @@ -14577,34 +14570,33 @@ void showlfstats(lifeform_t *lf, int showall) { } else { snprintf(buf, BUFLEN, "%s %s incubating %s.", you(lf), is(lf), pt->name); } - mvwprintw(mainwin, y, 0, buf); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, buf); + } } - f = lfhasflag(lf, F_MUTABLE); if (f && (f->known)) { - mvwprintw(mainwin, y, 0, "%s body is receptive to mutations.", your(lf), isplayer(lf) ? "is" : "are"); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s body is receptive to mutations.", your(lf), isplayer(lf) ? "is" : "are"); + } f = lfhasflag(lf, F_NAUSEATED); if (f && (f->known)) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s nauseated.%s", you(lf), is(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s nauseated.%s", you(lf), is(lf),source); + } f = lfhasknownflag(lf, F_HOLYAURA); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s surrounded by a holy aura.%s", you(lf), is(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s surrounded by a holy aura.%s", you(lf), is(lf),source); + } f = lfhasknownflag(lf, F_HOLYTOUCH); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "Any object %s weild%s will be temporarily blessed.%s", you(lf), + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "Any object %s weild%s will be temporarily blessed.%s", you(lf), isplayer(lf) ? "" : "s",source); - y++; + } f = lfhasknownflag(lf, F_HOTFEET); if (f) { @@ -14617,7 +14609,6 @@ void showlfstats(lifeform_t *lf, int showall) { getflagsourcetext(f,source); msg("%s feet automatically generating sheets of ice.%s",your(lf),source); } - f = lfhasknownflag(lf, F_FREEZINGTOUCH); if (f && (f->known)) { getflagsourcetext(f,source); @@ -14627,21 +14618,21 @@ void showlfstats(lifeform_t *lf, int showall) { snprintf(buf2, BUFLEN, " [%d uses left]", f->val[0]); strcat(buf, buf2); } - mvwprintw(mainwin, y, 0, "%s%s",buf,source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s%s",buf,source); + } f = lfhasflag(lf, F_GRAVBOOSTED); if (f && (f->known)) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "Gravity is increased around %s.%s", you_l(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "Gravity is increased around %s.%s", you_l(lf),source); + } f = lfhasflag(lf, F_GRAVLESSENED); if (f && (f->known)) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "Gravity is lessened around %s, preventing fall damage, increasing flight speed and reducing load.%s", + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "Gravity is lessened around %s, preventing fall damage, increasing flight speed and reducing load.%s", you_l(lf),source); - y++; + } f = lfhasknownflag(lf, F_FULLSHIELD); if (f && (f->known)) { @@ -14650,8 +14641,8 @@ void showlfstats(lifeform_t *lf, int showall) { sh = hasobid(lf->pack, atol(f->text)); getobname(sh, obname, 1); getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s fully shielded by %s %s.%s", you(lf), is(lf), your(lf), obname,source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s fully shielded by %s %s.%s", you(lf), is(lf), your(lf), obname,source); + } f = lfhasknownflag(lf, F_HEAVENARM); if (f && (f->known)) { @@ -14662,147 +14653,138 @@ void showlfstats(lifeform_t *lf, int showall) { strcpy(hpbuf, ""); } getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s surrounded by a %s. %s%s", you(lf), is(lf), f->text, hpbuf,source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s surrounded by a %s. %s%s", you(lf), is(lf), f->text, hpbuf,source); + } f = lfhasknownflag(lf, F_INVULNERABLE); if (f && (f->known)) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s protected from all physical harm.%s", you(lf), is(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s protected from all physical harm.%s", you(lf), is(lf),source); + } f = lfhasflag(lf, F_MAGSHIELD); if (f && (f->known)) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s surrounded by a magnetic shield.%s", you(lf), is(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s surrounded by a magnetic shield.%s", you(lf), is(lf),source); + } f = lfhasflag(lf, F_PAIN); if (f && (f->known)) { getflagsourcetext(f,source); if (lfhasflag(lf, F_DRUNK)) { - mvwprintw(mainwin, y, 0, "%s %s in extreme pain, somewhat mitigated by %s inebriation.%s", you(lf), is(lf), isplayer(lf) ? "Your" : "its",source); + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s in extreme pain, somewhat mitigated by %s inebriation.%s", you(lf), is(lf), isplayer(lf) ? "Your" : "its",source); } else { - mvwprintw(mainwin, y, 0, "%s %s in extreme pain, and movement will cause %s damage.%s", you(lf), is(lf), isplayer(lf) ? "You" : "it",source); + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s in extreme pain, and movement will cause %s damage.%s", you(lf), is(lf), isplayer(lf) ? "You" : "it",source); } - y++; + } - f = lfhasflag(lf, F_PARALYZED); if (f && (f->known)) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s paralyzed.%s", you(lf), is(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s paralyzed.%s", you(lf), is(lf),source); + } f = hasflag_real(lf->flags, F_PHOTOMEM, NA, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s do not forget your surroundings.%s", you(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s do not forget your surroundings.%s", you(lf),source); + } f = hasflag_real(lf->flags, F_PLANTFRIEND, NA, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "Plants are friendly towards %s.%s", you(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "Plants are friendly towards %s.%s", you(lf),source); + } f = hasflag_real(lf->flags, F_POLYIMMUNE, NA, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s cannot be polymorphed.%s", you(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s cannot be polymorphed.%s", you(lf),source); + } f = hasflag_real(lf->flags, F_PROTALIGN, NA, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s protected from attacks by %s-aligned creatures.%s", you(lf), is(lf), + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s protected from attacks by %s-aligned creatures.%s", you(lf), is(lf), getalignmentname(f->val[1]),source); - y++; + } f = lfhasflag(lf, F_RAGE); if (f && (f->known)) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s enraged, gaining accuracy, damage and hit point bonuses.%s", you(lf), is(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s enraged, gaining accuracy, damage and hit point bonuses.%s", you(lf), is(lf),source); + } f = lfhasflag(lf, F_REFLECTION); if (f && (f->known)) { getflagsourcetext(f,source); - wrapprint(mainwin, &y, &x, 0, "%s %s surrounded by a negative gravity field.%s", you(lf), is(lf),source); + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s surrounded by a negative gravity field.%s", you(lf), is(lf),source); } f = lfhasknownflag(lf, F_TRUESTRIKE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s%s attacks will automatically hit.%s", you(lf), getpossessive(you(lf)),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s%s attacks will automatically hit.%s", you(lf), getpossessive(you(lf)),source); + } f = lfhasknownflag(lf, F_WINDSHIELD); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s protected from missiles by a cyclonic shield", you(lf), is(lf)); - + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s protected from missiles by a cyclonic shield", you(lf), is(lf)); if (isplayer(lf)) { wprintw(mainwin, " (power %d).%s",roman(f->val[0]),source); } else { wprintw(mainwin, ".%s",source); } - y++; + } f = lfhasflag(lf, F_RISEASGHOST); if (f && (f->known)) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s will rise as a ghost after death.%s", you(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s will rise as a ghost after death.%s", you(lf),source); + } - f = hasflag_real(lf->flags, F_STASIS, B_TRUE, NULL, FROMRACE); if (f && (f->known)) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "Time within your body has been frozen.%s", you(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "Time within your body has been frozen.%s", you(lf),source); + } - f = hasflag_real(lf->flags, F_STAMBOOST, B_TRUE, NULL, FROMRACE); if (f && (f->known)) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s stamina is currently being boosted.%s", your(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s stamina is currently being boosted.%s", your(lf),source); + } - f = hasflag_real(lf->flags, F_STENCH, B_TRUE, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s emitting a foul stench, nauseating those nearby.%s", you(lf), is(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s emitting a foul stench, nauseating those nearby.%s", you(lf), is(lf),source); + } - f = hasflag_real(lf->flags, F_UNDEAD, B_TRUE, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s have been rendered undead.%s", you(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s have been rendered undead.%s", you(lf),source); + } - f = hasflag_real(lf->flags, F_SILENCED, B_TRUE, NULL, FROMRACE); if (f) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s been magically silenced.%s", you(lf), + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s been magically silenced.%s", you(lf), isplayer(lf) ? "have" : "has", source); - y++; + } - f = lfhasflag(lf, F_STRIKETOKO); if (f && (f->known)) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s attacking in a non-lethal manner.%s", you(lf), is(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s attacking in a non-lethal manner.%s", you(lf), is(lf),source); + } - f = lfhasflag(lf, F_STUNNED); if (f && (f->known)) { getflagsourcetext(f,source); - mvwprintw(mainwin, y, 0, "%s %s stunned and cannot attack, cast spells or use abilities.%s", you(lf), is(lf),source); - y++; + effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s %s stunned and cannot attack, cast spells or use abilities.%s", you(lf), is(lf),source); + } } else if (mode == 'i') { object_t *o; @@ -14898,9 +14880,7 @@ void showlfstats(lifeform_t *lf, int showall) { plev = getpietylev(god->race->id, &col, happiness); } - // TODO: construct piety buf [---+--|--------------------] - - + // construct piety buf [---+--|--------------------] snprintf(pietybuf, BUFLEN, "%s[", blocked ? "" : "^n"); switch (col) { @@ -15570,8 +15550,30 @@ void wingame(void) { } } -// @ = tab char wrapprint(WINDOW *win, int *y, int *x, int newlineindent, char *format, ... ) { + char buf[HUGEBUFLEN]; + va_list args; + + va_start(args, format); + vsnprintf( buf, HUGEBUFLEN, format, args ); + va_end(args); + + return real_wrapprint(win, y, x, B_TRUE, newlineindent, "%s", buf); +} + +char wrapprint_nomore(WINDOW *win, int *y, int *x, int newlineindent, char *format, ... ) { + char buf[HUGEBUFLEN]; + va_list args; + + va_start(args, format); + vsnprintf( buf, HUGEBUFLEN, format, args ); + va_end(args); + + return real_wrapprint(win, y, x, B_FALSE, newlineindent, "%s", buf); +} + +// @ = tab +char real_wrapprint(WINDOW *win, int *y, int *x, int pager, int newlineindent, char *format, ... ) { char word[HUGEBUFLEN],buf[HUGEBUFLEN]; char *p; va_list args; @@ -15644,7 +15646,7 @@ char wrapprint(WINDOW *win, int *y, int *x, int newlineindent, char *format, ... } } - if (gamemode == GM_GAMESTARTED) { + if (pager && (gamemode == GM_GAMESTARTED)) { if (*y >= h-2) { char ch; centre(win,C_WHITE, h-1, "--More--"); diff --git a/io.h b/io.h index 3c63cd7..de6ca35 100644 --- a/io.h +++ b/io.h @@ -105,6 +105,7 @@ void dumpcols(void); void dumpskills(void); void dumpspells(void); void dumpweps(void); +int effectline(int *stopnow, int *count, int offset, int *nextoffset, int headinglines, WINDOW *win, int *y, int *x, int newlineindent, char *format, ... ); void forceredraw(void); enum COLOUR getattrcolour(enum ATTRBRACKET brack); char getchoice(prompt_t *prompt); @@ -164,3 +165,5 @@ int warnabout(char *what); int real_warnabout(char *what, int lifetime, int doquestion); void wingame(void); char wrapprint(WINDOW *win, int *y, int *x, int newlineindent, char *format, ... ); +char wrapprint_nomore(WINDOW *win, int *y, int *x, int newlineindent, char *format, ... ); +char real_wrapprint(WINDOW *win, int *y, int *x, int pager, int newlineindent, char *format, ... ); diff --git a/lf.c b/lf.c index d031d0a..e705ea1 100644 --- a/lf.c +++ b/lf.c @@ -22908,6 +22908,13 @@ int slipon(lifeform_t *lf, object_t *o) { if (isplayer(lf)) { real_warnabout("(use 'm-tiptoe' to walk carefully)", PERMENANT, B_FALSE); + } else { + // most monsters who slipped will tiptoe next turn, if it is still slippery here. + if (getattrbracket(getattr(lf, A_IQ), A_IQ, NULL) >= IQ_ANIMAL) { + if (getslipperyness(lf->cell, NULL)) { + addflag(lf->flags, F_SLIPPEDLASTTURN, B_TRUE, NA, NA, NULL); + } + } } if (o) { diff --git a/move.c b/move.c index 5254f56..bc834a4 100644 --- a/move.c +++ b/move.c @@ -2017,7 +2017,19 @@ int movetowards(lifeform_t *lf, cell_t *dst, int dirtype, int strafe) { if (db) { dblog(".oO { dir from %d,%d -> %d,%d is %s }", lf->cell->x, lf->cell->y, dst->x, dst->y, getdirname(dir)); } - rv = trymove(lf, dir, B_TRUE, strafe); + + if (isplayer(lf)) { + rv = trymove(lf, dir, B_TRUE, strafe); + } else { + flag_t *f; + f = lfhasflag(lf, F_SLIPPEDLASTTURN); + if (f) { + killflag(f); + rv = trysneak(lf, dir); + } else { + rv = trymove(lf, dir, B_TRUE, strafe); + } + } } else { if (db) dblog(".oO { dir from %d,%d -> %d,%d is DT_NONE ! }", lf->cell->x, lf->cell->y, dst->x, dst->y); }