diff --git a/CHANGELOG.md b/CHANGELOG.md index 0434d1984..13b432380 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ - **Merged changes from [Woof! 15.0.0](https://github.com/fabiangreffrath/woof/releases/tag/woof_15.0.0)**, note: - NUGHUD now partially uses SBARDEF as its backend, which may cause some rendering differences - Integrated periodic auto saves into the save/load menus - - Maintained message list, message duration, and chat-message duration settings [1] + - Maintained key blink, message list, message duration, and chat-message duration settings [1] - Removed `show_ssg` (now default behavior), `alt_arms` and `hud_highlight_weapon` settings - Renamed `#_bobbing_percentage` to `#_bobbing_pct` [2] - Renamed `show_berserk` to `sts_show_berserk` [2] @@ -32,6 +32,6 @@ - **Crash when loading WADs with empty lumps between `C_#` markers** (fixes `nt_rc1.wad`) - **Shadows not being drawn for HUD icons when using Boom font** -**[1].** Not necessarily with the same CVARs; existing config files will be affected. +**[1].** Not necessarily with the same CVARs; existing config files may be affected. **[2].** This will affect existing config files. diff --git a/README.md b/README.md index 58dffbe63..0c6cdcdde 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,8 @@ For these settings, their CVAR names are provided alongside the _CFG-only_ label - **_Message Lines_** setting (scrolling direction determined by the CFG-only `hud_msg_scrollup` CVAR) - **_(Chat) Message Duration_** settings - **_Show Powerup Timers_** setting -- **_Berserk display when using Fist** setting [partially p.f. Crispy Doom] +- **_Blink Missing Keys_** setting [partially p.f. Crispy Doom] +- **_Berserk display when using Fist_** setting [partially p.f. Crispy Doom] - **_Automap Level Stats Format_** setting - **Level-Stats Selection** settings (CFG-only: `hud_stats_#[_map]`) - **Event Timers:** diff --git a/src/mn_setup.c b/src/mn_setup.c index ec9c4d0cb..835a074a1 100644 --- a/src/mn_setup.c +++ b/src/mn_setup.c @@ -2252,6 +2252,7 @@ static setup_menu_t stat_settings5[] = {"Nugget - HUD", S_SKIP|S_TITLE, M_X, M_SPC}, {"Show Powerup Timers", S_CHOICE|S_COSMETIC, M_X, M_SPC, {"hud_power_timers"}, .strings_id = str_show_widgets}, + {"Blink Missing Keys", S_ONOFF, M_X, M_SPC, {"hud_blink_keys"}}, {"Berserk display when using Fist", S_ONOFF, M_X, M_SPC, {"sts_show_berserk"}}, {"Allow HUD Icons", S_ONOFF, M_X, M_SPC, {"hud_allow_icons"}}, diff --git a/src/p_doors.c b/src/p_doors.c index 958801038..4d055110b 100644 --- a/src/p_doors.c +++ b/src/p_doors.c @@ -272,7 +272,7 @@ int EV_DoLockedDoor(line_t *line, vldoor_e type, mobj_t *thing) doomprintf(p, MESSAGES_NONE, "%s", s_PD_BLUEO); // Ty 03/27/98 - externalized S_StartSoundOptional(p->mo, sfx_locked, // [Nugget]: [NS] Locked door sound. STRICTMODE(comp_keynoway) ? sfx_noway : sfx_oof); // [Nugget] - // ST_SetKeyBlink(p, KEYBLINK_EITHER, KEYBLINK_NONE, KEYBLINK_NONE); + ST_SetKeyBlink(p, KEYBLINK_EITHER, KEYBLINK_NONE, KEYBLINK_NONE); // [Nugget] Key blinking return 0; } break; @@ -284,7 +284,7 @@ int EV_DoLockedDoor(line_t *line, vldoor_e type, mobj_t *thing) doomprintf(p, MESSAGES_NONE, "%s", s_PD_REDO); // Ty 03/27/98 - externalized S_StartSoundOptional(p->mo, sfx_locked, // [Nugget]: [NS] Locked door sound. STRICTMODE(comp_keynoway) ? sfx_noway : sfx_oof); // [Nugget] - // ST_SetKeyBlink(p, KEYBLINK_NONE, KEYBLINK_NONE, KEYBLINK_EITHER); + ST_SetKeyBlink(p, KEYBLINK_NONE, KEYBLINK_NONE, KEYBLINK_EITHER); // [Nugget] Key blinking return 0; } break; @@ -296,7 +296,7 @@ int EV_DoLockedDoor(line_t *line, vldoor_e type, mobj_t *thing) doomprintf(p, MESSAGES_NONE, "%s", s_PD_YELLOWO); // Ty 03/27/98 - externalized S_StartSoundOptional(p->mo, sfx_locked, // [Nugget]: [NS] Locked door sound. STRICTMODE(comp_keynoway) ? sfx_noway : sfx_oof); // [Nugget] - // ST_SetKeyBlink(p, KEYBLINK_NONE, KEYBLINK_EITHER, KEYBLINK_NONE); + ST_SetKeyBlink(p, KEYBLINK_NONE, KEYBLINK_EITHER, KEYBLINK_NONE); // [Nugget] Key blinking return 0; } break; @@ -427,7 +427,7 @@ int EV_VerticalDoor(line_t *line, mobj_t *thing) doomprintf(player, MESSAGES_NONE, "%s", s_PD_BLUEK); // Ty 03/27/98 - externalized S_StartSoundOptional(player->mo, sfx_locked, // [Nugget]: [NS] Locked door sound. STRICTMODE(comp_keynoway) ? sfx_noway : sfx_oof); // [Nugget] - // ST_SetKeyBlink(player, KEYBLINK_EITHER, KEYBLINK_NONE, KEYBLINK_NONE); + ST_SetKeyBlink(player, KEYBLINK_EITHER, KEYBLINK_NONE, KEYBLINK_NONE); // [Nugget] Key blinking return 0; } break; @@ -441,7 +441,7 @@ int EV_VerticalDoor(line_t *line, mobj_t *thing) doomprintf(player, MESSAGES_NONE, "%s", s_PD_YELLOWK); // Ty 03/27/98 - externalized S_StartSoundOptional(player->mo, sfx_locked, // [Nugget]: [NS] Locked door sound. STRICTMODE(comp_keynoway) ? sfx_noway : sfx_oof); // [Nugget] - // ST_SetKeyBlink(player, KEYBLINK_NONE, KEYBLINK_EITHER, KEYBLINK_NONE); + ST_SetKeyBlink(player, KEYBLINK_NONE, KEYBLINK_EITHER, KEYBLINK_NONE); // [Nugget] Key blinking return 0; } break; @@ -455,7 +455,7 @@ int EV_VerticalDoor(line_t *line, mobj_t *thing) doomprintf(player, MESSAGES_NONE, "%s", s_PD_REDK); // Ty 03/27/98 - externalized S_StartSoundOptional(player->mo, sfx_locked, // [Nugget]: [NS] Locked door sound. STRICTMODE(comp_keynoway) ? sfx_noway : sfx_oof); // [Nugget] - // ST_SetKeyBlink(player, KEYBLINK_NONE, KEYBLINK_NONE, KEYBLINK_EITHER); + ST_SetKeyBlink(player, KEYBLINK_NONE, KEYBLINK_NONE, KEYBLINK_EITHER); // [Nugget] Key blinking return 0; } break; diff --git a/src/p_mobj.c b/src/p_mobj.c index 6197adad2..d74311cfc 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1547,6 +1547,19 @@ void P_SpawnMapThing (mapthing_t* mthing) { mobj->health = 1000 + musid; } + + // [Nugget] Key blinking: + // [crispy] blinking key or skull in the status bar + switch (mobj->sprite) + { + case SPR_BKEY: st_keyorskull[it_bluecard] |= KEYBLINK_CARD; break; + case SPR_BSKU: st_keyorskull[it_bluecard] |= KEYBLINK_SKULL; break; + case SPR_RKEY: st_keyorskull[it_redcard] |= KEYBLINK_CARD; break; + case SPR_RSKU: st_keyorskull[it_redcard] |= KEYBLINK_SKULL; break; + case SPR_YKEY: st_keyorskull[it_yellowcard] |= KEYBLINK_CARD; break; + case SPR_YSKU: st_keyorskull[it_yellowcard] |= KEYBLINK_SKULL; break; + default: break; + } } // diff --git a/src/p_setup.c b/src/p_setup.c index c6d0152ad..23c1870b9 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -56,6 +56,7 @@ // [Nugget] #include "m_array.h" +#include "st_stuff.h" // // MAP related Lookup tables. @@ -1726,6 +1727,10 @@ void P_SetupLevel(int episode, int map, int playermask, skill_t skill) // [crispy] fix long wall wobble P_SegLengths(false); + // [Nugget] Key blinking: + // [crispy] blinking key or skull in the status bar + memset(st_keyorskull, 0, sizeof(st_keyorskull)); + // Note: you don't need to clear player queue slots -- // a much simpler fix is in g_game.c -- killough 10/98 diff --git a/src/p_spec.c b/src/p_spec.c index c2038ddad..4e1e35a10 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -825,7 +825,7 @@ boolean P_CanUnlockGenDoor(line_t *line, player_t *player) doomprintf(player, MESSAGES_NONE, "%s", s_PD_ANY); // Ty 03/27/98 - externalized S_StartSoundOptional(player->mo, sfx_locked, // [Nugget] Locked door sound STRICTMODE(comp_keynoway) ? sfx_noway : sfx_oof); // [Nugget] - // ST_SetKeyBlink(player, KEYBLINK_EITHER, KEYBLINK_EITHER, KEYBLINK_EITHER); + ST_SetKeyBlink(player, KEYBLINK_EITHER, KEYBLINK_EITHER, KEYBLINK_EITHER); // [Nugget] Key blinking return false; } break; @@ -836,7 +836,7 @@ boolean P_CanUnlockGenDoor(line_t *line, player_t *player) doomprintf(player, MESSAGES_NONE, "%s", skulliscard? s_PD_REDK : s_PD_REDC); // Ty 03/27/98 - externalized S_StartSoundOptional(player->mo, sfx_locked, // [Nugget] Locked door sound STRICTMODE(comp_keynoway) ? sfx_noway : sfx_oof); // [Nugget] - // ST_SetKeyBlink(player, KEYBLINK_NONE, KEYBLINK_NONE, skulliscard ? KEYBLINK_EITHER : KEYBLINK_CARD); + ST_SetKeyBlink(player, KEYBLINK_NONE, KEYBLINK_NONE, skulliscard ? KEYBLINK_EITHER : KEYBLINK_CARD); // [Nugget] Key blinking return false; } break; @@ -847,7 +847,7 @@ boolean P_CanUnlockGenDoor(line_t *line, player_t *player) doomprintf(player, MESSAGES_NONE, "%s", skulliscard? s_PD_BLUEK : s_PD_BLUEC); // Ty 03/27/98 - externalized S_StartSoundOptional(player->mo, sfx_locked, // [Nugget] Locked door sound STRICTMODE(comp_keynoway) ? sfx_noway : sfx_oof); // [Nugget] - // ST_SetKeyBlink(player, skulliscard ? KEYBLINK_EITHER : KEYBLINK_CARD, KEYBLINK_NONE, KEYBLINK_NONE); + ST_SetKeyBlink(player, skulliscard ? KEYBLINK_EITHER : KEYBLINK_CARD, KEYBLINK_NONE, KEYBLINK_NONE); // [Nugget] Key blinking return false; } break; @@ -858,7 +858,7 @@ boolean P_CanUnlockGenDoor(line_t *line, player_t *player) doomprintf(player, MESSAGES_NONE, "%s", skulliscard? s_PD_YELLOWK : s_PD_YELLOWC); // Ty 03/27/98 - externalized S_StartSoundOptional(player->mo, sfx_locked, // [Nugget] Locked door sound STRICTMODE(comp_keynoway) ? sfx_noway : sfx_oof); // [Nugget] - // ST_SetKeyBlink(player, KEYBLINK_NONE, skulliscard ? KEYBLINK_EITHER : KEYBLINK_CARD, KEYBLINK_NONE); + ST_SetKeyBlink(player, KEYBLINK_NONE, skulliscard ? KEYBLINK_EITHER : KEYBLINK_CARD, KEYBLINK_NONE); // [Nugget] Key blinking return false; } break; @@ -869,7 +869,7 @@ boolean P_CanUnlockGenDoor(line_t *line, player_t *player) doomprintf(player, MESSAGES_NONE, "%s", skulliscard? s_PD_REDK : s_PD_REDS); // Ty 03/27/98 - externalized S_StartSoundOptional(player->mo, sfx_locked, // [Nugget] Locked door sound STRICTMODE(comp_keynoway) ? sfx_noway : sfx_oof); // [Nugget] - // ST_SetKeyBlink(player, KEYBLINK_NONE, KEYBLINK_NONE, skulliscard ? KEYBLINK_EITHER : KEYBLINK_SKULL); + ST_SetKeyBlink(player, KEYBLINK_NONE, KEYBLINK_NONE, skulliscard ? KEYBLINK_EITHER : KEYBLINK_SKULL); // [Nugget] Key blinking return false; } break; @@ -880,7 +880,7 @@ boolean P_CanUnlockGenDoor(line_t *line, player_t *player) doomprintf(player, MESSAGES_NONE, "%s", skulliscard? s_PD_BLUEK : s_PD_BLUES); // Ty 03/27/98 - externalized S_StartSoundOptional(player->mo, sfx_locked, // [Nugget] Locked door sound STRICTMODE(comp_keynoway) ? sfx_noway : sfx_oof); // [Nugget] - // ST_SetKeyBlink(player, skulliscard ? KEYBLINK_EITHER : KEYBLINK_SKULL, KEYBLINK_NONE, KEYBLINK_NONE); + ST_SetKeyBlink(player, skulliscard ? KEYBLINK_EITHER : KEYBLINK_SKULL, KEYBLINK_NONE, KEYBLINK_NONE); // [Nugget] Key blinking return false; } break; @@ -891,7 +891,7 @@ boolean P_CanUnlockGenDoor(line_t *line, player_t *player) doomprintf(player, MESSAGES_NONE, "%s", skulliscard? s_PD_YELLOWK : s_PD_YELLOWS); // Ty 03/27/98 - externalized S_StartSoundOptional(player->mo, sfx_locked, // [Nugget] Locked door sound STRICTMODE(comp_keynoway) ? sfx_noway : sfx_oof); // [Nugget] - // ST_SetKeyBlink(player, KEYBLINK_NONE, skulliscard ? KEYBLINK_EITHER : KEYBLINK_SKULL, KEYBLINK_NONE); + ST_SetKeyBlink(player, KEYBLINK_NONE, skulliscard ? KEYBLINK_EITHER : KEYBLINK_SKULL, KEYBLINK_NONE); // [Nugget] Key blinking return false; } break; @@ -907,7 +907,7 @@ boolean P_CanUnlockGenDoor(line_t *line, player_t *player) doomprintf(player, MESSAGES_NONE, "%s", s_PD_ALL6); // Ty 03/27/98 - externalized S_StartSoundOptional(player->mo, sfx_locked, // [Nugget] Locked door sound STRICTMODE(comp_keynoway) ? sfx_noway : sfx_oof); // [Nugget] - // ST_SetKeyBlink(player, KEYBLINK_BOTH, KEYBLINK_BOTH, KEYBLINK_BOTH); + ST_SetKeyBlink(player, KEYBLINK_BOTH, KEYBLINK_BOTH, KEYBLINK_BOTH); // [Nugget] Key blinking return false; } if (skulliscard && @@ -920,7 +920,7 @@ boolean P_CanUnlockGenDoor(line_t *line, player_t *player) doomprintf(player, MESSAGES_NONE, "%s", s_PD_ALL3); // Ty 03/27/98 - externalized S_StartSoundOptional(player->mo, sfx_locked, // [Nugget] Locked door sound STRICTMODE(comp_keynoway) ? sfx_noway : sfx_oof); // [Nugget] - // ST_SetKeyBlink(player, KEYBLINK_EITHER, KEYBLINK_EITHER, KEYBLINK_EITHER); + ST_SetKeyBlink(player, KEYBLINK_EITHER, KEYBLINK_EITHER, KEYBLINK_EITHER); // [Nugget] Key blinking return false; } break; diff --git a/src/st_stuff.c b/src/st_stuff.c index 54b4657c2..5f6f8b831 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -61,6 +61,7 @@ // [Nugget] #include "m_nughud.h" +#include "sounds.h" // [Nugget] /================================================================= @@ -81,6 +82,7 @@ boolean no_berserk_tint; boolean no_radsuit_tint; boolean comp_godface; boolean comp_unusedpals; +static boolean hud_blink_keys; static boolean sts_show_berserk; typedef enum hudtype_s @@ -97,6 +99,23 @@ static hudtype_t hud_type; static patch_t *font_extras[HU_FONTEXTRAS] = { NULL }; +// Key blinking -------------------------------------------------------------- + +#define KEYBLINKMASK 0x8 +#define KEYBLINKTICS (7*KEYBLINKMASK) + +keyblink_t st_keyorskull[3]; + +static keyblink_t keyblinkkeys[3]; +static int keyblinktics; + +static int key_override[6]; + +static void ResetKeyOverride(void) +{ + for (int i = 0; i < 6; i++) { key_override[i] = -1; } +} + // NUGHUD -------------------------------------------------------------------- static int nughud_patchlump[NUMNUGHUDPATCHES]; @@ -226,9 +245,6 @@ static boolean weapon_carousel; // used for evil grin static boolean oldweaponsowned[NUMWEAPONS]; -// [crispy] blinking key or skull in the status bar -int st_keyorskull[3]; - static sbardef_t *sbardef; static statusbar_t *statusbar; @@ -422,11 +438,33 @@ static boolean CheckConditions(sbarcondition_t *conditions, player_t *player) break; case sbc_itemowned: + { // [Nugget] Key blinking + const int i = cond->param - item_bluecard; + + if (item_bluecard <= cond->param && cond->param <= item_redskull + && key_override[i] != -1) + { + result &= !!key_override[i]; + break; + } + } + result &= !!P_EvaluateItemOwned((itemtype_t)cond->param, player); break; case sbc_itemnotowned: + { // [Nugget] Key blinking + const int i = cond->param - item_bluecard; + + if (item_bluecard <= cond->param && cond->param <= item_redskull + && key_override[i] != -1) + { + result &= !key_override[i]; + break; + } + } + result &= !P_EvaluateItemOwned((itemtype_t)cond->param, player); break; @@ -1153,6 +1191,69 @@ static void UpdateStatusBar(player_t *player) statusbar = &sbardef->statusbars[st_nughud ? 0 : barindex]; // [Nugget] NUGHUD + // [Nugget] Key blinking /------------------------------------------------ + + static boolean was_blinking = false; + + if (was_blinking != !!keyblinktics) + { + if (was_blinking) { ResetKeyOverride(); } + + was_blinking = !!keyblinktics; + } + + // [crispy] blinking key or skull in the status bar + if (keyblinktics) + { + if (!hud_blink_keys || barindex == 2) + { + keyblinktics = 0; + } + else { + if (!(keyblinktics & (2*KEYBLINKMASK - 1))) + { S_StartSoundPitchOptional(NULL, sfx_keybnk, sfx_itemup, PITCH_NONE); } + + keyblinktics--; + + for (int i = 0; i < 3; i++) + { + keyblink_t keyblink = keyblinkkeys[i]; + + if (!keyblink) { continue; } + + key_override[i] = key_override[i + 3] = 0; + + if (keyblinktics & KEYBLINKMASK) + { + if (keyblink == KEYBLINK_EITHER) + { + if (st_keyorskull[i] && st_keyorskull[i] != KEYBLINK_BOTH) + { + // Map has only one type + keyblink = st_keyorskull[i]; + } + else + // Map has none or both types + if ( (keyblinktics & (2*KEYBLINKMASK)) && + !(keyblinktics & (4*KEYBLINKMASK))) + { + keyblink = KEYBLINK_SKULL; + } + else + { + keyblink = KEYBLINK_CARD; + } + } + + if (keyblink & KEYBLINK_CARD) { key_override[i] = 1; } + if (keyblink & KEYBLINK_SKULL) { key_override[i + 3] = 1; } + } + } + } + } + + // [Nugget] -------------------------------------------------------------/ + sbarelem_t *child; array_foreach(child, statusbar->children) { @@ -2099,6 +2200,10 @@ void ST_Drawer(void) void ST_Start(void) { + // [Nugget] Key blinking + memset(keyblinkkeys, 0, sizeof(keyblinkkeys)); + keyblinktics = 0; + if (!sbardef) { return; @@ -2150,6 +2255,8 @@ void ST_Init(void) // [Nugget] ============================================================== + ResetKeyOverride(); + LoadNuggetGraphics(); // NUGHUD ---------------------------------------------------------------- @@ -2477,6 +2584,34 @@ void LoadNuggetGraphics(void) else { nhinfnty = NULL; } } +// Key blinking -------------------------------------------------------------- + +void ST_SetKeyBlink(player_t* player, int blue, int yellow, int red) +{ + if (player != &players[displayplayer]) { return; } + + ResetKeyOverride(); + + // Init array with args to iterate through + const int keys[3] = { blue, yellow, red }; + + keyblinktics = KEYBLINKTICS; + + for (int i = 0; i < 3; i++) + { + if ( ((keys[i] == KEYBLINK_EITHER) && !(player->cards[i] || player->cards[i+3])) + || ((keys[i] == KEYBLINK_CARD) && !(player->cards[i])) + || ((keys[i] == KEYBLINK_SKULL) && !(player->cards[i+3])) + || ((keys[i] == KEYBLINK_BOTH) && !(player->cards[i] && player->cards[i+3]))) + { + keyblinkkeys[i] = keys[i]; + } + else { + keyblinkkeys[i] = KEYBLINK_NONE; + } + } +} + // NUGHUD -------------------------------------------------------------------- void ST_refreshBackground(void) @@ -3449,10 +3584,16 @@ void ST_BindSTSVariables(void) M_BindBool("hud_armor_type", &hud_armor_type, NULL, true, ss_none, wad_no, "Armor count is colored based on armor type"); - // [Nugget] + // [Nugget] /--------------------------------------------------------------- + M_BindBool("sts_show_berserk", &sts_show_berserk, NULL, true, ss_stat, wad_yes, "Show Berserk pack on the status bar when using the Fist, if available"); + M_BindBool("hud_blink_keys", &hud_blink_keys, NULL, false, ss_stat, wad_yes, + "Make missing keys blink when trying to trigger linedef actions"); + + // [Nugget] ---------------------------------------------------------------/ + M_BindNum("health_red", &health_red, NULL, 25, 0, 200, ss_none, wad_yes, "Amount of health for red-to-yellow transition"); M_BindNum("health_yellow", &health_yellow, NULL, 50, 0, 200, ss_none, wad_yes, diff --git a/src/st_stuff.h b/src/st_stuff.h index da7cc7c0a..028a02868 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -28,6 +28,10 @@ struct event_s; struct patch_s; +// [Nugget] +enum keyblink_e; +struct player_s; + // [Nugget] /================================================================= // CVARs @@ -41,6 +45,20 @@ int ST_GetMessageFontHeight(void); boolean ST_IconAvailable(const int i); boolean ST_GetNughudOn(void); +// Key blinking -------------------------------------------------------------- + +typedef enum keyblink_e +{ + KEYBLINK_NONE, + KEYBLINK_CARD, + KEYBLINK_SKULL, + KEYBLINK_BOTH, + KEYBLINK_EITHER, +} keyblink_t; + +extern void ST_SetKeyBlink(struct player_s *player, int blue, int yellow, int red); +extern enum keyblink_e st_keyorskull[3]; + // [Nugget] =================================================================/ // Size of statusbar.