make direct aiming slope range symmetrical, so it matches autoaim slope range (#1117)

This commit is contained in:
Fabian Greffrath 2023-06-26 06:22:31 +02:00 committed by GitHub
parent b131d5ff12
commit c86904de68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 9 deletions

View File

@ -232,7 +232,7 @@ void P_MovePlayer (player_t* player)
if (!menuactive && !demoplayback) if (!menuactive && !demoplayback)
{ {
player->lookdir = BETWEEN(-LOOKDIRMIN * MLOOKUNIT, player->lookdir = BETWEEN(-LOOKDIRMAX * MLOOKUNIT,
LOOKDIRMAX * MLOOKUNIT, LOOKDIRMAX * MLOOKUNIT,
player->lookdir + cmd->lookdir); player->lookdir + cmd->lookdir);
} }

View File

@ -24,9 +24,8 @@
#include "r_defs.h" #include "r_defs.h"
#include "r_state.h" #include "r_state.h"
#define LOOKDIRMIN 110 // [crispy] -110, actually #define LOOKDIRMAX 100
#define LOOKDIRMAX 90 #define LOOKDIRS (2*LOOKDIRMAX+1) // [crispy] lookdir range: -100..100
#define LOOKDIRS (LOOKDIRMIN+1+LOOKDIRMAX) // [crispy] lookdir range: -110..0..90
#define MLOOKUNIT 8 #define MLOOKUNIT 8
// Retrieve column data for span blitting. // Retrieve column data for span blitting.

View File

@ -502,11 +502,11 @@ void R_ExecuteSetViewSize (void)
for (j = 0; j < LOOKDIRS; j++) for (j = 0; j < LOOKDIRS; j++)
{ {
// [crispy] re-generate lookup-table for yslope[] whenever "viewheight" or "hires" change // [crispy] re-generate lookup-table for yslope[] whenever "viewheight" or "hires" change
fixed_t dy = abs(((i-viewheight/2-(j-LOOKDIRMIN)*viewblocks/10)<<FRACBITS)+FRACUNIT/2); fixed_t dy = abs(((i-viewheight/2-(j-LOOKDIRMAX)*viewblocks/10)<<FRACBITS)+FRACUNIT/2);
yslopes[j][i] = FixedDiv(viewwidth_nonwide*(FRACUNIT/2), dy); yslopes[j][i] = FixedDiv(viewwidth_nonwide*(FRACUNIT/2), dy);
} }
} }
yslope = yslopes[LOOKDIRMIN]; yslope = yslopes[LOOKDIRMAX];
for (i=0 ; i<viewwidth ; i++) for (i=0 ; i<viewwidth ; i++)
{ {
@ -652,8 +652,8 @@ void R_SetupFrame (player_t *player)
if (pitch > LOOKDIRMAX) if (pitch > LOOKDIRMAX)
pitch = LOOKDIRMAX; pitch = LOOKDIRMAX;
else if (pitch < -LOOKDIRMIN) else if (pitch < -LOOKDIRMAX)
pitch = -LOOKDIRMIN; pitch = -LOOKDIRMAX;
// apply new yslope[] whenever "lookdir", "viewheight" or "hires" change // apply new yslope[] whenever "lookdir", "viewheight" or "hires" change
tempCentery = viewheight/2 + pitch * viewblocks / 10; tempCentery = viewheight/2 + pitch * viewblocks / 10;
@ -661,7 +661,7 @@ void R_SetupFrame (player_t *player)
{ {
centery = tempCentery; centery = tempCentery;
centeryfrac = centery << FRACBITS; centeryfrac = centery << FRACBITS;
yslope = yslopes[LOOKDIRMIN + pitch]; yslope = yslopes[LOOKDIRMAX + pitch];
} }
viewsin = finesine[viewangle>>ANGLETOFINESHIFT]; viewsin = finesine[viewangle>>ANGLETOFINESHIFT];