Skip to content

Commit

Permalink
Heretic & Hexen: Add option in the Gameplay options menu for the skip…
Browse files Browse the repository at this point in the history
… of the unusable artifact

Vanilla behavior: if you try to use an artifact that can't be used (e.g., Quartz flask while having 100 HP), then the previous artifact in inventory will be selected

Always enabled in `-vanilla`, netgame and demo playback/recording
  • Loading branch information
Dasperal committed Jan 21, 2024
1 parent bee3f36 commit b395193
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 26 deletions.
2 changes: 2 additions & 0 deletions src/heretic/hr_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ int fix_map_errors = 1;
int flip_levels = 0;
int breathing = 0;
int pistol_start = 0;
int skip_unusable_artifact = 0;

// Gameplay: Demos
int demotimer = 0;
Expand Down Expand Up @@ -1157,6 +1158,7 @@ void D_BindVariables(void)
M_BindIntVariable("flip_levels", &flip_levels);
M_BindIntVariable("breathing", &breathing);
M_BindIntVariable("pistol_start", &pistol_start);
M_BindIntVariable("skip_unusable_artifact", &skip_unusable_artifact);

// Gameplay: Demos
M_BindIntVariable("demotimer", &demotimer);
Expand Down
33 changes: 25 additions & 8 deletions src/heretic/mn_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ static void M_RD_FlipLevels();
static void M_RD_Breathing();
static void M_RD_WandStart();
static void M_RD_CenterInventoryCursor();
static void M_RD_SkipUnusableArtifact();
static void M_RD_DemoTimer(Direction_t direction);
static void M_RD_DemoTimerDir();
static void M_RD_DemoBar();
Expand Down Expand Up @@ -1334,6 +1335,7 @@ static MenuItem_t Gameplay4Items[] = {
I_SWITCH("IMITATE PLAYER'S BREATHING:", "BVBNFWBZ LS[FYBZ BUHJRF:", M_RD_Breathing), // ИМИТАЦИЯ ДЫХАНИЯ ИГРОКА
I_SWITCH("WAND START GAME MODE:", NULL, /* [JN] Joint EN/RU string*/ M_RD_WandStart), // РЕЖИМ ИГРЫ "WAND START"
I_SWITCH("CENTER INVENTORY CURSOR:", "WTYNHBHJDFNM REHCJH BYDTYNFHZ:", M_RD_CenterInventoryCursor), // ЦЕНТРИРОВАТЬ КУРСОР ИНВЕНТАРЯ
I_SWITCH("SKIP UNUSABLE ARTIFACT:", "CRBG YTGHBVTYBVJUJ FHNTAFRNF:", M_RD_SkipUnusableArtifact), // СКИП НЕПРИМЕНИМОГО АРТEФАКТА
I_TITLE( "DEMOS", "LTVJPFGBCB"), // ДЕМОЗАПИСИ
I_LRFUNC("SHOW DEMO TIMER:", "JNJ,HF;FNM NFQVTH:", M_RD_DemoTimer), // ОТОБРАЖАТЬ ТАЙМЕР
I_SWITCH("TIMER DIRECTION:", "DHTVZ NFQVTHF:", M_RD_DemoTimerDir), // ВРЕМЯ ТАЙМЕРА
Expand Down Expand Up @@ -4999,6 +5001,10 @@ static void DrawGameplay4Menu(void)
RD_M_DrawTextSmallENG(center_inventory_cursor ? "ON" : "OFF", 216 + wide_delta, 86,
center_inventory_cursor ? CR_GREEN : CR_RED);

// Skip unusable artifact
RD_M_DrawTextSmallENG(skip_unusable_artifact ? "ON" : "OFF", 202 + wide_delta, 96,
skip_unusable_artifact ? CR_GREEN : CR_RED);

//
// DEMOS
//
Expand All @@ -5007,20 +5013,20 @@ static void DrawGameplay4Menu(void)
RD_M_DrawTextSmallENG(demotimer == 1 ? "PLAYBACK" :
demotimer == 2 ? "RECORDING" :
demotimer == 3 ? "ALWAYS" :
"OFF", 153 + wide_delta, 106,
"OFF", 153 + wide_delta, 116,
demotimer > 0 ? CR_GREEN : CR_RED);

// Timer direction
RD_M_DrawTextSmallENG(demotimerdir ? "BACKWARD" : "FORWARD", 147 + wide_delta, 116,
RD_M_DrawTextSmallENG(demotimerdir ? "BACKWARD" : "FORWARD", 147 + wide_delta, 126,
demotimer > 0 ? CR_GREEN : CR_RED);

// Show progress bar
RD_M_DrawTextSmallENG(demobar ? "ON" : "OFF", 174 + wide_delta, 126,
RD_M_DrawTextSmallENG(demobar ? "ON" : "OFF", 174 + wide_delta, 136,
demobar ? CR_GREEN : CR_RED);

// Play internal demos
RD_M_DrawTextSmallENG(no_internal_demos ? "OFF" : "ON",
179 + wide_delta, 136,
179 + wide_delta, 146,
no_internal_demos ? CR_RED : CR_GREEN);
}
else
Expand Down Expand Up @@ -5059,6 +5065,10 @@ static void DrawGameplay4Menu(void)
RD_M_DrawTextSmallRUS(center_inventory_cursor ? "DRK" : "DSRK", 257 + wide_delta, 86,
center_inventory_cursor ? CR_GREEN : CR_RED);

// Скип неприменимого артефакта
RD_M_DrawTextSmallRUS(skip_unusable_artifact ? "DRK" : "DSRK", 253 + wide_delta, 96,
skip_unusable_artifact ? CR_GREEN : CR_RED);

//
// ДЕМОЗАПИСИ
//
Expand All @@ -5067,20 +5077,20 @@ static void DrawGameplay4Menu(void)
RD_M_DrawTextSmallRUS(demotimer == 1 ? "GHB GHJBUHSDFYBB" :
demotimer == 2 ? "GHB PFGBCB" :
demotimer == 3 ? "DCTULF" :
"DSRK", 175 + wide_delta, 106,
"DSRK", 175 + wide_delta, 116,
demotimer > 0 ? CR_GREEN : CR_DARKRED);

// Время таймера
RD_M_DrawTextSmallRUS(demotimerdir ? "JCNFDITTCZ" : "GHJITLITT", 142 + wide_delta, 116,
RD_M_DrawTextSmallRUS(demotimerdir ? "JCNFDITTCZ" : "GHJITLITT", 142 + wide_delta, 126,
demotimer > 0 ? CR_GREEN : CR_DARKRED);

// Шкала прогресса
RD_M_DrawTextSmallRUS(demobar ? "DRK" : "DSRK", 161 + wide_delta, 126,
RD_M_DrawTextSmallRUS(demobar ? "DRK" : "DSRK", 161 + wide_delta, 136,
demobar ? CR_GREEN : CR_RED);

// Проигрывать демозаписи
RD_M_DrawTextSmallRUS(no_internal_demos ? "DSRK" : "DRK",
211 + wide_delta, 136,
211 + wide_delta, 146,
no_internal_demos ? CR_RED : CR_GREEN);
}

Expand Down Expand Up @@ -5120,6 +5130,11 @@ static void M_RD_CenterInventoryCursor()
center_inventory_cursor ^= 1;
}

static void M_RD_SkipUnusableArtifact()
{
skip_unusable_artifact ^= 1;
}

static void M_RD_DemoTimer(Direction_t direction)
{
RD_Menu_SpinInt(&demotimer, 0, 3, direction);
Expand Down Expand Up @@ -5845,6 +5860,7 @@ static void M_RD_BackToDefaults_Recommended(void)
breathing = 0;
pistol_start = 0;
center_inventory_cursor = 1;
skip_unusable_artifact = 0;
demotimer = 0;
demotimerdir = 0;
demobar = 0;
Expand Down Expand Up @@ -6005,6 +6021,7 @@ static void M_RD_BackToDefaults_Original(void)
breathing = 0;
pistol_start = 0;
center_inventory_cursor = 0;
skip_unusable_artifact = 1;
demotimer = 0;
demotimerdir = 0;
demobar = 0;
Expand Down
5 changes: 3 additions & 2 deletions src/heretic/p_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -973,8 +973,9 @@ void P_PlayerUseArtifact (player_t *player, artitype_t arti)
ArtifactFlash = 4;
}
}
else
{ // Unable to use artifact, advance pointer
else if(skip_unusable_artifact || vanillaparm || !singleplayer)
{
// Unable to use artifact, advance pointer
P_PlayerNextArtifact(player);
}
break;
Expand Down
2 changes: 2 additions & 0 deletions src/hexen/h2_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ int fix_map_errors = 1;
int flip_levels = 0;
int no_internal_demos = 0;
int breathing = 0;
int skip_unusable_artifact = 0;

int selective_class = 0;
int selective_skill = 2;
Expand Down Expand Up @@ -404,6 +405,7 @@ void D_BindVariables(void)
M_BindIntVariable("flip_levels", &flip_levels);
M_BindIntVariable("no_internal_demos", &no_internal_demos);
M_BindIntVariable("breathing", &breathing);
M_BindIntVariable("skip_unusable_artifact", &skip_unusable_artifact);

// Gameplay: Crosshair
M_BindIntVariable("crosshair_draw", &crosshair_draw);
Expand Down
43 changes: 29 additions & 14 deletions src/hexen/mn_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ static void M_RD_FixMapErrors();
static void M_RD_FlipLevels();
static void M_RD_NoDemos();
static void M_RD_Breathing();
static void M_RD_SkipUnusableArtifact();

// Level Select (1)
static void DrawLevelSelect1Menu(void);
Expand Down Expand Up @@ -1318,6 +1319,7 @@ MENU_STATIC_PAGED(Gameplay2Menu,

static MenuItem_t Gameplay3Items[] = {
I_SWITCH("IMITATE PLAYER'S BREATHING:", "BVBNFWBZ LS[FYBZ BUHJRF:", M_RD_Breathing), // ИМИТАЦИЯ ДЫХАНИЯ ИГРОКА
I_SWITCH("SKIP UNUSABLE ARTIFACT:", "CRBG YTGHBVTYBVJUJ FHNTAFRNF:", M_RD_SkipUnusableArtifact), // СКИП НЕПРИМЕНИМОГО АРТEФАКТА
I_TITLE( "CROSSHAIR", "GHBWTK"), // ПРИЦЕЛ
I_SWITCH("DRAW CROSSHAIR:", "JNJ,HF;FNM GHBWTK:", M_RD_CrossHairDraw), // ОТОБРАЖАТЬ ПРИЦЕЛ
I_LRFUNC("SHAPE:", "AJHVF:", M_RD_CrossHairShape), // ФОРМА
Expand All @@ -1329,7 +1331,6 @@ static MenuItem_t Gameplay3Items[] = {
I_EMPTY,
I_EMPTY,
I_EMPTY,
I_EMPTY,
I_SETMENU("FIRST PAGE >", "GTHDFZ CNHFYBWF `", &Gameplay1Menu), // ПЕРВАЯ СТРАНИЦА >
I_SETMENU("< PREV PAGE", "^ GHTLSLEOFZ CNHFYBWF", &Gameplay2Menu) // < ПРЕДЫДУЩАЯ СТРАНИЦА
};
Expand Down Expand Up @@ -4733,12 +4734,16 @@ static void DrawGameplay3Menu(void)
RD_M_DrawTextSmallENG(breathing ? "ON" : "OFF", 224 + wide_delta, 32,
breathing ? CR_GREEN : CR_RED);

// Skip unusable artifact
RD_M_DrawTextSmallENG(skip_unusable_artifact ? "ON" : "OFF", 202 + wide_delta, 42,
skip_unusable_artifact ? CR_GREEN : CR_RED);

//
// CROSSHAIR
//

// Draw crosshair
RD_M_DrawTextSmallENG(crosshair_draw ? "ON" : "OFF", 150 + wide_delta, 52,
RD_M_DrawTextSmallENG(crosshair_draw ? "ON" : "OFF", 150 + wide_delta, 62,
crosshair_draw ? CR_GREEN : CR_RED);

// Shape
Expand All @@ -4748,14 +4753,14 @@ static void DrawGameplay3Menu(void)
crosshair_shape == 4 ? "ANGLE" :
crosshair_shape == 5 ? "TRIANGLE" :
crosshair_shape == 6 ? "DOT" : "CROSS",
84 + wide_delta, 62, CR_GREEN);
84 + wide_delta, 72, CR_GREEN);

// Indication
RD_M_DrawTextSmallENG(crosshair_type == 1 ? "HEALTH" : "STATIC", 111 + wide_delta, 72,
RD_M_DrawTextSmallENG(crosshair_type == 1 ? "HEALTH" : "STATIC", 111 + wide_delta, 82,
crosshair_type ? CR_GREEN : CR_RED);

// Increased size
RD_M_DrawTextSmallENG(crosshair_scale ? "ON" : "OFF", 146 + wide_delta, 82,
RD_M_DrawTextSmallENG(crosshair_scale ? "ON" : "OFF", 146 + wide_delta, 92,
crosshair_scale ? CR_GREEN : CR_RED);
}
else
Expand All @@ -4764,12 +4769,16 @@ static void DrawGameplay3Menu(void)
RD_M_DrawTextSmallRUS(breathing ? "DRK": "DSRK", 214 + wide_delta, 32,
breathing ? CR_GREEN : CR_RED);

// Скип неприменимого артефакта
RD_M_DrawTextSmallRUS(skip_unusable_artifact ? "DRK" : "DSRK", 253 + wide_delta, 42,
skip_unusable_artifact ? CR_GREEN : CR_RED);

//
// ПРИЦЕЛ
//

// Отображать прицел
RD_M_DrawTextSmallRUS(crosshair_draw ? "DRK" : "DSRK", 175 + wide_delta, 52,
RD_M_DrawTextSmallRUS(crosshair_draw ? "DRK" : "DSRK", 175 + wide_delta, 62,
crosshair_draw ? CR_GREEN : CR_RED);

// Форма
Expand All @@ -4780,30 +4789,30 @@ static void DrawGameplay3Menu(void)
crosshair_shape == 5 ? "NHTEUJKMYBR" : // ТРЕУГОЛЬНИК
crosshair_shape == 6 ? "NJXRF" : // ТОЧКА
"RHTCN", // КРЕСТ
87 + wide_delta, 62, CR_GREEN);
87 + wide_delta, 72, CR_GREEN);

// Индикация
RD_M_DrawTextSmallRUS(crosshair_type == 1 ? "PLJHJDMT" : // ЗДОРОВЬЕ
"CNFNBXYFZ", // СТАТИЧНАЯ
111 + wide_delta, 72, crosshair_type ? CR_GREEN : CR_RED);
111 + wide_delta, 82, crosshair_type ? CR_GREEN : CR_RED);

// Увеличенный размер
RD_M_DrawTextSmallRUS(crosshair_scale ? "DRK" : "DSRK", 181 + wide_delta, 82,
RD_M_DrawTextSmallRUS(crosshair_scale ? "DRK" : "DSRK", 181 + wide_delta, 92,
crosshair_scale ? CR_GREEN : CR_RED);
}

// Draw crosshair background.
V_DrawPatch(235 + wide_delta, 63, W_CacheLumpName("XHAIRBOX", PU_CACHE), NULL);
V_DrawPatch(235 + wide_delta, 73, W_CacheLumpName("XHAIRBOX", PU_CACHE), NULL);
// Colorize crosshair depending on it's type.
Crosshair_Colorize_inMenu();
// Draw crosshair preview.
if (crosshair_scale)
{
V_DrawPatch(250 + wide_delta, 78, CrosshairPatch, CrosshairOpacity);
V_DrawPatch(250 + wide_delta, 88, CrosshairPatch, CrosshairOpacity);
}
else
{
V_DrawPatchUnscaled(500 + wide_delta*2, 156, CrosshairPatch, CrosshairOpacity);
V_DrawPatchUnscaled(500 + wide_delta*2, 176, CrosshairPatch, CrosshairOpacity);
}
// Clear colorization.
dp_translation = NULL;
Expand All @@ -4817,8 +4826,8 @@ static void DrawGameplay3Menu(void)
crosshair_opacity == 5 ? "70%" :
crosshair_opacity == 6 ? "80%" :
crosshair_opacity == 7 ? "90%" : "100%",
(english_language ? 95 : 149) + wide_delta,
92, CR_GRAY);
(english_language ? 95 : 159) + wide_delta,
102, CR_GRAY);
}

