update PR #1071 - highlighting critical HP
If status field 'hitpoints' has rules for both 'criticalhp' and 'up' or 'down' or 'changed', make critical-hp take precedence. Otherwise critical-hp might never be seen because of the value changing every move (if hero has regeneration attribute). Normally up/down/changed take precedence over other types of highlighting. Something is messed up with up/down/changed HP though. I'm seeing the 'up' highlight when it goes either up or down and not seeing the 'down' highlight at all. 'up' and 'down' for gold work as expected.
This commit is contained in:
@@ -1654,6 +1654,7 @@ if something breakable was set up as alternate weapon and the second of two
|
||||
"objfree: deleting worn obj"
|
||||
strength cap for hero poly'd into an orc captain was 18/50 even though it is
|
||||
10/100 for Uruk-Hai and monster Uruk-Hai can grow into orc captains
|
||||
status_hilite rule for critical-hp takes precedence over up/down/changed HP
|
||||
|
||||
|
||||
Fixes to 3.7.0-x Platform and/or Interface Problems Exposed Via git Repository
|
||||
|
||||
38
src/botl.c
38
src/botl.c
@@ -1895,10 +1895,10 @@ fldname_to_bl_indx(const char *name)
|
||||
}
|
||||
|
||||
static boolean
|
||||
hilite_reset_needed(struct istat_s *bl_p,
|
||||
long augmented_time) /* no longer augmented; it once
|
||||
* encoded fractional amounts for
|
||||
* multiple moves within same turn */
|
||||
hilite_reset_needed(
|
||||
struct istat_s *bl_p,
|
||||
long augmented_time) /* no longer augmented; it once encoded fractional
|
||||
* amounts for multiple moves within same turn */
|
||||
{
|
||||
/*
|
||||
* This 'multi' handling may need some tuning...
|
||||
@@ -1923,13 +1923,13 @@ status_eval_next_unhilite(void)
|
||||
struct istat_s *curr;
|
||||
long next_unhilite, this_unhilite;
|
||||
|
||||
gb.bl_hilite_moves = gm.moves; /* simplified; at one point we used to try
|
||||
* to encode fractional amounts for multiple
|
||||
* moves within same turn */
|
||||
gb.bl_hilite_moves = gm.moves; /* simplified; at one point we used to
|
||||
* try to encode fractional amounts for
|
||||
* multiple moves within same turn */
|
||||
/* figure out whether an unhilight needs to be performed now */
|
||||
next_unhilite = 0L;
|
||||
for (i = 0; i < MAXBLSTATS; ++i) {
|
||||
curr = &gb.blstats[0][i]; /* blstats[0][*].time == blstats[1][*].time */
|
||||
curr = &gb.blstats[0][i]; /* blstats[0][*].time==blstats[1][*].time */
|
||||
|
||||
if (curr->chg) {
|
||||
struct istat_s *prev = &gb.blstats[1][i];
|
||||
@@ -2002,8 +2002,11 @@ noneoftheabove(const char *hl_text)
|
||||
* pointer to rule that applies; Null if no rule does.
|
||||
*/
|
||||
static struct hilite_s *
|
||||
get_hilite(int idx, int fldidx, genericptr_t vp, int chg, int pc,
|
||||
int *colorptr)
|
||||
get_hilite(
|
||||
int idx, int fldidx,
|
||||
genericptr_t vp,
|
||||
int chg, int pc,
|
||||
int *colorptr)
|
||||
{
|
||||
struct hilite_s *hl, *rule = 0;
|
||||
anything *value = (anything *) vp;
|
||||
@@ -2023,11 +2026,20 @@ get_hilite(int idx, int fldidx, genericptr_t vp, int chg, int pc,
|
||||
ancient configurations; we don't need LONG_MIN */
|
||||
long max_lval = -LONG_MAX, min_lval = LONG_MAX;
|
||||
boolean exactmatch = FALSE, updown = FALSE, changed = FALSE,
|
||||
perc_or_abs = FALSE;
|
||||
perc_or_abs = FALSE, crit_hp = FALSE;
|
||||
|
||||
/* min_/max_ are used to track best fit */
|
||||
for (hl = gb.blstats[0][fldidx].thresholds; hl; hl = hl->next) {
|
||||
dt = initblstats[fldidx].anytype; /* only needed for 'absolute' */
|
||||
/* for HP, if we already have a critical-hp rule then we ignore
|
||||
other HP rules unless we hit another critical-hp one (last
|
||||
one found wins); critical-hp takes precedence over temporary
|
||||
HP highlights, otherwise a hero with regeneration and an up
|
||||
or changed rule for HP would always show that up or changed
|
||||
highlight even when within the critical-hp threshold because
|
||||
the value will go up by at least one on every move */
|
||||
if (crit_hp && hl->behavior != BL_TH_CRITICALHP)
|
||||
continue;
|
||||
/* if we've already matched a temporary highlight, it takes
|
||||
precedence over all persistent ones; we still process
|
||||
updown rules to get the last one which qualifies */
|
||||
@@ -2181,8 +2193,10 @@ get_hilite(int idx, int fldidx, genericptr_t vp, int chg, int pc,
|
||||
rule = hl;
|
||||
break;
|
||||
case BL_TH_CRITICALHP:
|
||||
if (critically_low_hp(FALSE)) {
|
||||
if (fldidx == BL_HP && critically_low_hp(FALSE)) {
|
||||
rule = hl;
|
||||
crit_hp = TRUE;
|
||||
updown = changed = perc_or_abs = FALSE;
|
||||
}
|
||||
break;
|
||||
case BL_TH_NONE:
|
||||
|
||||
@@ -103,11 +103,12 @@ static const char *const godvoices[] = {
|
||||
|
||||
/* critically low hit points if hp <= 5 or hp <= maxhp/N for some N */
|
||||
boolean
|
||||
critically_low_hp(boolean only_if_injured) /* determines whether maxhp <= 5
|
||||
matters */
|
||||
critically_low_hp(
|
||||
boolean only_if_injured) /* determines whether maxhp <= 5 matters */
|
||||
{
|
||||
int divisor, hplim, curhp = Upolyd ? u.mh : u.uhp,
|
||||
maxhp = Upolyd ? u.mhmax : u.uhpmax;
|
||||
int divisor, hplim,
|
||||
curhp = Upolyd ? u.mh : u.uhp,
|
||||
maxhp = Upolyd ? u.mhmax : u.uhpmax;
|
||||
|
||||
if (only_if_injured && !(curhp < maxhp))
|
||||
return FALSE;
|
||||
|
||||
Reference in New Issue
Block a user