diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 4154fa3d5..f365e4231 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -127,7 +127,7 @@ void playerLookUp(int snum, ESyncBits actions); void playerLookDown(int snum, ESyncBits actions); void playerAimUp(int snum, ESyncBits actions); void playerAimDown(int snum, ESyncBits actions); -void tracers(int x1, int y1, int z1, int x2, int y2, int z2, int n); +void tracers(const DVector3& start, const DVector3& dest, int n); DDukeActor* aim(DDukeActor* s, int aang); void checkweapons(player_struct* const p); int findotherplayer(int p, double* d); diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index c9828314e..c7d955a75 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -128,31 +128,27 @@ void forceplayerangle(int snum) // //--------------------------------------------------------------------------- -void tracers(int x1, int y1, int z1, int x2, int y2, int z2, int n) +void tracers(const DVector3& start, const DVector3& dest, int n) { - int i, xv, yv, zv; sectortype* sect = nullptr; - i = n + 1; - xv = (x2 - x1) / i; - yv = (y2 - y1) / i; - zv = (z2 - z1) / i; + auto direction = dest - start; - if ((abs(x1 - x2) + abs(y1 - y2)) < 3084) + if (direction.XY().Sum() < 192.75) return; - for (i = n; i > 0; i--) + auto pos = start; + auto add = direction / (n + 1); + for (int i = n; i > 0; i--) { - x1 += xv; - y1 += yv; - z1 += zv; - updatesector(x1, y1, §); + pos += add; + updatesector(pos, §); if (sect) { if (sect->lotag == 2) - EGS(sect, x1, y1, z1, TILE_WATERBUBBLE, -32, 4 + (krand() & 3), 4 + (krand() & 3), krand() & 2047, 0, 0, ps[0].GetActor(), 5); + CreateActor(sect, pos, TILE_WATERBUBBLE, -32, 4 + (krand() & 3), 4 + (krand() & 3), krand() & 2047, 0, 0, ps[0].GetActor(), 5); else - EGS(sect, x1, y1, z1, TILE_SMALLSMOKE, -32, 14, 14, 0, 0, 0, ps[0].GetActor(), 5); + CreateActor(sect, pos, TILE_SMALLSMOKE, -32, 14, 14, 0, 0, 0, ps[0].GetActor(), 5); } } } diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 280ce3a43..ffdecfae4 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -407,7 +407,7 @@ static void shootweapon(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int if (hit.hitSector == nullptr) return; if ((krand() & 15) == 0 && hit.hitSector->lotag == 2) - tracers(hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, pos.X * worldtoint, pos.Y * worldtoint, pos.Z * zworldtoint, 8 - (ud.multimode >> 1)); + tracers(hit.hitpos, pos, 8 - (ud.multimode >> 1)); DDukeActor* spark; if (p >= 0) diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 4a8a03066..82c7b53e1 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -296,7 +296,7 @@ static void shootweapon(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int return; if ((krand() & 15) == 0 && hit.hitSector->lotag == 2) - tracers(hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, pos.X * worldtoint, pos.Y * worldtoint, pos.Z * zworldtoint, 8 - (ud.multimode >> 1)); + tracers(hit.hitpos, pos, 8 - (ud.multimode >> 1)); DDukeActor* spark; if (p >= 0)