- scriptified P_BobWeapon as a virtual function on PlayerPawn.
This commit is contained in:
parent
b75ee1027a
commit
34b7e5f435
6 changed files with 145 additions and 93 deletions
|
|
@ -151,6 +151,7 @@ public:
|
|||
|
||||
// [SP] ViewBob Multiplier
|
||||
double ViewBob;
|
||||
double curBob;
|
||||
|
||||
// Former class properties that were moved into the object to get rid of the meta class.
|
||||
FName SoundClass; // Sound class
|
||||
|
|
|
|||
103
src/p_pspr.cpp
103
src/p_pspr.cpp
|
|
@ -579,101 +579,17 @@ void P_BringUpWeapon (player_t *player)
|
|||
|
||||
void P_BobWeapon (player_t *player, float *x, float *y, double ticfrac)
|
||||
{
|
||||
static float curbob;
|
||||
double xx[2], yy[2];
|
||||
|
||||
AWeapon *weapon;
|
||||
float bobtarget;
|
||||
|
||||
weapon = player->ReadyWeapon;
|
||||
|
||||
if (weapon == nullptr || weapon->WeaponFlags & WIF_DONTBOB)
|
||||
IFVIRTUALPTR(player->mo, APlayerPawn, BobWeapon)
|
||||
{
|
||||
*x = *y = 0;
|
||||
VMValue param[] = { player->mo, ticfrac };
|
||||
DVector2 result;
|
||||
VMReturn ret(&result);
|
||||
VMCall(func, param, 2, &ret, 1);
|
||||
*x = (float)result.X;
|
||||
*y = (float)result.Y;
|
||||
return;
|
||||
}
|
||||
|
||||
// [XA] Get the current weapon's bob properties.
|
||||
int bobstyle = weapon->BobStyle;
|
||||
float BobSpeed = (weapon->BobSpeed * 128);
|
||||
float Rangex = weapon->BobRangeX;
|
||||
float Rangey = weapon->BobRangeY;
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
// Bob the weapon based on movement speed. ([SP] And user's bob speed setting)
|
||||
FAngle angle = (BobSpeed * player->userinfo.GetWBobSpeed() * 35 /
|
||||
TICRATE*(level.time - 1 + i)) * (360.f / 8192.f);
|
||||
|
||||
// [RH] Smooth transitions between bobbing and not-bobbing frames.
|
||||
// This also fixes the bug where you can "stick" a weapon off-center by
|
||||
// shooting it when it's at the peak of its swing.
|
||||
bobtarget = float((player->WeaponState & WF_WEAPONBOBBING) ? player->bob : 0.);
|
||||
if (curbob != bobtarget)
|
||||
{
|
||||
if (fabsf(bobtarget - curbob) <= 1)
|
||||
{
|
||||
curbob = bobtarget;
|
||||
}
|
||||
else
|
||||
{
|
||||
float zoom = MAX(1.f, fabsf(curbob - bobtarget) / 40);
|
||||
if (curbob > bobtarget)
|
||||
{
|
||||
curbob -= zoom;
|
||||
}
|
||||
else
|
||||
{
|
||||
curbob += zoom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (curbob != 0)
|
||||
{
|
||||
//[SP] Added in decorate player.viewbob checks
|
||||
float bobx = float(player->bob * Rangex * (float)player->mo->ViewBob);
|
||||
float boby = float(player->bob * Rangey * (float)player->mo->ViewBob);
|
||||
switch (bobstyle)
|
||||
{
|
||||
case AWeapon::BobNormal:
|
||||
xx[i] = bobx * angle.Cos();
|
||||
yy[i] = boby * fabsf(angle.Sin());
|
||||
break;
|
||||
|
||||
case AWeapon::BobInverse:
|
||||
xx[i] = bobx*angle.Cos();
|
||||
yy[i] = boby * (1.f - fabsf(angle.Sin()));
|
||||
break;
|
||||
|
||||
case AWeapon::BobAlpha:
|
||||
xx[i] = bobx * angle.Sin();
|
||||
yy[i] = boby * fabsf(angle.Sin());
|
||||
break;
|
||||
|
||||
case AWeapon::BobInverseAlpha:
|
||||
xx[i] = bobx * angle.Sin();
|
||||
yy[i] = boby * (1.f - fabsf(angle.Sin()));
|
||||
break;
|
||||
|
||||
case AWeapon::BobSmooth:
|
||||
xx[i] = bobx*angle.Cos();
|
||||
yy[i] = 0.5f * (boby * (1.f - ((angle * 2).Cos())));
|
||||
break;
|
||||
|
||||
case AWeapon::BobInverseSmooth:
|
||||
xx[i] = bobx*angle.Cos();
|
||||
yy[i] = 0.5f * (boby * (1.f + ((angle * 2).Cos())));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
xx[i] = 0;
|
||||
yy[i] = 0;
|
||||
}
|
||||
}
|
||||
*x = (float)(xx[0] * (1. - ticfrac) + xx[1] * ticfrac);
|
||||
*y = (float)(yy[0] * (1. - ticfrac) + yy[1] * ticfrac);
|
||||
*x = *y = 0;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
|
@ -1363,10 +1279,11 @@ float DPSprite::GetYAdjust(bool fullscreen)
|
|||
}
|
||||
else
|
||||
{
|
||||
return StatusBar->GetDisplacement() * fYAd;
|
||||
return (float)StatusBar->GetDisplacement() * fYAd;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -780,6 +780,12 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, GetNoAutostartMap)
|
|||
ACTION_RETURN_INT(self->userinfo.GetNoAutostartMap());
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_PlayerInfo, GetWBobSpeed)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(player_t);
|
||||
ACTION_RETURN_FLOAT(self->userinfo.GetWBobSpeed());
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
|
|
@ -2278,6 +2284,7 @@ DEFINE_FIELD(APlayerPawn, AirCapacity)
|
|||
DEFINE_FIELD(APlayerPawn, FlechetteType)
|
||||
DEFINE_FIELD(APlayerPawn, DamageFade)
|
||||
DEFINE_FIELD(APlayerPawn, ViewBob)
|
||||
DEFINE_FIELD(APlayerPawn, curBob)
|
||||
DEFINE_FIELD(APlayerPawn, FullHeight)
|
||||
DEFINE_FIELD(APlayerPawn, SoundClass)
|
||||
DEFINE_FIELD(APlayerPawn, Face)
|
||||
|
|
|
|||
|
|
@ -177,6 +177,11 @@ struct VMReturn
|
|||
Location = loc;
|
||||
RegType = REGT_FLOAT;
|
||||
}
|
||||
void Vec2At(DVector2 *loc)
|
||||
{
|
||||
Location = loc;
|
||||
RegType = REGT_FLOAT | REGT_MULTIREG2;
|
||||
}
|
||||
void StringAt(FString *loc)
|
||||
{
|
||||
Location = loc;
|
||||
|
|
@ -190,6 +195,7 @@ struct VMReturn
|
|||
VMReturn() { }
|
||||
VMReturn(int *loc) { IntAt(loc); }
|
||||
VMReturn(double *loc) { FloatAt(loc); }
|
||||
VMReturn(DVector2 *loc) { Vec2At(loc); }
|
||||
VMReturn(FString *loc) { StringAt(loc); }
|
||||
VMReturn(void **loc) { PointerAt(loc); }
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue