- floatified USER slide variables.

This commit is contained in:
Christoph Oelckers 2022-09-04 20:23:54 +02:00
parent 2ab87ad18c
commit 7ba56bc6cc
6 changed files with 45 additions and 54 deletions

View file

@ -614,13 +614,13 @@ void KeepActorOnFloor(DSWActor* actor)
//
//---------------------------------------------------------------------------
int DoActorBeginSlide(DSWActor* actor, int ang, int vel, int dec)
int DoActorBeginSlide(DSWActor* actor, DAngle ang, double vel)
{
actor->user.Flags |= (SPR_SLIDING);
actor->user._slide_ang = ang;
actor->user._slide_vel = vel;
actor->user._slide_dec = dec;
actor->user.slide_ang = ang;
actor->user.slide_vel = vel;
actor->user.slide_dec = 5/16.;
//DoActorSlide(actor);
@ -632,20 +632,17 @@ int DoActorBeginSlide(DSWActor* actor, int ang, int vel, int dec)
int DoActorSlide(DSWActor* actor)
{
int nx, ny;
auto vec = actor->user.slide_ang.ToVector() * actor->user.slide_vel;
nx = MulScale(actor->user._slide_vel, bcos(actor->user._slide_ang), 14);
ny = MulScale(actor->user._slide_vel, bsin(actor->user._slide_ang), 14);
if (!move_actor(actor, DVector3(nx * inttoworld, ny * inttoworld, 0)))
if (!move_actor(actor, DVector3(vec, 0)))
{
actor->user.Flags &= ~(SPR_SLIDING);
return false;
}
actor->user._slide_vel -= actor->user._slide_dec * ACTORMOVETICS;
actor->user.slide_vel -= actor->user.slide_dec * ACTORMOVETICS;
if (actor->user._slide_vel < 20)
if (actor->user.slide_vel < 1.25)
{
actor->user.Flags &= ~(SPR_SLIDING);
}

View file

@ -120,7 +120,7 @@ inline double RandomRangeF(double range)
}
int RANDOM_P2(int pwr_of_2) { return (RANDOM() & (pwr_of_2 - 1)); }
double RANDOM_P2F(int pwr_of_2, int shift) { return (RANDOM() & ((pwr_of_2 << shift) - 1)) * (1./(1 << shift)); }
DAngle RANDOM_ANGLE() { return DAngle::fromBuild(RANDOM_P2(2048)); }
DAngle RANDOM_ANGLE(int range = 2048) { return DAngle::fromBuild(RANDOM_P2(range)); }
//
// Map directions/degrees
@ -1040,9 +1040,9 @@ struct USER
int track_vel;
// sliding variables - slide backwards etc
int16_t _slide_ang;
int _slide_vel;
int16_t _slide_dec;
DAngle slide_ang;
double slide_vel;
double slide_dec;
int16_t motion_blur_dist;
int16_t motion_blur_num;

View file

@ -2361,7 +2361,7 @@ void DriveCrush(PLAYER* pp, DVector2* quad)
int32_t const vel = FindDistance2D(pp->vect.X>>8, pp->vect.Y>>8);
if (vel < 9000)
{
DoActorBeginSlide(actor, getangle(pp->vect.X, pp->vect.Y), vel/8, 5);
DoActorBeginSlide(actor, VecToAngle(pp->vect.X, pp->vect.Y), vel/8 * inttoworld);
if (DoActorSlide(actor))
continue;
}
@ -5451,7 +5451,7 @@ void DoPlayerBeginDie(PLAYER* pp)
pp->Flags |= (PF_DEAD_HEAD | PF_JUMPING);
pp->jump_speed = -300;
plActor->user._slide_vel = 0;
plActor->user.slide_vel = 0;
SpawnShrap(pp->actor, nullptr);
plActor->spr.cstat |= (CSTAT_SPRITE_YCENTER);
NewStateGroup(pp->actor, sg_PlayerHeadFly);
@ -5484,7 +5484,7 @@ void DoPlayerBeginDie(PLAYER* pp)
pp->Flags |= (PF_DEAD_HEAD | PF_JUMPING);
pp->jump_speed = 200;
plActor->user._slide_vel = 800;
plActor->user.slide_vel = 50;
SpawnShrap(pp->actor, nullptr);
plActor->spr.cstat |= (CSTAT_SPRITE_YCENTER);
NewStateGroup(pp->actor, sg_PlayerHeadFly);
@ -5703,10 +5703,10 @@ void DoPlayerDeathCheckKick(PLAYER* pp)
{
pp->KillerActor = itActor;
plActor->user._slide_ang = getangle(plActor->int_pos().X - itActor->int_pos().X, plActor->int_pos().Y - itActor->int_pos().Y);
plActor->user._slide_ang = NORM_ANGLE(plActor->user._slide_ang + (RANDOM_P2(128<<5)>>5) - 64);
plActor->user.slide_ang = VecToAngle(plActor->spr.pos - itActor->spr.pos);
plActor->user.slide_ang += DAngle::fromBuild((RANDOM_P2(128<<5)>>5) - 64);
plActor->user._slide_vel = itActor->int_xvel() << 1;
plActor->user.slide_vel = itActor->vel.X * 2;
plActor->user.Flags &= ~(SPR_BOUNCE);
pp->jump_speed = -500;
NewStateGroup(pp->actor, sg_PlayerHeadFly);
@ -5721,8 +5721,8 @@ void DoPlayerDeathCheckKick(PLAYER* pp)
// sector stomper kick
if (abs(pp->loz - pp->hiz) < ActorSizeZ(plActor) - 8)
{
plActor->user._slide_ang = RANDOM_P2(2048);
plActor->user._slide_vel = 1000;
plActor->user.slide_ang = RANDOM_ANGLE();
plActor->user.slide_vel = 62.5;
plActor->user.Flags &= ~(SPR_BOUNCE);
pp->jump_speed = -100;
NewStateGroup(pp->actor, sg_PlayerHeadFly);
@ -5735,38 +5735,33 @@ void DoPlayerDeathCheckKick(PLAYER* pp)
void DoPlayerDeathMoveHead(PLAYER* pp)
{
DSWActor* plActor = pp->actor;
int dax,day;
dax = MOVEx(plActor->user._slide_vel, plActor->user._slide_ang);
day = MOVEy(plActor->user._slide_vel, plActor->user._slide_ang);
auto davec = plActor->user.slide_ang.ToVector() * plActor->user.slide_vel;
plActor->user.coll = move_sprite(pp->actor, dax, day, 0, Z(16), Z(16), 1, synctics);
plActor->user.coll = move_sprite(pp->actor, DVector3(davec, 0), 16, 16, 1, synctics);
{
switch (plActor->user.coll.type)
{
case kHitSprite:
{
short wall_ang, dang;
auto hitActor = plActor->user.coll.actor();
if (!(hitActor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_WALL))
break;
wall_ang = NORM_ANGLE(hitActor->int_ang());
dang = getincangle(wall_ang, plActor->user._slide_ang);
plActor->user._slide_ang = NORM_ANGLE(wall_ang + 1024 - dang);
DAngle wall_ang = hitActor->spr.angle;
DAngle dang = deltaangle(wall_ang, plActor->user.slide_ang);
plActor->user.slide_ang = wall_ang + DAngle180 - dang;
SpawnShrap(pp->actor, nullptr);
break;
}
case kHitWall:
{
int wall_ang = NORM_ANGLE(getangle(plActor->user.coll.hitWall->delta())-512);
int dang = getincangle(wall_ang, plActor->user._slide_ang);
plActor->user._slide_ang = NORM_ANGLE(wall_ang + 1024 - dang);
DAngle wall_ang = VecToAngle(plActor->user.coll.hitWall->delta()) - DAngle90;
DAngle dang = deltaangle(wall_ang, plActor->user.slide_ang);
plActor->user.slide_ang = wall_ang + DAngle180 - dang;
SpawnShrap(pp->actor, nullptr);
break;
@ -5879,7 +5874,7 @@ void DoPlayerDeathBounce(PLAYER* pp)
{
plActor->spr.cstat &= ~(CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN);
NewStateGroup(pp->actor, sg_PlayerHead);
plActor->user._slide_vel = 0;
plActor->user.slide_vel = 0;
plActor->user.Flags |= (SPR_BOUNCE);
@ -5888,8 +5883,8 @@ void DoPlayerDeathBounce(PLAYER* pp)
plActor->user.Flags |= (SPR_BOUNCE);
pp->jump_speed = -300;
plActor->user._slide_vel >>= 2;
plActor->user._slide_ang = NORM_ANGLE((RANDOM_P2(64<<8)>>8) - 32);
plActor->user.slide_vel *= 0.25;
plActor->user.slide_ang = DAngle::fromBuild((RANDOM_P2(64<<8)>>8) - 32);
pp->Flags |= (PF_JUMPING);
SpawnShrap(pp->actor, nullptr);
}

View file

@ -815,9 +815,9 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, USER& w, USER* def
("point", w.point, def->point)
("track_dir", w.track_dir, def->track_dir)
("track_vel", w.track_vel, def->track_vel)
("slide_ang", w._slide_ang, def->_slide_ang)
("slide_vel", w._slide_vel, def->_slide_vel)
("slide_dec", w._slide_dec, def->_slide_dec)
("slide_ang", w.slide_ang, def->slide_ang)
("slide_vel", w.slide_vel, def->slide_vel)
("slide_dec", w.slide_dec, def->slide_dec)
("motion_blur_dist", w.motion_blur_dist, def->motion_blur_dist)
("motion_blur_num", w.motion_blur_num, def->motion_blur_num)
("wait_active_check", w.wait_active_check, def->wait_active_check)

View file

@ -5198,7 +5198,7 @@ int ActorStdMissile(DSWActor* actor, DSWActor* weapActor)
int ActorDamageSlide(DSWActor* actor, int damage, int ang)
{
int slide_vel,slide_dec;
auto angle = DAngle::fromBuild(ang);
if (actor->user.Flags & (SPR_CLIMBING))
return false;
@ -5210,22 +5210,21 @@ int ActorDamageSlide(DSWActor* actor, int damage, int ang)
if (damage <= 10)
{
DoActorBeginSlide(actor, ang, 64, 5);
DoActorBeginSlide(actor, angle, 4);
return true;
}
else if (damage <= 20)
{
DoActorBeginSlide(actor, ang, 128, 5);
DoActorBeginSlide(actor, angle, 8);
return true;
}
else
{
slide_vel = (damage * 6) - (actor->user.MaxHealth);
int slide_vel = (damage * 6) - (actor->user.MaxHealth);
if (slide_vel < -1000) slide_vel = -1000;
slide_dec = 5;
DoActorBeginSlide(actor, ang, slide_vel, slide_dec);
DoActorBeginSlide(actor, angle, slide_vel / 16.);
return true;
}
@ -5366,9 +5365,9 @@ int PlayerCheckDeath(PLAYER* pp, DSWActor* weapActor)
DoPlayerBeginDie(pp);
// for death direction
actor->user._slide_ang = getangle(actor->int_pos().X - weapActor->int_pos().X, actor->int_pos().Y - weapActor->int_pos().Y);
actor->user.slide_ang = VecToAngle(actor->spr.pos - weapActor->spr.pos);
// for death velocity
actor->user._slide_vel = actor->user.LastDamage * 5;
actor->user.slide_vel = actor->user.LastDamage * (5 / 16.);
return true;
}
@ -11114,7 +11113,7 @@ int DoSerpRing(DSWActor* actor)
}
// rotate the ring
actor->user._slide_ang = NORM_ANGLE(actor->user._slide_ang + actor->spr.yint);
actor->user.slide_ang += DAngle::fromBuild(actor->spr.yint);
// rotate the heads
if (actor->user.Flags & (SPR_BOUNCE))
@ -11123,7 +11122,7 @@ int DoSerpRing(DSWActor* actor)
actor->set_int_ang(NORM_ANGLE(actor->int_ang() - (28 * RINGMOVETICS)));
// put it out there
actor->add_int_pos({ MulScale(int(actor->user.Dist * worldtoint), bcos(actor->user._slide_ang), 14), MulScale(int(actor->user.Dist * worldtoint), bsin(actor->user._slide_ang), 14), 0 });
actor->spr.pos += actor->user.slide_ang.ToVector() * actor->user.Dist;
SetActor(actor, actor->spr.pos);
@ -11337,7 +11336,7 @@ int InitSerpRing(DSWActor* actor)
actorNew->user.pos.Z = 50;
// ang around the serp is now slide_ang
actorNew->user._slide_ang = actorNew->int_ang();
actorNew->user.slide_ang = actorNew->spr.angle;
// randomize the head turning angle
actorNew->set_int_ang(RANDOM_P2(2048<<5)>>5);

View file

@ -169,7 +169,7 @@ inline int CloseRangeDist(DSWActor* a1, DSWActor* a2, int fudge)
extern short target_ang;
DSWActor* SpawnShotgunSparks(PLAYER* pp, sectortype* hit_sect, walltype* hit_wall, int hit_x, int hit_y, int hit_z, short hit_ang);
int DoActorBeginSlide(DSWActor* actor, int ang, int vel, int dec);
int DoActorBeginSlide(DSWActor* actor, DAngle ang, double vel);
int GetOverlapSector(int x, int y, sectortype** over, sectortype** under);
bool MissileHitDiveArea(DSWActor*);