From 58642c4d2f6fb897446d7aabd62b315edfcc57a1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 2 Sep 2022 23:52:40 +0200 Subject: [PATCH] - cleaned up the distance checks in operatetripbomb --- source/games/duke/src/player_d.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 3c951e729..713d77c64 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -2032,19 +2032,25 @@ int operateTripbomb(int snum) DukeSectIterator it(hit.hitSector); while ((act = it.Next())) { - if (!actorflag(act, SFLAG_BLOCK_TRIPBOMB) && - abs(act->int_pos().Z - hit.int_hitpos().Z) < (12 << 8) && ((act->int_pos().X - hit.int_hitpos().X) * (act->int_pos().X - hit.int_hitpos().X) + (act->int_pos().Y - hit.int_hitpos().Y) * (act->int_pos().Y - hit.int_hitpos().Y)) < (290 * 290)) - return 0; + if (!actorflag(act, SFLAG_BLOCK_TRIPBOMB)) + { + auto delta = act->spr.pos - hit.hitpos; + if (abs(delta.Z) < 12 && delta.XY().LengthSquared() < (18.125 * 18.125)) + return 0; + } } if (act == nullptr && hit.hitWall != nullptr && (hit.hitWall->cstat & CSTAT_WALL_MASKED) == 0) if ((hit.hitWall->twoSided() && hit.hitWall->nextSector()->lotag <= 2) || (!hit.hitWall->twoSided() && hit.hitSector->lotag <= 2)) - if (((hit.int_hitpos().X - p->player_int_pos().X) * (hit.int_hitpos().X - p->player_int_pos().X) + (hit.int_hitpos().Y - p->player_int_pos().Y) * (hit.int_hitpos().Y - p->player_int_pos().Y)) < (290 * 290)) + { + auto delta = hit.hitpos.XY() - p->pos.XY(); + if (delta.LengthSquared() < (18.125 * 18.125)) { p->pos.Z = p->opos.Z; p->vel.Z = 0; return 1; } + } return 0; }