- some pSprite2's plus CheckSector.

This commit is contained in:
Christoph Oelckers 2021-12-22 15:40:15 +01:00
parent fbb8f1ee70
commit 88c77ec71a
5 changed files with 25 additions and 28 deletions

View file

@ -2657,7 +2657,7 @@ void actRadiusDamage(DBloodActor* source, int x, int y, int z, sectortype* pSect
if (act2->hasX()) if (act2->hasX())
{ {
if (act2->spr.flags & 0x20) continue; if (act2->spr.flags & 0x20) continue;
if (!CheckSector(sectorMap, pSprite2)) continue; if (!CheckSector(sectorMap, act2)) continue;
if (!CheckProximity(act2, x, y, z, pSector, nDist)) continue; if (!CheckProximity(act2, x, y, z, pSector, nDist)) continue;
int dx = abs(x - act2->spr.pos.X); int dx = abs(x - act2->spr.pos.X);
@ -2682,7 +2682,7 @@ void actRadiusDamage(DBloodActor* source, int x, int y, int z, sectortype* pSect
while (auto act2 = it.Next()) while (auto act2 = it.Next())
{ {
if (act2->spr.flags & 0x20) continue; if (act2->spr.flags & 0x20) continue;
if (!CheckSector(sectorMap, pSprite2)) continue; if (!CheckSector(sectorMap, act2)) continue;
if (!CheckProximity(act2, x, y, z, pSector, nDist)) continue; if (!CheckProximity(act2, x, y, z, pSector, nDist)) continue;
XSPRITE* pXSprite2 = &act2->x(); XSPRITE* pXSprite2 = &act2->x();
@ -5909,7 +5909,7 @@ static void actCheckExplosion()
if (pDude->flags & 32) continue; if (pDude->flags & 32) continue;
if (CheckSector(sectorMap, pDude)) if (CheckSector(sectorMap, dudeactor))
{ {
if (pXSprite->data1 && CheckProximity(dudeactor, x, y, z, pSector, radius)) if (pXSprite->data1 && CheckProximity(dudeactor, x, y, z, pSector, radius))
{ {
@ -5938,7 +5938,7 @@ static void actCheckExplosion()
if (pThing->flags & 32) continue; if (pThing->flags & 32) continue;
if (CheckSector(sectorMap, pThing)) if (CheckSector(sectorMap, thingactor))
{ {
if (pXSprite->data1 && CheckProximity(thingactor, x, y, z, pSector, radius) && thingactor->hasX()) if (pXSprite->data1 && CheckProximity(thingactor, x, y, z, pSector, radius) && thingactor->hasX())
{ {
@ -5960,10 +5960,10 @@ static void actCheckExplosion()
for (int p = connecthead; p >= 0; p = connectpoint2[p]) for (int p = connecthead; p >= 0; p = connectpoint2[p])
{ {
spritetype* pSprite2 = gPlayer[p].pSprite; auto pos = gPlayer[p].pSprite->pos;
int dx = (x - pSprite2->pos.X) >> 4; int dx = (x - pos.X) >> 4;
int dy = (y - pSprite2->pos.Y) >> 4; int dy = (y - pos.Y) >> 4;
int dz = (z - pSprite2->pos.Z) >> 8; int dz = (z - pos.Z) >> 8;
int nDist = dx * dx + dy * dy + dz * dz + 0x40000; int nDist = dx * dx + dy * dy + dz * dz + 0x40000;
int t = DivScale(pXSprite->data2, nDist, 16); int t = DivScale(pXSprite->data2, nDist, 16);
gPlayer[p].flickerEffect += t; gPlayer[p].flickerEffect += t;
@ -5982,7 +5982,7 @@ static void actCheckExplosion()
spritetype* pDebris = &physactor->s(); spritetype* pDebris = &physactor->s();
if (!pDebris->insector() || (pDebris->flags & kHitagFree) != 0) continue; if (!pDebris->insector() || (pDebris->flags & kHitagFree) != 0) continue;
if (!CheckSector(sectorMap, pDebris) || !CheckProximity(physactor, x, y, z, pSector, radius)) continue; if (!CheckSector(sectorMap, physactor) || !CheckProximity(physactor, x, y, z, pSector, radius)) continue;
else debrisConcuss(Owner, i, x, y, z, pExplodeInfo->dmgType); else debrisConcuss(Owner, i, x, y, z, pExplodeInfo->dmgType);
} }
} }
@ -5996,7 +5996,7 @@ static void actCheckExplosion()
DBloodActor* impactactor = gImpactSpritesList[i]; DBloodActor* impactactor = gImpactSpritesList[i];
if (!impactactor->hasX() || !impactactor->spr.insector() || (impactactor->spr.flags & kHitagFree) != 0) continue; if (!impactactor->hasX() || !impactactor->spr.insector() || (impactactor->spr.flags & kHitagFree) != 0) continue;
if (!CheckSector(sectorMap, &impactactor->s()) || !CheckProximity(impactactor, x, y, z, pSector, radius)) if (!CheckSector(sectorMap, impactactor) || !CheckProximity(impactactor, x, y, z, pSector, radius))
continue; continue;
trTriggerSprite(impactactor, kCmdSpriteImpact); trTriggerSprite(impactactor, kCmdSpriteImpact);
@ -6137,8 +6137,7 @@ static void actCheckDudes()
BloodStatIterator it1(kStatDude); BloodStatIterator it1(kStatDude);
while (auto actor2 = it1.Next()) while (auto actor2 = it1.Next())
{ {
spritetype* pSprite2 = &actor2->s(); if (actor2->spr.flags & 32) continue;
if (pSprite2->flags & 32) continue;
XSPRITE* pXSprite2 = &actor2->x(); XSPRITE* pXSprite2 = &actor2->x();
@ -6362,7 +6361,6 @@ DBloodActor* actSpawnDude(DBloodActor* source, int nType, int a3, int a4)
XSPRITE* pXSource = &source->x(); XSPRITE* pXSource = &source->x();
auto spawned = actSpawnSprite(source, kStatDude); auto spawned = actSpawnSprite(source, kStatDude);
if (!spawned) return NULL; if (!spawned) return NULL;
spritetype* pSprite2 = &spawned->s();
XSPRITE* pXSprite2 = &spawned->x(); XSPRITE* pXSprite2 = &spawned->x();
int angle = pSource->ang; int angle = pSource->ang;
int nDude = nType - kDudeBase; int nDude = nType - kDudeBase;
@ -6378,12 +6376,12 @@ DBloodActor* actSpawnDude(DBloodActor* source, int nType, int a3, int a4)
x = pSource->pos.X + mulscale30r(Cos(angle), a3); x = pSource->pos.X + mulscale30r(Cos(angle), a3);
y = pSource->pos.Y + mulscale30r(Sin(angle), a3); y = pSource->pos.Y + mulscale30r(Sin(angle), a3);
} }
pSprite2->type = nType; spawned->spr.type = nType;
pSprite2->ang = angle; spawned->spr.ang = angle;
vec3_t pos = { x, y, z }; vec3_t pos = { x, y, z };
SetActor(spawned, &pos); SetActor(spawned, &pos);
pSprite2->cstat |= CSTAT_SPRITE_BLOCK_ALL | CSTAT_SPRITE_BLOOD_BIT1; spawned->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL | CSTAT_SPRITE_BLOOD_BIT1;
pSprite2->clipdist = getDudeInfo(nDude + kDudeBase)->clipdist; spawned->spr.clipdist = getDudeInfo(nDude + kDudeBase)->clipdist;
pXSprite2->health = getDudeInfo(nDude + kDudeBase)->startHealth << 4; pXSprite2->health = getDudeInfo(nDude + kDudeBase)->startHealth << 4;
pXSprite2->respawn = 1; pXSprite2->respawn = 1;
if (getSequence(getDudeInfo(nDude + kDudeBase)->seqStartID)) if (getSequence(getDudeInfo(nDude + kDudeBase)->seqStartID))
@ -6399,7 +6397,7 @@ DBloodActor* actSpawnDude(DBloodActor* source, int nType, int a3, int a4)
{ {
case kMarkerDudeSpawn: case kMarkerDudeSpawn:
//inherit pal? //inherit pal?
if (pSprite2->pal <= 0) pSprite2->pal = pSource->pal; if (spawned->spr.pal <= 0) spawned->spr.pal = pSource->pal;
// inherit spawn sprite trigger settings, so designer can count monsters. // inherit spawn sprite trigger settings, so designer can count monsters.
pXSprite2->txID = pXSource->txID; pXSprite2->txID = pXSource->txID;

View file

@ -110,7 +110,7 @@ void StompSeqCallback(int, DBloodActor* actor1)
continue; continue;
if (pSprite2->flags & 32) if (pSprite2->flags & 32)
continue; continue;
if (CheckSector(sectorMap, pSprite2) && CheckProximity(actor2, x, y, z, pSector, vc)) if (CheckSector(sectorMap, actor2) && CheckProximity(actor2, x, y, z, pSector, vc))
{ {
int top, bottom; int top, bottom;
GetActorExtents(actor1, &top, &bottom); GetActorExtents(actor1, &top, &bottom);
@ -141,7 +141,7 @@ void StompSeqCallback(int, DBloodActor* actor1)
spritetype* pSprite2 = &actor2->s(); spritetype* pSprite2 = &actor2->s();
if (pSprite2->flags & 32) if (pSprite2->flags & 32)
continue; continue;
if (CheckSector(sectorMap, pSprite2) && CheckProximity(actor2, x, y, z, pSector, vc)) if (CheckSector(sectorMap, actor2) && CheckProximity(actor2, x, y, z, pSector, vc))
{ {
XSPRITE* pXSprite = &actor2->x(); XSPRITE* pXSprite = &actor2->x();
if (pXSprite->locked) if (pXSprite->locked)

View file

@ -179,4 +179,9 @@ inline void GetActorExtents(DBloodActor* actor, int* top, int* bottom)
GetSpriteExtents(&actor->s(), top, bottom); GetSpriteExtents(&actor->s(), top, bottom);
} }
inline bool CheckSector(const BitArray& bits, DBloodActor* act)
{
return bits[act->spr.sectno()];
}
END_BLD_NS END_BLD_NS

View file

@ -51,10 +51,4 @@ BitArray GetClosestSpriteSectors(sectortype* pSector, int x, int y, int nDist, T
int picWidth(int nPic, int repeat); int picWidth(int nPic, int repeat);
int picHeight(int nPic, int repeat); int picHeight(int nPic, int repeat);
inline bool CheckSector(const BitArray& bits, spritetype* spr)
{
return bits[spr->sectno()];
}
END_BLD_NS END_BLD_NS

View file

@ -2682,7 +2682,7 @@ void teslaHit(DBloodActor *missileactor, int a2)
spritetype *pHitSprite = &hitactor->s(); spritetype *pHitSprite = &hitactor->s();
if (pHitSprite->flags&32) if (pHitSprite->flags&32)
continue; continue;
if (CheckSector(sectorMap, pHitSprite) && CheckProximity(hitactor, x, y, z, pSector, nDist)) if (CheckSector(sectorMap, hitactor) && CheckProximity(hitactor, x, y, z, pSector, nDist))
{ {
int dx = pMissile->pos.X - pHitSprite->pos.X; int dx = pMissile->pos.X - pHitSprite->pos.X;
int dy = pMissile->pos.Y - pHitSprite->pos.Y; int dy = pMissile->pos.Y - pHitSprite->pos.Y;
@ -2699,7 +2699,7 @@ void teslaHit(DBloodActor *missileactor, int a2)
spritetype *pHitSprite = &hitactor->s(); spritetype *pHitSprite = &hitactor->s();
if (pHitSprite->flags&32) if (pHitSprite->flags&32)
continue; continue;
if (CheckSector(sectorMap, pHitSprite) && CheckProximity(hitactor, x, y, z, pSector, nDist)) if (CheckSector(sectorMap, hitactor) && CheckProximity(hitactor, x, y, z, pSector, nDist))
{ {
XSPRITE *pXSprite = &hitactor->x(); XSPRITE *pXSprite = &hitactor->x();
if (!pXSprite->locked) if (!pXSprite->locked)