mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-21 11:21:11 +00:00
Automatically rotate camera to reflect player actions
This commit is contained in:
parent
075f751f67
commit
36fa94a22c
4 changed files with 55 additions and 2 deletions
|
@ -826,6 +826,12 @@ void D_RegisterClientCommands(void)
|
|||
// hi here's some new controls
|
||||
CV_RegisterVar(&cv_abilitydirection[0]);
|
||||
CV_RegisterVar(&cv_abilitydirection[1]);
|
||||
CV_RegisterVar(&cv_cam_turnfacing[0]);
|
||||
CV_RegisterVar(&cv_cam_turnfacing[1]);
|
||||
CV_RegisterVar(&cv_cam_turnfacingability[0]);
|
||||
CV_RegisterVar(&cv_cam_turnfacingability[1]);
|
||||
CV_RegisterVar(&cv_cam_turnfacinginput[0]);
|
||||
CV_RegisterVar(&cv_cam_turnfacinginput[1]);
|
||||
|
||||
// s_sound.c
|
||||
CV_RegisterVar(&cv_soundvolume);
|
||||
|
|
43
src/g_game.c
43
src/g_game.c
|
@ -399,6 +399,19 @@ 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},
|
||||
};
|
||||
static CV_PossibleValue_t zerotoone_cons_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}};
|
||||
consvar_t cv_cam_turnfacing[2] = {
|
||||
{"cam_turnfacingchar", "0.002", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"cam2_turnfacingchar", "0.002", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
};
|
||||
consvar_t cv_cam_turnfacingability[2] = {
|
||||
{"cam_turnfacingability", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"cam2_turnfacingability", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
};
|
||||
consvar_t cv_cam_turnfacinginput[2] = {
|
||||
{"cam_turnfacinginput", "0.15", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"cam2_turnfacinginput", "0.15", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -1133,7 +1146,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
|||
{
|
||||
if (turnright)
|
||||
cmd->angleturn = (INT16)(cmd->angleturn - angleturn[tspeed]);
|
||||
else if (turnleft)
|
||||
if (turnleft)
|
||||
cmd->angleturn = (INT16)(cmd->angleturn + angleturn[tspeed]);
|
||||
|
||||
if (analogjoystickmove && axis != 0)
|
||||
|
@ -1360,6 +1373,15 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
|||
*myangle += (cmd->angleturn<<16);
|
||||
cmd->angleturn = (INT16)(*myangle >> 16);
|
||||
|
||||
// Adjust camera angle by player input
|
||||
if (!forcestrafe && !turnheld[forplayer] && !player->climbing)
|
||||
{
|
||||
fixed_t camadjustfactor = cv_cam_turnfacinginput[forplayer].value; //@TODO cvar
|
||||
|
||||
if (camadjustfactor)
|
||||
*myangle -= cmd->sidemove * 50 * camadjustfactor;
|
||||
}
|
||||
|
||||
if (abilitydirection && !player->climbing && !forcestrafe)
|
||||
{
|
||||
if (cmd->forwardmove || cmd->sidemove)
|
||||
|
@ -1375,6 +1397,25 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
|||
else
|
||||
cmd->angleturn = (player->drawangle>>16);
|
||||
}
|
||||
|
||||
// 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 && !turnheld[forplayer])
|
||||
{
|
||||
fixed_t camadjustfactor;
|
||||
|
||||
if (player->climbing || player->pflags & (PF_GLIDING|PF_STARTDASH))
|
||||
camadjustfactor = cv_cam_turnfacingability[forplayer].value;
|
||||
else
|
||||
camadjustfactor = cv_cam_turnfacing[forplayer].value;
|
||||
|
||||
if (camadjustfactor)
|
||||
{
|
||||
INT32 anglediff = player->drawangle - *myangle;
|
||||
|
||||
*myangle += FixedMul(anglediff, camadjustfactor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Reset away view if a command is given.
|
||||
|
|
|
@ -77,7 +77,7 @@ extern consvar_t cv_sideaxis2,cv_turnaxis2,cv_moveaxis2,cv_lookaxis2,cv_jumpaxis
|
|||
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];
|
||||
extern consvar_t cv_abilitydirection[2], cv_cam_turnfacing[2], cv_cam_turnfacingability[2], cv_cam_turnfacinginput[2];
|
||||
|
||||
// mouseaiming (looking up/down with the mouse or keyboard)
|
||||
#define KB_LOOKSPEED (1<<25)
|
||||
|
|
|
@ -5350,6 +5350,12 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd)
|
|||
|
||||
player->pflags &= ~(PF_SPINNING|PF_STARTDASH);
|
||||
player->pflags |= PF_THOKKED;
|
||||
|
||||
// Change localangle to match?
|
||||
if (player == &players[consoleplayer] && cv_cam_turnfacingability[0].value > 0)
|
||||
localangle = player->mo->angle;
|
||||
else if (player == &players[secondarydisplayplayer] && cv_cam_turnfacingability[1].value > 0)
|
||||
localangle2 = player->mo->angle;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in a new issue