- cleaned up assignments of random values to vel

This commit is contained in:
Christoph Oelckers 2022-09-03 10:07:06 +02:00
parent eed7f0806c
commit 5cde04fee7
5 changed files with 36 additions and 31 deletions

View file

@ -5146,9 +5146,9 @@ void MoveDude(DBloodActor* actor)
auto pFX2 = gFX.fxSpawnActor(FX_14, pFX->sector(), pFX->spr.pos, 0);
if (pFX2)
{
pFX2->set_int_bvel_x(Random2(0x6aaaa));
pFX2->set_int_bvel_y(Random2(0x6aaaa));
pFX2->set_int_bvel_z(-(int)Random(0xd5555));
pFX2->vel.X = Random2F(0x6aaaa);
pFX2->vel.Y = Random2F(0x6aaaa);
pFX2->vel.Z = -Random2F(0xd5555);
}
}
}
@ -5955,7 +5955,7 @@ static void actCheckTraps()
{
pFX->set_int_bvel_x(dx + Random2(0x8888));
pFX->set_int_bvel_y(dy + Random2(0x8888));
pFX->set_int_bvel_z(Random2(0x8888));
pFX->vel.Z = Random2F(0x8888);
}
x += (dx / 2) >> 12;
y += (dy / 2) >> 12;

View file

@ -546,6 +546,11 @@ inline int Random2(int a1)
return MulScale(wrand(), a1, 14) - a1;
}
inline double Random2F(int a1)
{
return FixedToFloat(MulScale(wrand(), a1, 14) - a1);
}
inline int Random3(int a1)
{
return MulScale(wrand() + wrand(), a1, 15) - a1;

View file

@ -283,9 +283,9 @@ void fxSpawnBlood(DBloodActor* actor, int)
if (bloodactor)
{
bloodactor->set_int_ang(1024);
bloodactor->set_int_bvel_x(Random2(0x6aaaa));
bloodactor->set_int_bvel_y(Random2(0x6aaaa));
bloodactor->set_int_bvel_z(-(int)Random(0x10aaaa) - 100);
bloodactor->vel.X = Random2F(0x6aaaa);
bloodactor->vel.Y = Random2F(0x6aaaa);
bloodactor->vel.Z = -Random2F(0x10aaaa) - FixedToFloat(100);
evPostActor(bloodactor, 8, kCallbackFXBloodSpurt);
}
}
@ -313,9 +313,9 @@ void fxSpawnPodStuff(DBloodActor* actor, int)
if (spawnactor)
{
spawnactor->set_int_ang(1024);
spawnactor->set_int_bvel_x(Random2(0x6aaaa));
spawnactor->set_int_bvel_y(Random2(0x6aaaa));
spawnactor->set_int_bvel_z(-(int)Random(0x10aaaa) - 100);
spawnactor->vel.X = Random2F(0x6aaaa);
spawnactor->vel.Y = Random2F(0x6aaaa);
spawnactor->vel.Z = -Random2F(0x10aaaa) - FixedToFloat(100);
evPostActor(spawnactor, 8, kCallbackFXPodBloodSpray);
}
}

View file

