- Duke: Convert RRRA's vehicle HUD tilting to a DAngle.

This commit is contained in:
Mitchell Richters 2023-04-24 22:17:37 +10:00
parent 11181f51f8
commit 6ac2af9f3c
5 changed files with 18 additions and 18 deletions

View file

@ -107,7 +107,8 @@ inline static void ShowBoat(double x, double y, int tilenum, int shade, int orie
void displayweapon_r(int snum, double interpfrac)
{
double weapon_sway, gun_pos, hard_landing, TiltStatus;
double weapon_sway, gun_pos, hard_landing;
DAngle TiltStatus;
auto p = &ps[snum];
auto kb = &p->kickback_pic;
@ -119,7 +120,7 @@ void displayweapon_r(int snum, double interpfrac)
weapon_sway = interpolatedvalue<double>(p->oweapon_sway, p->weapon_sway, interpfrac);
hard_landing = interpolatedvalue<double>(p->ohard_landing, p->hard_landing, interpfrac);
gun_pos = 80 - interpolatedvalue<double>(p->oweapon_pos * p->oweapon_pos, p->weapon_pos * p->weapon_pos, interpfrac);
TiltStatus = interpolatedvalue<double>(p->oTiltStatus, p->TiltStatus, interpfrac);
TiltStatus = interpolatedvalue(p->oTiltStatus, p->TiltStatus, interpfrac);
}
else
{
@ -150,7 +151,6 @@ void displayweapon_r(int snum, double interpfrac)
if (p->OnMotorcycle)
{
angle = DAngle::fromBuild(-TiltStatus);
int temp_kb;
if (numplayers == 1)
{
@ -199,15 +199,14 @@ void displayweapon_r(int snum, double interpfrac)
temp_kb = RTILE_MOTOHIT;
}
ShowMotorcycle(160 + offsets.X, 174, temp_kb, shade, 0, pal, angle * 5);
ShowMotorcycle(160 + offsets.X, 174, temp_kb, shade, 0, pal, -TiltStatus * 5);
return;
}
if (p->OnBoat)
{
angle = DAngle::fromBuild(-TiltStatus);
int temp2, temp_kb, temp3;
temp2 = 0;
if (TiltStatus > 0)
if (TiltStatus.Sgn() > 0)
{
if (*kb == 0)
temp_kb = RTILE_BOATHIT+1;
@ -224,7 +223,7 @@ void displayweapon_r(int snum, double interpfrac)
else
temp_kb = RTILE_BOATHIT+1;
}
else if (TiltStatus < 0)
else if (TiltStatus.Sgn() < 0)
{
if (*kb == 0)
temp_kb = RTILE_BOATHIT+2;
@ -267,7 +266,7 @@ void displayweapon_r(int snum, double interpfrac)
if (temp2)
shade = -96;
ShowBoat(160 + offsets.X, temp3, temp_kb, shade, 0, pal, angle);
ShowBoat(160 + offsets.X, temp3, temp_kb, shade, 0, pal, -TiltStatus);
return;
}

View file

@ -619,7 +619,7 @@ void checkweapons_r(player_struct* p)
p->GetActor()->spr.Angles.Pitch = nullAngle;
p->moto_do_bump = 0;
p->MotoSpeed = 0;
p->TiltStatus = 0;
p->TiltStatus = nullAngle;
p->moto_drink = 0;
p->VBumpTarget = 0;
p->VBumpNow = 0;
@ -638,7 +638,7 @@ void checkweapons_r(player_struct* p)
p->GetActor()->spr.Angles.Pitch = nullAngle;
p->moto_do_bump = 0;
p->MotoSpeed = 0;
p->TiltStatus = 0;
p->TiltStatus = nullAngle;
p->moto_drink = 0;
p->VBumpTarget = 0;
p->VBumpNow = 0;
@ -723,8 +723,9 @@ static unsigned outVehicleFlags(player_struct* p, ESyncBits& actions)
static void doVehicleTilting(player_struct* const p, const int turndir, const bool canTilt)
{
constexpr auto amt = DAngle::fromBuild(1);
p->oTiltStatus = p->TiltStatus;
p->TiltStatus = clamp(p->TiltStatus + (turndir && canTilt ? turndir : -Sgn(p->TiltStatus)), -10, 10);
p->TiltStatus = clamp(p->TiltStatus + (turndir && canTilt ? amt : -amt * p->TiltStatus.Sgn()), -amt, amt);
}
//---------------------------------------------------------------------------
@ -1435,7 +1436,7 @@ void onMotorcycleHit(int snum, DDukeActor* victim)
if (numplayers == 1)
{
Collision coll;
DAngle ang = DAngle::fromBuild(p->TiltStatus * 20) + p->GetActor()->spr.Angles.Yaw;
DAngle ang = p->TiltStatus * 20 + p->GetActor()->spr.Angles.Yaw;
movesprite_ex(victim, DVector3(ang.ToVector() * 4, victim->vel.Z), CLIPMASK0, coll);
}
}
@ -1469,7 +1470,7 @@ void onBoatHit(int snum, DDukeActor* victim)
if (numplayers == 1)
{
Collision coll;
DAngle ang = DAngle::fromBuild(p->TiltStatus * 20) + p->GetActor()->spr.Angles.Yaw;
DAngle ang = p->TiltStatus * 20 + p->GetActor()->spr.Angles.Yaw;
movesprite_ex(victim, DVector3(ang.ToVector() * 2, victim->vel.Z), CLIPMASK0, coll);
}
}
@ -2975,7 +2976,7 @@ void OffMotorcycle(player_struct *p)
p->GetActor()->spr.Angles.Pitch = nullAngle;
p->moto_do_bump = 0;
p->MotoSpeed = 0;
p->TiltStatus = 0;
p->TiltStatus = nullAngle;
p->moto_drink = 0;
p->VBumpTarget = 0;
p->VBumpNow = 0;
@ -3029,7 +3030,7 @@ void OffBoat(player_struct *p)
p->GetActor()->spr.Angles.Pitch = nullAngle;
p->moto_do_bump = 0;
p->MotoSpeed = 0;
p->TiltStatus = 0;
p->TiltStatus = nullAngle;
p->moto_drink = 0;
p->VBumpTarget = 0;
p->VBumpNow = 0;

View file

@ -216,7 +216,7 @@ void resetplayerstats(int snum)
p->MotoOnGround = 1;
p->moto_underwater = 0;
p->MotoSpeed = 0;
p->TiltStatus = 0;
p->TiltStatus = nullAngle;
p->moto_drink = 0;
p->VBumpTarget = 0;
p->VBumpNow =0;

View file

@ -329,7 +329,7 @@ struct player_struct
int SeaSick;
short MamaEnd; // raat609
short moto_drink;
short TiltStatus, oTiltStatus;
DAngle TiltStatus, oTiltStatus;
double VBumpNow, VBumpTarget;
short TurbCount;
short drug_stat[3]; // raat5f1..5

View file

@ -337,7 +337,7 @@ struct DukePlayer native
native int SeaSick;
native int16 MamaEnd; // raat609
native int16 moto_drink;
native int16 TiltStatus, oTiltStatus;
native double TiltStatus, oTiltStatus;
native double VBumpNow, VBumpTarget;
native int16 TurbCount;
native int16 drug_stat[3]; // raat5f1..5