status_hilite for Xp and Exp by percent rules

Extend support for highlight rules that specify percentages from HP
and spell power to experience level and experience points.  For both
of those, the percentage is based on progress from the start of the
current Xp level to the start of the next Xp level.  100% isn't
possible so is used to enable highlighting a special case:  1 point
shy of next level, most likely to occur after losing a level.

This is something I had in mind a long time ago and then forgot all
about until fiddling with the final disclosure of experience points
recently.  It turned out to be trickier than expected because it needs
to check whether Xp should have a status update when it hasn't changed
but Exp has gone up.  The latter might hit a percentage threshold that
switches to another highlight rule.  Fortunately changes to Exp, at
least that aren't part of level gain or loss (which always trigger
status updating), are all funnelled through a single place (I hope).
This commit is contained in:
PatR
2019-07-02 17:39:23 -07:00
parent ad88205229
commit 1e7fb839a3
6 changed files with 165 additions and 29 deletions

View File

@@ -1,4 +1,4 @@
.\" $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.305 $ $NHDT-Date: 1557251604 2019/05/07 17:53:24 $
.\" $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.310 $ $NHDT-Date: 1562114349 2019/07/03 00:39:09 $
.\"
.\" This is an excerpt from the 'roff' man page from the 'groff' package.
.\" NetHack's Guidebook.mn currently does *not* adhere to these guidelines.
@@ -4284,7 +4284,24 @@ it also matches when value is below or above the percentage.
Use prefix \(oq<\(cq or \(oq>\(cq to match when strictly below or above.
(The numeric limit is relaxed slightly for those: \f(CR>-1%\fP
and \f(CR<101%\fP are allowed.)
Only valid for \(lqhitpoints\(rq and \(lqpower\(rq fields.
Only four fields support percentage rules.
Percentages for \(lqhitpoints\(rq and \(lqpower\(rq are
straightforward; they're based on the corresponding maximum field.
Percentage highlight rules are also allowed for \(lqexperience level\(rq
and \(lqexperience points\(rq (valid when the
.op showexp
option is enabled).
For those, the percentage is based on the progress from the start of
the current experience level to the start of the next level.
So if level 2 starts at 20 points and level 3 starts at 40 points,
having 30 points is 50% and 35 points is 75%.
100% is unattainable for experience because you'll gain a level and
the calculations will be reset for that new level, but a rule for
\f(CR=100%\fP is allowed and matches the special case of being
exactly 1 experience point short of the next level.
.\" (If you manage to reach level 30, there is no next level and the
.\" percentage will remain at 0% no matter have many additional experience
.\" points you earn.)
.lp "*"
absolute value sets the attribute when the field value matches
that number.

View File

@@ -4773,7 +4773,24 @@ it also matches when value is below or above the percentage.
Use prefix `{\tt <}' or `{\tt >}' to match when strictly below or above.
(The numeric limit is relaxed slightly for those: {\tt >-1\%}
and {\tt <101\%} are allowed.)
Only valid for ``{\it hitpoints\/}'' and ``{\it power\/}'' fields.
Only four fields support percentage rules.
Percentages for ``{\it hitpoints\/}'' and ``{\it power\/}'' are
straightforward; they're based on the corresponding maximum field.
Percentage highlight rules are also allowed for ``{\it experience level\/}''
and ``{\it experience points\/}'' (valid when the
(\it showexp\/}
option is enabled).
For those, the percentage is based on the progress from the start of
the current experience level to the start of the next level.
So if level 2 starts at 20 points and level 3 starts at 40 points,
having 30 points is 50\% and 35 points is 75\%.
100\% is unattainable for experience because you'll gain a level and
the calculations will be reset for that new level, but a rule for
{\tt =100\%} is allowed and matches the special case of being
exactly 1 experience point short of the next level.
% (If you manage to reach level 30, there is no next level and the
% percentage will remain at 0\% no matter have many additional experience
% points you earn.)
%.lp "*"
\item{\bb{}}
absolute value sets the attribute when the field value

View File

@@ -1,4 +1,4 @@
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.81 $ $NHDT-Date: 1562056615 2019/07/02 08:36:55 $
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.83 $ $NHDT-Date: 1562114348 2019/07/03 00:39:08 $
This fixes36.3 file is here to capture information about updates in the 3.6.x
lineage following the release of 3.6.2 in May 2019. Please note, however,
@@ -206,6 +206,10 @@ if you reach the edge of a level (relatively uncommon) and try to move off,
'attributes' disclosure at end of game includes number of experience points
that were needed to reach the next experience level (new for normal
play and explore mode; previously only shown for wizard mode)
status highlighting using percentage rules now supported for experience level
and experience points; for both, percent is based on Exp progress from
the start of the current Xp level to the start of the next Xp level;
100% isn't possible so used as special case for next_Xp_lvl - 1 Exp_pt
wizard-mode: display effect to show where an unseen wished-for monster landed
curses: enable latent mouse support
curses: give menus and text windows a minimum size of 5x25 since tiny ones can