mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-25 13:55:36 -04:00
Smooth Health/Armor Count (#959)
* Smooth Health/Armor Count * Move smooth counts menu item
This commit is contained in:
parent
6323e85a84
commit
1a2de565fc
@ -777,6 +777,9 @@ static void G_DoLoadLevel(void)
|
||||
|
||||
P_SetupLevel (gameepisode, gamemap, 0, gameskill);
|
||||
displayplayer = consoleplayer; // view the guy you are playing
|
||||
// [Alaux] Update smooth count values
|
||||
st_health = players[displayplayer].health;
|
||||
st_armor = players[displayplayer].armorpoints;
|
||||
gameaction = ga_nothing;
|
||||
|
||||
// clear cmd building stuff
|
||||
@ -2189,6 +2192,11 @@ static void G_DoLoadGame(void)
|
||||
// done
|
||||
Z_Free(savebuffer);
|
||||
|
||||
// [Alaux] Update smooth count values;
|
||||
// the same procedure is done in G_LoadLevel, but we have to repeat it here
|
||||
st_health = players[displayplayer].health;
|
||||
st_armor = players[displayplayer].armorpoints;
|
||||
|
||||
if (setsizeneeded)
|
||||
R_ExecuteSetViewSize();
|
||||
|
||||
|
@ -801,8 +801,7 @@ static void HU_widget_build_ammo (void)
|
||||
static void HU_widget_build_health (void)
|
||||
{
|
||||
int i;
|
||||
int health = plr->health;
|
||||
int healthbars = (health > 100) ? 25 : (health / 4);
|
||||
int healthbars = (st_health > 100) ? 25 : (st_health / 4);
|
||||
|
||||
// clear the widgets internal line
|
||||
HUlib_clearTextLine(&w_health);
|
||||
@ -834,10 +833,10 @@ static void HU_widget_build_health (void)
|
||||
hud_healthstr[i] = '\0';
|
||||
|
||||
// build the numeric amount init string
|
||||
sprintf(hud_healthstr + i, "%3d", health);
|
||||
sprintf(hud_healthstr + i, "%3d", st_health);
|
||||
|
||||
// set the display color from the amount of health posessed
|
||||
w_health.cr = ColorByHealth(health, 100, hu_invul);
|
||||
w_health.cr = ColorByHealth(plr->health, 100, hu_invul);
|
||||
|
||||
// transfer the init string to the widget
|
||||
HUlib_addStringToTextLine(&w_health, hud_healthstr);
|
||||
@ -847,8 +846,7 @@ static void HU_widget_build_health (void)
|
||||
static void HU_widget_build_armor (void)
|
||||
{
|
||||
int i;
|
||||
int armor = plr->armorpoints;
|
||||
int armorbars = (armor > 100) ? 25 : (armor / 4);
|
||||
int armorbars = (st_armor > 100) ? 25 : (st_armor / 4);
|
||||
|
||||
// clear the widgets internal line
|
||||
HUlib_clearTextLine(&w_armor);
|
||||
@ -880,7 +878,7 @@ static void HU_widget_build_armor (void)
|
||||
hud_armorstr[i] = '\0';
|
||||
|
||||
// build the numeric amount init string
|
||||
sprintf(hud_armorstr + i, "%3d", armor);
|
||||
sprintf(hud_armorstr + i, "%3d", st_armor);
|
||||
|
||||
// color of armor depends on type
|
||||
if (hud_armor_type)
|
||||
@ -893,6 +891,8 @@ static void HU_widget_build_armor (void)
|
||||
}
|
||||
else
|
||||
{
|
||||
int armor = plr->armorpoints;
|
||||
|
||||
// set the display color from the amount of armor posessed
|
||||
w_armor.cr =
|
||||
hu_invul ? colrngs[CR_GRAY] :
|
||||
|
@ -3335,6 +3335,7 @@ enum {
|
||||
stat2_title1,
|
||||
stat2_backpack,
|
||||
stat2_armortype,
|
||||
stat2_smooth,
|
||||
stat2_stub1,
|
||||
stat2_title2,
|
||||
stat2_crispyhud,
|
||||
@ -3374,10 +3375,11 @@ static const char *hudcolor_str[] = {
|
||||
|
||||
setup_menu_t stat_settings2[] =
|
||||
{
|
||||
{"WIDGET COLORS",S_SKIP|S_TITLE,m_null,M_X,M_Y},
|
||||
{"WIDGET APPEARANCE",S_SKIP|S_TITLE,m_null,M_X,M_Y},
|
||||
|
||||
{"BACKPACK CHANGES THRESHOLDS" ,S_YESNO,m_null,M_X,M_Y+stat2_backpack*M_SPC, {"hud_backpack_thresholds"}},
|
||||
{"COLOR OF ARMOR DEPENDS ON TYPE" ,S_YESNO,m_null,M_X,M_Y+stat2_armortype*M_SPC, {"hud_armor_type"}},
|
||||
{"SMOOTH HEALTH/ARMOR COUNT" ,S_YESNO,m_null,M_X,M_Y+stat2_smooth*M_SPC, {"smooth_counts"}},
|
||||
|
||||
{"",S_SKIP,m_null,M_X,M_Y+stat2_stub1*M_SPC},
|
||||
|
||||
|
@ -2397,6 +2397,13 @@ default_t defaults[] = {
|
||||
"1 to disable doubled card and skull key display on status bar"
|
||||
},
|
||||
|
||||
{ // [Alaux]
|
||||
"smooth_counts",
|
||||
(config_t *) &smooth_counts, NULL,
|
||||
{0}, {0,1}, number, ss_stat, wad_yes,
|
||||
"1 to enable smooth health/armor counts"
|
||||
},
|
||||
|
||||
{ // below is red
|
||||
"health_red",
|
||||
(config_t *) &health_red, NULL,
|
||||
|
@ -273,6 +273,11 @@ static patch_t *arms[6][2];
|
||||
// ready-weapon widget
|
||||
static st_number_t w_ready;
|
||||
|
||||
// [Alaux]
|
||||
int smooth_counts;
|
||||
int st_health = 100;
|
||||
int st_armor = 0;
|
||||
|
||||
//jff 2/16/98 status color change levels
|
||||
int ammo_red; // ammo percent less than which status is red
|
||||
int ammo_yellow; // ammo percent less is yellow more green
|
||||
@ -786,8 +791,36 @@ void ST_updateWidgets(void)
|
||||
|
||||
}
|
||||
|
||||
// [Alaux]
|
||||
static int SmoothCount(int shownval, int realval)
|
||||
{
|
||||
int step = realval - shownval;
|
||||
|
||||
if (!smooth_counts || !step)
|
||||
{
|
||||
return realval;
|
||||
}
|
||||
else
|
||||
{
|
||||
int sign = step / abs(step);
|
||||
step = BETWEEN(1, 7, abs(step) / 20);
|
||||
shownval += (step+1)*sign;
|
||||
|
||||
if ( (sign > 0 && shownval > realval)
|
||||
||(sign < 0 && shownval < realval))
|
||||
{
|
||||
shownval = realval;
|
||||
}
|
||||
|
||||
return shownval;
|
||||
}
|
||||
}
|
||||
|
||||
void ST_Ticker(void)
|
||||
{
|
||||
st_health = SmoothCount(st_health, plyr->health);
|
||||
st_armor = SmoothCount(st_armor, plyr->armorpoints);
|
||||
|
||||
st_clock++;
|
||||
st_randomnumber = M_Random();
|
||||
ST_updateWidgets();
|
||||
@ -872,6 +905,10 @@ void ST_drawWidgets(void)
|
||||
int i;
|
||||
int maxammo = plyr->maxammo[weaponinfo[w_ready.data].ammo];
|
||||
|
||||
// [Alaux] Used to color health and armor counts based on
|
||||
// the real values, only ever relevant when using smooth counts
|
||||
const int health = plyr->health, armor = plyr->armorpoints;
|
||||
|
||||
boolean st_invul = (plyr->powers[pw_invulnerability] > 4*32 ||
|
||||
plyr->powers[pw_invulnerability] & 8) ||
|
||||
plyr->cheats & CF_GODMODE;
|
||||
@ -915,11 +952,11 @@ void ST_drawWidgets(void)
|
||||
STlib_updatePercent(&w_health, cr_gray);
|
||||
else
|
||||
//jff 2/16/98 make color of health depend on amount
|
||||
if (*w_health.n.num<health_red)
|
||||
if (health<health_red)
|
||||
STlib_updatePercent(&w_health, cr_red);
|
||||
else if (*w_health.n.num<health_yellow)
|
||||
else if (health<health_yellow)
|
||||
STlib_updatePercent(&w_health, cr_gold);
|
||||
else if (*w_health.n.num<=health_green)
|
||||
else if (health<=health_green)
|
||||
STlib_updatePercent(&w_health, cr_green);
|
||||
else
|
||||
STlib_updatePercent(&w_health, cr_blue2); //killough 2/28/98
|
||||
@ -942,11 +979,11 @@ void ST_drawWidgets(void)
|
||||
STlib_updatePercent(&w_armor, cr_gray);
|
||||
else
|
||||
//jff 2/16/98 make color of armor depend on amount
|
||||
if (*w_armor.n.num<armor_red)
|
||||
if (armor<armor_red)
|
||||
STlib_updatePercent(&w_armor, cr_red);
|
||||
else if (*w_armor.n.num<armor_yellow)
|
||||
else if (armor<armor_yellow)
|
||||
STlib_updatePercent(&w_armor, cr_gold);
|
||||
else if (*w_armor.n.num<=armor_green)
|
||||
else if (armor<=armor_green)
|
||||
STlib_updatePercent(&w_armor, cr_green);
|
||||
else
|
||||
STlib_updatePercent(&w_armor, cr_blue2); //killough 2/28/98
|
||||
@ -1206,7 +1243,7 @@ void ST_createWidgets(void)
|
||||
ST_HEALTHX - distributed_delta,
|
||||
ST_HEALTHY,
|
||||
tallnum,
|
||||
&plyr->health,
|
||||
&st_health,
|
||||
&st_statusbaron,
|
||||
tallpercent);
|
||||
|
||||
@ -1242,7 +1279,7 @@ void ST_createWidgets(void)
|
||||
ST_ARMORX + distributed_delta,
|
||||
ST_ARMORY,
|
||||
tallnum,
|
||||
&plyr->armorpoints,
|
||||
&st_armor,
|
||||
&st_statusbaron, tallpercent);
|
||||
|
||||
// keyboxes 0-2
|
||||
|
@ -80,6 +80,11 @@ typedef enum
|
||||
|
||||
// killough 5/2/98: moved from m_misc.c:
|
||||
|
||||
// [Alaux]
|
||||
extern int smooth_counts;
|
||||
extern int st_health;
|
||||
extern int st_armor;
|
||||
|
||||
extern int health_red; // health amount less than which status is red
|
||||
extern int health_yellow; // health amount less than which status is yellow
|
||||
extern int health_green; // health amount above is blue, below is green
|
||||
|
Loading…
x
Reference in New Issue
Block a user