mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- floatified PLAYER::bob_amt
This commit is contained in:
parent
4dc2fc9151
commit
e089100ab1
6 changed files with 33 additions and 34 deletions
|
@ -1448,7 +1448,7 @@ void drawscreen(PLAYER* pp, double smoothratio, bool sceneonly)
|
|||
}
|
||||
else
|
||||
{
|
||||
bob_amt = camerapp->bob_amt;
|
||||
bob_amt = camerapp->int_bob_amt();
|
||||
|
||||
if (CameraTestMode)
|
||||
{
|
||||
|
|
|
@ -620,6 +620,10 @@ struct PLAYER
|
|||
{
|
||||
return p_floor_dist * 256;
|
||||
}
|
||||
int int_bob_amt() const
|
||||
{
|
||||
return p_bob_amt * zworldtoint;
|
||||
}
|
||||
|
||||
DSWActor* actor; // this may not be a TObjPtr!
|
||||
TObjPtr<DSWActor*> lowActor, highActor;
|
||||
|
@ -637,6 +641,7 @@ struct PLAYER
|
|||
SECTOR_OBJECT* sop; // will either be sop_remote or sop_control
|
||||
|
||||
double hiz, loz;
|
||||
double p_bob_amt;
|
||||
|
||||
int jump_count, jump_speed; // jumping
|
||||
int16_t down_speed, up_speed; // diving
|
||||
|
@ -687,7 +692,6 @@ struct PLAYER
|
|||
|
||||
int16_t JumpDuration;
|
||||
int16_t WadeDepth;
|
||||
int16_t bob_amt;
|
||||
int16_t bob_ndx;
|
||||
int16_t bcnt; // bob count
|
||||
int bob_z, obob_z;
|
||||
|
|
|
@ -1661,14 +1661,11 @@ void DoPlayerRecoil(PLAYER* pp)
|
|||
|
||||
|
||||
// for wading
|
||||
void DoPlayerSpriteBob(PLAYER* pp, short player_height, short bob_amt, short bob_speed)
|
||||
void DoPlayerSpriteBob(PLAYER* pp, double player_height, double bob_amt, short bob_speed)
|
||||
{
|
||||
|
||||
pp->bob_ndx = (pp->bob_ndx + (synctics << bob_speed)) & 2047;
|
||||
|
||||
pp->bob_amt = MulScale(bob_amt, bsin(pp->bob_ndx), 14);
|
||||
|
||||
pp->actor->set_int_z((pp->int_ppos().Z + player_height) + pp->bob_amt);
|
||||
pp->p_bob_amt = bob_amt * DAngle::fromBuild(pp->bob_ndx).Sin();
|
||||
pp->actor->spr.pos.Z = pp->pos.Z + player_height + pp->p_bob_amt;
|
||||
}
|
||||
|
||||
void UpdatePlayerUnderSprite(PLAYER* pp)
|
||||
|
@ -1774,7 +1771,7 @@ void UpdatePlayerSprite(PLAYER* pp)
|
|||
|
||||
if (pp->WadeDepth > Z(29))
|
||||
{
|
||||
DoPlayerSpriteBob(pp, PLAYER_HEIGHT, Z(3), 3);
|
||||
DoPlayerSpriteBob(pp, PLAYER_HEIGHTF, 3, 3);
|
||||
}
|
||||
}
|
||||
else if (pp->DoPlayerAction == DoPlayerDive)
|
||||
|
@ -1791,11 +1788,8 @@ void UpdatePlayerSprite(PLAYER* pp)
|
|||
}
|
||||
else if (pp->DoPlayerAction == DoPlayerFly)
|
||||
{
|
||||
// actor->spr.z = pp->posz + PLAYER_HEIGHT;
|
||||
// bobbing and sprite position taken care of in DoPlayerFly
|
||||
//actor->spr.z = pp->posz + PLAYER_HEIGHT;
|
||||
//DoPlayerSpriteBob(pp, PLAYER_HEIGHT, PLAYER_FLY_BOB_AMT, 3);
|
||||
DoPlayerSpriteBob(pp, PLAYER_HEIGHT, Z(6), 3);
|
||||
DoPlayerSpriteBob(pp, PLAYER_HEIGHTF, 6, 3);
|
||||
ChangeActorSect(pp->actor, pp->cursector);
|
||||
}
|
||||
else if (pp->DoPlayerAction == DoPlayerJump || pp->DoPlayerAction == DoPlayerFall || pp->DoPlayerAction == DoPlayerForceJump)
|
||||
|
@ -3517,7 +3511,7 @@ void DoPlayerBeginFly(PLAYER* pp)
|
|||
|
||||
pp->z_speed = -Z(10);
|
||||
pp->jump_speed = 0;
|
||||
pp->bob_amt = 0;
|
||||
pp->p_bob_amt = 0;
|
||||
pp->bob_ndx = 1024;
|
||||
|
||||
NewStateGroup(pp->actor, sg_PlayerNinjaFly);
|
||||
|
@ -3590,7 +3584,7 @@ void DoPlayerFly(PLAYER* pp)
|
|||
if (PlayerFlyKey())
|
||||
{
|
||||
pp->Flags &= ~(PF_FLYING);
|
||||
pp->bob_amt = 0;
|
||||
pp->p_bob_amt = 0;
|
||||
pp->bob_ndx = 0;
|
||||
DoPlayerBeginFall(pp);
|
||||
DoPlayerFall(pp);
|
||||
|
@ -4219,7 +4213,7 @@ void DoPlayerStopDiveNoWarp(PLAYER* pp)
|
|||
// stop diving no warp
|
||||
PlayerSound(DIGI_SURFACE, v3df_dontpan|v3df_follow|v3df_doppler,pp);
|
||||
|
||||
pp->bob_amt = 0;
|
||||
pp->p_bob_amt = 0;
|
||||
|
||||
pp->Flags &= ~(PF_DIVING|PF_DIVING_IN_LAVA);
|
||||
DoPlayerDivePalette(pp);
|
||||
|
@ -4246,7 +4240,7 @@ void DoPlayerStopDive(PLAYER* pp)
|
|||
// stop diving with warp
|
||||
PlayerSound(DIGI_SURFACE, v3df_dontpan|v3df_follow|v3df_doppler,pp);
|
||||
|
||||
pp->bob_amt = 0;
|
||||
pp->p_bob_amt = 0;
|
||||
DoPlayerWarpToSurface(pp);
|
||||
DoPlayerBeginWade(pp);
|
||||
pp->Flags &= ~(PF_DIVING|PF_DIVING_IN_LAVA);
|
||||
|
@ -4429,35 +4423,35 @@ void DoPlayerDive(PLAYER* pp)
|
|||
// make player bob if sitting still
|
||||
if (!PLAYER_MOVING(pp) && pp->z_speed == 0 && pp->up_speed == 0)
|
||||
{
|
||||
DoPlayerSpriteBob(pp, PLAYER_DIVE_HEIGHT, PLAYER_DIVE_BOB_AMT, 3);
|
||||
DoPlayerSpriteBob(pp, PLAYER_DIVE_HEIGHTF, PLAYER_DIVE_BOB_AMTF, 3);
|
||||
}
|
||||
// player is moving
|
||||
else
|
||||
{
|
||||
// if bob_amt is approx 0
|
||||
if (labs(pp->bob_amt) < Z(1))
|
||||
if (abs(pp->p_bob_amt) < 1)
|
||||
{
|
||||
pp->bob_amt = 0;
|
||||
pp->p_bob_amt = 0;
|
||||
pp->bob_ndx = 0;
|
||||
}
|
||||
// else keep bobbing until its back close to 0
|
||||
else
|
||||
{
|
||||
DoPlayerSpriteBob(pp, PLAYER_DIVE_HEIGHT, PLAYER_DIVE_BOB_AMT, 3);
|
||||
DoPlayerSpriteBob(pp, PLAYER_DIVE_HEIGHTF, PLAYER_DIVE_BOB_AMTF, 3);
|
||||
}
|
||||
}
|
||||
|
||||
// Reverse bobbing when getting close to the floor
|
||||
if (pp->int_ppos().Z + pp->bob_amt >= pp->int_ploz() - PLAYER_DIVE_HEIGHT)
|
||||
if (pp->pos.Z + pp->p_bob_amt >= pp->loz - PLAYER_DIVE_HEIGHTF)
|
||||
{
|
||||
pp->bob_ndx = NORM_ANGLE(pp->bob_ndx + ((1024 + 512) - pp->bob_ndx) * 2);
|
||||
DoPlayerSpriteBob(pp, PLAYER_DIVE_HEIGHT, PLAYER_DIVE_BOB_AMT, 3);
|
||||
DoPlayerSpriteBob(pp, PLAYER_DIVE_HEIGHTF, PLAYER_DIVE_BOB_AMTF, 3);
|
||||
}
|
||||
// Reverse bobbing when getting close to the ceiling
|
||||
if (pp->int_ppos().Z + pp->bob_amt < pp->int_phiz() + pp->player_int_ceiling_dist())
|
||||
if (pp->pos.Z + pp->p_bob_amt < pp->hiz + pp->p_ceiling_dist)
|
||||
{
|
||||
pp->bob_ndx = NORM_ANGLE(pp->bob_ndx + ((512) - pp->bob_ndx) * 2);
|
||||
DoPlayerSpriteBob(pp, PLAYER_DIVE_HEIGHT, PLAYER_DIVE_BOB_AMT, 3);
|
||||
DoPlayerSpriteBob(pp, PLAYER_DIVE_HEIGHTF, PLAYER_DIVE_BOB_AMTF, 3);
|
||||
}
|
||||
|
||||
DoPlayerMove(pp);
|
||||
|
@ -4625,7 +4619,7 @@ void DoPlayerWade(PLAYER* pp)
|
|||
{
|
||||
pp->KeyPressBits &= ~SB_OPEN;
|
||||
DoPlayerBeginOperate(pp);
|
||||
pp->bob_amt = 0;
|
||||
pp->p_bob_amt = 0;
|
||||
pp->bob_ndx = 0;
|
||||
return;
|
||||
}
|
||||
|
@ -4661,7 +4655,7 @@ void DoPlayerWade(PLAYER* pp)
|
|||
//DoPlayerHeight(pp);
|
||||
//DoPlayerHeight(pp);
|
||||
DoPlayerBeginJump(pp);
|
||||
pp->bob_amt = 0;
|
||||
pp->p_bob_amt = 0;
|
||||
pp->bob_ndx = 0;
|
||||
return;
|
||||
}
|
||||
|
@ -4674,7 +4668,7 @@ void DoPlayerWade(PLAYER* pp)
|
|||
if (PlayerFlyKey())
|
||||
{
|
||||
DoPlayerBeginFly(pp);
|
||||
pp->bob_amt = 0;
|
||||
pp->p_bob_amt = 0;
|
||||
pp->bob_ndx = 0;
|
||||
return;
|
||||
}
|
||||
|
@ -4717,7 +4711,7 @@ void DoPlayerWade(PLAYER* pp)
|
|||
|
||||
if (PlayerCanDive(pp))
|
||||
{
|
||||
pp->bob_amt = 0;
|
||||
pp->p_bob_amt = 0;
|
||||
pp->bob_ndx = 0;
|
||||
return;
|
||||
}
|
||||
|
@ -4729,7 +4723,7 @@ void DoPlayerWade(PLAYER* pp)
|
|||
DoPlayerBeginFall(pp);
|
||||
// call PlayerFall now seems to iron out a hitch before falling
|
||||
DoPlayerFall(pp);
|
||||
pp->bob_amt = 0;
|
||||
pp->p_bob_amt = 0;
|
||||
pp->bob_ndx = 0;
|
||||
return;
|
||||
}
|
||||
|
@ -5760,11 +5754,11 @@ void DoPlayerHeadDebris(PLAYER* pp)
|
|||
|
||||
if ((sectp->extra & SECTFX_SINK))
|
||||
{
|
||||
DoPlayerSpriteBob(pp, Z(8), Z(4), 3);
|
||||
DoPlayerSpriteBob(pp, 8, 4, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
pp->bob_amt = 0;
|
||||
pp->p_bob_amt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -88,6 +88,7 @@ constexpr double PLAYER_DIVE_HEIGHTF = 26;
|
|||
#define PLAYER_DIVE_MAX_SPEED (1700)
|
||||
#define PLAYER_DIVE_INC (600)
|
||||
#define PLAYER_DIVE_BOB_AMT (Z(8))
|
||||
constexpr double PLAYER_DIVE_BOB_AMTF = 8;
|
||||
|
||||
#define PLAYER_DIVE_TIME (12*120) // time before damage is taken
|
||||
#define PLAYER_DIVE_DAMAGE_AMOUNT (-1) // amount of damage accessed
|
||||
|
|
|
@ -504,7 +504,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PLAYER& w, PLAYER*
|
|||
("ly", w.LadderPosition.Y)
|
||||
("JumpDuration", w.JumpDuration)
|
||||
("WadeDepth", w.WadeDepth)
|
||||
("bob_amt", w.bob_amt)
|
||||
("bob_amt", w.p_bob_amt)
|
||||
("bob_ndx", w.bob_ndx)
|
||||
("bcnt", w.bcnt)
|
||||
("bob_z", w.bob_z)
|
||||
|
|
|
@ -220,7 +220,7 @@ struct SWPlayer native
|
|||
//native int16 LadderSector;
|
||||
native int16 JumpDuration;
|
||||
native int16 WadeDepth;
|
||||
native int16 bob_amt;
|
||||
//native double bob_amt;
|
||||
native int16 bob_ndx;
|
||||
native int16 bcnt; // bob count
|
||||
native int bob_z, obob_z;
|
||||
|
|
Loading…
Reference in a new issue