- use actors in the CFX interface.

This commit is contained in:
Christoph Oelckers 2021-08-27 00:07:33 +02:00
parent 77c827e817
commit 93e909dd58
9 changed files with 70 additions and 74 deletions

View file

@ -3654,7 +3654,7 @@ void actKillDude(DBloodActor* killerActor, DBloodActor* actor, DAMAGE_TYPE damag
if (pDudeInfo->nGibType[i] > -1) if (pDudeInfo->nGibType[i] > -1)
GibSprite(pSprite, (GIBTYPE)pDudeInfo->nGibType[i], nullptr, nullptr); GibSprite(pSprite, (GIBTYPE)pDudeInfo->nGibType[i], nullptr, nullptr);
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
fxSpawnBlood(pSprite, damage); fxSpawnBlood(actor, damage);
} }
gKillMgr.AddKill(pSprite); gKillMgr.AddKill(pSprite);
actCheckRespawn(actor); actCheckRespawn(actor);
@ -5618,7 +5618,7 @@ void actExplodeSprite(DBloodActor* actor)
seqSpawn(9, actor, -1); seqSpawn(9, actor, -1);
sfxPlay3DSound(actor, 307, -1, 0); sfxPlay3DSound(actor, 307, -1, 0);
GibSprite(pSprite, GIBTYPE_5, nullptr, nullptr); GibSprite(pSprite, GIBTYPE_5, nullptr, nullptr);
sub_746D4(pSprite, 240); fxSpawnPodStuff(actor, 240);
break; break;
default: default:
@ -7106,7 +7106,7 @@ void actFireVector(DBloodActor* shooter, int a2, int a3, int a4, int a5, int a6,
} }
for (int i = 0; i < pVectorData->bloodSplats; i++) for (int i = 0; i < pVectorData->bloodSplats; i++)
if (Chance(pVectorData->splatChance)) if (Chance(pVectorData->splatChance))
fxSpawnBlood(pSprite, pVectorData->dmg << 4); fxSpawnBlood(actor, pVectorData->dmg << 4);
} }
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
// add impulse for sprites from physics list // add impulse for sprites from physics list

View file

@ -105,7 +105,7 @@ void podAttack(int, DBloodActor* actor)
break; break;
} }
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
sub_746D4(pSprite, 240); fxSpawnPodStuff(actor, 240);
} }
void sub_70284(int, DBloodActor* actor) void sub_70284(int, DBloodActor* actor)

View file

@ -2607,7 +2607,7 @@ void genDudePostDeath(DBloodActor* actor, DAMAGE_TYPE damageType, int damage)
GibSprite(pSprite, (GIBTYPE)pDudeInfo->nGibType[i], NULL, NULL); GibSprite(pSprite, (GIBTYPE)pDudeInfo->nGibType[i], NULL, NULL);
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
fxSpawnBlood(pSprite, damage); fxSpawnBlood(actor, damage);
} }
gKillMgr.AddKill(pSprite); gKillMgr.AddKill(pSprite);

View file

@ -416,7 +416,7 @@ void fxBloodBits(DBloodActor* actor, int) // 14
if (pFX) if (pFX)
pFX->s().ang = nAngle; pFX->s().ang = nAngle;
} }
gFX.remove(actor->s().index); gFX.remove(actor);
} }
@ -575,7 +575,7 @@ void fxPodBloodSplat(DBloodActor* actor, int) // 19
if (pFX) if (pFX)
pFX->s().ang = nAngle; pFX->s().ang = nAngle;
} }
gFX.remove(actor->s().index); gFX.remove(actor);
} }

View file

