- Blood: Floatified GibThing().

This commit is contained in:
Mitchell Richters 2022-09-24 23:43:01 +10:00 committed by Christoph Oelckers
parent 2e202a022c
commit ef3be6181e

View file

@ -350,27 +350,23 @@ void GibThing(DBloodActor* actor, GIBTHING* pGThing, DVector3* pPos, DVector3* p
if (pGThing->chance == 65536 || Chance(pGThing->chance)) if (pGThing->chance == 65536 || Chance(pGThing->chance))
{ {
auto pSector = actor->sector(); auto pSector = actor->sector();
int top, bottom; double top, bottom;
GetActorExtents(actor, &top, &bottom); GetActorExtents(actor, &top, &bottom);
int x, y, z; DVector3 gPos;
if (!pPos) if (!pPos)
{ {
int nAngle = Random(2048); DAngle nAngle = RandomAngle();
x = actor->int_pos().X + MulScale(actor->int_clipdist(), Cos(nAngle), 30); gPos = DVector3(actor->spr.pos.XY() + actor->fClipdist() * nAngle.ToVector(), bottom - RandomD(bottom - top, 8));
y = actor->int_pos().Y + MulScale(actor->int_clipdist(), Sin(nAngle), 30);
z = bottom - Random(bottom - top);
} }
else else
{ {
x = pPos->X * worldtoint; gPos = *pPos;
y = pPos->Y * worldtoint;
z = pPos->Z * zworldtoint;
} }
int32_t ceilZ, floorZ; double ceilZ, floorZ;
getzsofslopeptr(pSector, x, y, &ceilZ, &floorZ); getzsofslopeptr(pSector, gPos, &ceilZ, &floorZ);
int dz1 = floorZ - z; double dz1 = floorZ - gPos.Z;
int dz2 = z - ceilZ; double dz2 = gPos.Z - ceilZ;
auto gibactor = actSpawnThing(pSector, x, y, z, pGThing->type); auto gibactor = actSpawnThing(pSector, gPos.X * worldtoint, gPos.Y * worldtoint, gPos.Z * zworldtoint, pGThing->type);
if (!gibactor) return; if (!gibactor) return;
if (pGThing->Kills > -1) if (pGThing->Kills > -1)
@ -389,11 +385,11 @@ void GibThing(DBloodActor* actor, GIBTHING* pGThing, DVector3* pPos, DVector3* p
gibactor->vel.Z = Random2F((pGThing->at10 << 18) / 120); gibactor->vel.Z = Random2F((pGThing->at10 << 18) / 120);
break; break;
default: default:
if (dz2 < dz1 && dz2 < 0x4000) if (dz2 < dz1 && dz2 < 0x400)
{ {
gibactor->set_int_bvel_z(0); gibactor->vel.Z = 0;
} }
else if (dz2 > dz1 && dz1 < 0x4000) else if (dz2 > dz1 && dz1 < 0x400)
{ {
gibactor->vel.Z = -Random2F((pGThing->at10 << 18) / 120); gibactor->vel.Z = -Random2F((pGThing->at10 << 18) / 120);
} }