mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Move Z-targeting behavior to Center View
This commit is contained in:
parent
0a480f1df6
commit
0ab83319a5
5 changed files with 36 additions and 37 deletions
47
src/g_game.c
47
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 sidemove[2] = {25<<FRACBITS>>16, 50<<FRACBITS>>16}; // faster!
|
||||||
static fixed_t angleturn[3] = {640, 1280, 320}; // + slow turn
|
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)
|
void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
||||||
{
|
{
|
||||||
boolean forcestrafe = false;
|
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 INT32 turnheld[2]; // for accelerative turning
|
||||||
static boolean keyboard_look[2]; // true if lookup/down using keyboard
|
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
|
static boolean joyaiming[2]; // check the last frame's value if we need to reset the camera
|
||||||
UINT8 forplayer = ssplayer-1;
|
UINT8 forplayer = ssplayer-1;
|
||||||
|
|
||||||
|
|
@ -1256,27 +1257,35 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
||||||
if (PLAYERINPUTDOWN(ssplayer, gc_use) || (usejoystick && axis > 0))
|
if (PLAYERINPUTDOWN(ssplayer, gc_use) || (usejoystick && axis > 0))
|
||||||
cmd->buttons |= BT_USE;
|
cmd->buttons |= BT_USE;
|
||||||
|
|
||||||
if (PLAYERINPUTDOWN(ssplayer, gc_camreset))
|
if (PLAYERINPUTDOWN(ssplayer, gc_centerview))
|
||||||
{
|
{
|
||||||
if (camera.chase && !ticcmd_resetdown[forplayer])
|
|
||||||
{
|
|
||||||
ticcmd_resetdown[forplayer] = true;
|
|
||||||
P_ResetCamera(&players[ssplayer == 1 ? displayplayer : secondarydisplayplayer], &camera);
|
|
||||||
|
|
||||||
if (abilitydirection)
|
if (abilitydirection)
|
||||||
|
{
|
||||||
CV_SetValue((ssplayer == 1 ? &cv_directionchar : &cv_directionchar2), 0);
|
CV_SetValue((ssplayer == 1 ? &cv_directionchar : &cv_directionchar2), 0);
|
||||||
|
*myangle = player->mo->angle;
|
||||||
|
*myaiming = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ticcmd_centerviewdown[forplayer] = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ticcmd_resetdown[forplayer] = true;
|
|
||||||
}
|
|
||||||
else if (ticcmd_resetdown[forplayer])
|
|
||||||
{
|
{
|
||||||
ticcmd_resetdown[forplayer] = false;
|
|
||||||
|
|
||||||
if (abilitydirection)
|
|
||||||
CV_SetValue((ssplayer == 1 ? &cv_directionchar : &cv_directionchar2), 1);
|
CV_SetValue((ssplayer == 1 ? &cv_directionchar : &cv_directionchar2), 1);
|
||||||
|
|
||||||
|
ticcmd_centerviewdown[forplayer] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (PLAYERINPUTDOWN(ssplayer, gc_camreset))
|
||||||
|
{
|
||||||
|
if (camera.chase && !resetdown[forplayer])
|
||||||
|
P_ResetCamera(&players[ssplayer == 1 ? displayplayer : secondarydisplayplayer], &camera);
|
||||||
|
|
||||||
|
resetdown[forplayer] = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
resetdown[forplayer] = false;
|
||||||
|
|
||||||
|
|
||||||
// jump button
|
// jump button
|
||||||
axis = PlayerJoyAxis(ssplayer, AXISJUMP);
|
axis = PlayerJoyAxis(ssplayer, AXISJUMP);
|
||||||
if (PLAYERINPUTDOWN(ssplayer, gc_jump) || (usejoystick && axis > 0))
|
if (PLAYERINPUTDOWN(ssplayer, gc_jump) || (usejoystick && axis > 0))
|
||||||
|
|
@ -1320,7 +1329,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
||||||
*myaiming -= KB_LOOKSPEED * screen_invert;
|
*myaiming -= KB_LOOKSPEED * screen_invert;
|
||||||
keyboard_look[forplayer] = true;
|
keyboard_look[forplayer] = true;
|
||||||
}
|
}
|
||||||
else if (PLAYERINPUTDOWN(ssplayer, gc_centerview))
|
else if (ticcmd_centerviewdown[forplayer])
|
||||||
*myaiming = 0;
|
*myaiming = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1408,7 +1417,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
||||||
|
|
||||||
// Adjust camera angle by player input
|
// Adjust camera angle by player input
|
||||||
if (abilitydirection && !forcestrafe && camera.chase && !turnheld[forplayer] &&
|
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)
|
&& !player->climbing && player->powers[pw_carry] != CR_MINECART)
|
||||||
{
|
{
|
||||||
fixed_t camadjustfactor = cv_cam_turnfacinginput[forplayer].value; //@TODO cvar
|
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 sine = FINESINE((R_PointToAngle2(0, 0, player->rmomx, player->rmomy) - localangle)>>ANGLETOFINESHIFT);
|
||||||
fixed_t factor = min(20, FixedMul(player->speed, abs(sine)) / FRACUNIT);
|
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
|
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;
|
*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;
|
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.
|
///@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.
|
// 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
|
// 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
|
// 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;
|
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
|
// build an internal map name MAPxx from map number
|
||||||
const char *G_BuildMapName(INT32 map);
|
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);
|
void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer);
|
||||||
|
|
||||||
// copy ticcmd_t to and fro the normal way
|
// copy ticcmd_t to and fro the normal way
|
||||||
|
|
|
||||||
|
|
@ -2194,10 +2194,10 @@ void HU_Drawer(void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// draw the crosshair, not when viewing demos nor with chasecam
|
// 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();
|
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();
|
HU_DrawCrosshair2();
|
||||||
|
|
||||||
// draw desynch text
|
// draw desynch text
|
||||||
|
|
|
||||||
|
|
@ -4256,7 +4256,7 @@ const char *PlaystyleDesc[4] = {
|
||||||
"and acts in the direction\n"
|
"and acts in the direction\n"
|
||||||
"they're moving.\n"
|
"they're moving.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Hold \x82Reset Camera\x80 to lock the\n"
|
"Hold \x82Center View\x80 to lock the\n"
|
||||||
"camera behind the player!\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->y = y;
|
||||||
thiscam->z = z;
|
thiscam->z = z;
|
||||||
|
|
||||||
if (thiscam == &camera && cv_abilitydirection[0].value && ticcmd_resetdown[0])
|
if (!(thiscam == &camera && (cv_cam_still.value || cv_analog.value))
|
||||||
{
|
|
||||||
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 == &camera2 && (cv_cam2_still.value || cv_analog2.value)))
|
||||||
{
|
{
|
||||||
thiscam->angle = player->mo->angle;
|
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)
|
if (player->powers[pw_carry] == CR_ROLLOUT)
|
||||||
shift = -shift;
|
shift = -shift;
|
||||||
|
|
||||||
if (ticcmd_resetdown[(thiscam == &camera) ? 0 : 1])
|
if (ticcmd_centerviewdown[(thiscam == &camera) ? 0 : 1])
|
||||||
shift = FixedMul(camsideshift[forplayer], FRACUNIT-camspeed);
|
shift = FixedMul(camsideshift[forplayer], FRACUNIT-camspeed);
|
||||||
else
|
else
|
||||||
shift += FixedMul(camsideshift[forplayer] - shift, FRACUNIT-(camspeed>>3));
|
shift += FixedMul(camsideshift[forplayer] - shift, FRACUNIT-(camspeed>>3));
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue