diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index c6674f328..b3d9d9c8d 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -6340,26 +6340,20 @@ DBloodActor* actSpawnThing(sectortype* pSector, int x, int y, int z, int nThingT // //--------------------------------------------------------------------------- -DBloodActor* actFireThing(DBloodActor* actor, int xyoff, int zoff, int zvel, int thingType, int nSpeed) +DBloodActor* actFireThing(DBloodActor* actor, double xyoff, double zoff, double zvel, int thingType, double nSpeed) { assert(thingType >= kThingBase && thingType < kThingMax); - int x = actor->int_pos().X + MulScale(xyoff, Cos(actor->int_ang() + 512), 30); - int y = actor->int_pos().Y + MulScale(xyoff, Sin(actor->int_ang() + 512), 30); - int z = actor->int_pos().Z + zoff; - x += MulScale(actor->native_clipdist(), Cos(actor->int_ang()), 28); - y += MulScale(actor->native_clipdist(), Sin(actor->int_ang()), 28); - if (HitScan(actor, z, x - actor->int_pos().X, y - actor->int_pos().Y, 0, CLIPMASK0, actor->native_clipdist()) != -1) + + DVector3 vect = actor->spr.pos.plusZ(zoff) + (actor->spr.angle + DAngle90).ToVector() * xyoff + actor->spr.angle.ToVector() * actor->fClipdist(); + + if (HitScan(actor, vect.Z, DVector3(vect.XY() - actor->spr.pos.XY(), 0), CLIPMASK0, actor->native_clipdist()) != -1) { - x = gHitInfo.int_hitpos().X - MulScale(actor->native_clipdist() << 1, Cos(actor->int_ang()), 28); - y = gHitInfo.int_hitpos().Y - MulScale(actor->native_clipdist() << 1, Sin(actor->int_ang()), 28); + vect.XY() = gHitInfo.hitpos.XY() - actor->spr.angle.ToVector() * actor->fClipdist() * 2; } - auto fired = actSpawnThing(actor->sector(), x, y, z, thingType); + auto fired = actSpawnThing(actor->sector(), vect, thingType); fired->SetOwner(actor); fired->spr.angle = actor->spr.angle; - fired->set_int_bvel_x(MulScale(nSpeed, Cos(fired->int_ang()), 30)); - fired->set_int_bvel_y(MulScale(nSpeed, Sin(fired->int_ang()), 30)); - fired->set_int_bvel_z(MulScale(nSpeed, zvel, 14)); - fired->vel += actor->vel * 0.5; + fired->vel = DVector3(fired->spr.angle.ToVector() * nSpeed, nSpeed * zvel * 4) + actor->vel * 0.5; return fired; } diff --git a/source/games/blood/src/actor.h b/source/games/blood/src/actor.h index c64b44033..5f768e0a4 100644 --- a/source/games/blood/src/actor.h +++ b/source/games/blood/src/actor.h @@ -226,7 +226,21 @@ DBloodActor* actSpawnSprite(sectortype* pSector, const DVector3& pos, int nStat, DBloodActor* actSpawnDude(DBloodActor* pSource, int nType, double dist); DBloodActor * actSpawnSprite(DBloodActor *pSource, int nStat); DBloodActor * actSpawnThing(sectortype* pSector, int x, int y, int z, int nThingType); -DBloodActor* actFireThing(DBloodActor* actor, int xyoff, int zoff, int zvel, int thingType, int nSpeed); +inline DBloodActor* actSpawnThing(sectortype* pSector, const DVector3& pos, int nThingType) +{ + return actSpawnThing(pSector, int(pos.X * worldtoint), int(pos.Y * worldtoint), int(pos.Z * zworldtoint), nThingType); +} + +inline DBloodActor* actFireThing(DBloodActor* actor, double xyoff, double zoff, double zvel, int thingType, double nSpeed); +inline DBloodActor* actFireThing(DBloodActor* actor, int xyoff_, int zoff_, int zvel_, int thingType, int nSpeed_) +{ + double xyoff = xyoff_ * inttoworld; + double zoff = zoff_ * zinttoworld; + double zvel = FixedToFloat(zvel_); + double nSpeed = FixedToFloat(nSpeed_); + return actFireThing(actor, xyoff, zoff, zvel, thingType, nSpeed); +} + DBloodActor* actFireMissile(DBloodActor* actor, int xyoff, int zoff, int dx, int dy, int dz, int nType); void actBurnSprite(DBloodActor* pSource, DBloodActor* pTarget, int nTime); diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index e80ca6320..13c0c6571 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -1914,13 +1914,13 @@ void playerProcess(PLAYER* pPlayer) DBloodActor* playerFireMissile(PLAYER* pPlayer, int xyoff, int dx, int dy, int dz, int nType) { - return actFireMissile(pPlayer->actor, xyoff, pPlayer->zWeapon * zworldtoint - pPlayer->actor->int_pos().Z, dx, dy, dz, nType); + return actFireMissile(pPlayer->actor, xyoff, int(pPlayer->zWeapon * zworldtoint) - pPlayer->actor->int_pos().Z, dx, dy, dz, nType); } DBloodActor* playerFireThing(PLAYER* pPlayer, int xyoff, int zvel, int thingType, int nSpeed) { assert(thingType >= kThingBase && thingType < kThingMax); - return actFireThing(pPlayer->actor, xyoff, pPlayer->zWeapon * zworldtoint - pPlayer->actor->int_pos().Z, pPlayer->slope + zvel, thingType, nSpeed); + return actFireThing(pPlayer->actor, xyoff, int(pPlayer->zWeapon * zworldtoint) - pPlayer->actor->int_pos().Z, pPlayer->slope + zvel, thingType, nSpeed); } //---------------------------------------------------------------------------