- eliminated HITINFO.hitsprite.

This was one of the more annoying sprite index variables because it is part of static global data.
This commit is contained in:
Christoph Oelckers 2021-05-05 16:43:42 +02:00
parent 9b4ee3dc2c
commit 62502439d7
19 changed files with 121 additions and 132 deletions

View file

@ -3852,17 +3852,17 @@ int actDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE damageT
//
//---------------------------------------------------------------------------
void actHitcodeToData(int a1, HITINFO* pHitInfo, DBloodActor** pActor, walltype** a7)
void actHitcodeToData(int a1, HITINFO* pHitInfo, DBloodActor** pActor, walltype** ppWall)
{
assert(pHitInfo != nullptr);
int nSprite = -1;
DBloodActor* actor = nullptr;
int nWall = -1;
walltype* pWall = nullptr;
switch (a1)
{
case 3:
case 5:
nSprite = pHitInfo->hitsprite;
actor = pHitInfo->hitactor;
break;
case 0:
case 4:
@ -3872,8 +3872,8 @@ void actHitcodeToData(int a1, HITINFO* pHitInfo, DBloodActor** pActor, walltype*
default:
break;
}
if (pActor) *pActor = nSprite == -1 ? nullptr : &bloodActors[nSprite];
if (a7) *a7 = pWall;
if (pActor) *pActor = actor;
if (ppWall) *ppWall = pWall;
}
//---------------------------------------------------------------------------
@ -4901,7 +4901,7 @@ void MoveDude(DBloodActor* actor)
if (pHitSprite->statnum == kStatProjectile && !(pHitSprite->flags & 32) && actor != Owner)
{
HITINFO hitInfo = gHitInfo;
gHitInfo.hitsprite = pSprite->index;
gHitInfo.hitactor = actor;
actImpactMissile(coll.actor, 3);
gHitInfo = hitInfo;
}
@ -5344,9 +5344,7 @@ int MoveMissile(DBloodActor* actor)
bakCstat = pOwner->cstat;
pOwner->cstat &= ~257;
}
gHitInfo.hitsect = -1;
gHitInfo.hitwall = -1;
gHitInfo.hitsprite = -1;
gHitInfo.clearObj();
if (pSprite->type == kMissileFlameSpray) actAirDrag(actor, 0x1000);
if (actor->GetTarget() != nullptr && (actor->xvel() || actor->yvel() || actor->zvel()))
@ -5405,7 +5403,7 @@ int MoveMissile(DBloodActor* actor)
}
if (clipmoveresult.type == kHitSprite)
{
gHitInfo.hitsprite = clipmoveresult.legacyVal & kHitIndexMask;
gHitInfo.hitactor = clipmoveresult.actor;
cliptype = 3;
}
else if (clipmoveresult.type == kHitWall)
@ -6924,17 +6922,16 @@ void actFireVector(DBloodActor* shooter, int a2, int a3, int a4, int a5, int a6,
int hit = VectorScan(pShooter, a2, a3, a4, a5, a6, nRange, 1);
if (hit == 3)
{
int nSprite_ = gHitInfo.hitsprite;
assert(nSprite_ >= 0 && nSprite_ < kMaxSprites);
auto actor = &bloodActors[nSprite_];
spritetype* pSprite = &actor->s();
auto hitactor = gHitInfo.hitactor;
assert(hitactor != nullptr);
spritetype* pSprite = &hitactor->s();
if (!gGameOptions.bFriendlyFire && IsTargetTeammate(pShooter, pSprite)) return;
if (IsPlayerSprite(pSprite))
{
PLAYER* pPlayer = &gPlayer[pSprite->type - kDudePlayer1];
if (powerupCheck(pPlayer, kPwUpReflectShots))
{
gHitInfo.hitsprite = pShooter->index;
gHitInfo.hitactor = shooter;
gHitInfo.hitx = pShooter->x;
gHitInfo.hity = pShooter->y;
gHitInfo.hitz = pShooter->z;
@ -7008,9 +7005,7 @@ void actFireVector(DBloodActor* shooter, int a2, int a3, int a4, int a5, int a6,
}
case 3:
{
int nSprite = gHitInfo.hitsprite;
assert(nSprite >= 0 && nSprite < kMaxSprites);
auto actor = &bloodActors[nSprite];
auto actor = gHitInfo.hitactor;
spritetype* pSprite = &actor->s();
nSurf = surfType[pSprite->picnum];
x -= MulScale(a4, 112, 14);
@ -7117,12 +7112,12 @@ void actFireVector(DBloodActor* shooter, int a2, int a3, int a4, int a5, int a6,
if (pXSprite->physAttr & kPhysDebrisVector) {
int impulse = DivScale(pVectorData->impulse, ClipLow(gSpriteMass[pSprite->extra].mass, 10), 6);
xvel[nSprite] += MulScale(a4, impulse, 16);
yvel[nSprite] += MulScale(a5, impulse, 16);
zvel[nSprite] += MulScale(a6, impulse, 16);
actor->xvel() += MulScale(a4, impulse, 16);
actor->yvel() += MulScale(a5, impulse, 16);
actor->zvel() += MulScale(a6, impulse, 16);
if (pVectorData->burnTime != 0) {
if (!pXSprite->burnTime) evPost(nSprite, 3, 0, kCallbackFXFlameLick);
if (!pXSprite->burnTime) evPost(actor, 0, kCallbackFXFlameLick);
actBurnSprite(shooter->GetOwner(), actor, pVectorData->burnTime);
}
@ -7404,6 +7399,19 @@ void SerializeActor(FSerializer& arc)
}
// dumping ground for temporary wrappers.
void HITINFO::set(hitdata_t* hit)
{
hitsect = hit->sect;
hitwall = hit->wall;
hitsprite = hit->sprite;
hitactor = hit->sprite >= 0 ? &bloodActors[hit->sprite] : nullptr;
hitx = hit->pos.x;
hity = hit->pos.y;
hitz = hit->pos.z;
}
void actPostSprite(int nSprite, int nStatus)
{
actPostSprite(&bloodActors[nSprite], nStatus);

View file

@ -142,7 +142,7 @@ bool CanMove(DBloodActor *actor, DBloodActor* target, int nAngle, int nRange)
int nDist = approxDist(x-gHitInfo.hitx, y-gHitInfo.hity);
if (nDist - (pSprite->clipdist << 2) < nRange)
{
if (gHitInfo.hitsprite < 0 || target == nullptr || target->s().index != gHitInfo.hitsprite)
if (gHitInfo.hitactor == nullptr || target == nullptr || target != gHitInfo.hitactor)
return false;
return true;
}

View file

@ -301,7 +301,7 @@ static void beastThinkChase(DBloodActor* actor)
aiNewState(actor, &beastStomp);
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type)
if (pSprite->type != gHitInfo.hitactor->s().type)
{
if (!pXSector || !pXSector->Underwater)
aiNewState(actor, &beastStomp);
@ -339,7 +339,7 @@ static void beastThinkChase(DBloodActor* actor)
aiNewState(actor, &beastSlash);
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type)
if (pSprite->type != gHitInfo.hitactor->s().type)
{
if (pXSector && pXSector->Underwater)
aiNewState(actor, &beastSwimSlash);

View file

@ -202,7 +202,7 @@ static void calebThinkChase(DBloodActor* actor)
aiNewState(actor, &tinycalebAttack);
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type)
if (pSprite->type != gHitInfo.hitactor->s().type)
{
if (pXSector && pXSector->Underwater)
aiNewState(actor, &tinycalebSwimAttack);

View file

@ -432,7 +432,7 @@ static void cerberusThinkChase(DBloodActor* actor)
aiNewState(actor, &cerberusBite);
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeHellHound)
if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeHellHound)
aiNewState(actor, &cerberusBite);
break;
case 0:
@ -449,7 +449,7 @@ static void cerberusThinkChase(DBloodActor* actor)
aiNewState(actor, &cerberus2Bite);
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeHellHound)
if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeHellHound)
aiNewState(actor, &cerberus2Bite);
break;
case 0:

View file

@ -316,7 +316,7 @@ static void cultThinkChase(DBloodActor* actor)
case 4:
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
aiNewState(actor, &cultistTThrow);
break;
default:
@ -338,7 +338,7 @@ static void cultThinkChase(DBloodActor* actor)
aiNewState(actor, &cultistTSwimFire);
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeCultistShotgun)
if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeCultistShotgun)
{
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
aiNewState(actor, &cultistTFire);
@ -384,7 +384,7 @@ static void cultThinkChase(DBloodActor* actor)
case 4:
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
aiNewState(actor, &cultistSThrow);
break;
default:
@ -406,7 +406,7 @@ static void cultThinkChase(DBloodActor* actor)
aiNewState(actor, &cultistSSwimFire);
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeCultistTommy)
if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeCultistTommy)
{
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
aiNewState(actor, &cultistSFire);
@ -452,7 +452,7 @@ static void cultThinkChase(DBloodActor* actor)
case 4:
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
aiNewState(actor, &cultistTsThrow);
break;
default:
@ -474,7 +474,7 @@ static void cultThinkChase(DBloodActor* actor)
aiNewState(actor, &cultistTsSwimFire);
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeCultistTommy)
if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeCultistTommy)
{
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
aiNewState(actor, &cultistTsFire);
@ -518,7 +518,7 @@ static void cultThinkChase(DBloodActor* actor)
case 4:
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
aiNewState(actor, &cultistDThrow);
break;
default:
@ -539,7 +539,7 @@ static void cultThinkChase(DBloodActor* actor)
case 4:
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
aiNewState(actor, &cultist139A78);
break;
default:
@ -564,7 +564,7 @@ static void cultThinkChase(DBloodActor* actor)
case 4:
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
aiNewState(actor, &cultistSThrow);
break;
default:
@ -586,7 +586,7 @@ static void cultThinkChase(DBloodActor* actor)
aiNewState(actor, &cultistSSwimFire);
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeCultistTommy)
if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeCultistTommy)
{
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
aiNewState(actor, &cultistSFire);

View file

@ -414,7 +414,7 @@ static void gargThinkChase(DBloodActor* actor)
case 4:
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeGargoyleStone)
if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeGargoyleStone)
{
sfxPlay3DSound(actor, 1408, 0, 0);
aiNewState(actor, &gargoyleFThrow);
@ -439,7 +439,7 @@ static void gargThinkChase(DBloodActor* actor)
case 4:
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeGargoyleStone)
if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeGargoyleStone)
{
sfxPlay3DSound(actor, 1406, 0, 0);
aiNewState(actor, &gargoyleFSlash);
@ -473,7 +473,7 @@ static void gargThinkChase(DBloodActor* actor)
case 4:
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeGargoyleFlesh)
if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeGargoyleFlesh)
{
sfxPlay3DSound(actor, 1457, 0, 0);
aiNewState(actor, &gargoyleSBlast);
@ -497,7 +497,7 @@ static void gargThinkChase(DBloodActor* actor)
case 4:
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeGargoyleFlesh)
if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeGargoyleFlesh)
aiNewState(actor, &gargoyleFSlash);
break;
default:

View file

@ -389,7 +389,7 @@ static void ghostThinkChase(DBloodActor* actor)
case 4:
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudePhantasm)
if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudePhantasm)
aiNewState(actor, &ghostBlast);
break;
default:
@ -409,7 +409,7 @@ static void ghostThinkChase(DBloodActor* actor)
case 4:
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudePhantasm)
if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudePhantasm)
aiNewState(actor, &ghostSlash);
break;
default:

View file

@ -192,7 +192,7 @@ static void gillThinkChase(DBloodActor* actor)
aiNewState(actor, &gillBeastBite);
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type)
if (pSprite->type != gHitInfo.hitactor->s().type)
{
if (pXSector && pXSector->Underwater)
aiNewState(actor, &gillBeastSwimBite);

View file

@ -79,7 +79,7 @@ void SpidBiteSeqCallback(int, DBloodActor* actor)
if (IsPlayerSprite(pTarget)) {
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
if (hit == 3 && IsPlayerSprite(&sprite[gHitInfo.hitsprite])) {
if (hit == 3 && gHitInfo.hitactor->IsPlayerActor()) {
dz += pTarget->z - pSprite->z;
PLAYER *pPlayer = &gPlayer[pTarget->type - kDudePlayer1];
switch (pSprite->type) {

View file

@ -140,8 +140,8 @@ static bool genDudeAdjustSlope(DBloodActor* actor, int dist, int weaponType, int
for (int i = -8191; i < 8192; i += by)
{
HitScan(pSprite, pSprite->z, CosScale16(pSprite->ang), SinScale16(pSprite->ang), i, clipMask, dist);
if (!fStart && pXSprite->target_i == gHitInfo.hitsprite) fStart = i;
else if (fStart && pXSprite->target_i != gHitInfo.hitsprite)
if (!fStart && actor->GetTarget() == gHitInfo.hitactor) fStart = i;
else if (fStart && actor->GetTarget() != gHitInfo.hitactor)
{
fEnd = i;
break;
@ -427,16 +427,20 @@ static void unicultThinkChase(DBloodActor* actor)
}
spritetype* pTarget = &sprite[pXSprite->target_i];
XSPRITE* pXTarget = (!IsDudeSprite(pTarget) || !xspriRangeIsFine(pTarget->extra)) ? NULL : &xsprite[pTarget->extra];
auto const targetactor = actor->GetTarget();
XSPRITE* pXTarget = !targetactor || !targetactor->IsDudeActor() || !targetactor->GetTarget() ? nullptr : &targetactor->x();
if (pXTarget == NULL) { // target lost
if (pXTarget == nullptr) // target lost
{
if(spriteIsUnderwater(pSprite,false)) aiGenDudeNewState(pSprite, &genDudeSearchShortW);
else aiGenDudeNewState(pSprite, &genDudeSearchShortL);
actor->SetTarget(nullptr);
return;
}
} else if (pXTarget->health <= 0) { // target is dead
auto const pTarget = &targetactor->s();
if (pXTarget->health <= 0) // target is dead
{
PLAYER* pPlayer = NULL;
if ((!IsPlayerSprite(pTarget)) || ((pPlayer = getPlayerById(pTarget->type)) != NULL && pPlayer->fraggerId == pSprite->index)) {
playGenDudeSound(pSprite, kGenDudeSndTargetDead);
@ -677,16 +681,27 @@ static void unicultThinkChase(DBloodActor* actor)
objDist = approxDist(gHitInfo.hitx - pSprite->x, gHitInfo.hity - pSprite->y);
}
if (pXSprite->target_i != gHitInfo.hitsprite && targetDist > objDist) {
walltype* pHWall = NULL; XWALL* pXHWall = NULL;
spritetype* pHSprite = NULL; XSPRITE* pXHSprite = NULL;
bool hscn = false; bool blck = false; bool failed = false;
if (actor != gHitInfo.hitactor && targetDist > objDist)
{
DBloodActor* hitactor = nullptr;
walltype* pHWall = NULL;
XWALL* pXHWall = NULL;
spritetype* pHSprite = NULL;
XSPRITE* pXHSprite = NULL;
bool hscn = false;
bool blck = false;
bool failed = false;
switch (hit) {
switch (hit)
{
case 3:
pHSprite = &sprite[gHitInfo.hitsprite];
if (xspriRangeIsFine(pHSprite->extra)) pXHSprite = &xsprite[pHSprite->extra];
hscn = (pHSprite->cstat & CSTAT_SPRITE_BLOCK_HITSCAN); blck = (pHSprite->cstat & CSTAT_SPRITE_BLOCK);
hitactor = gHitInfo.hitactor;
if (hitactor)
{
pHSprite = &hitactor->s();
pXHSprite = &hitactor->x();
hscn = (pHSprite->cstat & CSTAT_SPRITE_BLOCK_HITSCAN); blck = (pHSprite->cstat & CSTAT_SPRITE_BLOCK);
}
break;
case 0:
case 4:
@ -774,7 +789,7 @@ static void unicultThinkChase(DBloodActor* actor)
{
if (genDudeAdjustSlope(actor, dist, weaponType)) break;
VectorScan(pSprite, 0, 0, CosScale16(pSprite->ang), SinScale16(pSprite->ang), actor->dudeSlope, dist, 1);
if (pXSprite->target_i == gHitInfo.hitsprite) break;
if (actor == gHitInfo.hitactor) break;
bool immune = nnExtIsImmune(pHSprite, gVectorData[curWeapon].dmgType);
if (!(pXHSprite != NULL && (!immune || (immune && pHSprite->statnum == kStatThing && pXHSprite->Vector)) && !pXHSprite->locked))
@ -828,7 +843,8 @@ static void unicultThinkChase(DBloodActor* actor)
if (masked) VectorScan(pSprite, 0, 0, CosScale16(pSprite->ang), SinScale16(pSprite->ang), actor->dudeSlope, dist, 1);
//viewSetSystemMessage("WALL VHIT: %d", gHitInfo.hitwall);
if ((pXSprite->target_i != gHitInfo.hitsprite) && (pHWall->type != kWallGib || !masked || pXHWall == NULL || !pXHWall->triggerVector || pXHWall->locked)) {
if ((actor != gHitInfo.hitactor) && (pHWall->type != kWallGib || !masked || pXHWall == NULL || !pXHWall->triggerVector || pXHWall->locked))
{
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(pSprite, &genDudeChaseW);
else aiGenDudeNewState(pSprite, &genDudeChaseL);
return;

View file

@ -156,7 +156,7 @@ static void zombfThinkChase(DBloodActor* actor)
aiNewState(actor, &zombieFThrow);
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type)
if (pSprite->type != gHitInfo.hitactor->s().type)
aiNewState(actor, &zombieFThrow);
else
aiNewState(actor, &zombieFDodge);
@ -175,7 +175,7 @@ static void zombfThinkChase(DBloodActor* actor)
aiNewState(actor, &zombieFPuke);
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type)
if (pSprite->type != gHitInfo.hitactor->s().type)
aiNewState(actor, &zombieFPuke);
else
aiNewState(actor, &zombieFDodge);
@ -194,7 +194,7 @@ static void zombfThinkChase(DBloodActor* actor)
aiNewState(actor, &zombieFHack);
break;
case 3:
if (pSprite->type != sprite[gHitInfo.hitsprite].type)
if (pSprite->type != gHitInfo.hitactor->s().type)
aiNewState(actor, &zombieFHack);
else
aiNewState(actor, &zombieFDodge);

View file

@ -277,7 +277,6 @@ struct Collision
}
};
inline DBloodActor* getUpperLink(int sect)
{
auto l = gUpperLink[sect];

View file

@ -382,9 +382,7 @@ int HitScan(spritetype *pSprite, int z, int dx, int dy, int dz, unsigned int nMa
{
assert(pSprite != NULL);
assert(dx != 0 || dy != 0);
gHitInfo.hitsect = -1;
gHitInfo.hitwall = -1;
gHitInfo.hitsprite = -1;
gHitInfo.clearObj();
int x = pSprite->x;
int y = pSprite->y;
int nSector = pSprite->sectnum;
@ -403,17 +401,12 @@ int HitScan(spritetype *pSprite, int z, int dx, int dy, int dz, unsigned int nMa
hitdata_t hitData;
hitData.pos.z = gHitInfo.hitz;
hitscan(&pos, nSector, dx, dy, dz << 4, &hitData, nMask);
gHitInfo.hitsect = hitData.sect;
gHitInfo.hitwall = hitData.wall;
gHitInfo.hitsprite = hitData.sprite;
gHitInfo.hitx = hitData.pos.x;
gHitInfo.hity = hitData.pos.y;
gHitInfo.hitz = hitData.pos.z;
gHitInfo.set(&hitData);
hitscangoal.x = hitscangoal.y = 0x1ffffff;
pSprite->cstat = bakCstat;
if (gHitInfo.hitsprite >= kMaxSprites || gHitInfo.hitwall >= kMaxWalls || gHitInfo.hitsect >= kMaxSectors)
if (gHitInfo.hitwall >= kMaxWalls || gHitInfo.hitsect >= kMaxSectors)
return -1;
if (gHitInfo.hitsprite >= 0)
if (gHitInfo.hitactor != nullptr)
return 3;
if (gHitInfo.hitwall >= 0)
{
@ -434,9 +427,7 @@ int VectorScan(spritetype *pSprite, int nOffset, int nZOffset, int dx, int dy, i
{
int nNum = 256;
assert(pSprite != NULL);
gHitInfo.hitsect = -1;
gHitInfo.hitwall = -1;
gHitInfo.hitsprite = -1;
gHitInfo.clearObj();
int x1 = pSprite->x+MulScale(nOffset, Cos(pSprite->ang+512), 30);
int y1 = pSprite->y+MulScale(nOffset, Sin(pSprite->ang+512), 30);
int z1 = pSprite->z+nZOffset;
@ -456,23 +447,18 @@ int VectorScan(spritetype *pSprite, int nOffset, int nZOffset, int dx, int dy, i
hitdata_t hitData;
hitData.pos.z = gHitInfo.hitz;
hitscan(&pos, nSector, dx, dy, dz << 4, &hitData, CLIPMASK1);
gHitInfo.hitsect = hitData.sect;
gHitInfo.hitwall = hitData.wall;
gHitInfo.hitsprite = hitData.sprite;
gHitInfo.hitx = hitData.pos.x;
gHitInfo.hity = hitData.pos.y;
gHitInfo.hitz = hitData.pos.z;
gHitInfo.set(&hitData);
hitscangoal.x = hitscangoal.y = 0x1ffffff;
pSprite->cstat = bakCstat;
while (nNum--)
{
if (gHitInfo.hitsprite >= kMaxSprites || gHitInfo.hitwall >= kMaxWalls || gHitInfo.hitsect >= kMaxSectors)
if (gHitInfo.hitwall >= kMaxWalls || gHitInfo.hitsect >= kMaxSectors)
return -1;
if (nRange && approxDist(gHitInfo.hitx - pSprite->x, gHitInfo.hity - pSprite->y) > nRange)
return -1;
if (gHitInfo.hitsprite >= 0)
if (gHitInfo.hitactor != nullptr)
{
spritetype *pOther = &sprite[gHitInfo.hitsprite];
spritetype *pOther = &gHitInfo.hitactor->s();
if ((pOther->flags & 8) && !(ac & 1))
return 3;
if ((pOther->cstat & 0x30) != 0)
@ -509,22 +495,14 @@ int VectorScan(spritetype *pSprite, int nOffset, int nZOffset, int dx, int dy, i
}
int bakCstat = pOther->cstat;
pOther->cstat &= ~256;
gHitInfo.hitsect = -1;
gHitInfo.hitwall = -1;
gHitInfo.hitsprite = -1;
gHitInfo.clearObj();
x1 = gHitInfo.hitx;
y1 = gHitInfo.hity;
z1 = gHitInfo.hitz;
pos = { x1, y1, z1 };
hitData.pos.z = gHitInfo.hitz;
hitscan(&pos, pOther->sectnum,
dx, dy, dz << 4, &hitData, CLIPMASK1);
gHitInfo.hitsect = hitData.sect;
gHitInfo.hitwall = hitData.wall;
gHitInfo.hitsprite = hitData.sprite;
gHitInfo.hitx = hitData.pos.x;
gHitInfo.hity = hitData.pos.y;
gHitInfo.hitz = hitData.pos.z;
hitscan(&pos, pOther->sectnum, dx, dy, dz << 4, &hitData, CLIPMASK1);
gHitInfo.set(&hitData);
pOther->cstat = bakCstat;
continue;
}
@ -584,9 +562,7 @@ int VectorScan(spritetype *pSprite, int nOffset, int nZOffset, int dx, int dy, i
pWall->cstat &= ~64;
int bakCstat2 = wall[pWall->nextwall].cstat;
wall[pWall->nextwall].cstat &= ~64;
gHitInfo.hitsect = -1;
gHitInfo.hitwall = -1;
gHitInfo.hitsprite = -1;
gHitInfo.clearObj();
x1 = gHitInfo.hitx;
y1 = gHitInfo.hity;
z1 = gHitInfo.hitz;
@ -594,12 +570,7 @@ int VectorScan(spritetype *pSprite, int nOffset, int nZOffset, int dx, int dy, i
hitData.pos.z = gHitInfo.hitz;
hitscan(&pos, pWall->nextsector,
dx, dy, dz << 4, &hitData, CLIPMASK1);
gHitInfo.hitsect = hitData.sect;
gHitInfo.hitwall = hitData.wall;
gHitInfo.hitsprite = hitData.sprite;
gHitInfo.hitx = hitData.pos.x;
gHitInfo.hity = hitData.pos.y;
gHitInfo.hitz = hitData.pos.z;
gHitInfo.set(&hitData);
pWall->cstat = bakCstat;
wall[pWall->nextwall].cstat = bakCstat2;
continue;
@ -614,21 +585,14 @@ int VectorScan(spritetype *pSprite, int nOffset, int nZOffset, int dx, int dy, i
return 2;
int nSprite = gUpperLink[gHitInfo.hitsect];
int nLink = sprite[nSprite].owner & 0xfff;
gHitInfo.hitsect = -1;
gHitInfo.hitwall = -1;
gHitInfo.hitsprite = -1;
gHitInfo.clearObj();
x1 = gHitInfo.hitx + sprite[nLink].x - sprite[nSprite].x;
y1 = gHitInfo.hity + sprite[nLink].y - sprite[nSprite].y;
z1 = gHitInfo.hitz + sprite[nLink].z - sprite[nSprite].z;
pos = { x1, y1, z1 };
hitData.pos.z = gHitInfo.hitz;
hitscan(&pos, sprite[nLink].sectnum, dx, dy, dz<<4, &hitData, CLIPMASK1);
gHitInfo.hitsect = hitData.sect;
gHitInfo.hitwall = hitData.wall;
gHitInfo.hitsprite = hitData.sprite;
gHitInfo.hitx = hitData.pos.x;
gHitInfo.hity = hitData.pos.y;
gHitInfo.hitz = hitData.pos.z;
gHitInfo.set(&hitData);
continue;
}
else
@ -637,21 +601,14 @@ int VectorScan(spritetype *pSprite, int nOffset, int nZOffset, int dx, int dy, i
return 1;
int nSprite = gLowerLink[gHitInfo.hitsect];
int nLink = sprite[nSprite].owner & 0xfff;
gHitInfo.hitsect = -1;
gHitInfo.hitwall = -1;
gHitInfo.hitsprite = -1;
gHitInfo.clearObj();
x1 = gHitInfo.hitx + sprite[nLink].x - sprite[nSprite].x;
y1 = gHitInfo.hity + sprite[nLink].y - sprite[nSprite].y;
z1 = gHitInfo.hitz + sprite[nLink].z - sprite[nSprite].z;
pos = { x1, y1, z1 };
hitData.pos.z = gHitInfo.hitz;
hitscan(&pos, sprite[nLink].sectnum, dx, dy, dz<<4, &hitData, CLIPMASK1);
gHitInfo.hitsect = hitData.sect;
gHitInfo.hitwall = hitData.wall;
gHitInfo.hitsprite = hitData.sprite;
gHitInfo.hitx = hitData.pos.x;
gHitInfo.hity = hitData.pos.y;
gHitInfo.hitz = hitData.pos.z;
gHitInfo.set(&hitData);
continue;
}
}

View file

@ -27,12 +27,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
struct HITINFO {
DBloodActor* hitactor;
short hitsect;
short hitwall;
short hitsprite;
int hitx;
int hity;
int hitz;
void clearObj()
{
hitsect = hitwall = -1;
hitsprite = -1;
hitactor = nullptr;
}
void set(hitdata_t* hit);
};
extern POINT2D baseWall[kMaxWalls];

View file

@ -615,7 +615,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, HITINFO& w, HITINF
if (arc.BeginObject(keyname))
{
arc("sect", w.hitsect)
("sprite", w.hitsprite)
("sprite", w.hitactor)
("wall", w.hitwall)
("x", w.hitx)
("y", w.hity)

View file

@ -3977,7 +3977,7 @@ bool condCheckSprite(XSPRITE* pXCond, int cmpOp, bool PUSH) {
switch (var) {
case 0: case 4: condPush(pXCond, OBJ_WALL, gHitInfo.hitwall); break;
case 1: case 2: condPush(pXCond, OBJ_SECTOR, gHitInfo.hitsect); break;
case 3: condPush(pXCond, OBJ_SPRITE, gHitInfo.hitsprite); break;
case 3: condPush(pXCond, OBJ_SPRITE, gHitInfo.hitactor? gHitInfo.hitactor->s().index : -1); break;
}
}

View file

@ -1254,7 +1254,7 @@ int ActionScan(PLAYER *pPlayer, int *a2, int *a3)
switch (hit)
{
case 3:
*a2 = gHitInfo.hitsprite;
*a2 = gHitInfo.hitactor ? gHitInfo.hitactor->s().index : -1;
*a3 = sprite[*a2].extra;
if (*a3 > 0 && sprite[*a2].statnum == kStatThing)
{

View file

@ -121,9 +121,9 @@ void viewDrawAimedPlayerName(void)
int hit = HitScan(gView->pSprite, gView->zView, gView->aim.dx, gView->aim.dy, gView->aim.dz, CLIPMASK0, 512);
if (hit == 3)
{
spritetype* pSprite = &sprite[gHitInfo.hitsprite];
if (IsPlayerSprite(pSprite))
if (gHitInfo.hitactor && gHitInfo.hitactor->IsPlayerActor())
{
spritetype* pSprite = &gHitInfo.hitactor->s();
int nPlayer = pSprite->type-kDudePlayer1;
const char* szName = PlayerName(nPlayer);
int nPalette = (gPlayer[nPlayer].teamId&3)+11;