* Auto-track current target monster when bored. Note that the
* health-bar stops tracking any monster that "disappears".
*/
-static void health_redraw(void)
+static void health_redraw(bool riding)
{
#ifdef DRS_SHOW_HEALTH_BAR
- /* Not tracking */
- if (!p_ptr->health_who)
- {
- /* Erase the health bar */
- Term_erase(COL_INFO, ROW_INFO, 12);
- }
-
- /* Tracking an unseen monster */
- else if (!m_list[p_ptr->health_who].ml)
- {
- /* Indicate that the monster health is "unknown" */
- Term_putstr(COL_INFO, ROW_INFO, 12, TERM_WHITE, "[----------]");
- }
-
- /* Tracking a hallucinatory monster */
- else if (p_ptr->image)
- {
- /* Indicate that the monster health is "unknown" */
- Term_putstr(COL_INFO, ROW_INFO, 12, TERM_WHITE, "[----------]");
- }
+ s16b health_who;
+ int row, col;
+ monster_type *m_ptr;
- /* Tracking a dead monster (???) */
- else if (!m_list[p_ptr->health_who].hp < 0)
+ if (riding)
{
- /* Indicate that the monster health is "unknown" */
- Term_putstr(COL_INFO, ROW_INFO, 12, TERM_WHITE, "[----------]");
+ health_who = p_ptr->riding;
+ row = ROW_RIDING_INFO;
+ col = COL_RIDING_INFO;
}
-
- /* Tracking a visible monster */
else
{
- int pct, pct2, len;
-
- monster_type *m_ptr = &m_list[p_ptr->health_who];
-
- /* Default to almost dead */
- byte attr = TERM_RED;
-
- /* Extract the "percent" of health */
- pct = 100L * m_ptr->hp / m_ptr->maxhp;
- pct2 = 100L * m_ptr->hp / m_ptr->max_maxhp;
-
- /* Badly wounded */
- if (pct >= 10) attr = TERM_L_RED;
-
- /* Wounded */
- if (pct >= 25) attr = TERM_ORANGE;
-
- /* Somewhat Wounded */
- if (pct >= 60) attr = TERM_YELLOW;
-
- /* Healthy */
- if (pct >= 100) attr = TERM_L_GREEN;
-
- /* Afraid */
- if (m_ptr->monfear) attr = TERM_VIOLET;
-
- /* Asleep */
- if (m_ptr->csleep) attr = TERM_BLUE;
-
- /* Invulnerable */
- if (m_ptr->invulner) attr = TERM_WHITE;
-
- /* Convert percent into "health" */
- len = (pct2 < 10) ? 1 : (pct2 < 90) ? (pct2 / 10 + 1) : 10;
-
- /* Default to "unknown" */
- Term_putstr(COL_INFO, ROW_INFO, 12, TERM_WHITE, "[----------]");
-
- /* Dump the current "health" (use '*' symbols) */
- Term_putstr(COL_INFO + 1, ROW_INFO, len, attr, "**********");
+ health_who = p_ptr->health_who;
+ row = ROW_INFO;
+ col = COL_INFO;
}
-#endif
-
-}
-
-
-
-static void riding_health_redraw(void)
-{
-
-#ifdef DRS_SHOW_HEALTH_BAR
+ m_ptr = &m_list[health_who];
/* Not tracking */
- if (!p_ptr->riding)
+ if (!health_who)
{
/* Erase the health bar */
- Term_erase(COL_RIDING_INFO, ROW_RIDING_INFO, 12);
+ Term_erase(col, row, 12);
+ }
+
+ /* Tracking an unseen monster */
+ else if (!m_ptr->ml)
+ {
+ /* Indicate that the monster health is "unknown" */
+ Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
}
/* Tracking a hallucinatory monster */
else if (p_ptr->image)
{
/* Indicate that the monster health is "unknown" */
- Term_putstr(COL_RIDING_INFO, ROW_RIDING_INFO, 12, TERM_WHITE, "[----------]");
+ Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
}
/* Tracking a dead monster (???) */
- else if (!m_list[p_ptr->health_who].hp < 0)
+ else if (m_ptr->hp < 0)
{
/* Indicate that the monster health is "unknown" */
- Term_putstr(COL_RIDING_INFO, ROW_RIDING_INFO, 12, TERM_WHITE, "[----------]");
+ Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
}
/* Tracking a visible monster */
else
{
- int pct, pct2, len;
+ /* Extract the "percent" of health */
+ int pct = 100L * m_ptr->hp / m_ptr->maxhp;
+ int pct2 = 100L * m_ptr->hp / m_ptr->max_maxhp;
- monster_type *m_ptr = &m_list[p_ptr->riding];
+ /* Convert percent into "health" */
+ int len = (pct2 < 10) ? 1 : (pct2 < 90) ? (pct2 / 10 + 1) : 10;
/* Default to almost dead */
byte attr = TERM_RED;
- /* Extract the "percent" of health */
- pct = 100L * m_ptr->hp / m_ptr->maxhp;
- pct2 = 100L * m_ptr->hp / m_ptr->max_maxhp;
-
- /* Badly wounded */
- if (pct >= 10) attr = TERM_L_RED;
+ /* Invulnerable */
+ if (m_ptr->invulner) attr = TERM_WHITE;
- /* Wounded */
- if (pct >= 25) attr = TERM_ORANGE;
+ /* Asleep */
+ else if (m_ptr->csleep) attr = TERM_BLUE;
- /* Somewhat Wounded */
- if (pct >= 60) attr = TERM_YELLOW;
+ /* Afraid */
+ else if (m_ptr->monfear) attr = TERM_VIOLET;
/* Healthy */
- if (pct >= 100) attr = TERM_L_GREEN;
-
- /* Afraid */
- if (m_ptr->monfear) attr = TERM_VIOLET;
+ else if (pct >= 100) attr = TERM_L_GREEN;
- /* Asleep */
- if (m_ptr->csleep) attr = TERM_BLUE;
+ /* Somewhat Wounded */
+ else if (pct >= 60) attr = TERM_YELLOW;
- /* Invulnerable */
- if (m_ptr->invulner) attr = TERM_WHITE;
+ /* Wounded */
+ else if (pct >= 25) attr = TERM_ORANGE;
- /* Convert percent into "health" */
- len = (pct2 < 10) ? 1 : (pct2 < 90) ? (pct2 / 10 + 1) : 10;
+ /* Badly wounded */
+ else if (pct >= 10) attr = TERM_L_RED;
/* Default to "unknown" */
- Term_putstr(COL_RIDING_INFO, ROW_RIDING_INFO, 12, TERM_WHITE, "[----------]");
+ Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
/* Dump the current "health" (use '*' symbols) */
- Term_putstr(COL_RIDING_INFO + 1, ROW_RIDING_INFO, len, attr, "**********");
+ Term_putstr(col + 1, row, len, attr, "**********");
}
#endif
prt_depth();
/* Special */
- health_redraw();
- riding_health_redraw();
+ health_redraw(FALSE);
+ health_redraw(TRUE);
}
if (p_ptr->redraw & (PR_HEALTH))
{
p_ptr->redraw &= ~(PR_HEALTH);
- health_redraw();
+ health_redraw(FALSE);
}
if (p_ptr->redraw & (PR_UHEALTH))
{
p_ptr->redraw &= ~(PR_UHEALTH);
- riding_health_redraw();
+ health_redraw(TRUE);
}