From bb6694a72b1eb6c5b56a33d20c4fa09004998ec1 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Mon, 22 Jan 2018 17:08:31 -0500 Subject: [PATCH 1/4] Camera adjustin's - Look backward button works - Increased default cam_speed, from 0.3 to 0.45. This is the highest value that I think doesn't look overly stiff. - Removed bobbing in first person I was trying to do the camera angle thing that we've been talking about for a while, but I can't get it to work well. --- src/d_player.h | 5 +- src/g_game.c | 214 ++++++++++++++++++++++---------------------- src/g_game.h | 1 + src/lua_playerlib.c | 8 +- src/m_cheat.c | 2 +- src/p_mobj.c | 7 +- src/p_user.c | 88 ++++++------------ 7 files changed, 147 insertions(+), 178 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index ccb428e1..accbacc9 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -244,7 +244,6 @@ typedef enum k_lakitu, // Timer for Lakitu to carry and drop the player k_throwdir, // Held dir of controls; 1 = forward, 0 = none, -1 = backward (was "player->heldDir") - k_camspin, // Used to 180 the camera while a button is held k_lapanimation, // Used to make a swoopy lap lakitu, maybe other effects in the future k_cardanimation, // Used to determine the position of some full-screen Battle Mode graphics k_sounds, // Used this to stop and then force music restores as it hits zero @@ -356,9 +355,9 @@ typedef struct player_s // Base height above floor for viewz. fixed_t viewheight; // Bob/squat speed. - fixed_t deltaviewheight; + //fixed_t deltaviewheight; // bounded/scaled total momentum. - fixed_t bob; + //fixed_t bob; // Mouse aiming, where the guy is looking at! // It is updated with cmd->aiming. diff --git a/src/g_game.c b/src/g_game.c index a0a40329..8d8ed407 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1160,6 +1160,7 @@ static INT32 JoyAxis(axis_input_e axissel, UINT8 p) // INT32 localaiming, localaiming2, localaiming3, localaiming4; angle_t localangle, localangle2, localangle3, localangle4; +boolean camspin, camspin2, camspin3, camspin4; static fixed_t forwardmove[2] = {25<>16, 50<>16}; static fixed_t sidemove[2] = {25<>16, 50<>16}; // faster! @@ -1179,45 +1180,45 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) static INT32 turnheld, turnheld2, turnheld3, turnheld4; // for accelerative turning static boolean keyboard_look, keyboard_look2, keyboard_look3, keyboard_look4; // true if lookup/down using keyboard - if (ssplayer == 2) + switch (ssplayer) { - player = &players[secondarydisplayplayer]; - thiscam = (player->bot == 2 ? &camera : &camera2); - lang = localangle2; - laim = localaiming2; - th = turnheld2; - kbl = keyboard_look2; - G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); - } - else if (ssplayer == 3) - { - player = &players[thirddisplayplayer]; - thiscam = &camera3; - lang = localangle3; - laim = localaiming3; - th = turnheld3; - kbl = keyboard_look3; - G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1); - } - else if (ssplayer == 4) - { - player = &players[fourthdisplayplayer]; - thiscam = &camera4; - lang = localangle4; - laim = localaiming4; - th = turnheld4; - kbl = keyboard_look4; - G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1); - } - else - { - player = &players[consoleplayer]; - thiscam = &camera; - lang = localangle; - laim = localaiming; - th = turnheld; - kbl = keyboard_look; - G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver + case 2: + player = &players[secondarydisplayplayer]; + thiscam = (player->bot == 2 ? &camera : &camera2); + lang = localangle2; + laim = localaiming2; + th = turnheld2; + kbl = keyboard_look2; + G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); + break; + case 3: + player = &players[thirddisplayplayer]; + thiscam = &camera3; + lang = localangle3; + laim = localaiming3; + th = turnheld3; + kbl = keyboard_look3; + G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1); + break; + case 4: + player = &players[fourthdisplayplayer]; + thiscam = &camera4; + lang = localangle4; + laim = localaiming4; + th = turnheld4; + kbl = keyboard_look4; + G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1); + break; + case 1: + default: + player = &players[consoleplayer]; + thiscam = &camera; + lang = localangle; + laim = localaiming; + th = turnheld; + kbl = keyboard_look; + G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver + break; } // why build a ticcmd if we're paused? @@ -1229,41 +1230,41 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) return; } - if (ssplayer == 2) + switch (ssplayer) { - mouseaiming = (PLAYER2INPUTDOWN(gc_mouseaiming)) ^ cv_alwaysfreelook2.value; - invertmouse = cv_invertmouse2.value; - lookaxis = cv_lookaxis2.value; - analogjoystickmove = cv_usejoystick2.value && !Joystick2.bGamepadStyle; - gamepadjoystickmove = cv_usejoystick2.value && Joystick2.bGamepadStyle; - analog = cv_analog2.value; - } - else if (ssplayer == 3) - { - mouseaiming = false; - invertmouse = false; - lookaxis = cv_lookaxis3.value; - analogjoystickmove = cv_usejoystick3.value && !Joystick3.bGamepadStyle; - gamepadjoystickmove = cv_usejoystick3.value && Joystick3.bGamepadStyle; - analog = cv_analog3.value; - } - else if (ssplayer == 4) - { - mouseaiming = false; - invertmouse = false; - lookaxis = cv_lookaxis4.value; - analogjoystickmove = cv_usejoystick4.value && !Joystick4.bGamepadStyle; - gamepadjoystickmove = cv_usejoystick4.value && Joystick4.bGamepadStyle; - analog = cv_analog4.value; - } - else - { - mouseaiming = (PLAYER1INPUTDOWN(gc_mouseaiming)) ^ cv_alwaysfreelook.value; - invertmouse = cv_invertmouse.value; - lookaxis = cv_lookaxis.value; - analogjoystickmove = cv_usejoystick.value && !Joystick.bGamepadStyle; - gamepadjoystickmove = cv_usejoystick.value && Joystick.bGamepadStyle; - analog = cv_analog.value; + case 2: + mouseaiming = (PLAYER2INPUTDOWN(gc_mouseaiming)) ^ cv_alwaysfreelook2.value; + invertmouse = cv_invertmouse2.value; + lookaxis = cv_lookaxis2.value; + analogjoystickmove = cv_usejoystick2.value && !Joystick2.bGamepadStyle; + gamepadjoystickmove = cv_usejoystick2.value && Joystick2.bGamepadStyle; + analog = cv_analog2.value; + break; + case 3: + mouseaiming = false; + invertmouse = false; + lookaxis = cv_lookaxis3.value; + analogjoystickmove = cv_usejoystick3.value && !Joystick3.bGamepadStyle; + gamepadjoystickmove = cv_usejoystick3.value && Joystick3.bGamepadStyle; + analog = cv_analog3.value; + break; + case 4: + mouseaiming = false; + invertmouse = false; + lookaxis = cv_lookaxis4.value; + analogjoystickmove = cv_usejoystick4.value && !Joystick4.bGamepadStyle; + gamepadjoystickmove = cv_usejoystick4.value && Joystick4.bGamepadStyle; + analog = cv_analog4.value; + break; + case 1: + default: + mouseaiming = (PLAYER1INPUTDOWN(gc_mouseaiming)) ^ cv_alwaysfreelook.value; + invertmouse = cv_invertmouse.value; + lookaxis = cv_lookaxis.value; + analogjoystickmove = cv_usejoystick.value && !Joystick.bGamepadStyle; + gamepadjoystickmove = cv_usejoystick.value && Joystick.bGamepadStyle; + analog = cv_analog.value; + break; } turnright = InputDown(gc_turnright, ssplayer); @@ -1429,6 +1430,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (InputDown(gc_spectate, ssplayer)) cmd->buttons |= BT_SPECTATE; + // SRB2Kart: look backward + if (InputDown(gc_lookback, ssplayer)) + // Lua scriptable buttons if (InputDown(gc_custom1, ssplayer)) cmd->buttons |= BT_CUSTOM1; @@ -1454,16 +1458,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } */ - /* - if (InputDown(gc_lookback, ssplayer)) - { - if (thiscam->chase && !player->kartstuff[k_camspin]) - player->kartstuff[k_camspin] = 1; - } - else if (player->kartstuff[k_camspin] > 0) - player->kartstuff[k_camspin] = -1; - */ - // jump button if (InputDown(gc_jump, ssplayer)) cmd->buttons |= BT_JUMP; @@ -1608,33 +1602,37 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->angleturn = (INT16)(lang >> 16); } - if (ssplayer == 2) + switch (ssplayer) { - localangle2 = lang; - localaiming2 = laim; - keyboard_look2 = kbl; - turnheld2 = th; - } - else if (ssplayer == 3) - { - localangle3 = lang; - localaiming3 = laim; - keyboard_look3 = kbl; - turnheld3 = th; - } - else if (ssplayer == 4) - { - localangle4 = lang; - localaiming4 = laim; - keyboard_look4 = kbl; - turnheld4 = th; - } - else - { - localangle = lang; - localaiming = laim; - keyboard_look = kbl; - turnheld = th; + case 2: + localangle2 = lang; + localaiming2 = laim; + keyboard_look2 = kbl; + turnheld2 = th; + camspin2 = InputDown(gc_lookback, ssplayer); + break; + case 3: + localangle3 = lang; + localaiming3 = laim; + keyboard_look3 = kbl; + turnheld3 = th; + camspin3 = InputDown(gc_lookback, ssplayer); + break; + case 4: + localangle4 = lang; + localaiming4 = laim; + keyboard_look4 = kbl; + turnheld4 = th; + camspin4 = InputDown(gc_lookback, ssplayer); + break; + case 1: + default: + localangle = lang; + localaiming = laim; + keyboard_look = kbl; + turnheld = th; + camspin = InputDown(gc_lookback, ssplayer); + break; } //Reset away view if a command is given. diff --git a/src/g_game.h b/src/g_game.h index ec8a1817..dfc7b0df 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -82,6 +82,7 @@ INT16 G_SoftwareClipAimingPitch(INT32 *aiming); extern angle_t localangle, localangle2, localangle3, localangle4; extern INT32 localaiming, localaiming2, localaiming3, localaiming4; // should be an angle_t but signed +extern boolean camspin, camspin2, camspin3, camspin4; // SRB2Kart // // GAME diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 47560847..0d488fdb 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -112,10 +112,10 @@ static int player_get(lua_State *L) lua_pushfixed(L, plr->viewz); else if (fastcmp(field,"viewheight")) lua_pushfixed(L, plr->viewheight); - else if (fastcmp(field,"deltaviewheight")) + /*else if (fastcmp(field,"deltaviewheight")) lua_pushfixed(L, plr->deltaviewheight); else if (fastcmp(field,"bob")) - lua_pushfixed(L, plr->bob); + lua_pushfixed(L, plr->bob);*/ else if (fastcmp(field,"aiming")) lua_pushangle(L, plr->aiming); else if (fastcmp(field,"health")) @@ -371,10 +371,10 @@ static int player_set(lua_State *L) plr->viewz = luaL_checkfixed(L, 3); else if (fastcmp(field,"viewheight")) plr->viewheight = luaL_checkfixed(L, 3); - else if (fastcmp(field,"deltaviewheight")) + /*else if (fastcmp(field,"deltaviewheight")) plr->deltaviewheight = luaL_checkfixed(L, 3); else if (fastcmp(field,"bob")) - plr->bob = luaL_checkfixed(L, 3); + plr->bob = luaL_checkfixed(L, 3);*/ else if (fastcmp(field,"aiming")) { plr->aiming = luaL_checkangle(L, 3); if (plr == &players[consoleplayer]) diff --git a/src/m_cheat.c b/src/m_cheat.c index cd08264d..c453e5d9 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -1130,7 +1130,7 @@ void OP_ObjectplaceMovement(player_t *player) player->mo->eflags &= ~MFE_VERTICALFLIP; // make sure viewz follows player if in 1st person mode - player->deltaviewheight = 0; + //player->deltaviewheight = 0; player->viewheight = FixedMul(cv_viewheight.value << FRACBITS, player->mo->scale); if (player->mo->eflags & MFE_VERTICALFLIP) player->viewz = player->mo->z + player->mo->height - player->viewheight; diff --git a/src/p_mobj.c b/src/p_mobj.c index 286fa292..3c09ee2d 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2738,8 +2738,8 @@ static void P_PlayerZMovement(mobj_t *mo) else mo->player->viewheight -= mo->floorz - mo->z; - mo->player->deltaviewheight = - (FixedMul(cv_viewheight.value<scale) - mo->player->viewheight)>>3; + /*mo->player->deltaviewheight = + (FixedMul(cv_viewheight.value<scale) - mo->player->viewheight)>>3;*/ } // adjust height @@ -2812,8 +2812,9 @@ static void P_PlayerZMovement(mobj_t *mo) mo->pmomz = 0; // We're on a new floor, don't keep doing platform movement. // Squat down. Decrease viewheight for a moment after hitting the ground (hard), - if (P_MobjFlip(mo)*mo->momz < -FixedMul(8*FRACUNIT, mo->scale)) + /*if (P_MobjFlip(mo)*mo->momz < -FixedMul(8*FRACUNIT, mo->scale)) mo->player->deltaviewheight = (P_MobjFlip(mo)*mo->momz)>>3; // make sure momz is negative + */ if (!tmfloorthing || tmfloorthing->flags & (MF_PUSHABLE|MF_MONITOR) || tmfloorthing->flags2 & MF2_STANDONME || tmfloorthing->type == MT_PLAYER) // Spin Attack diff --git a/src/p_user.c b/src/p_user.c index 467a5057..dab7d1c9 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -63,7 +63,7 @@ static void P_NukeAllPlayers(player_t *player); // // 16 pixels of bob -#define MAXBOB (0x10 << FRACBITS) +//#define MAXBOB (0x10 << FRACBITS) static boolean onground; @@ -179,9 +179,9 @@ boolean P_AutoPause(void) // void P_CalcHeight(player_t *player) { - INT32 angle; - fixed_t bob; - fixed_t pviewheight; + //INT32 angle; + //fixed_t bob; + //fixed_t pviewheight; mobj_t *mo = player->mo; // Regular movement bobbing. @@ -190,11 +190,11 @@ void P_CalcHeight(player_t *player) // Note: a LUT allows for effects // like a ramp with low health. - player->bob = (FixedMul(player->rmomx,player->rmomx) + /*player->bob = (FixedMul(player->rmomx,player->rmomx) + FixedMul(player->rmomy,player->rmomy))>>2; if (player->bob > FixedMul(MAXBOB, mo->scale)) - player->bob = FixedMul(MAXBOB, mo->scale); + player->bob = FixedMul(MAXBOB, mo->scale);*/ if (!P_IsObjectOnGround(mo)) { @@ -213,13 +213,13 @@ void P_CalcHeight(player_t *player) return; } - angle = (FINEANGLES/20*localgametic)&FINEMASK; - bob = FixedMul(player->bob/2, FINESINE(angle)); + //angle = (FINEANGLES/20*localgametic)&FINEMASK; + //bob = FixedMul(player->bob/2, FINESINE(angle)); // move viewheight - pviewheight = FixedMul(cv_viewheight.value << FRACBITS, mo->scale); // default eye view height + player->viewheight = FixedMul(cv_viewheight.value << FRACBITS, mo->scale); // default eye view height - if (player->playerstate == PST_LIVE) + /*if (player->playerstate == PST_LIVE) { player->viewheight += player->deltaviewheight; @@ -242,12 +242,12 @@ void P_CalcHeight(player_t *player) if (!player->deltaviewheight) player->deltaviewheight = 1; } - } + }*/ if (player->mo->eflags & MFE_VERTICALFLIP) - player->viewz = mo->z + mo->height - player->viewheight - bob; + player->viewz = mo->z + mo->height - player->viewheight; //- bob else - player->viewz = mo->z + player->viewheight + bob; + player->viewz = mo->z + player->viewheight; //+ bob if (player->viewz > mo->ceilingz-FixedMul(4*FRACUNIT, mo->scale)) player->viewz = mo->ceilingz-FixedMul(4*FRACUNIT, mo->scale); @@ -7992,7 +7992,7 @@ void P_FindEmerald(void) static void P_DeathThink(player_t *player) { ticcmd_t *cmd = &player->cmd; - player->deltaviewheight = 0; + //player->deltaviewheight = 0; if (player->deadtimer < INT32_MAX) player->deadtimer++; @@ -8160,25 +8160,25 @@ static CV_PossibleValue_t CV_CamRotate[] = {{-720, "MIN"}, {720, "MAX"}, {0, NUL consvar_t cv_cam_dist = {"cam_dist", "160", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam_height = {"cam_height", "50", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam_still = {"cam_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam_speed = {"cam_speed", "0.3", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam_speed = {"cam_speed", "0.45", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam_rotate = {"cam_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam_rotspeed = {"cam_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam2_dist = {"cam2_dist", "160", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam2_height = {"cam2_height", "50", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam2_still = {"cam2_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam2_speed = {"cam2_speed", "0.3", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam2_speed = {"cam2_speed", "0.45", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam2_rotate = {"cam2_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate2_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam2_rotspeed = {"cam2_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam3_dist = {"cam3_dist", "160", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam3_height = {"cam3_height", "50", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam3_still = {"cam3_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam3_speed = {"cam3_speed", "0.3", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam3_speed = {"cam3_speed", "0.45", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam3_rotate = {"cam3_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate3_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam3_rotspeed = {"cam3_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam4_dist = {"cam4_dist", "160", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam4_height = {"cam4_height", "50", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam4_still = {"cam4_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam4_speed = {"cam4_speed", "0.3", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam4_speed = {"cam4_speed", "0.45", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam4_rotate = {"cam4_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate4_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam4_rotspeed = {"cam4_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -8244,7 +8244,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall angle_t angle = 0, focusangle = 0, focusaiming = 0; fixed_t x, y, z, dist, height, checkdist, viewpointx, viewpointy, camspeed, camdist, camheight, pviewheight; INT32 camrotate; - boolean camstill, cameranoclip; + boolean camstill, cameranoclip, lookback; mobj_t *mo; subsector_t *newsubsec; fixed_t f1, f2; @@ -8353,6 +8353,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall camrotate = cv_cam_rotate.value; camdist = FixedMul(cv_cam_dist.value, mapheaderinfo[gamemap-1]->mobj_scale); camheight = FixedMul(cv_cam_height.value, mapheaderinfo[gamemap-1]->mobj_scale); + lookback = camspin; } else if (thiscam == &camera2) // Camera 2 { @@ -8361,6 +8362,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall camrotate = cv_cam2_rotate.value; camdist = FixedMul(cv_cam2_dist.value, mapheaderinfo[gamemap-1]->mobj_scale); camheight = FixedMul(cv_cam2_height.value, mapheaderinfo[gamemap-1]->mobj_scale); + lookback = camspin2; } else if (thiscam == &camera3) // Camera 3 { @@ -8369,6 +8371,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall camrotate = cv_cam3_rotate.value; camdist = FixedMul(cv_cam3_dist.value, mapheaderinfo[gamemap-1]->mobj_scale); camheight = FixedMul(cv_cam3_height.value, mapheaderinfo[gamemap-1]->mobj_scale); + lookback = camspin3; } else // Camera 4 { @@ -8377,12 +8380,16 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall camrotate = cv_cam4_rotate.value; camdist = FixedMul(cv_cam4_dist.value, mapheaderinfo[gamemap-1]->mobj_scale); camheight = FixedMul(cv_cam4_height.value, mapheaderinfo[gamemap-1]->mobj_scale); + lookback = camspin4; } + // SRB2kart - Camera flipper + if (lookback) + camrotate += 180; + #ifdef REDSANALOG if (P_AnalogMove(player) && (player->cmd.buttons & (BT_FORWARD|BT_BACKWARD)) == (BT_FORWARD|BT_BACKWARD)) { camstill = true; - if (camspeed < 4*FRACUNIT/5) camspeed = 4*FRACUNIT/5; } @@ -8437,43 +8444,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall thiscam->angle = angle; } - // SRB2kart - Camera flipper - if (!objectplacing && displayplayer == consoleplayer) - { - if (player->kartstuff[k_camspin] == 1) - { - if (thiscam == &camera) - { - CV_SetValue(&cv_cam_rotate, camrotate + 180); - } - else if (thiscam == &camera2) - { - CV_SetValue(&cv_cam2_rotate, camrotate + 180); - } - else if (thiscam == &camera3) - { - CV_SetValue(&cv_cam3_rotate, camrotate + 180); - } - else - { - CV_SetValue(&cv_cam4_rotate, camrotate + 180); - } - player->kartstuff[k_camspin] = 2; - } - if (player->kartstuff[k_camspin] == -1) - { - if (thiscam == &camera) - { - CV_SetValue(&cv_cam_rotate, camrotate - 180); - } - else - { - CV_SetValue(&cv_cam2_rotate, camrotate - 180); - } - player->kartstuff[k_camspin] = 0; - } - } - /* // SRB2kart - camera controls are disabled... for now. if (!objectplacing && !(twodlevel || (mo->flags2 & MF2_TWOD)) && !(player->pflags & PF_NIGHTSMODE) && displayplayer == consoleplayer) { @@ -8791,7 +8761,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall // point viewed by the camera // this point is just 64 unit forward the player - dist = FixedMul(64 << FRACBITS, mo->scale); + dist = FixedMul(64 << FRACBITS, mapheaderinfo[gamemap-1]->mobj_scale); viewpointx = mo->x + FixedMul(FINECOSINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist); viewpointy = mo->y + FixedMul(FINESINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist); @@ -10032,7 +10002,7 @@ void P_PlayerAfterThink(player_t *player) else { // defaults to make sure 1st person cam doesn't do anything weird on startup - player->deltaviewheight = 0; + //player->deltaviewheight = 0; player->viewheight = FixedMul(cv_viewheight.value << FRACBITS, player->mo->scale); if (player->mo->eflags & MFE_VERTICALFLIP) player->viewz = player->mo->z + player->mo->height - player->viewheight; From 8bb4259de85a281a01ea1c306bf466d8e68b09e4 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Mon, 22 Jan 2018 18:39:53 -0500 Subject: [PATCH 2/4] Fixed brakes --- src/g_game.c | 15 ++++++++++++--- src/hu_stuff.c | 5 +++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 8d8ed407..f2f07493 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1368,7 +1368,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (InputDown(gc_brake, ssplayer)) { cmd->buttons |= BT_BRAKE; - forward -= forwardmove[0]; // 25 - Halved value so clutching is possible + if (cmd->buttons & BT_ACCELERATE || cmd->forwardmove <= 0) + forward -= forwardmove[0]; // 25 - Halved value so clutching is possible } // But forward/backward IS used for aiming. axis = JoyAxis(AXISMOVE, ssplayer); @@ -1544,8 +1545,16 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) side = temp; } - cmd->forwardmove = (SINT8)(cmd->forwardmove + forward); - cmd->sidemove = (SINT8)(cmd->sidemove + side); + if (cmd->buttons & BT_BRAKE && !forward) // Sal: If you're not accelerating, but going forward, then you should just lose your momentum. Request from Sev + { + cmd->forwardmove = (SINT8)(cmd->forwardmove / 2); + cmd->sidemove = (SINT8)(cmd->sidemove / 2); + } + else + { + cmd->forwardmove = (SINT8)(cmd->forwardmove + forward); + cmd->sidemove = (SINT8)(cmd->sidemove + side); + } if (cv_kartmirror.value) cmd->sidemove = -cmd->sidemove; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index abc94f59..24e4da10 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1171,7 +1171,8 @@ void HU_Drawer(void) return; // draw the crosshair, not when viewing demos nor with chasecam - if (!automapactive && cv_crosshair.value && !demoplayback && !camera.chase && !players[displayplayer].spectator) + // SRB2kart: not for kart though :V + /*if (!automapactive && cv_crosshair.value && !demoplayback && !camera.chase && !players[displayplayer].spectator) HU_DrawCrosshair(); if (!automapactive && cv_crosshair2.value && !demoplayback && !camera2.chase && !players[secondarydisplayplayer].spectator) @@ -1181,7 +1182,7 @@ void HU_Drawer(void) HU_DrawCrosshair3(); if (!automapactive && cv_crosshair4.value && !demoplayback && !camera4.chase && !players[fourthdisplayplayer].spectator) - HU_DrawCrosshair4(); + HU_DrawCrosshair4();*/ // draw desynch text if (hu_resynching) From 41250d1751677d6bba412ff79a24d535056514ae Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Mon, 22 Jan 2018 19:19:17 -0500 Subject: [PATCH 3/4] Commiting what I have currently, but disabled --- src/p_user.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index dab7d1c9..b9a1924d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8872,6 +8872,17 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall thiscam->aiming = ANGLE_22h; } +#if 0 + // SRB2Kart: keep camera the same distance away from the player, while maintaining its angle + { + fixed_t xlen = (thiscam->x+thiscam->momx) - (mo->x+mo->momx); + fixed_t ylen = (thiscam->y+thiscam->momy) - (mo->y+mo->momy); + fixed_t xydist = P_AproxDistance(xlen, ylen); + thiscam->momx = FixedMul(dist, FixedDiv(xlen, xydist)); + thiscam->momy = FixedMul(dist, FixedDiv(ylen, xydist)); + } +#endif + return (x == thiscam->x && y == thiscam->y && z == thiscam->z && angle == thiscam->aiming); } From 8b88a2ebd8f6cc8b05e97a24898a50a1eef46d49 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Mon, 22 Jan 2018 22:18:57 -0500 Subject: [PATCH 4/4] Spectating is properly implemented now - Spectate button works - Spectating & objectplace controls are usable now - New spectator HUD --- src/d_netcmd.c | 192 +++++++++++++++++++++++++++++++++++++++++++++++-- src/g_game.c | 155 +++++++++++++++++---------------------- src/k_kart.c | 54 ++++++++------ src/m_cheat.c | 16 ++--- src/p_mobj.c | 8 +-- src/p_user.c | 36 ++++++++-- src/st_stuff.c | 18 ++--- 7 files changed, 338 insertions(+), 141 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 11c9acff..b8eb5ec8 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2477,9 +2477,9 @@ static void Command_Teamchange2_f(void) if (COM_Argc() <= 1) { if (G_GametypeHasTeams()) - CONS_Printf(M_GetText("changeteam : switch to a new team (%s)\n"), "red, blue or spectator"); + CONS_Printf(M_GetText("changeteam2 : switch to a new team (%s)\n"), "red, blue or spectator"); else if (G_GametypeHasSpectators()) - CONS_Printf(M_GetText("changeteam : switch to a new team (%s)\n"), "spectator or playing"); + CONS_Printf(M_GetText("changeteam2 : switch to a new team (%s)\n"), "spectator or playing"); else CONS_Alert(CONS_NOTICE, M_GetText("This command cannot be used in this gametype.\n")); return; @@ -2563,12 +2563,196 @@ static void Command_Teamchange2_f(void) static void Command_Teamchange3_f(void) { - ; + changeteam_union NetPacket; + boolean error = false; + UINT16 usvalue; + NetPacket.value.l = NetPacket.value.b = 0; + + // 0 1 + // changeteam3 + + if (COM_Argc() <= 1) + { + if (G_GametypeHasTeams()) + CONS_Printf(M_GetText("changeteam3 : switch to a new team (%s)\n"), "red, blue or spectator"); + else if (G_GametypeHasSpectators()) + CONS_Printf(M_GetText("changeteam3 : switch to a new team (%s)\n"), "spectator or playing"); + else + CONS_Alert(CONS_NOTICE, M_GetText("This command cannot be used in this gametype.\n")); + return; + } + + if (G_GametypeHasTeams()) + { + if (!strcasecmp(COM_Argv(1), "red") || !strcasecmp(COM_Argv(1), "1")) + NetPacket.packet.newteam = 1; + else if (!strcasecmp(COM_Argv(1), "blue") || !strcasecmp(COM_Argv(1), "2")) + NetPacket.packet.newteam = 2; + else if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) + NetPacket.packet.newteam = 0; + else + error = true; + } + else if (G_GametypeHasSpectators()) + { + if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) + NetPacket.packet.newteam = 0; + else if (!strcasecmp(COM_Argv(1), "playing") || !strcasecmp(COM_Argv(1), "1")) + NetPacket.packet.newteam = 3; + else + error = true; + } + + else + { + CONS_Alert(CONS_NOTICE, M_GetText("This command cannot be used in this gametype.\n")); + return; + } + + if (error) + { + if (G_GametypeHasTeams()) + CONS_Printf(M_GetText("changeteam3 : switch to a new team (%s)\n"), "red, blue or spectator"); + else if (G_GametypeHasSpectators()) + CONS_Printf(M_GetText("changeteam3 : switch to a new team (%s)\n"), "spectator or playing"); + return; + } + + if (G_GametypeHasTeams()) + { + if (NetPacket.packet.newteam == (unsigned)players[thirddisplayplayer].ctfteam || + (players[thirddisplayplayer].spectator && !NetPacket.packet.newteam)) + error = true; + } + else if (G_GametypeHasSpectators()) + { + if ((players[thirddisplayplayer].spectator && !NetPacket.packet.newteam) || + (!players[thirddisplayplayer].spectator && NetPacket.packet.newteam == 3)) + error = true; + } +#ifdef PARANOIA + else + I_Error("Invalid gametype after initial checks!"); +#endif + + if (error) + { + CONS_Alert(CONS_NOTICE, M_GetText("You're already on that team!\n")); + return; + } + + if (!cv_allowteamchange.value && NetPacket.packet.newteam) // allow swapping to spectator even in locked teams. + { + CONS_Alert(CONS_NOTICE, M_GetText("The server is not allowing team changes at the moment.\n")); + return; + } + + //additional check for hide and seek. Don't allow change of status after hidetime ends. + if (gametype == GT_HIDEANDSEEK && leveltime >= (hidetime * TICRATE)) + { + CONS_Alert(CONS_NOTICE, M_GetText("Hiding time expired; no Hide and Seek status changes allowed!\n")); + return; + } + + usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); + SendNetXCmd3(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); } static void Command_Teamchange4_f(void) { - ; + changeteam_union NetPacket; + boolean error = false; + UINT16 usvalue; + NetPacket.value.l = NetPacket.value.b = 0; + + // 0 1 + // changeteam4 + + if (COM_Argc() <= 1) + { + if (G_GametypeHasTeams()) + CONS_Printf(M_GetText("changeteam4 : switch to a new team (%s)\n"), "red, blue or spectator"); + else if (G_GametypeHasSpectators()) + CONS_Printf(M_GetText("changeteam4 : switch to a new team (%s)\n"), "spectator or playing"); + else + CONS_Alert(CONS_NOTICE, M_GetText("This command cannot be used in this gametype.\n")); + return; + } + + if (G_GametypeHasTeams()) + { + if (!strcasecmp(COM_Argv(1), "red") || !strcasecmp(COM_Argv(1), "1")) + NetPacket.packet.newteam = 1; + else if (!strcasecmp(COM_Argv(1), "blue") || !strcasecmp(COM_Argv(1), "2")) + NetPacket.packet.newteam = 2; + else if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) + NetPacket.packet.newteam = 0; + else + error = true; + } + else if (G_GametypeHasSpectators()) + { + if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) + NetPacket.packet.newteam = 0; + else if (!strcasecmp(COM_Argv(1), "playing") || !strcasecmp(COM_Argv(1), "1")) + NetPacket.packet.newteam = 3; + else + error = true; + } + + else + { + CONS_Alert(CONS_NOTICE, M_GetText("This command cannot be used in this gametype.\n")); + return; + } + + if (error) + { + if (G_GametypeHasTeams()) + CONS_Printf(M_GetText("changeteam4 : switch to a new team (%s)\n"), "red, blue or spectator"); + else if (G_GametypeHasSpectators()) + CONS_Printf(M_GetText("changeteam4 : switch to a new team (%s)\n"), "spectator or playing"); + return; + } + + if (G_GametypeHasTeams()) + { + if (NetPacket.packet.newteam == (unsigned)players[fourthdisplayplayer].ctfteam || + (players[fourthdisplayplayer].spectator && !NetPacket.packet.newteam)) + error = true; + } + else if (G_GametypeHasSpectators()) + { + if ((players[fourthdisplayplayer].spectator && !NetPacket.packet.newteam) || + (!players[fourthdisplayplayer].spectator && NetPacket.packet.newteam == 3)) + error = true; + } +#ifdef PARANOIA + else + I_Error("Invalid gametype after initial checks!"); +#endif + + if (error) + { + CONS_Alert(CONS_NOTICE, M_GetText("You're already on that team!\n")); + return; + } + + if (!cv_allowteamchange.value && NetPacket.packet.newteam) // allow swapping to spectator even in locked teams. + { + CONS_Alert(CONS_NOTICE, M_GetText("The server is not allowing team changes at the moment.\n")); + return; + } + + //additional check for hide and seek. Don't allow change of status after hidetime ends. + if (gametype == GT_HIDEANDSEEK && leveltime >= (hidetime * TICRATE)) + { + CONS_Alert(CONS_NOTICE, M_GetText("Hiding time expired; no Hide and Seek status changes allowed!\n")); + return; + } + + usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); + SendNetXCmd4(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); } static void Command_ServerTeamChange_f(void) diff --git a/src/g_game.c b/src/g_game.c index f2f07493..cb20dbe8 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1343,62 +1343,43 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } } - /* - axis = JoyAxis(AXISSTRAFE, ssplayer); - if (gamepadjoystickmove && axis != 0) + if (player->spectator || objectplacing) // SRB2Kart: spectators need special controls { - if (axis < 0) - side += sidemove[speed]; - else if (axis > 0) - side -= sidemove[speed]; + if (InputDown(gc_accelerate, ssplayer)) + cmd->buttons |= BT_ACCELERATE; + if (InputDown(gc_brake, ssplayer)) + cmd->buttons |= BT_BRAKE; + axis = JoyAxis(AXISMOVE, ssplayer); + if (InputDown(gc_aimforward, ssplayer) || (gamepadjoystickmove && axis < 0) || (analogjoystickmove && axis < 0)) + forward += forwardmove[1]; + if (InputDown(gc_aimbackward, ssplayer) || (gamepadjoystickmove && axis > 0) || (analogjoystickmove && axis > 0)) + forward -= forwardmove[1]; } - else if (analogjoystickmove && axis != 0) + else { - // JOYAXISRANGE is supposed to be 1023 (divide by 1024) - side += ((axis * sidemove[1]) >> 10); + // forward with key or button // SRB2kart - we use an accel/brake instead of forward/backward. + if (InputDown(gc_accelerate, ssplayer) || player->kartstuff[k_mushroomtimer]) + { + cmd->buttons |= BT_ACCELERATE; + forward = forwardmove[1]; // 50 + } + + if (InputDown(gc_brake, ssplayer)) + { + cmd->buttons |= BT_BRAKE; + if (cmd->buttons & BT_ACCELERATE || cmd->forwardmove <= 0) + forward -= forwardmove[0]; // 25 - Halved value so clutching is possible + } + + // But forward/backward IS used for aiming. + axis = JoyAxis(AXISMOVE, ssplayer); + if (InputDown(gc_aimforward, ssplayer) || (gamepadjoystickmove && axis < 0) || (analogjoystickmove && axis < 0)) + cmd->buttons |= BT_FORWARD; + if (InputDown(gc_aimbackward, ssplayer) || (gamepadjoystickmove && axis > 0) || (analogjoystickmove && axis > 0)) + cmd->buttons |= BT_BACKWARD; } - */ - // forward with key or button // SRB2kart - we use an accel/brake instead of forward/backward. - if (InputDown(gc_accelerate, ssplayer) || player->kartstuff[k_mushroomtimer]) - { - cmd->buttons |= BT_ACCELERATE; - forward = forwardmove[1]; // 50 - } - if (InputDown(gc_brake, ssplayer)) - { - cmd->buttons |= BT_BRAKE; - if (cmd->buttons & BT_ACCELERATE || cmd->forwardmove <= 0) - forward -= forwardmove[0]; // 25 - Halved value so clutching is possible - } - // But forward/backward IS used for aiming. - axis = JoyAxis(AXISMOVE, ssplayer); - if (InputDown(gc_aimforward, ssplayer) || (gamepadjoystickmove && axis < 0) || (analogjoystickmove && axis < 0)) - cmd->buttons |= BT_FORWARD; - if (InputDown(gc_aimbackward, ssplayer) || (gamepadjoystickmove && axis > 0) || (analogjoystickmove && axis > 0)) - cmd->buttons |= BT_BACKWARD; - /* - if (InputDown(gc_forward, ssplayer) || (gamepadjoystickmove && axis < 0)) - forward = forwardmove[speed]; - if (InputDown(gc_backward, ssplayer) || (gamepadjoystickmove && axis > 0)) - forward -= forwardmove[speed]; - */ - - /* - if (analogjoystickmove && axis != 0) - forward -= ((axis * forwardmove[1]) >> 10); // ANALOG! - */ - - // some people strafe left & right with mouse buttons - // those people are weird - - /* // SRB2kart - these aren't used in kart - if (InputDown(gc_straferight, ssplayer)) - side += sidemove[speed]; - if (InputDown(gc_strafeleft, ssplayer)) - side -= sidemove[speed]; - - if (InputDown(gc_driftleft, ssplayer)) + /*if (InputDown(gc_driftleft, ssplayer)) cmd->buttons |= BT_WEAPONNEXT; // Next Weapon if (InputDown(gc_driftright, ssplayer)) cmd->buttons |= BT_WEAPONPREV; // Previous Weapon @@ -1428,26 +1409,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->buttons |= BT_ACCELERATE; */ - if (InputDown(gc_spectate, ssplayer)) - cmd->buttons |= BT_SPECTATE; - - // SRB2Kart: look backward - if (InputDown(gc_lookback, ssplayer)) - - // Lua scriptable buttons - if (InputDown(gc_custom1, ssplayer)) - cmd->buttons |= BT_CUSTOM1; - if (InputDown(gc_custom2, ssplayer)) - cmd->buttons |= BT_CUSTOM2; - if (InputDown(gc_custom3, ssplayer)) - cmd->buttons |= BT_CUSTOM3; - - // use with any button/key - /* - if (InputDown(gc_brake, ssplayer)) - cmd->buttons |= BT_BRAKE; - */ - // Camera Controls /* if (cv_debug || cv_analog.value || demoplayback || objectplacing || player->pflags & PF_NIGHTSMODE) @@ -1463,6 +1424,17 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (InputDown(gc_jump, ssplayer)) cmd->buttons |= BT_JUMP; + if (InputDown(gc_spectate, ssplayer)) + cmd->buttons |= BT_SPECTATE; + + // Lua scriptable buttons + if (InputDown(gc_custom1, ssplayer)) + cmd->buttons |= BT_CUSTOM1; + if (InputDown(gc_custom2, ssplayer)) + cmd->buttons |= BT_CUSTOM2; + if (InputDown(gc_custom3, ssplayer)) + cmd->buttons |= BT_CUSTOM3; + // player aiming shit, ahhhh... { INT32 player_invert = invertmouse ? -1 : 1; @@ -1559,6 +1531,19 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (cv_kartmirror.value) cmd->sidemove = -cmd->sidemove; + if (ssplayer == 2 && player->bot == 1) { + if (!player->powers[pw_tailsfly] && (cmd->forwardmove || cmd->sidemove || cmd->buttons)) + { + player->bot = 2; // A player-controlled bot. Returns to AI when it respawns. + CV_SetValue(&cv_analog2, true); + } + else + { + G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); // empty, or external driver + B_BuildTiccmd(player, cmd); + } + } + //{ SRB2kart - Drift support axis = JoyAxis(AXISTURN, ssplayer); if (cv_kartmirror.value) @@ -1575,19 +1560,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->buttons &= ~BT_DRIFTRIGHT; //} - if (ssplayer == 2 && player->bot == 1) { - if (!player->powers[pw_tailsfly] && (cmd->forwardmove || cmd->sidemove || cmd->buttons)) - { - player->bot = 2; // A player-controlled bot. Returns to AI when it respawns. - CV_SetValue(&cv_analog2, true); - } - else - { - G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); // empty, or external driver - B_BuildTiccmd(player, cmd); - } - } - if (analog) { cmd->angleturn = (INT16)(thiscam->angle >> 16); if (player->awayviewtics) @@ -1605,7 +1577,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->angleturn = K_GetKartTurnValue(player, cmd->angleturn); // SRB2kart - no additional angle if not moving - if ((player->mo && player->speed > 0) || (leveltime > 140 && (cmd->buttons & BT_ACCELERATE) && (cmd->buttons & BT_BRAKE))) + if ((player->mo && player->speed > 0) || (leveltime > 140 && cmd->buttons & BT_ACCELERATE && cmd->buttons & BT_BRAKE) || (player->spectator || objectplacing)) lang += (cmd->angleturn<<16); cmd->angleturn = (INT16)(lang >> 16); @@ -1899,11 +1871,12 @@ boolean G_Responder(event_t *ev) continue; }*/ - if (gametype != GT_RACE) // srb2kart + // SRB2Kart: Ehhh, who cares, Mario Kart's designed around screen-cheating anyway + /*if (gametype != GT_RACE) { if (players[consoleplayer].kartstuff[k_balloon] > 0) continue; - } + }*/ break; } while (displayplayer != consoleplayer); @@ -2983,8 +2956,12 @@ boolean G_GametypeHasTeams(void) // boolean G_GametypeHasSpectators(void) { - return (gametype != GT_COOP && gametype != GT_COMPETITION && gametype != GT_RACE - && gametype != GT_MATCH); // srb2kart: temporary? + // SRB2Kart: We don't have any exceptions to not being able to spectate yet. Maybe when SP & bots roll around. +#if 0 + return (gametype != GT_COOP && gametype != GT_COMPETITION && gametype != GT_RACE); +#else + return true; +#endif } // diff --git a/src/k_kart.c b/src/k_kart.c index 4ceb8b72..9e54559b 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2767,6 +2767,9 @@ INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue) fixed_t p_maxspeed = FixedMul(K_GetKartSpeed(player, false), 3*FRACUNIT); fixed_t adjustangle = FixedDiv((p_maxspeed>>16) - (player->speed>>16), (p_maxspeed>>16) + player->kartweight); + if (player->spectator) + return turnvalue; + if (player->kartstuff[k_feather] & 2 && !P_IsObjectOnGround(player->mo)) adjustangle /= 2; @@ -4682,9 +4685,12 @@ static void K_drawKartPositionFaces(void) if (!playeringame[j]) continue; + if (players[j].spectator) + continue; + for (i = 0; i < MAXPLAYERS; i++) { - if (playeringame[i] && completed[i] == false + if (playeringame[i] && completed[i] == false && players[i].mo && !players[i].spectator && (rankplayer[ranklines] < 0 || players[i].kartstuff[k_position] < players[rankplayer[ranklines]].kartstuff[k_position])) { rankplayer[ranklines] = i; @@ -4839,7 +4845,7 @@ static void K_drawKartSpeedometer(void) static void K_drawKartBalloonsOrKarma(void) { - UINT8 *colormap = R_GetTranslationColormap(-1, stplyr->skincolor, 0); + UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, stplyr->skincolor, 0); INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT); if (splitscreen > 1) @@ -4916,6 +4922,9 @@ static void K_drawKartPlayerCheck(void) if (stplyr->awayviewtics) return; + if (camspin) + return; + for (i = 0; i < MAXPLAYERS; i++) { if (&players[i] == stplyr) @@ -4950,7 +4959,7 @@ static void K_drawKartPlayerCheck(void) else if (x > 306) x = 306; - colormap = R_GetTranslationColormap(-1, players[i].mo->color, 0); + colormap = R_GetTranslationColormap(TC_DEFAULT, players[i].mo->color, 0); V_DrawMappedPatch(x, CHEK_Y, V_HUDTRANS|splitflags, localpatch, colormap); } } @@ -5358,28 +5367,31 @@ void K_drawKartHUD(void) } } - if (gametype == GT_RACE) // Race-only elements + if (!stplyr->spectator) // Bottom of the screen elements, don't need in spectate mode { - // Draw the lap counter - K_drawKartLaps(); - - if (!splitscreen) + if (gametype == GT_RACE) // Race-only elements { - // Draw the speedometer - // TODO: Make a better speedometer. - K_drawKartSpeedometer(); - } + // Draw the lap counter + K_drawKartLaps(); - if (!modeattacking) - { - // Draw the numerical position - K_DrawKartPositionNum(stplyr->kartstuff[k_position]); + if (!splitscreen) + { + // Draw the speedometer + // TODO: Make a better speedometer. + K_drawKartSpeedometer(); + } + + if (!modeattacking) + { + // Draw the numerical position + K_DrawKartPositionNum(stplyr->kartstuff[k_position]); + } + } + else if (gametype == GT_MATCH) // Battle-only + { + // Draw the hits left! + K_drawKartBalloonsOrKarma(); } - } - else if (gametype == GT_MATCH) // Battle-only - { - // Draw the hits left! - K_drawKartBalloonsOrKarma(); } } diff --git a/src/m_cheat.c b/src/m_cheat.c index c453e5d9..afa2663c 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -1101,7 +1101,7 @@ void OP_ObjectplaceMovement(player_t *player) if (!(cmd->angleturn & TICCMD_RECEIVED)) ticmiss++; - if (cmd->buttons & BT_JUMP) + if (cmd->buttons & BT_ACCELERATE) player->mo->z += FRACUNIT*cv_speed.value; else if (cmd->buttons & BT_BRAKE) player->mo->z -= FRACUNIT*cv_speed.value; @@ -1167,19 +1167,19 @@ void OP_ObjectplaceMovement(player_t *player) if (player->pflags & PF_ATTACKDOWN) { // Are ANY objectplace buttons pressed? If no, remove flag. - if (!(cmd->buttons & (BT_ATTACK|BT_SPECTATE|BT_BACKWARD|BT_FORWARD))) + if (!(cmd->buttons & (BT_ATTACK|BT_JUMP))) player->pflags &= ~PF_ATTACKDOWN; // Do nothing. return; } - if (cmd->buttons & BT_FORWARD) + /*if (cmd->buttons & BT_FORWARD) { OP_CycleThings(-1); player->pflags |= PF_ATTACKDOWN; } - else if (cmd->buttons & BT_BACKWARD) + else*/ if (cmd->buttons & BT_JUMP) { OP_CycleThings(1); player->pflags |= PF_ATTACKDOWN; @@ -1266,10 +1266,10 @@ void Command_ObjectPlace_f(void) HU_DoCEcho(va(M_GetText( "\\\\\\\\\\\\\\\\\\\\\\\\\x82" " Objectplace Controls: \x80\\\\" - "Camera L/R: Cycle mapthings\\" - " Jump: Float up \\" - " Spin: Float down \\" - " Fire Ring: Place object \\"))); + " Drift: Cycle mapthings\\" + "Accelerate: Float up \\" + " Brake: Float down \\" + " Item: Place object \\"))); } // Save all the player's data. diff --git a/src/p_mobj.c b/src/p_mobj.c index 3c09ee2d..184166b8 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9468,7 +9468,10 @@ void P_SpawnPlayer(INT32 playernum) p->spectator = false; } else if (netgame && p->jointime < 1) - /*p->spectator = true*/; + { + //p->spectator = true; + p->kartstuff[k_comebackshowninfo] = 0; + } else if (multiplayer && !netgame) { // If you're in a team game and you don't have a team assigned yet... @@ -9545,9 +9548,6 @@ void P_SpawnPlayer(INT32 playernum) overheadarrow->flags2 |= MF2_DONTDRAW; P_SetScale(overheadarrow, mobj->destscale); - if (leveltime < 1) - p->kartstuff[k_comebackshowninfo] = 0; - if (gametype != GT_RACE) { /*INT32 i; diff --git a/src/p_user.c b/src/p_user.c index b9a1924d..f286601d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5067,7 +5067,7 @@ static void P_SpectatorMovement(player_t *player) if (player->mo->z < player->mo->floorz) player->mo->z = player->mo->floorz; - if (cmd->buttons & BT_JUMP) + if (cmd->buttons & BT_ACCELERATE) player->mo->z += FRACUNIT*16; else if (cmd->buttons & BT_BRAKE) player->mo->z -= FRACUNIT*16; @@ -8011,12 +8011,13 @@ static void P_DeathThink(player_t *player) player->playerstate = PST_REBORN; else if (player->lives > 0 && !G_IsSpecialStage(gamemap) && leveltime >= 140) // Don't allow "click to respawn" in special stages! { - // SRB2kart - if (player->spectator) + // SRB2kart-- But wait, why'd we add this? :eggthinking: + /*if (player->spectator) { CONS_Printf("%s entered the game.\n", player_names[player-players]); player->spectator = false; - } + }*/ + //player->kartstuff[k_lakitu] = 48; // See G_PlayerReborn in g_game.c // SRB2kart - spawn automatically after 1 second @@ -8385,7 +8386,12 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall // SRB2kart - Camera flipper if (lookback) + { camrotate += 180; + camspeed *= 2; + if (camspeed > FRACUNIT) + camspeed = FRACUNIT; + } #ifdef REDSANALOG if (P_AnalogMove(player) && (player->cmd.buttons & (BT_FORWARD|BT_BACKWARD)) == (BT_FORWARD|BT_BACKWARD)) { @@ -9379,10 +9385,26 @@ void P_PlayerThink(player_t *player) player->realtime = 0; } - if ((netgame || splitscreen) && player->spectator && cmd->buttons & BT_ATTACK && !player->powers[pw_flashing]) + + if ((netgame || splitscreen) && !player->powers[pw_flashing]) { - if (P_SpectatorJoinGame(player)) - return; // player->mo was removed. + if (player->spectator && cmd->buttons & BT_ATTACK) + { + if (P_SpectatorJoinGame(player)) + return; // player->mo was removed. + } + else if (!player->spectator && cmd->buttons & BT_SPECTATE) + { + if (player == &players[consoleplayer]) + COM_ImmedExecute("changeteam spectator"); + else if (splitscreen && player == &players[secondarydisplayplayer]) + COM_ImmedExecute("changeteam2 spectator"); + else if (splitscreen > 1 && player == &players[thirddisplayplayer]) + COM_ImmedExecute("changeteam3 spectator"); + else if (splitscreen > 2 && player == &players[fourthdisplayplayer]) + COM_ImmedExecute("changeteam4 spectator"); + //return; + } } // Even if not NiGHTS, pull in nearby objects when walking around as John Q. Elliot. diff --git a/src/st_stuff.c b/src/st_stuff.c index 85b74bd2..6a5bc796 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -1951,15 +1951,17 @@ static void ST_overlayDrawer(void) #endif ) { - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(60), V_HUDTRANSHALF, M_GetText("You are a spectator.")); - if (G_GametypeHasTeams()) - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), V_HUDTRANSHALF, M_GetText("Press Fire to be assigned to a team.")); + // SRB2kart: changed positions & text + V_DrawString(2, BASEVIDHEIGHT-50, V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); + /*if (G_GametypeHasTeams()) + V_DrawString(2, BASEVIDHEIGHT-40, V_HUDTRANSHALF, M_GetText("Item - Join Team")); else if (G_IsSpecialStage(gamemap) && useNightsSS) - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), V_HUDTRANSHALF, M_GetText("You cannot join the game until the stage has ended.")); - else - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), V_HUDTRANSHALF, M_GetText("Press Fire to enter the game.")); - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(148), V_HUDTRANSHALF, M_GetText("Press F12 to watch another player.")); - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(164), V_HUDTRANSHALF, M_GetText("Press Jump to float and Spin to sink.")); + V_DrawString(2, BASEVIDHEIGHT-40, V_HUDTRANSHALF|V_REDMAP, M_GetText("- CANNOT JOIN -")); + else*/ + V_DrawString(2, BASEVIDHEIGHT-40, V_HUDTRANSHALF, M_GetText("Item - Enter Game")); + V_DrawString(2, BASEVIDHEIGHT-30, V_HUDTRANSHALF, M_GetText("F12 - Change View")); + V_DrawString(2, BASEVIDHEIGHT-20, V_HUDTRANSHALF, M_GetText("Accelerate - Float")); + V_DrawString(2, BASEVIDHEIGHT-10, V_HUDTRANSHALF, M_GetText("Brake - Sink")); } }