Skip to content

Commit

Permalink
Add custom weapon slots feature (#1923)
Browse files Browse the repository at this point in the history
* Lower priority of shortcut responder

* Raise priority of chat, cheat, automap responders

* Add custom weapon slots

* Disable weapon slots by default
  • Loading branch information
ceski-1 authored Sep 25, 2024
1 parent d225e33 commit 796c0d0
Show file tree
Hide file tree
Showing 14 changed files with 1,093 additions and 29 deletions.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ set(WOOF_SOURCES
w_zip.c
wi_stuff.c wi_stuff.h
wi_interlvl.c wi_interlvl.h
ws_stuff.c ws_stuff.h
z_zone.c z_zone.h)

# Standard target definition
Expand Down
24 changes: 16 additions & 8 deletions src/am_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "v_flextran.h"
#include "v_fmt.h"
#include "v_video.h"
#include "ws_stuff.h"
#include "z_zone.h"

//jff 1/7/98 default automap colors added
Expand Down Expand Up @@ -794,7 +795,7 @@ boolean AM_Responder

if (!automapactive)
{
if (M_InputActivated(input_map))
if (M_InputActivated(input_map) && !WS_Override())
{
AM_Start ();
viewactive = false;
Expand All @@ -808,22 +809,22 @@ boolean AM_Responder
rc = true;
// phares
if (M_InputActivated(input_map_right)) // |
if (!followplayer) // V
if (!followplayer && !WS_HoldOverride()) // V
buttons_state[PAN_RIGHT] = 1;
else
rc = false;
else if (M_InputActivated(input_map_left))
if (!followplayer)
if (!followplayer && !WS_HoldOverride())
buttons_state[PAN_LEFT] = 1;
else
rc = false;
else if (M_InputActivated(input_map_up))
if (!followplayer)
if (!followplayer && !WS_HoldOverride())
buttons_state[PAN_UP] = 1;
else
rc = false;
else if (M_InputActivated(input_map_down))
if (!followplayer)
if (!followplayer && !WS_HoldOverride())
buttons_state[PAN_DOWN] = 1;
else
rc = false;
Expand Down Expand Up @@ -851,9 +852,16 @@ boolean AM_Responder
}
else if (M_InputActivated(input_map))
{
bigstate = 0;
viewactive = true;
AM_Stop ();
if (!WS_Override())
{
bigstate = 0;
viewactive = true;
AM_Stop ();
}
else
{
rc = false;
}
}
else if (M_InputActivated(input_map_gobig))
{
Expand Down
2 changes: 2 additions & 0 deletions src/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
#include "v_video.h"
#include "w_wad.h"
#include "wi_stuff.h"
#include "ws_stuff.h"
#include "z_zone.h"

// DEHacked support - Ty 03/09/97
Expand Down Expand Up @@ -2439,6 +2440,7 @@ void D_DoomMain(void)
G_UpdateGamepadVariables();
G_UpdateMouseVariables();
R_UpdateViewAngleFunction();
WS_Init();

MN_ResetTimeScale();

Expand Down
1 change: 1 addition & 0 deletions src/doomkeys.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
// This is the stuff configured by Setup.Exe.
// Most key data are simple ascii (uppercased).
//
#define NUMKEYS 256
#define KEY_RIGHTARROW 0xae
#define KEY_LEFTARROW 0xac
#define KEY_UPARROW 0xad
Expand Down
31 changes: 24 additions & 7 deletions src/g_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
#include "version.h"
#include "w_wad.h"
#include "wi_stuff.h"
#include "ws_stuff.h"
#include "z_zone.h"

#define SAVEGAMESIZE 0x20000
Expand Down Expand Up @@ -188,7 +189,6 @@ static boolean dclick_use;
#define TURBOTHRESHOLD 0x32
#define SLOWTURNTICS 6
#define QUICKREVERSE 32768 // 180 degree reverse // phares
#define NUMKEYS 256

fixed_t forwardmove[2] = {0x19, 0x32};
fixed_t default_sidemove[2] = {0x18, 0x28};
Expand Down Expand Up @@ -857,6 +857,10 @@ void G_BuildTiccmd(ticcmd_t* cmd)
boom_weapon_state_injection = false;
newweapon = P_SwitchWeapon(&players[consoleplayer]); // phares
}
else if (WS_SlotSelected())
{
newweapon = WS_SlotWeapon();
}
else if (M_InputGameActive(input_lastweapon))
{
newweapon = LastWeapon();
Expand Down Expand Up @@ -899,6 +903,7 @@ void G_BuildTiccmd(ticcmd_t* cmd)

// [FG] prev/next weapon keys and buttons
next_weapon = 0;
WS_ClearSharedEvent();

// [FG] double click acts as "use"
if (dclick)
Expand Down Expand Up @@ -946,6 +951,7 @@ void G_ClearInput(void)
memset(&basecmd, 0, sizeof(basecmd));
I_ResetRelativeMouseState();
I_ResetAllRumbleChannels();
WS_Reset();
}

//
Expand Down Expand Up @@ -1316,6 +1322,23 @@ boolean G_MovementResponder(event_t *ev)

boolean G_Responder(event_t* ev)
{
WS_UpdateState(ev);

// killough 9/29/98: reformatted
if (gamestate == GS_LEVEL
&& (HU_Responder(ev) || // chat ate the event
ST_Responder(ev) || // status window ate it
AM_Responder(ev) || // automap ate it
WS_Responder(ev))) // weapon slots ate it
{
return true;
}

if (M_ShortcutResponder(ev))
{
return true;
}

// allow spy mode changes even during the demo
// killough 2/22/98: even during DM demo
//
Expand Down Expand Up @@ -1346,12 +1369,6 @@ boolean G_Responder(event_t* ev)
return true;
}

// killough 9/29/98: reformatted
if (gamestate == GS_LEVEL && (HU_Responder(ev) || // chat ate the event
ST_Responder(ev) || // status window ate it
AM_Responder(ev))) // automap ate it
return true;

// any other key pops up menu if in demos
//
// killough 8/2/98: enable automap in -timedemo demos
Expand Down
21 changes: 20 additions & 1 deletion src/i_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

static SDL_GameController *gamepad;
static boolean gyro_supported;
static joy_platform_t platform;

// [FG] adapt joystick button and axis handling from Chocolate Doom 3.0

Expand Down Expand Up @@ -265,9 +266,27 @@ static joy_platform_t GetSwitchSubPlatform(void)
return PLATFORM_SWITCH_PRO;
}

void I_GetFaceButtons(int *buttons)
{
if (platform < PLATFORM_SWITCH)
{
buttons[0] = GAMEPAD_Y;
buttons[1] = GAMEPAD_A;
buttons[2] = GAMEPAD_X;
buttons[3] = GAMEPAD_B;
}
else
{
buttons[0] = GAMEPAD_X;
buttons[1] = GAMEPAD_B;
buttons[2] = GAMEPAD_Y;
buttons[3] = GAMEPAD_A;
}
}

static void UpdatePlatform(void)
{
joy_platform_t platform = joy_platform;
platform = joy_platform;

if (platform == PLATFORM_AUTO)
{
Expand Down
1 change: 1 addition & 0 deletions src/i_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ enum evtype_e;
int I_GetAxisState(int axis);
boolean I_UseGamepad(void);
boolean I_GyroSupported(void);
void I_GetFaceButtons(int *buttons);
void I_FlushGamepadSensorEvents(void);
void I_FlushGamepadEvents(void);
void I_SetSensorEventState(boolean condition);
Expand Down
4 changes: 4 additions & 0 deletions src/m_cheat.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include "tables.h"
#include "u_mapinfo.h"
#include "w_wad.h"
#include "ws_stuff.h"

#define plyr (players+consoleplayer) /* the console player */

Expand Down Expand Up @@ -1312,6 +1313,9 @@ boolean M_CheatResponder(event_t *ev)
if (ev->type == ev_keydown && M_FindCheats(ev->data1.i))
return true;

if (WS_Override())
return false;

for (i = 0; i < arrlen(cheat_input); ++i)
{
if (M_InputActivated(cheat_input[i].input))
Expand Down
2 changes: 2 additions & 0 deletions src/m_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include "r_main.h"
#include "st_stuff.h"
#include "w_wad.h"
#include "ws_stuff.h"
#include "z_zone.h"

//
Expand Down Expand Up @@ -133,6 +134,7 @@ void M_InitConfig(void)
G_BindEnemVariables();
G_BindCompVariables();
G_BindWeapVariables();
WS_BindVariables();

HU_BindHUDVariables();
ST_BindSTSVariables();
Expand Down
7 changes: 1 addition & 6 deletions src/mn_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2108,7 +2108,7 @@ void M_Ticker(void)
// action based on the state of the system.
//

static boolean ShortcutResponder(const event_t *ev)
boolean M_ShortcutResponder(const event_t *ev)
{
// If there is no active menu displayed...

Expand Down Expand Up @@ -2823,11 +2823,6 @@ boolean M_Responder(event_t *ev)
G_ScreenShot();
}

if (ShortcutResponder(ev))
{
return true;
}

// Pop-up Main menu?

if (!menuactive)
Expand Down
2 changes: 2 additions & 0 deletions src/mn_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ struct event_s;

boolean M_Responder(struct event_s *ev);

boolean M_ShortcutResponder(const struct event_s *ev);

// Called by main loop,
// only used for menu (skull cursor) animation.

Expand Down
Loading

0 comments on commit 796c0d0

Please sign in to comment.