- actor parameter substitution and a few bad constants.

This commit is contained in:
Christoph Oelckers 2021-09-16 21:10:23 +02:00
parent fbae41ee0a
commit b8d55feb1e
5 changed files with 34 additions and 36 deletions

View file

@ -2953,7 +2953,7 @@ static bool actKillModernDude(DBloodActor* actor, DAMAGE_TYPE damageType)
if (pExtra->weaponType == kGenDudeWeaponKamikaze && Chance(0x4000) && damageType != kDamageSpirit && damageType != kDamageDrown) if (pExtra->weaponType == kGenDudeWeaponKamikaze && Chance(0x4000) && damageType != kDamageSpirit && damageType != kDamageDrown)
{ {
doExplosion(pSprite, pXSprite->data1 - kTrapExploder); doExplosion(pSprite, pXSprite->data1 - kTrapExploder);
if (Chance(0x9000)) damageType = (DAMAGE_TYPE)3; if (Chance(0x9000)) damageType = kDamageExplode;
} }
if (damageType == kDamageBurn) if (damageType == kDamageBurn)
@ -3966,7 +3966,7 @@ static void actImpactMissile(DBloodActor* missileActor, int hitCode)
{ {
int nOwner = pMissile->owner; int nOwner = pMissile->owner;
int nDamage = (15 + Random(7)) << 4; int nDamage = (15 + Random(7)) << 4;
actDamageSprite_(nOwner, pSpriteHit, kDamageBullet, nDamage); actDamageSprite(missileOwner, actorHit, kDamageBullet, nDamage);
} }
actPostSprite(missileActor, kStatFree); actPostSprite(missileActor, kStatFree);
break; break;
@ -4276,7 +4276,7 @@ static void checkCeilHit(DBloodActor* actor)
int dmg = abs((mass1 - mass2) * (pSprite2->clipdist - pSprite->clipdist)); int dmg = abs((mass1 - mass2) * (pSprite2->clipdist - pSprite->clipdist));
if (actor2->IsDudeActor()) if (actor2->IsDudeActor())
{ {
if (dmg > 0) actDamageSprite_(pSprite2->index, pSprite, (Chance(0x2000)) ? kDamageFall : (Chance(0x4000)) ? kDamageExplode : kDamageBullet, dmg); if (dmg > 0) actDamageSprite(actor2, actor, (Chance(0x2000)) ? kDamageFall : (Chance(0x4000)) ? kDamageExplode : kDamageBullet, dmg);
if (Chance(0x0200)) actKickObject(actor2, actor); if (Chance(0x0200)) actKickObject(actor2, actor);
} }
} }
@ -4475,7 +4475,7 @@ static void checkFloorHit(DBloodActor* actor)
} }
actKickObject(actor, actor2); actKickObject(actor, actor2);
sfxPlay3DSound(pSprite->x, pSprite->y, pSprite->z, 357, pSprite->sectnum); sfxPlay3DSound(pSprite->x, pSprite->y, pSprite->z, 357, pSprite->sectnum);
actDamageSprite_(-1, pSprite2, kDamageFall, 80); actDamageSprite(nullptr, actor2, kDamageFall, 80);
break; break;
case kTrapSawCircular: case kTrapSawCircular:
if (!pXSprite2->state) actDamageSprite(actor, actor, kDamageBullet, 1); if (!pXSprite2->state) actDamageSprite(actor, actor, kDamageBullet, 1);
@ -4874,7 +4874,7 @@ void MoveDude(DBloodActor* actor)
{ {
nSector = pSprite->sectnum; nSector = pSprite->sectnum;
if (pSprite->statnum == kStatDude || pSprite->statnum == kStatThing) if (pSprite->statnum == kStatDude || pSprite->statnum == kStatThing)
actDamageSprite_(pSprite->index, pSprite, kDamageFall, 1000 << 4); actDamageSprite(actor, actor, kDamageFall, 1000 << 4);
} }
if (sector[nSector].type >= kSectorPath && sector[nSector].type <= kSectorRotate) if (sector[nSector].type >= kSectorPath && sector[nSector].type <= kSectorRotate)

View file