static void M_RD_FixMapErrors()
Expand All @@ -4844,6 +4853,10 @@ static void M_RD_Breathing()
breathing ^= 1;
}

static void M_RD_SkipUnusableArtifact()
{
skip_unusable_artifact ^= 1;
}

//---------------------------------------------------------------------------
// DrawLevelSelect1Menu
Expand Down Expand Up @@ -5886,6 +5899,7 @@ void M_RD_BackToDefaults_Recommended (void)
show_all_artifacts = 0;
show_artifacts_timer = 0;
weapon_widget = 0;
skip_unusable_artifact = 0;
// Gameplay (4)
crosshair_draw = 0;
crosshair_shape = 0;
Expand Down Expand Up @@ -6003,6 +6017,7 @@ static void M_RD_BackToDefaults_Original(void)
show_all_artifacts = 0;
show_artifacts_timer = 0;
weapon_widget = 0;
skip_unusable_artifact = 1;
// Gameplay (4)
crosshair_draw = 0;
crosshair_shape = 0;
Expand Down
5 changes: 3 additions & 2 deletions src/hexen/p_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -1492,8 +1492,9 @@ void P_PlayerUseArtifact(player_t * player, artitype_t arti)
ArtifactFlash = 4;
}
}
else if (arti < arti_firstpuzzitem)
{ // Unable to use artifact, advance pointer
else if(arti < arti_firstpuzzitem && (skip_unusable_artifact || vanillaparm || !singleplayer))
{
// Unable to use artifact, advance pointer
P_PlayerNextArtifact(player);
}
break;
Expand Down
1 change: 1 addition & 0 deletions src/jn.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ extern int pistol_start;
extern int breathing;
extern int unlimited_lost_souls;
extern int fast_quickload;
extern int skip_unusable_artifact;

// Gameplay: Demos
extern int demotimer;
Expand Down
1 change: 1 addition & 0 deletions src/m_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@ static default_t defaults_list[] =
CONFIG_VARIABLE_INT(breathing),
CONFIG_VARIABLE_INT(unlimited_lost_souls),
CONFIG_VARIABLE_INT(fast_quickload),
CONFIG_VARIABLE_INT(skip_unusable_artifact),

// Gameplay: Demos
CONFIG_VARIABLE_INT(demotimer),
Expand Down

0 comments on commit b395193

Please sign in to comment.