@ -306,12 +306,12 @@ void GibFX(DBloodActor* actor, GIBFX* pGFX, DVector3* pPos, CGibVelocity* pVel)
}
else
{
pFX->set_int_bvel_x(Random2((pGFX->atd << 18) / 120));
pFX->set_int_bvel_y(Random2((pGFX->atd << 18) / 120));
pFX->vel.X = Random2F((pGFX->atd << 18) / 120);
pFX->vel.Y = Random2F((pGFX->atd << 18) / 120);
switch (actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK)
{
case 16:
pFX->set_int_bvel_z(Random2((pGFX->at11 << 18) / 120));
pFX->vel.Z = Random2F((pGFX->at11 << 18) / 120);
break;
default:
if (dz2 < dz1 && dz2 < 0x4000)
@ -320,14 +320,14 @@ void GibFX(DBloodActor* actor, GIBFX* pGFX, DVector3* pPos, CGibVelocity* pVel)
}
else if (dz2 > dz1 && dz1 < 0x4000)
{
pFX->set_int_bvel_z(-(int)Random((abs(pGFX->at11) << 18) / 120));
pFX->vel.Z = -Random2F((abs(pGFX->at11) << 18) / 120);
}
else
{
if ((pGFX->at11 << 18) / 120 < 0)
pFX->set_int_bvel_z(-(int)Random((abs(pGFX->at11) << 18) / 120));
pFX->vel.Z = -Random2F((abs(pGFX->at11) << 18) / 120);
else
pFX->set_int_bvel_z(Random2((pGFX->at11 << 18) / 120));
pFX->vel.Z = Random2F((pGFX->at11 << 18) / 120);
}
break;
}
@ -387,12 +387,12 @@ void GibThing(DBloodActor* actor, GIBTHING* pGThing, DVector3* pPos, CGibVelocit
}
else
{
gibactor->set_int_bvel_x(Random2((pGThing->atc << 18) / 120));
gibactor->set_int_bvel_y(Random2((pGThing->atc << 18) / 120));
gibactor->vel.X = Random2F((pGThing->atc << 18) / 120);
gibactor->vel.Y = Random2F((pGThing->atc << 18) / 120);
switch (actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK)
{
case 16:
gibactor->set_int_bvel_z(Random2((pGThing->at10 << 18) / 120));
gibactor->vel.Z = Random2F((pGThing->at10 << 18) / 120);
break;
default:
if (dz2 < dz1 && dz2 < 0x4000)
@ -401,11 +401,11 @@ void GibThing(DBloodActor* actor, GIBTHING* pGThing, DVector3* pPos, CGibVelocit
}
else if (dz2 > dz1 && dz1 < 0x4000)
{
gibactor->set_int_bvel_z(-(int)Random((pGThing->at10 << 18) / 120));
gibactor->vel.Z = -Random2F((pGThing->at10 << 18) / 120);
}
else
{
gibactor->set_int_bvel_z(Random2((pGThing->at10 << 18) / 120));
gibactor->vel.Z = Random2F((pGThing->at10 << 18) / 120);
}
break;
}
@ -464,15 +464,15 @@ void GibFX(walltype* pWall, GIBFX* pGFX, int a3, int a4, int a5, int a6, CGibVel
pGib->spr.pal = pWall->pal;
if (!pVel)
{
pGib->set_int_bvel_x(Random2((pGFX->atd << 18) / 120));
pGib->set_int_bvel_y(Random2((pGFX->atd << 18) / 120));
pGib->set_int_bvel_z(-(int)Random((pGFX->at11 << 18) / 120));
pGib->vel.X = Random2F((pGFX->atd << 18) / 120);
pGib->vel.Y = Random2F((pGFX->atd << 18) / 120);
pGib->vel.Z = -Random2F((pGFX->at11 << 18) / 120);
}
else
{
pGib->set_int_bvel_x(Random2((pVel->vx << 18) / 120));
pGib->set_int_bvel_y(Random2((pVel->vy << 18) / 120));
pGib->set_int_bvel_z(-(int)Random((pVel->vz << 18) / 120));
pGib->vel.X = Random2F((pVel->vx << 18) / 120);
pGib->vel.Y = Random2F((pVel->vy << 18) / 120);
pGib->vel.Z = -Random2F((pVel->vz << 18) / 120);
}
}
}

View file

@ -1805,9 +1805,9 @@ void debrisMove(int listIndex)
for (i = 0; i < 7; i++)
{
if ((pFX2 = gFX.fxSpawnActor(FX_14, pFX->sector(), pFX->spr.pos, 0)) == NULL) continue;
pFX2->set_int_bvel_x(Random2(0x6aaaa));
pFX2->set_int_bvel_y(Random2(0x6aaaa));
pFX2->set_int_bvel_z(-(int)Random(0xd5555));
pFX2->vel.X = Random2F(0x6aaaa);
pFX2->vel.Y = Random2F(0x6aaaa);
pFX2->vel.Z = -Random2F(0xd5555);
}
break;
case kSurfWater:
@ -8823,7 +8823,7 @@ void aiPatrolThink(DBloodActor* actor)
if (actor->xspr.stateTimer > 0 || markeractor->xspr.data1 == markeractor->xspr.data2)
{
if (pExtra->flying)
actor->set_int_bvel_z(Random2(0x8000));
actor->vel.Z = Random2F(0x8000);
// turn while waiting
if (markeractor->spr.flags & kModernTypeFlag16)