@ -1230,7 +1230,7 @@ void removeDudeStuff(spritetype* pSprite) {
while ((nSprite = it.NextIndex()) >= 0) while ((nSprite = it.NextIndex()) >= 0)
{ {
if (sprite[nSprite].owner != pSprite->index) continue; if (sprite[nSprite].owner != pSprite->index) continue;
actDamageSprite(&bloodActors[sprite[nSprite].owner], &bloodActors[nSprite], (DAMAGE_TYPE) 0, 65535); actDamageSprite(&bloodActors[sprite[nSprite].owner], &bloodActors[nSprite], kDamageFall, 65535);
} }
} }

View file

@ -1504,8 +1504,6 @@ void debrisConcuss(int nOwner, int listIndex, int x, int y, int z, int dmg) {
if (thing) if (thing)
pSprite->statnum = kStatDecoration; // return statnum property back pSprite->statnum = kStatDecoration; // return statnum property back
return;
} }
} }

View file

@ -268,7 +268,7 @@ char powerupActivate(PLAYER *pPlayer, int nPowerUp)
} }
if (ceilIsTooLow(pPlayer->pSprite)) if (ceilIsTooLow(pPlayer->pSprite))
actDamageSprite_(pPlayer->pSprite->index, pPlayer->pSprite, kDamageExplode, 65535); actDamageSprite(pPlayer->actor(), pPlayer->actor(), kDamageExplode, 65535);
} }
break; break;
#endif #endif
@ -316,7 +316,7 @@ void powerupDeactivate(PLAYER *pPlayer, int nPowerUp)
if (gModernMap) { if (gModernMap) {
playerSizeReset(pPlayer); playerSizeReset(pPlayer);
if (ceilIsTooLow(pPlayer->pSprite)) if (ceilIsTooLow(pPlayer->pSprite))
actDamageSprite_(pPlayer->pSprite->index, pPlayer->pSprite, kDamageExplode, 65535); actDamageSprite(pPlayer->actor(), pPlayer->actor(), kDamageExplode, 65535);
} }
break; break;
case kItemShroomGrow: case kItemShroomGrow:
@ -1654,9 +1654,8 @@ void ProcessInput(PLAYER *pPlayer)
void playerProcess(PLAYER *pPlayer) void playerProcess(PLAYER *pPlayer)
{ {
auto actor = pPlayer->actor();
spritetype *pSprite = pPlayer->pSprite; spritetype *pSprite = pPlayer->pSprite;
int nSprite = pPlayer->nSprite;
int nXSprite = pSprite->extra;
XSPRITE *pXSprite = pPlayer->pXSprite; XSPRITE *pXSprite = pPlayer->pXSprite;
POSTURE* pPosture = &pPlayer->pPosture[pPlayer->lifeMode][pPlayer->posture]; POSTURE* pPosture = &pPlayer->pPosture[pPlayer->lifeMode][pPlayer->posture];
powerupProcess(pPlayer); powerupProcess(pPlayer);
@ -1669,28 +1668,28 @@ void playerProcess(PLAYER *pPlayer)
{ {
short nSector = pSprite->sectnum; short nSector = pSprite->sectnum;
if (pushmove_old(&pSprite->x, &pSprite->y, &pSprite->z, &nSector, dw, dzt, dzb, CLIPMASK0) == -1) if (pushmove_old(&pSprite->x, &pSprite->y, &pSprite->z, &nSector, dw, dzt, dzb, CLIPMASK0) == -1)
actDamageSprite_(nSprite, pSprite, kDamageFall, 500<<4); actDamageSprite(actor, actor, kDamageFall, 500<<4);
if (pSprite->sectnum != nSector) if (pSprite->sectnum != nSector)
{ {
if (nSector == -1) if (nSector == -1)
{ {
nSector = pSprite->sectnum; nSector = pSprite->sectnum;
actDamageSprite_(nSprite, pSprite, kDamageFall, 500<<4); actDamageSprite(actor, actor, kDamageFall, 500<<4);
} }
assert(nSector >= 0 && nSector < kMaxSectors); assert(nSector >= 0 && nSector < kMaxSectors);
ChangeSpriteSect(nSprite, nSector); ChangeSpriteSect(pSprite->index, nSector);
} }
} }
ProcessInput(pPlayer); ProcessInput(pPlayer);
int nSpeed = approxDist(xvel[nSprite], yvel[nSprite]); int nSpeed = approxDist(actor->xvel(), actor->yvel());
pPlayer->zViewVel = interpolatedvalue(pPlayer->zViewVel, zvel[nSprite], 0x7000); pPlayer->zViewVel = interpolatedvalue(pPlayer->zViewVel, actor->zvel(), 0x7000);
int dz = pPlayer->pSprite->z-pPosture->eyeAboveZ-pPlayer->zView; int dz = pPlayer->pSprite->z-pPosture->eyeAboveZ-pPlayer->zView;
if (dz > 0) if (dz > 0)
pPlayer->zViewVel += MulScale(dz<<8, 0xa000, 16); pPlayer->zViewVel += MulScale(dz<<8, 0xa000, 16);
else else
pPlayer->zViewVel += MulScale(dz<<8, 0x1800, 16); pPlayer->zViewVel += MulScale(dz<<8, 0x1800, 16);
pPlayer->zView += pPlayer->zViewVel>>8; pPlayer->zView += pPlayer->zViewVel>>8;
pPlayer->zWeaponVel = interpolatedvalue(pPlayer->zWeaponVel, zvel[nSprite], 0x5000); pPlayer->zWeaponVel = interpolatedvalue(pPlayer->zWeaponVel, actor->zvel(), 0x5000);
dz = pPlayer->pSprite->z-pPosture->weaponAboveZ-pPlayer->zWeapon; dz = pPlayer->pSprite->z-pPosture->weaponAboveZ-pPlayer->zWeapon;
if (dz > 0) if (dz > 0)
pPlayer->zWeaponVel += MulScale(dz<<8, 0x8000, 16); pPlayer->zWeaponVel += MulScale(dz<<8, 0x8000, 16);
@ -1765,16 +1764,16 @@ void playerProcess(PLAYER *pPlayer)
switch (pPlayer->posture) switch (pPlayer->posture)
{ {
case 1: case 1:
seqSpawn(dudeInfo[nType].seqStartID+9, 3, nXSprite, -1); seqSpawn(dudeInfo[nType].seqStartID+9, actor, -1);
break; break;
case 2: case 2:
seqSpawn(dudeInfo[nType].seqStartID+10, 3, nXSprite, -1); seqSpawn(dudeInfo[nType].seqStartID+10, actor, -1);
break; break;
default: default:
if (!nSpeed) if (!nSpeed)
seqSpawn(dudeInfo[nType].seqStartID, 3, nXSprite, -1); seqSpawn(dudeInfo[nType].seqStartID, actor, -1);
else else
seqSpawn(dudeInfo[nType].seqStartID+8, 3, nXSprite, -1); seqSpawn(dudeInfo[nType].seqStartID+8, actor, -1);
break; break;
} }
} }

