Skip to content

Commit

Permalink
Blood: fixed vector math in spider attacks.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Feb 4, 2024
1 parent 0ad7e19 commit 3dbc671
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions source/core/gamefuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion source/core/gamefuncs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion source/games/blood/src/aispid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions source/games/blood/src/gameutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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--)
Expand Down

0 comments on commit 3dbc671

Please sign in to comment.