RR: Process one_eighty_count (Turn-around key) at frame-rate.

This commit is contained in:
Mitchell Richters 2020-05-13 19:21:11 +10:00 committed by Christoph Oelckers
parent 2129d3b4e7
commit 5f59c1364c
6 changed files with 44 additions and 41 deletions

View file

@ -1111,23 +1111,6 @@ static int P_Submerge(int, int, DukePlayer_t *, int, int);
static int P_Emerge(int, int, DukePlayer_t *, int, int); static int P_Emerge(int, int, DukePlayer_t *, int, int);
static void P_FinishWaterChange(int, DukePlayer_t *, int, int, int); static void P_FinishWaterChange(int, DukePlayer_t *, int, int, int);
static fix16_t P_GetQ16AngleDeltaForTic(DukePlayer_t const *pPlayer)
{
auto oldAngle = pPlayer->oq16ang;
auto newAngle = pPlayer->q16ang;
if (klabs(fix16_sub(oldAngle, newAngle)) < F16(1024))
return fix16_sub(newAngle, oldAngle);
if (newAngle > F16(1024))
newAngle = fix16_sub(newAngle, F16(2048));
if (oldAngle > F16(1024))
oldAngle = fix16_sub(oldAngle, F16(2048));
return fix16_sub(newAngle, oldAngle);
}
ACTOR_STATIC void G_MovePlayers(void) ACTOR_STATIC void G_MovePlayers(void)
{ {
int spriteNum = headspritestat[STAT_PLAYER]; int spriteNum = headspritestat[STAT_PLAYER];
@ -1181,7 +1164,7 @@ ACTOR_STATIC void G_MovePlayers(void)
if (G_HaveActor(sprite[spriteNum].picnum)) if (G_HaveActor(sprite[spriteNum].picnum))
A_Execute(spriteNum, P_GetP(pSprite), otherPlayerDist); A_Execute(spriteNum, P_GetP(pSprite), otherPlayerDist);
pPlayer->q16angvel = P_GetQ16AngleDeltaForTic(pPlayer); pPlayer->q16angvel = G_GetQ16AngleDelta(pPlayer->oq16ang, pPlayer->q16ang);
pPlayer->oq16ang = pPlayer->q16ang; pPlayer->oq16ang = pPlayer->q16ang;
pPlayer->oq16horiz = pPlayer->q16horiz; pPlayer->oq16horiz = pPlayer->q16horiz;
pPlayer->oq16horizoff = pPlayer->q16horizoff; pPlayer->oq16horizoff = pPlayer->q16horizoff;

View file

@ -492,6 +492,20 @@ int32_t __fastcall G_GetAngleDelta(int32_t currAngle, int32_t newAngle)
return newAngle-currAngle; return newAngle-currAngle;
} }
fix16_t __fastcall G_GetQ16AngleDelta(fix16_t oldAngle, fix16_t newAngle)
{
if (fix16_abs(fix16_sub(oldAngle, newAngle)) < fix16_from_int(1024))
return fix16_sub(newAngle, oldAngle);
if (newAngle > fix16_from_int(1024))
newAngle = fix16_sub(newAngle, fix16_from_int(2048));
if (oldAngle > fix16_from_int(1024))
oldAngle = fix16_sub(oldAngle, fix16_from_int(2048));
return fix16_sub(newAngle, oldAngle);
}
GAMEEXEC_STATIC void VM_AlterAng(int32_t const moveFlags) GAMEEXEC_STATIC void VM_AlterAng(int32_t const moveFlags)
{ {
int const elapsedTics = (AC_COUNT(vm.pData))&31; int const elapsedTics = (AC_COUNT(vm.pData))&31;

View file

@ -74,6 +74,7 @@ void A_Fall(int spriteNum);
int32_t A_GetFurthestAngle(int spriteNum, int angDiv); int32_t A_GetFurthestAngle(int spriteNum, int angDiv);
void A_GetZLimits(int spriteNum); void A_GetZLimits(int spriteNum);
int32_t __fastcall G_GetAngleDelta(int32_t currAngle, int32_t newAngle); int32_t __fastcall G_GetAngleDelta(int32_t currAngle, int32_t newAngle);
fix16_t __fastcall G_GetQ16AngleDelta(fix16_t oldAngle, fix16_t newAngle);
//void G_RestoreMapState(); //void G_RestoreMapState();
//void G_SaveMapState(); //void G_SaveMapState();

View file

@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "ns.h" // Must come before everything else! #include "ns.h" // Must come before everything else!
#include "duke3d.h" #include "duke3d.h"
#include "gameexec.h"
#include "demo.h" #include "demo.h"
#include "d_event.h" #include "d_event.h"
@ -3163,7 +3164,7 @@ enddisplayweapon:
#define MAXSVEL ((NORMALKEYMOVE*2)+10) #define MAXSVEL ((NORMALKEYMOVE*2)+10)
#define MAXANGVEL 1024 #define MAXANGVEL 1024
#define MAXHORIZVEL 256 #define MAXHORIZVEL 256
#define ONEEIGHTYSCALE 4
#define MAXVELMOTO 120 #define MAXVELMOTO 120
int32_t g_myAimStat = 0, g_oldAimStat = 0; int32_t g_myAimStat = 0, g_oldAimStat = 0;
@ -3536,6 +3537,12 @@ void P_GetInput(int const playerNum)
pPlayer->q16rotscrnang = fix16_ssub(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24))); pPlayer->q16rotscrnang = fix16_ssub(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24)));
} }
if (pPlayer->one_eighty_count < 0)
{
pPlayer->one_eighty_count = -fix16_to_int(fix16_abs(G_GetQ16AngleDelta(pPlayer->one_eighty_target, pPlayer->q16ang)));
pPlayer->q16ang = fix16_sadd(pPlayer->q16ang, fix16_max(fix16_one, fix16_from_dbl(scaleAdjustmentToInterval(-pPlayer->one_eighty_count / ONEEIGHTYSCALE)))) & 0x7FFFFFF;
}
if (RRRA && pPlayer->sea_sick) if (RRRA && pPlayer->sea_sick)
{ {
if (pPlayer->sea_sick < 250) if (pPlayer->sea_sick < 250)
@ -4297,6 +4304,12 @@ void P_DHGetInput(int const playerNum)
pPlayer->q16look_ang = fix16_sadd(pPlayer->q16look_ang, fix16_from_dbl(scaleAdjustmentToInterval(152))); pPlayer->q16look_ang = fix16_sadd(pPlayer->q16look_ang, fix16_from_dbl(scaleAdjustmentToInterval(152)));
pPlayer->q16rotscrnang = fix16_ssub(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24))); pPlayer->q16rotscrnang = fix16_ssub(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24)));
} }
if (pPlayer->one_eighty_count < 0)
{
pPlayer->one_eighty_count = -fix16_to_int(fix16_abs(G_GetQ16AngleDelta(pPlayer->one_eighty_target, pPlayer->q16ang)));
pPlayer->q16ang = fix16_sadd(pPlayer->q16ang, fix16_max(fix16_one, fix16_from_dbl(scaleAdjustmentToInterval(-pPlayer->one_eighty_count / ONEEIGHTYSCALE)))) & 0x7FFFFFF;
}
} }
// A horiz diff of 128 equal 45 degrees, so we convert horiz to 1024 angle units // A horiz diff of 128 equal 45 degrees, so we convert horiz to 1024 angle units
@ -8010,12 +8023,6 @@ check_enemy_sprite:
pPlayer->opos.z = pPlayer->pos.z; pPlayer->opos.z = pPlayer->pos.z;
pPlayer->opyoff = pPlayer->pyoff; pPlayer->opyoff = pPlayer->pyoff;
if (pPlayer->one_eighty_count < 0)
{
pPlayer->one_eighty_count += 128;
pPlayer->q16ang += F16(128);
}
// Shrinking code // Shrinking code
if (RR) if (RR)
@ -9235,12 +9242,6 @@ void P_DHProcessInput(int playerNum)
pPlayer->opos.z = pPlayer->pos.z; pPlayer->opos.z = pPlayer->pos.z;
pPlayer->opyoff = pPlayer->pyoff; pPlayer->opyoff = pPlayer->pyoff;
if (pPlayer->one_eighty_count < 0)
{
pPlayer->one_eighty_count += 128;
pPlayer->q16ang += F16(128);
}
// Shrinking code // Shrinking code
if (sectorLotag == ST_2_UNDERWATER) if (sectorLotag == ST_2_UNDERWATER)