@ -107,34 +107,30 @@ FXDATA gFXData[] = {
{ kCallbackNone, 1, 70, 1, -13981, 5120, 0, 0, 0, 0, 0, 0, 0 } { kCallbackNone, 1, 70, 1, -13981, 5120, 0, 0, 0, 0, 0, 0, 0 }
}; };
void CFX::destroy(int nSprite) void CFX::destroy(DBloodActor* actor)
{ {
if (nSprite < 0 || nSprite >= kMaxSprites) if (!actor) return;
return; evKill(actor);
evKill_(nSprite, 3); if (actor->hasX()) seqKill(actor);
if (sprite[nSprite].extra > 0) DeleteSprite(actor);
seqKill(3, sprite[nSprite].extra);
DeleteSprite(nSprite);
} }
void CFX::remove(int nSprite) void CFX::remove(DBloodActor* actor)
{ {
if (nSprite < 0 || nSprite >= kMaxSprites) if (!actor) return;
return; spritetype *pSprite = &actor->s();
spritetype *pSprite = &sprite[nSprite]; if (actor->hasX()) seqKill(actor);
if (pSprite->extra > 0)
seqKill(3, pSprite->extra);
if (pSprite->statnum != kStatFree) if (pSprite->statnum != kStatFree)
actPostSprite(nSprite, kStatFree); actPostSprite(actor, kStatFree);
} }
DBloodActor* CFX::fxSpawnActor(FX_ID nFx, int nSector, int x, int y, int z, unsigned int a6) DBloodActor* CFX::fxSpawnActor(FX_ID nFx, int nSector, int x, int y, int z, unsigned int a6)
{ {
if (nSector < 0 || nSector >= numsectors) if (nSector < 0 || nSector >= numsectors)
return NULL; return nullptr;
int nSector2 = nSector; int nSector2 = nSector;
if (!FindSector(x, y, z, &nSector2)) if (!FindSector(x, y, z, &nSector2))
return NULL; return nullptr;
if (adult_lockout && gGameOptions.nGameType <= 0) if (adult_lockout && gGameOptions.nGameType <= 0)
{ {
switch (nFx) switch (nFx)
@ -147,13 +143,13 @@ DBloodActor* CFX::fxSpawnActor(FX_ID nFx, int nSector, int x, int y, int z, unsi
case FX_34: case FX_34:
case FX_35: case FX_35:
case FX_36: case FX_36:
return NULL; return nullptr;
default: default:
break; break;
} }
} }
if (nFx < 0 || nFx >= kFXMax) if (nFx < 0 || nFx >= kFXMax)
return NULL; return nullptr;
FXDATA *pFX = &gFXData[nFx]; FXDATA *pFX = &gFXData[nFx];
if (gStatCount[1] == 512) if (gStatCount[1] == 512)
{ {
@ -162,8 +158,8 @@ DBloodActor* CFX::fxSpawnActor(FX_ID nFx, int nSector, int x, int y, int z, unsi
while (iactor && (iactor->s().flags & 32)) while (iactor && (iactor->s().flags & 32))
iactor = it.Next(); iactor = it.Next();
if (!iactor) if (!iactor)
return NULL; return nullptr;
destroy(iactor->s().index); destroy(iactor);
} }
auto actor = actSpawnSprite(nSector, x, y, z, 1, 0); auto actor = actSpawnSprite(nSector, x, y, z, 1, 0);
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
@ -195,76 +191,73 @@ DBloodActor* CFX::fxSpawnActor(FX_ID nFx, int nSector, int x, int y, int z, unsi
void CFX::fxProcess(void) void CFX::fxProcess(void)
{ {
int nSprite; BloodStatIterator it(kStatFX);
StatIterator it(kStatFX); while (auto actor = it.Next())
while ((nSprite = it.NextIndex()) >= 0)
{ {
spritetype *pSprite = &sprite[nSprite]; spritetype *pSprite = &actor->s();
viewBackupSpriteLoc(nSprite, pSprite); viewBackupSpriteLoc(actor);
short nSector = pSprite->sectnum; short nSector = pSprite->sectnum;
assert(nSector >= 0 && nSector < kMaxSectors); assert(nSector >= 0 && nSector < kMaxSectors);
assert(pSprite->type < kFXMax); assert(pSprite->type < kFXMax);
FXDATA *pFXData = &gFXData[pSprite->type]; FXDATA *pFXData = &gFXData[pSprite->type];
actAirDrag(&bloodActors[pSprite->index], pFXData->drag); actAirDrag(&bloodActors[pSprite->index], pFXData->drag);
if (xvel[nSprite]) pSprite->x += actor->xvel()>>12;
pSprite->x += xvel[nSprite]>>12; pSprite->y += actor->yvel()>>12;
if (yvel[nSprite]) pSprite->z += actor->zvel()>>8;
pSprite->y += yvel[nSprite]>>12;
if (zvel[nSprite])
pSprite->z += zvel[nSprite]>>8;
// Weird... // Weird...
if (xvel[nSprite] || (yvel[nSprite] && pSprite->z >= sector[pSprite->sectnum].floorz)) if (actor->xvel() || (actor->yvel() && pSprite->z >= sector[pSprite->sectnum].floorz))
{ {
updatesector(pSprite->x, pSprite->y, &nSector); updatesector(pSprite->x, pSprite->y, &nSector);
if (nSector == -1) if (nSector == -1)
{ {
remove(nSprite); remove(actor);
continue; continue;
} }
if (getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y) <= pSprite->z) if (getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y) <= pSprite->z)
{ {
if (pFXData->funcID < 0 || pFXData->funcID >= kCallbackMax) if (pFXData->funcID < 0 || pFXData->funcID >= kCallbackMax)
{ {
remove(nSprite); remove(actor);
continue; continue;
} }
assert(gCallback[pFXData->funcID] != NULL); assert(gCallback[pFXData->funcID] != nullptr);
gCallback[pFXData->funcID](&bloodActors[nSprite], 0); gCallback[pFXData->funcID](actor, 0);
continue; continue;
} }
if (nSector != pSprite->sectnum) if (nSector != pSprite->sectnum)
{ {
assert(nSector >= 0 && nSector < kMaxSectors); assert(nSector >= 0 && nSector < kMaxSectors);
ChangeSpriteSect(nSprite, nSector); ChangeSpriteSect(actor->s().index, nSector);
} }
} }
if (xvel[nSprite] || yvel[nSprite] || zvel[nSprite]) if (actor->xvel() || actor->yvel() || actor->zvel())
{ {
int32_t floorZ, ceilZ; int32_t floorZ, ceilZ;
getzsofslope(nSector, pSprite->x, pSprite->y, &ceilZ, &floorZ); getzsofslope(nSector, pSprite->x, pSprite->y, &ceilZ, &floorZ);
if (ceilZ > pSprite->z && !(sector[nSector].ceilingstat&1)) if (ceilZ > pSprite->z && !(sector[nSector].ceilingstat&1))
{ {
remove(nSprite); remove(actor);
continue; continue;
} }
if (floorZ < pSprite->z) if (floorZ < pSprite->z)
{ {
if (pFXData->funcID < 0 || pFXData->funcID >= kCallbackMax) if (pFXData->funcID < 0 || pFXData->funcID >= kCallbackMax)
{ {
remove(nSprite); remove(actor);
continue; continue;
} }
assert(gCallback[pFXData->funcID] != NULL); assert(gCallback[pFXData->funcID] != nullptr);
gCallback[pFXData->funcID](&bloodActors[nSprite], 0); gCallback[pFXData->funcID](actor, 0);
continue; continue;
} }
} }
zvel[nSprite] += pFXData->gravity; actor->zvel() += pFXData->gravity;
} }
} }
void fxSpawnBlood(spritetype *pSprite, int ) void fxSpawnBlood(DBloodActor *actor, int )
{ {
spritetype* pSprite = &actor->s();
if (pSprite->sectnum < 0 || pSprite->sectnum >= numsectors) if (pSprite->sectnum < 0 || pSprite->sectnum >= numsectors)
return; return;
int nSector = pSprite->sectnum; int nSector = pSprite->sectnum;
@ -283,8 +276,9 @@ void fxSpawnBlood(spritetype *pSprite, int )
} }
} }
void sub_746D4(spritetype *pSprite, int ) void fxSpawnPodStuff(DBloodActor* actor, int )
{ {
auto pSprite = &actor->s();
if (pSprite->sectnum < 0 || pSprite->sectnum >= numsectors) if (pSprite->sectnum < 0 || pSprite->sectnum >= numsectors)
return; return;
int nSector = pSprite->sectnum; int nSector = pSprite->sectnum;
@ -307,8 +301,9 @@ void sub_746D4(spritetype *pSprite, int )
} }
} }
void fxSpawnEjectingBrass(spritetype *pSprite, int z, int a3, int a4) void fxSpawnEjectingBrass(DBloodActor* actor, int z, int a3, int a4)
{ {
auto pSprite = &actor->s();
int x = pSprite->x+MulScale(pSprite->clipdist-4, Cos(pSprite->ang), 28); int x = pSprite->x+MulScale(pSprite->clipdist-4, Cos(pSprite->ang), 28);
int y = pSprite->y+MulScale(pSprite->clipdist-4, Sin(pSprite->ang), 28); int y = pSprite->y+MulScale(pSprite->clipdist-4, Sin(pSprite->ang), 28);
x += MulScale(a3, Cos(pSprite->ang+512), 30); x += MulScale(a3, Cos(pSprite->ang+512), 30);
@ -326,8 +321,9 @@ void fxSpawnEjectingBrass(spritetype *pSprite, int z, int a3, int a4)
} }
} }
void fxSpawnEjectingShell(spritetype *pSprite, int z, int a3, int a4) void fxSpawnEjectingShell(DBloodActor* actor, int z, int a3, int a4)
{ {
auto pSprite = &actor->s();
int x = pSprite->x+MulScale(pSprite->clipdist-4, Cos(pSprite->ang), 28); int x = pSprite->x+MulScale(pSprite->clipdist-4, Cos(pSprite->ang), 28);
int y = pSprite->y+MulScale(pSprite->clipdist-4, Sin(pSprite->ang), 28); int y = pSprite->y+MulScale(pSprite->clipdist-4, Sin(pSprite->ang), 28);
x += MulScale(a3, Cos(pSprite->ang+512), 30); x += MulScale(a3, Cos(pSprite->ang+512), 30);

View file

@ -91,16 +91,16 @@ enum FX_ID {
class CFX { class CFX {
public: public:
void destroy(int); void destroy(DBloodActor*);
void remove(int); void remove(DBloodActor*);
DBloodActor* fxSpawnActor(FX_ID, int, int, int, int, unsigned int); DBloodActor* fxSpawnActor(FX_ID, int, int, int, int, unsigned int);
void fxProcess(void); void fxProcess(void);
}; };
void fxSpawnBlood(spritetype *pSprite, int a2); void fxSpawnBlood(DBloodActor* pSprite, int a2);
void sub_746D4(spritetype *pSprite, int a2); void fxSpawnPodStuff(DBloodActor *pSprite, int a2);
void fxSpawnEjectingBrass(spritetype *pSprite, int z, int a3, int a4); void fxSpawnEjectingBrass(DBloodActor*pSprite, int z, int a3, int a4);
void fxSpawnEjectingShell(spritetype *pSprite, int z, int a3, int a4); void fxSpawnEjectingShell(DBloodActor*pSprite, int z, int a3, int a4);
extern CFX gFX; extern CFX gFX;

View file

@ -3082,18 +3082,18 @@ void damageSprites(XSPRITE* pXSource, spritetype* pSprite)
case kDmgBurn: case kDmgBurn:
if (pXSprite->burnTime > 0) break; if (pXSprite->burnTime > 0) break;
actBurnSprite(pSource->index, pXSprite, ClipLow(dmg >> 1, 128)); actBurnSprite(pSource->index, pXSprite, ClipLow(dmg >> 1, 128));
evKill_(pSprite->index, OBJ_SPRITE, kCallbackFXFlameLick); evKill(actor, kCallbackFXFlameLick);
evPost_(pSprite->index, OBJ_SPRITE, 0, kCallbackFXFlameLick); // show flames evPost(actor, 0, kCallbackFXFlameLick); // show flames
break; break;
case kDmgElectric: case kDmgElectric:
forceRecoil = true; // show tesla recoil animation forceRecoil = true; // show tesla recoil animation
break; break;
case kDmgBullet: case kDmgBullet:
evKill_(pSprite->index, OBJ_SPRITE, kCallbackFXBloodSpurt); evKill(actor, kCallbackFXBloodSpurt);
for (int i = 1; i < 6; i++) { for (int i = 1; i < 6; i++) {
if (Chance(0x16000 >> i)) if (Chance(0x16000 >> i))
fxSpawnBlood(pSprite, dmg << 4); fxSpawnBlood(actor, dmg << 4);
} }
break; break;
case kDmgChoke: case kDmgChoke:

View file

@ -1974,8 +1974,8 @@ int playerDamageSprite(DBloodActor* source, PLAYER *pPlayer, DAMAGE_TYPE nDamage
CGibVelocity gibVel(xvel[pSprite->index]>>1, yvel[pSprite->index]>>1, -0xccccc); CGibVelocity gibVel(xvel[pSprite->index]>>1, yvel[pSprite->index]>>1, -0xccccc);
GibSprite(pSprite, GIBTYPE_27, &gibPos, &gibVel); GibSprite(pSprite, GIBTYPE_27, &gibPos, &gibVel);
GibSprite(pSprite, GIBTYPE_7, NULL, NULL); GibSprite(pSprite, GIBTYPE_7, NULL, NULL);
fxSpawnBlood(pSprite, nDamage<<4); fxSpawnBlood(pActor, nDamage<<4);
fxSpawnBlood(pSprite, nDamage<<4); fxSpawnBlood(pActor, nDamage<<4);
nDeathSeqID = 17; nDeathSeqID = 17;
break; break;
} }

View file

@ -214,7 +214,7 @@ void SpawnBulletEject(PLAYER *pPlayer, int a2, int a3)
POSTURE *pPosture = &pPlayer->pPosture[pPlayer->lifeMode][pPlayer->posture]; POSTURE *pPosture = &pPlayer->pPosture[pPlayer->lifeMode][pPlayer->posture];
pPlayer->zView = pPlayer->pSprite->z-pPosture->eyeAboveZ; pPlayer->zView = pPlayer->pSprite->z-pPosture->eyeAboveZ;
int dz = pPlayer->zWeapon-(pPlayer->zWeapon-pPlayer->zView)/2; int dz = pPlayer->zWeapon-(pPlayer->zWeapon-pPlayer->zView)/2;
fxSpawnEjectingBrass(pPlayer->pSprite, dz, a2, a3); fxSpawnEjectingBrass(pPlayer->actor(), dz, a2, a3);
} }
void SpawnShellEject(PLAYER *pPlayer, int a2, int a3) void SpawnShellEject(PLAYER *pPlayer, int a2, int a3)
@ -223,7 +223,7 @@ void SpawnShellEject(PLAYER *pPlayer, int a2, int a3)
pPlayer->zView = pPlayer->pSprite->z-pPosture->eyeAboveZ; pPlayer->zView = pPlayer->pSprite->z-pPosture->eyeAboveZ;
int t = pPlayer->zWeapon - pPlayer->zView; int t = pPlayer->zWeapon - pPlayer->zView;
int dz = pPlayer->zWeapon-t+(t>>2); int dz = pPlayer->zWeapon-t+(t>>2);
fxSpawnEjectingShell(pPlayer->pSprite, dz, a2, a3); fxSpawnEjectingShell(pPlayer->actor(), dz, a2, a3);
} }
void WeaponInit(void) void WeaponInit(void)
@ -1447,7 +1447,7 @@ void FireVoodoo(int nTrigger, PLAYER *pPlayer)
case 0: case 0:
{ {
sfxPlay3DSound(pSprite, 460, 2, 0); sfxPlay3DSound(pSprite, 460, 2, 0);
fxSpawnBlood(pTarget, 17<<4); fxSpawnBlood(targetactor, 17<<4);
int nDamage = actDamageSprite(actor, targetactor, kDamageSpirit, 17<<4); int nDamage = actDamageSprite(actor, targetactor, kDamageSpirit, 17<<4);
UseAmmo(pPlayer, 9, nDamage/4); UseAmmo(pPlayer, 9, nDamage/4);
break; break;
@ -1455,7 +1455,7 @@ void FireVoodoo(int nTrigger, PLAYER *pPlayer)
case 1: case 1:
{ {
sfxPlay3DSound(pSprite, 460, 2, 0); sfxPlay3DSound(pSprite, 460, 2, 0);
fxSpawnBlood(pTarget, 17<<4); fxSpawnBlood(targetactor, 17<<4);
int nDamage = actDamageSprite(actor, targetactor, kDamageSpirit, 9<<4); int nDamage = actDamageSprite(actor, targetactor, kDamageSpirit, 9<<4);
if (IsPlayerSprite(pTarget)) if (IsPlayerSprite(pTarget))
WeaponLower(&gPlayer[pTarget->type-kDudePlayer1]); WeaponLower(&gPlayer[pTarget->type-kDudePlayer1]);
@ -1465,7 +1465,7 @@ void FireVoodoo(int nTrigger, PLAYER *pPlayer)
case 3: case 3:
{ {
sfxPlay3DSound(pSprite, 463, 2, 0); sfxPlay3DSound(pSprite, 463, 2, 0);
fxSpawnBlood(pTarget, 17<<4); fxSpawnBlood(targetactor, 17<<4);
int nDamage = actDamageSprite(actor, targetactor, kDamageSpirit, 49<<4); int nDamage = actDamageSprite(actor, targetactor, kDamageSpirit, 49<<4);
UseAmmo(pPlayer, 9, nDamage/4); UseAmmo(pPlayer, 9, nDamage/4);
break; break;
@ -1473,7 +1473,7 @@ void FireVoodoo(int nTrigger, PLAYER *pPlayer)
case 2: case 2:
{ {
sfxPlay3DSound(pSprite, 460, 2, 0); sfxPlay3DSound(pSprite, 460, 2, 0);
fxSpawnBlood(pTarget, 17<<4); fxSpawnBlood(targetactor, 17<<4);
int nDamage = actDamageSprite(actor, targetactor, kDamageSpirit, 11<<4); int nDamage = actDamageSprite(actor, targetactor, kDamageSpirit, 11<<4);
if (IsPlayerSprite(pTarget)) if (IsPlayerSprite(pTarget))
{ {
@ -1519,7 +1519,7 @@ void AltFireVoodoo(int nTrigger, PLAYER *pPlayer)
if (!pOtherPlayer->godMode || !powerupCheck(pOtherPlayer, kPwUpDeathMask)) if (!pOtherPlayer->godMode || !powerupCheck(pOtherPlayer, kPwUpDeathMask))
powerupActivate(pOtherPlayer, kPwUpDeliriumShroom); powerupActivate(pOtherPlayer, kPwUpDeliriumShroom);
} }
fxSpawnBlood(pTarget, 0); fxSpawnBlood(targetactor, 0);
} }
} }
} }
@ -1558,7 +1558,7 @@ void AltFireVoodoo(int nTrigger, PLAYER *pPlayer)
if (!pOtherPlayer->godMode || !powerupCheck(pOtherPlayer, kPwUpDeathMask)) if (!pOtherPlayer->godMode || !powerupCheck(pOtherPlayer, kPwUpDeathMask))
powerupActivate(pOtherPlayer, kPwUpDeliriumShroom); powerupActivate(pOtherPlayer, kPwUpDeliriumShroom);
} }
fxSpawnBlood(pTarget, 0); fxSpawnBlood(targetactor, 0);
} }
} }
} }