mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-19 16:01:35 +00:00
Lock camera behind player when holding cam reset
This also disables abilitydirection movement temporarily.
This commit is contained in:
parent
c99b137298
commit
e4626e9396
3 changed files with 28 additions and 9 deletions
18
src/g_game.c
18
src/g_game.c
|
@ -1006,6 +1006,7 @@ static fixed_t forwardmove[2] = {25<<FRACBITS>>16, 50<<FRACBITS>>16};
|
|||
static fixed_t sidemove[2] = {25<<FRACBITS>>16, 50<<FRACBITS>>16}; // faster!
|
||||
static fixed_t angleturn[3] = {640, 1280, 320}; // + slow turn
|
||||
|
||||
boolean ticcmd_resetdown[2]; // don't cam reset every frame
|
||||
void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
||||
{
|
||||
boolean forcestrafe = false;
|
||||
|
@ -1024,7 +1025,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
|||
|
||||
static INT32 turnheld[2]; // for accelerative turning
|
||||
static boolean keyboard_look[2]; // true if lookup/down using keyboard
|
||||
static boolean resetdown[2]; // don't cam reset every frame
|
||||
static boolean joyaiming[2]; // check the last frame's value if we need to reset the camera
|
||||
UINT8 forplayer = ssplayer-1;
|
||||
|
||||
|
@ -1244,12 +1244,16 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
|||
|
||||
if (PLAYERINPUTDOWN(ssplayer, gc_camreset))
|
||||
{
|
||||
if (camera.chase && !resetdown[forplayer])
|
||||
if (camera.chase && !ticcmd_resetdown[forplayer])
|
||||
{
|
||||
ticcmd_resetdown[forplayer] = true;
|
||||
P_ResetCamera(&players[ssplayer == 1 ? displayplayer : secondarydisplayplayer], &camera);
|
||||
resetdown[forplayer] = true;
|
||||
}
|
||||
else
|
||||
ticcmd_resetdown[forplayer] = true;
|
||||
}
|
||||
else
|
||||
resetdown[forplayer] = false;
|
||||
ticcmd_resetdown[forplayer] = false;
|
||||
|
||||
// jump button
|
||||
axis = PlayerJoyAxis(ssplayer, AXISJUMP);
|
||||
|
@ -1381,7 +1385,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
|||
cmd->angleturn = (INT16)(*myangle >> 16);
|
||||
|
||||
// Adjust camera angle by player input
|
||||
if (!forcestrafe && camera.chase && !turnheld[forplayer] && !player->climbing && player->powers[pw_carry] != CR_MINECART)
|
||||
if (!forcestrafe && camera.chase && !turnheld[forplayer] && !ticcmd_resetdown[forplayer] && !player->climbing && player->powers[pw_carry] != CR_MINECART)
|
||||
{
|
||||
fixed_t camadjustfactor = cv_cam_turnfacinginput[forplayer].value; //@TODO cvar
|
||||
|
||||
|
@ -1389,7 +1393,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
|||
*myangle -= cmd->sidemove * min(50, player->speed / (FRACUNIT/7)) * camadjustfactor;
|
||||
}
|
||||
|
||||
if (abilitydirection && camera.chase && !player->climbing && !forcestrafe && (player->pflags & PF_DIRECTIONCHAR) && player->powers[pw_carry] != CR_MINECART)
|
||||
if (abilitydirection && camera.chase && !ticcmd_resetdown[forplayer] && !player->climbing && !forcestrafe && (player->pflags & PF_DIRECTIONCHAR) && player->powers[pw_carry] != CR_MINECART)
|
||||
{
|
||||
if (cmd->forwardmove || cmd->sidemove)
|
||||
{
|
||||
|
@ -1407,7 +1411,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
|||
|
||||
// Adjust camera angle to face player direction, depending on circumstances
|
||||
// Nothing happens if cam left/right are held, so you can hold both to lock the camera in one direction
|
||||
if (!forcestrafe && camera.chase && !turnheld[forplayer] && player->powers[pw_carry] != CR_MINECART)
|
||||
if (!forcestrafe && camera.chase && !turnheld[forplayer] && !ticcmd_resetdown[forplayer] && player->powers[pw_carry] != CR_MINECART)
|
||||
{
|
||||
fixed_t camadjustfactor;
|
||||
|
||||
|
|
|
@ -86,6 +86,8 @@ extern consvar_t cv_abilitydirection[2], cv_cam_shiftfacing[2], cv_cam_turnfacin
|
|||
|
||||
// build an internal map name MAPxx from map number
|
||||
const char *G_BuildMapName(INT32 map);
|
||||
|
||||
extern boolean ticcmd_resetdown[2]; // don't cam reset every frame
|
||||
void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer);
|
||||
|
||||
// copy ticcmd_t to and fro the normal way
|
||||
|
|
17
src/p_user.c
17
src/p_user.c
|
@ -9651,7 +9651,17 @@ void P_ResetCamera(player_t *player, camera_t *thiscam)
|
|||
thiscam->y = y;
|
||||
thiscam->z = z;
|
||||
|
||||
if (!(thiscam == &camera && (cv_cam_still.value || cv_analog.value))
|
||||
if (thiscam == &camera && cv_abilitydirection[0].value && ticcmd_resetdown[0])
|
||||
{
|
||||
localangle = player->mo->angle;
|
||||
localaiming = thiscam->aiming = 0;
|
||||
}
|
||||
else if (thiscam == &camera2 && cv_abilitydirection[1].value && ticcmd_resetdown[1])
|
||||
{
|
||||
localangle2 = player->mo->angle;
|
||||
localaiming2 = thiscam->aiming = 0;
|
||||
}
|
||||
else if (!(thiscam == &camera && (cv_cam_still.value || cv_analog.value))
|
||||
&& !(thiscam == &camera2 && (cv_cam2_still.value || cv_analog2.value)))
|
||||
{
|
||||
thiscam->angle = player->mo->angle;
|
||||
|
@ -9891,7 +9901,10 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
|||
UINT8 forplayer = (thiscam == &camera) ? 0 : 1;
|
||||
fixed_t shift = FixedMul(FINESINE((player->drawangle - angle) >> ANGLETOFINESHIFT), cv_cam_shiftfacing[forplayer].value);
|
||||
|
||||
shift += FixedMul(camsideshift[forplayer] - shift, FRACUNIT-(camspeed>>3));
|
||||
if (ticcmd_resetdown[(thiscam == &camera) ? 0 : 1])
|
||||
shift = FixedMul(camsideshift[forplayer], FRACUNIT-camspeed);
|
||||
else
|
||||
shift += FixedMul(camsideshift[forplayer] - shift, FRACUNIT-(camspeed>>3));
|
||||
camsideshift[forplayer] = shift;
|
||||
|
||||
shift = FixedMul(shift, camdist);
|
||||
|
|
Loading…
Reference in a new issue