From 3dbc67150d25048b6b91565d413d0bfe609ea723 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 4 Feb 2024 13:26:46 +0100 Subject: [PATCH] Blood: fixed vector math in spider attacks. --- source/core/gamefuncs.cpp | 4 ++-- source/core/gamefuncs.h | 2 +- source/games/blood/src/aispid.cpp | 2 +- source/games/blood/src/gameutil.cpp | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/core/gamefuncs.cpp b/source/core/gamefuncs.cpp index af5b231f5..7810dd486 100644 --- a/source/core/gamefuncs.cpp +++ b/source/core/gamefuncs.cpp @@ -745,7 +745,7 @@ double checkSectorPlaneHit(sectortype* sec, const DVector3& start, const DVector // //========================================================================== -int hitscan(const DVector3& start, const sectortype* startsect, const DVector3& vect, HitInfoBase& hitinfo, unsigned cliptype, double maxrange) +int hitscan(const DVector3& start, const sectortype* startsect, const DVector3& vect, HitInfoBase& hitinfo, unsigned cliptype, double maxrange, bool rangeisxy) { double hitfactor = DBL_MAX; @@ -758,7 +758,7 @@ int hitscan(const DVector3& start, const sectortype* startsect, const DVector3& if (maxrange > 0) { - hitfactor = maxrange / vect.Length(); + hitfactor = maxrange / (rangeisxy? vect.XY().Length() : vect.Length()); hitinfo.hitpos = start + hitfactor * vect; } else hitinfo.hitpos.X = hitinfo.hitpos.Y = DBL_MAX; diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index 8b0190f5a..7451dbcf8 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -215,7 +215,7 @@ double checkWallHit(walltype* wal, EWallFlags flagmask, const DVector3& start, c double checkSectorPlaneHit(sectortype* sec, const DVector3& start, const DVector3& direction, DVector3& result, double maxfactor); void neartag(const DVector3& start, sectortype* sect, DAngle angle, HitInfoBase& result, double neartagrange, int tagsearch); int testpointinquad(const DVector2& pt, const DVector2* quad); -int hitscan(const DVector3& start, const sectortype* startsect, const DVector3& vect, HitInfoBase& hitinfo, unsigned cliptype, double maxrange = -1); +int hitscan(const DVector3& start, const sectortype* startsect, const DVector3& vect, HitInfoBase& hitinfo, unsigned cliptype, double maxrange = -1, bool rangeisxy = false); bool checkRangeOfWall(walltype* wal, EWallFlags flagmask, const DVector3& pos, double maxdist, double* theZs); bool checkRangeOfFaceSprite(DCoreActor* itActor, const DVector3& pos, double maxdist, double* theZs); diff --git a/source/games/blood/src/aispid.cpp b/source/games/blood/src/aispid.cpp index 41fb7628e..193a3d44e 100644 --- a/source/games/blood/src/aispid.cpp +++ b/source/games/blood/src/aispid.cpp @@ -73,7 +73,7 @@ void SpidBiteSeqCallback(int, DBloodActor* actor) int hit = HitScan(actor, actor->spr.pos.Z, DVector3(vec.XY(), 0), CLIPMASK1, 0); if (hit == 3 && gHitInfo.actor()->IsPlayerActor()) { - vec.Z += target->spr.pos.Z - actor->spr.pos.Z; + vec.Z += (target->spr.pos.Z - actor->spr.pos.Z) / (target->spr.pos.XY() - actor->spr.pos.XY()).Length(); DBloodPlayer* pPlayer = getPlayer(target->spr.type - kDudePlayer1); switch (actor->spr.type) { diff --git a/source/games/blood/src/gameutil.cpp b/source/games/blood/src/gameutil.cpp index 5bf6417e5..7568ad625 100644 --- a/source/games/blood/src/gameutil.cpp +++ b/source/games/blood/src/gameutil.cpp @@ -219,7 +219,7 @@ int HitScan(DBloodActor* actor, double z, const DVector3& vect, unsigned int nMa gHitInfo.clearObj(); auto bakCstat = actor->spr.cstat; actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_HITSCAN; - hitscan(DVector3(actor->spr.pos.XY(), z), actor->sector(), vect, gHitInfo, nMask, nRange); + hitscan(DVector3(actor->spr.pos.XY(), z), actor->sector(), vect, gHitInfo, nMask, nRange, true); actor->spr.cstat = bakCstat; if (gHitInfo.actor() != nullptr) @@ -257,7 +257,7 @@ int VectorScan(DBloodActor* actor, double nOffset, double nZOffset, const DVecto auto bakCstat = actor->spr.cstat; actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_HITSCAN; - hitscan(pos, actor->sector(), vel, gHitInfo, CLIPMASK1, nRange); + hitscan(pos, actor->sector(), vel, gHitInfo, CLIPMASK1, nRange, true); actor->spr.cstat = bakCstat; while (nNum--)