diff -uNr ./include/config.h ../nethack-3.3.1.h/include/config.h --- ./include/config.h Sat Jul 22 11:13:51 2000 +++ ../nethack-3.3.1.h/include/config.h Sun Aug 27 23:41:48 2000 @@ -47,6 +47,8 @@ /* #define QT_GRAPHICS */ /* Qt interface */ /* #define GNOME_GRAPHICS */ /* Gnome interface */ +#define HITPOINTBAR + /* * Define the default window system. This should be one that is compiled * into your system (see defines above). Known window systems are: diff -uNr ./include/decl.h ../nethack-3.3.1.h/include/decl.h --- ./include/decl.h Sat Jul 22 10:58:59 2000 +++ ../nethack-3.3.1.h/include/decl.h Sun Aug 27 23:21:11 2000 @@ -26,6 +26,8 @@ E NEARDATA int bases[MAXOCLASSES]; + +E int damagetaken; E NEARDATA int multi; E NEARDATA int warnlevel; E NEARDATA int nroom; diff -uNr ./include/flag.h ../nethack-3.3.1.h/include/flag.h --- ./include/flag.h Sat Jul 22 10:59:00 2000 +++ ../nethack-3.3.1.h/include/flag.h Sun Aug 27 23:21:11 2000 @@ -42,6 +42,9 @@ boolean forcefight; boolean friday13; /* it's Friday the 13th */ boolean help; /* look in data file for info about stuff */ +#ifdef HITPOINTBAR + boolean hitpointbar; /* colourful hit point status bar */ +#endif boolean ignintr; /* ignore interrupts */ #ifdef INSURANCE boolean ins_chkpt; /* checkpoint as appropriate */ diff -uNr ./src/botl.c ../nethack-3.3.1.h/src/botl.c --- ./src/botl.c Tue May 2 23:37:13 2000 +++ ../nethack-3.3.1.h/src/botl.c Mon Aug 28 00:15:57 2000 @@ -4,6 +4,12 @@ #include "hack.h" +#define HP_RED "\e[41;30m" +#define HP_PURPLE "\e[45;30m" +#define HP_YELLOW "\e[43;30m" +#define HP_GREEN "\e[42;30m" +#define HP_BLUE "\e[44;30m" + #ifdef OVL0 extern const char *hu_stat[]; /* defined in eat.c */ @@ -160,10 +166,49 @@ bot1() { char newbot1[MAXCO]; + char temp[1024]; register char *nb; register int i,j; + int hp,hpmax; +#ifndef HITPOINTBAR + int damagetaken = 0; +#endif + int barstart,barend; + int bardam; /* damage taken last turn */ + int barlength; /* number of characters wide hpbar is + (barend - barstart) */ + int baramount; /* how much of the bar is drawn(depends on current hp)*/ + int damageamount; /* how much of the bar is drawn for damage taken */ + char hpbar[80]; + char hpcolor[15]; + + /*Strcpy(newbot1, plname); */ + + hp = Upolyd ? u.mh : u.uhp; + hpmax = Upolyd ? u.mhmax : u.uhpmax; + if(hp < 0) hp = 0; + + if (hp == hpmax) { + strcpy(hpcolor, HP_GREEN); + } else if (((double)hp / (double)hpmax) > 0.5) { + strcpy(hpcolor, HP_YELLOW); + } else if (((double)hp / (double)hpmax) > 0.25) { + strcpy(hpcolor, HP_PURPLE); + } else { + strcpy(hpcolor, HP_RED); + } + +#ifdef HITPOINTBAR + if (flags.hitpointbar) { + Strcpy(newbot1, "["); + Strcat(newbot1, plname); + } else { + Strcpy(newbot1, plname); + } +#else + Strcpy(newbot1, plname); +#endif - Strcpy(newbot1, plname); if('a' <= newbot1[0] && newbot1[0] <= 'z') newbot1[0] += 'A'-'a'; newbot1[10] = 0; Sprintf(nb = eos(newbot1)," the "); @@ -183,6 +228,47 @@ } else Sprintf(nb = eos(nb), rank()); + /* position of start/end of status bar */ + barstart = 1; + barend = strlen(newbot1); + + /* */ + barlength = barend - barstart; + baramount = ((double)hp / (double)hpmax) * barlength; + + /* damage taken */ + damageamount = ((double)damagetaken / (double)hpmax) * barlength; + if (damagetaken > 0) { + bardam = barstart + baramount + damageamount; + if (bardam > barend) bardam = barend; + } else { /* no damage */ + bardam = barstart + baramount; + } + +#ifdef HITPOINTBAR + damagetaken = 0; +#endif + + /* adjust bar end */ + barend = barstart + baramount; + + /* setup bar */ + strcpy(hpbar, ""); + for (i = 0; i < 80; i++) { + strcat(hpbar, " "); + } + + hpbar[1] = 'S'; + hpbar[barend] = 'E'; + /* this might overwrite the barend - this is okay */ + hpbar[bardam] = 'D'; + +#ifdef HITPOINTBAR + if (flags.hitpointbar) { + Strcat(newbot1, "]"); + } +#endif + Sprintf(nb = eos(nb)," "); i = mrank_sz + 15; j = (nb + 2) - newbot1; /* aka strlen(newbot1) but less computation */ @@ -206,8 +292,40 @@ if (flags.showscore) Sprintf(nb = eos(nb), " S:%ld", botl_score()); #endif +#ifdef HITPOINTBAR + if (flags.hitpointbar) { + /* merge hpbar and newbot1 */ + for (i = 0; i < strlen(newbot1); i++) { + char temp2[2]; + char bar_coloured[6]; + char bar_blank[6]; + + sprintf(bar_coloured, "\e[41m"); + sprintf(bar_blank, "\e[10m"); + sprintf(temp2, "%c", newbot1[i]); + if (hpbar[i] == 'S') { + strcat(temp, hpcolor); + strcat(temp, temp2); + } else if (hpbar[i] == 'E') { + strcat(temp, HP_BLUE); + strcat(temp, temp2); + } else if (hpbar[i] == 'D') { + strcat(temp, "\e[0m"); + strcat(temp, temp2); + } else { + strcat(temp, temp2); + } + } + } else { + strcpy(temp, newbot1); + } +#else + strcpy(temp, newbot1); +#endif + curs(WIN_STATUS, 1, 0); - putstr(WIN_STATUS, 0, newbot1); + /*putstr(WIN_STATUS, 0, newbot1); */ + putstr(WIN_STATUS, 0, temp); } /* provide the name of the current level for display by various ports */ @@ -278,6 +396,7 @@ if(Slimed) Sprintf(nb = eos(nb), " Slime"); if(cap > UNENCUMBERED) Sprintf(nb = eos(nb), " %s", enc_stat[cap]); + Strcat(newbot2, "\e[0m"); curs(WIN_STATUS, 1, 1); putstr(WIN_STATUS, 0, newbot2); } diff -uNr ./src/decl.c ../nethack-3.3.1.h/src/decl.c --- ./src/decl.c Wed May 10 10:50:12 2000 +++ ../nethack-3.3.1.h/src/decl.c Sun Aug 27 23:50:30 2000 @@ -19,6 +19,9 @@ NEARDATA int bases[MAXOCLASSES] = DUMMY; +#ifdef HITPOINTBAR +int damagetaken; +#endif NEARDATA int multi = 0; NEARDATA int warnlevel = 0; /* used by movemon and dochugw */ NEARDATA int nroom = 0; diff -uNr ./src/hack.c ../nethack-3.3.1.h/src/hack.c --- ./src/hack.c Sat Jul 22 10:59:06 2000 +++ ../nethack-3.3.1.h/src/hack.c Sun Aug 27 23:36:00 2000 @@ -1689,6 +1689,10 @@ return; } +#ifdef HITPOINTBAR + damagetaken = n; +#endif + u.uhp -= n; if(u.uhp > u.uhpmax) u.uhpmax = u.uhp; /* perhaps n was negative */ diff -uNr ./src/mhitu.c ../nethack-3.3.1.h/src/mhitu.c --- ./src/mhitu.c Sat Aug 5 09:37:50 2000 +++ ../nethack-3.3.1.h/src/mhitu.c Sun Aug 27 23:36:12 2000 @@ -1864,6 +1864,9 @@ if (u.mh < 1) rehumanize(); } else { u.uhp -= n; +#ifdef HITPOINTBAR + damagetaken += n; +#endif if(u.uhp < 1) done_in_by(mtmp); } } diff -uNr ./src/options.c ../nethack-3.3.1.h/src/options.c --- ./src/options.c Thu Aug 10 04:33:01 2000 +++ ../nethack-3.3.1.h/src/options.c Sun Aug 27 23:21:11 2000 @@ -96,6 +96,9 @@ #else {"hilite_pet", (boolean *)0, FALSE}, #endif +#ifdef HITPOINTBAR + {"hitpointbar", &flags.hitpointbar, FALSE}, +#endif #ifdef ASCIIGRAPH {"IBMgraphics", &iflags.IBMgraphics, FALSE}, #else diff -uNr ./win/tty/wintty.c ../nethack-3.3.1.h/win/tty/wintty.c --- ./win/tty/wintty.c Sat Jul 22 10:59:28 2000 +++ ../nethack-3.3.1.h/win/tty/wintty.c Sun Aug 27 23:30:44 2000 @@ -1721,7 +1721,8 @@ if(flags.botlx) *ob = 0; if(!cw->cury && (int)strlen(str) >= CO) { /* the characters before "St:" are unnecessary */ - nb = index(str, ':'); + /*nb = index(str, ':'); */ + nb = 0; if(nb && nb > str+2) str = nb - 2; } @@ -1735,7 +1736,11 @@ } break; } +#ifdef HITPOINTBAR + if((*ob != *nb) || (flags.hitpointbar)) +#else if(*ob != *nb) +#endif tty_putsym(WIN_STATUS, i, cw->cury, *nb); if(*ob) ob++; }