View file

@ -164,6 +164,7 @@ typedef struct {
int16_t random_club_frame, one_eighty_count; int16_t random_club_frame, one_eighty_count;
int16_t dummyplayersprite, extra_extra8; int16_t dummyplayersprite, extra_extra8;
int16_t actorsqu, timebeforeexit, customexitsound, last_pissed_time; int16_t actorsqu, timebeforeexit, customexitsound, last_pissed_time;
fix16_t one_eighty_target;
int16_t weaprecs[MAX_WEAPON_RECS], weapon_sway, crack_time, bobcounter; int16_t weaprecs[MAX_WEAPON_RECS], weapon_sway, crack_time, bobcounter;

View file

@ -4248,7 +4248,10 @@ rrtripbomb_case:
if (TEST_SYNC_KEY(playerBits, SK_TURNAROUND) && pPlayer->one_eighty_count == 0) if (TEST_SYNC_KEY(playerBits, SK_TURNAROUND) && pPlayer->one_eighty_count == 0)
if (VM_OnEvent(EVENT_TURNAROUND,pPlayer->i,playerNum) == 0) if (VM_OnEvent(EVENT_TURNAROUND,pPlayer->i,playerNum) == 0)
{
pPlayer->one_eighty_count = -1024; pPlayer->one_eighty_count = -1024;
pPlayer->one_eighty_target = fix16_sadd(pPlayer->q16ang, -fix16_from_int(pPlayer->one_eighty_count)) & 0x7FFFFFF;
}
} }
} }