View file

@ -1150,11 +1150,12 @@ int VDoorBusy(unsigned int nSector, unsigned int a2)
vbp = -65536/ClipLow((120*pXSector->busyTimeB)/10, 1); vbp = -65536/ClipLow((120*pXSector->busyTimeB)/10, 1);
int top, bottom; int top, bottom;
int nSprite = GetCrushedSpriteExtents(nSector,&top,&bottom); int nSprite = GetCrushedSpriteExtents(nSector,&top,&bottom);
auto actor = &bloodActors[nSprite];
if (nSprite >= 0 && a2 > pXSector->busy) if (nSprite >= 0 && a2 > pXSector->busy)
{ {
spritetype *pSprite = &sprite[nSprite]; spritetype *pSprite = &actor->s();
assert(pSprite->extra > 0 && pSprite->extra < kMaxXSprites); assert(pSprite->extra > 0 && pSprite->extra < kMaxXSprites);
XSPRITE *pXSprite = &xsprite[pSprite->extra]; XSPRITE *pXSprite = &actor->x();
if (pXSector->onCeilZ > pXSector->offCeilZ || pXSector->onFloorZ < pXSector->offFloorZ) if (pXSector->onCeilZ > pXSector->offCeilZ || pXSector->onFloorZ < pXSector->offFloorZ)
{ {
if (pXSector->interruptable) if (pXSector->interruptable)
@ -1168,7 +1169,7 @@ int VDoorBusy(unsigned int nSector, unsigned int a2)
nDamage = 500; nDamage = 500;
else else
nDamage = pXSector->data; nDamage = pXSector->data;
actDamageSprite_(nSprite, &sprite[nSprite], kDamageFall, nDamage<<4); actDamageSprite(actor, actor, kDamageFall, nDamage<<4);
} }
a2 = ClipRange(a2-(vbp/2)*4, 0, 65536); a2 = ClipRange(a2-(vbp/2)*4, 0, 65536);
} }
@ -1179,16 +1180,16 @@ int VDoorBusy(unsigned int nSector, unsigned int a2)
nDamage = 500; nDamage = 500;
else else
nDamage = pXSector->data; nDamage = pXSector->data;
actDamageSprite_(nSprite, &sprite[nSprite], kDamageFall, nDamage<<4); actDamageSprite(actor, actor, kDamageFall, nDamage<<4);
a2 = ClipRange(a2-(vbp/2)*4, 0, 65536); a2 = ClipRange(a2-(vbp/2)*4, 0, 65536);
} }
} }
} }
else if (nSprite >= 0 && a2 < pXSector->busy) else if (nSprite >= 0 && a2 < pXSector->busy)
{ {
spritetype *pSprite = &sprite[nSprite]; spritetype* pSprite = &actor->s();
assert(pSprite->extra > 0 && pSprite->extra < kMaxXSprites); assert(pSprite->extra > 0 && pSprite->extra < kMaxXSprites);
XSPRITE *pXSprite = &xsprite[pSprite->extra]; XSPRITE* pXSprite = &actor->x();
if (pXSector->offCeilZ > pXSector->onCeilZ || pXSector->offFloorZ < pXSector->onFloorZ) if (pXSector->offCeilZ > pXSector->onCeilZ || pXSector->offFloorZ < pXSector->onFloorZ)
{ {
if (pXSector->interruptable) if (pXSector->interruptable)
@ -1202,7 +1203,7 @@ int VDoorBusy(unsigned int nSector, unsigned int a2)
nDamage = 500; nDamage = 500;
else else
nDamage = pXSector->data; nDamage = pXSector->data;
actDamageSprite_(nSprite, &sprite[nSprite], kDamageFall, nDamage<<4); actDamageSprite(actor, actor, kDamageFall, nDamage<<4);
} }
a2 = ClipRange(a2+(vbp/2)*4, 0, 65536); a2 = ClipRange(a2+(vbp/2)*4, 0, 65536);
} }
@ -1213,7 +1214,7 @@ int VDoorBusy(unsigned int nSector, unsigned int a2)
nDamage = 500; nDamage = 500;
else else
nDamage = pXSector->data; nDamage = pXSector->data;
actDamageSprite_(nSprite, &sprite[nSprite], kDamageFall, nDamage<<4); actDamageSprite(actor, actor, kDamageFall, nDamage<<4);
a2 = ClipRange(a2+(vbp/2)*4, 0, 65536); a2 = ClipRange(a2+(vbp/2)*4, 0, 65536);
} }
} }
@ -1420,15 +1421,15 @@ char SectorContainsDudes(int nSector)
void TeleFrag(int nKiller, int nSector) void TeleFrag(int nKiller, int nSector)
{ {
int nSprite; auto killer = &bloodActors[nKiller];
SectIterator it(nSector); BloodSectIterator it(nSector);
while ((nSprite = it.NextIndex()) >= 0) while (auto victim = it.Next())
{ {
spritetype *pSprite = &sprite[nSprite]; spritetype *pSprite = &victim->s();
if (pSprite->statnum == kStatDude) if (pSprite->statnum == kStatDude)
actDamageSprite_(nKiller, pSprite, kDamageExplode, 4000); actDamageSprite(killer, victim, kDamageExplode, 4000);
else if (pSprite->statnum == kStatThing) else if (pSprite->statnum == kStatThing)
actDamageSprite_(nKiller, pSprite, kDamageExplode, 4000); actDamageSprite(killer, victim, kDamageExplode, 4000);
} }
} }