From 075f751f674e0285f554e7d2569a04470e9ba902 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 8 Dec 2019 14:17:48 -0600 Subject: [PATCH] Add cvar to use abilities in input direction --- src/d_netcmd.c | 4 ++++ src/g_game.c | 25 ++++++++++++++++++++++++- src/g_game.h | 3 +++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index e80d07b76..f181c6e57 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -823,6 +823,10 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_autobrake); CV_RegisterVar(&cv_autobrake2); + // hi here's some new controls + CV_RegisterVar(&cv_abilitydirection[0]); + CV_RegisterVar(&cv_abilitydirection[1]); + // s_sound.c CV_RegisterVar(&cv_soundvolume); CV_RegisterVar(&cv_closedcaptioning); diff --git a/src/g_game.c b/src/g_game.c index a55c1b1eb..598f328aa 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -394,6 +394,12 @@ consvar_t cv_directionchar2 = {"directionchar2", "Movement", CV_SAVE|CV_CALL, di consvar_t cv_autobrake = {"autobrake", "On", CV_SAVE|CV_CALL, CV_OnOff, AutoBrake_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_autobrake2 = {"autobrake2", "On", CV_SAVE|CV_CALL, CV_OnOff, AutoBrake2_OnChange, 0, NULL, NULL, 0, 0, NULL}; +// hi here's some new controls +consvar_t cv_abilitydirection[2] = { + {"abilitydirection", "Movement", CV_SAVE, directionchar_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"abilitydirection2", "Movement", CV_SAVE, directionchar_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, +}; + typedef enum { AXISNONE = 0, @@ -996,7 +1002,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) angle_t *myangle = (ssplayer == 1 ? &localangle : &localangle2); INT32 *myaiming = (ssplayer == 1 ? &localaiming : &localaiming2); - INT32 chasecam, chasefreelook, alwaysfreelook, usejoystick, analog, invertmouse, mousemove; + INT32 chasecam, chasefreelook, alwaysfreelook, usejoystick, analog, invertmouse, mousemove, abilitydirection; INT32 *mx; INT32 *my; INT32 *mly; static INT32 turnheld[2]; // for accelerative turning @@ -1033,6 +1039,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) mly = &mlook2y; G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); // empty, or external driver } + abilitydirection = cv_abilitydirection[forplayer].value; // why build a ticcmd if we're paused? // Or, for that matter, if we're being reborn. @@ -1352,6 +1359,22 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { *myangle += (cmd->angleturn<<16); cmd->angleturn = (INT16)(*myangle >> 16); + + if (abilitydirection && !player->climbing && !forcestrafe) + { + if (cmd->forwardmove || cmd->sidemove) + { + angle_t controlangle = R_PointToAngle2(0, 0, cmd->forwardmove << FRACBITS, -cmd->sidemove << FRACBITS); + cmd->angleturn += (controlangle>>16); + + cmd->forwardmove = R_PointToDist2(0, 0, cmd->forwardmove, cmd->sidemove); + if (cmd->forwardmove > MAXPLMOVE) + cmd->forwardmove = MAXPLMOVE; + cmd->sidemove = 0; + } + else + cmd->angleturn = (player->drawangle>>16); + } } //Reset away view if a command is given. diff --git a/src/g_game.h b/src/g_game.h index 3067751ee..86bcf3d59 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -76,6 +76,9 @@ extern consvar_t cv_sideaxis,cv_turnaxis,cv_moveaxis,cv_lookaxis,cv_jumpaxis,cv_ extern consvar_t cv_sideaxis2,cv_turnaxis2,cv_moveaxis2,cv_lookaxis2,cv_jumpaxis2,cv_spinaxis2,cv_fireaxis2,cv_firenaxis2; extern consvar_t cv_ghost_bestscore, cv_ghost_besttime, cv_ghost_bestrings, cv_ghost_last, cv_ghost_guest; +// hi here's some new controls +extern consvar_t cv_abilitydirection[2]; + // mouseaiming (looking up/down with the mouse or keyboard) #define KB_LOOKSPEED (1<<25) #define MAXPLMOVE (50)