mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-31 13:40:45 +00:00
Move Z-targeting behavior to Center View
This commit is contained in:
parent
f74d7163e6
commit
f1b5a2b2d3
5 changed files with 36 additions and 37 deletions
51
src/g_game.c
51
src/g_game.c
|
@ -1019,7 +1019,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
|
||||
boolean ticcmd_centerviewdown[2]; // For simple controls, lock the camera behind the player
|
||||
void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
||||
{
|
||||
boolean forcestrafe = false;
|
||||
|
@ -1039,6 +1039,7 @@ 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;
|
||||
|
||||
|
@ -1256,26 +1257,34 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
|||
if (PLAYERINPUTDOWN(ssplayer, gc_use) || (usejoystick && axis > 0))
|
||||
cmd->buttons |= BT_USE;
|
||||
|
||||
if (PLAYERINPUTDOWN(ssplayer, gc_centerview))
|
||||
{
|
||||
if (abilitydirection)
|
||||
{
|
||||
CV_SetValue((ssplayer == 1 ? &cv_directionchar : &cv_directionchar2), 0);
|
||||
*myangle = player->mo->angle;
|
||||
*myaiming = 0;
|
||||
}
|
||||
|
||||
ticcmd_centerviewdown[forplayer] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_SetValue((ssplayer == 1 ? &cv_directionchar : &cv_directionchar2), 1);
|
||||
|
||||
ticcmd_centerviewdown[forplayer] = false;
|
||||
}
|
||||
|
||||
if (PLAYERINPUTDOWN(ssplayer, gc_camreset))
|
||||
{
|
||||
if (camera.chase && !ticcmd_resetdown[forplayer])
|
||||
{
|
||||
ticcmd_resetdown[forplayer] = true;
|
||||
if (camera.chase && !resetdown[forplayer])
|
||||
P_ResetCamera(&players[ssplayer == 1 ? displayplayer : secondarydisplayplayer], &camera);
|
||||
|
||||
if (abilitydirection)
|
||||
CV_SetValue((ssplayer == 1 ? &cv_directionchar : &cv_directionchar2), 0);
|
||||
}
|
||||
else
|
||||
ticcmd_resetdown[forplayer] = true;
|
||||
resetdown[forplayer] = true;
|
||||
}
|
||||
else if (ticcmd_resetdown[forplayer])
|
||||
{
|
||||
ticcmd_resetdown[forplayer] = false;
|
||||
else
|
||||
resetdown[forplayer] = false;
|
||||
|
||||
if (abilitydirection)
|
||||
CV_SetValue((ssplayer == 1 ? &cv_directionchar : &cv_directionchar2), 1);
|
||||
}
|
||||
|
||||
// jump button
|
||||
axis = PlayerJoyAxis(ssplayer, AXISJUMP);
|
||||
|
@ -1320,7 +1329,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
|||
*myaiming -= KB_LOOKSPEED * screen_invert;
|
||||
keyboard_look[forplayer] = true;
|
||||
}
|
||||
else if (PLAYERINPUTDOWN(ssplayer, gc_centerview))
|
||||
else if (ticcmd_centerviewdown[forplayer])
|
||||
*myaiming = 0;
|
||||
}
|
||||
|
||||
|
@ -1408,7 +1417,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
|||
|
||||
// Adjust camera angle by player input
|
||||
if (abilitydirection && !forcestrafe && camera.chase && !turnheld[forplayer] &&
|
||||
!(ticcmd_resetdown[forplayer] && !(cv_cam_lockedinput[forplayer].value || (player->pflags & PF_STARTDASH)))
|
||||
!(ticcmd_centerviewdown[forplayer] && !(cv_cam_lockedinput[forplayer].value || (player->pflags & PF_STARTDASH)))
|
||||
&& !player->climbing && player->powers[pw_carry] != CR_MINECART)
|
||||
{
|
||||
fixed_t camadjustfactor = cv_cam_turnfacinginput[forplayer].value; //@TODO cvar
|
||||
|
@ -1418,17 +1427,17 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
|||
fixed_t sine = FINESINE((R_PointToAngle2(0, 0, player->rmomx, player->rmomy) - localangle)>>ANGLETOFINESHIFT);
|
||||
fixed_t factor = min(20, FixedMul(player->speed, abs(sine)) / FRACUNIT);
|
||||
|
||||
if (ticcmd_resetdown[forplayer] && (cv_cam_lockedinput[forplayer].value || (player->pflags & PF_STARTDASH)))
|
||||
if (ticcmd_centerviewdown[forplayer] && (cv_cam_lockedinput[forplayer].value || (player->pflags & PF_STARTDASH)))
|
||||
factor = (ssplayer == 1 ? cv_cam_rotspeed.value : cv_cam2_rotspeed.value) * (cv_cam_lockedinput[forplayer].value ?: 1); // Turn while in startdash and locking camera
|
||||
|
||||
*myangle -= cmd->sidemove * factor * camadjustfactor;
|
||||
}
|
||||
|
||||
if (ticcmd_resetdown[forplayer] && (cv_cam_lockedinput[forplayer].value || (player->pflags & PF_STARTDASH)))
|
||||
if (ticcmd_centerviewdown[forplayer] && (cv_cam_lockedinput[forplayer].value || (player->pflags & PF_STARTDASH)))
|
||||
cmd->sidemove = 0;
|
||||
}
|
||||
|
||||
if (abilitydirection && camera.chase && !ticcmd_resetdown[forplayer] && !player->climbing && !forcestrafe && (player->pflags & PF_DIRECTIONCHAR) && player->powers[pw_carry] != CR_MINECART)
|
||||
if (abilitydirection && camera.chase && !ticcmd_centerviewdown[forplayer] && !player->climbing && !forcestrafe && (player->pflags & PF_DIRECTIONCHAR) && player->powers[pw_carry] != CR_MINECART)
|
||||
{
|
||||
///@TODO This block of code is a hack to get the desired abilitydirection and player angle behaviors while remaining netplay-compatible with EXEs without those features.
|
||||
// This has side effects like making F12 spectate look kind of weird, and making the input viewer inaccurate.
|
||||
|
@ -1451,7 +1460,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 (abilitydirection && !forcestrafe && camera.chase && !turnheld[forplayer] && !ticcmd_resetdown[forplayer] && player->powers[pw_carry] != CR_MINECART)
|
||||
if (abilitydirection && !forcestrafe && camera.chase && !turnheld[forplayer] && !ticcmd_centerviewdown[forplayer] && player->powers[pw_carry] != CR_MINECART)
|
||||
{
|
||||
fixed_t camadjustfactor;
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ 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
|
||||
extern boolean ticcmd_centerviewdown[2]; // For simple controls, lock the camera behind the player
|
||||
void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer);
|
||||
|
||||
// copy ticcmd_t to and fro the normal way
|
||||
|
|
|
@ -2194,10 +2194,10 @@ void HU_Drawer(void)
|
|||
return;
|
||||
|
||||
// draw the crosshair, not when viewing demos nor with chasecam
|
||||
if (!automapactive && cv_crosshair.value && !demoplayback && (!camera.chase || (cv_abilitydirection[0].value && ticcmd_resetdown[0])) && !players[displayplayer].spectator)
|
||||
if (!automapactive && cv_crosshair.value && !demoplayback && (!camera.chase || (cv_abilitydirection[0].value && ticcmd_centerviewdown[0])) && !players[displayplayer].spectator)
|
||||
HU_DrawCrosshair();
|
||||
|
||||
if (!automapactive && cv_crosshair2.value && !demoplayback && (!camera2.chase || (cv_abilitydirection[1].value && ticcmd_resetdown[1])) && !players[secondarydisplayplayer].spectator)
|
||||
if (!automapactive && cv_crosshair2.value && !demoplayback && (!camera2.chase || (cv_abilitydirection[1].value && ticcmd_centerviewdown[1])) && !players[secondarydisplayplayer].spectator)
|
||||
HU_DrawCrosshair2();
|
||||
|
||||
// draw desynch text
|
||||
|
|
|
@ -4256,7 +4256,7 @@ const char *PlaystyleDesc[4] = {
|
|||
"and acts in the direction\n"
|
||||
"they're moving.\n"
|
||||
"\n"
|
||||
"Hold \x82Reset Camera\x80 to lock the\n"
|
||||
"Hold \x82Center View\x80 to lock the\n"
|
||||
"camera behind the player!\n"
|
||||
,
|
||||
|
||||
|
|
14
src/p_user.c
14
src/p_user.c
|
@ -9652,17 +9652,7 @@ void P_ResetCamera(player_t *player, camera_t *thiscam)
|
|||
thiscam->y = y;
|
||||
thiscam->z = z;
|
||||
|
||||
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))
|
||||
if (!(thiscam == &camera && (cv_cam_still.value || cv_analog.value))
|
||||
&& !(thiscam == &camera2 && (cv_cam2_still.value || cv_analog2.value)))
|
||||
{
|
||||
thiscam->angle = player->mo->angle;
|
||||
|
@ -9905,7 +9895,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
|||
if (player->powers[pw_carry] == CR_ROLLOUT)
|
||||
shift = -shift;
|
||||
|
||||
if (ticcmd_resetdown[(thiscam == &camera) ? 0 : 1])
|
||||
if (ticcmd_centerviewdown[(thiscam == &camera) ? 0 : 1])
|
||||
shift = FixedMul(camsideshift[forplayer], FRACUNIT-camspeed);
|
||||
else
|
||||
shift += FixedMul(camsideshift[forplayer] - shift, FRACUNIT-(camspeed>>3));
|
||||
|
|
Loading…
Reference in a new issue