- 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)
GibSprite(pSprite, (GIBTYPE)pDudeInfo->nGibType[i], nullptr, nullptr);
for (int i = 0; i < 4; i++)
fxSpawnBlood(pSprite, damage);
fxSpawnBlood(actor, damage);
}
gKillMgr.AddKill(pSprite);
actCheckRespawn(actor);
@ -5618,7 +5618,7 @@ void actExplodeSprite(DBloodActor* actor)
seqSpawn(9, actor, -1);
sfxPlay3DSound(actor, 307, -1, 0);
GibSprite(pSprite, GIBTYPE_5, nullptr, nullptr);
sub_746D4(pSprite, 240);
fxSpawnPodStuff(actor, 240);
break;
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++)
if (Chance(pVectorData->splatChance))
fxSpawnBlood(pSprite, pVectorData->dmg << 4);
fxSpawnBlood(actor, pVectorData->dmg << 4);
}
#ifdef NOONE_EXTENSIONS
// add impulse for sprites from physics list

View file

@ -105,7 +105,7 @@ void podAttack(int, DBloodActor* actor)
break;
}
for (int i = 0; i < 4; i++)
sub_746D4(pSprite, 240);
fxSpawnPodStuff(actor, 240);
}
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);
for (int i = 0; i < 4; i++)
fxSpawnBlood(pSprite, damage);
fxSpawnBlood(actor, damage);
}
gKillMgr.AddKill(pSprite);

View file

@ -416,7 +416,7 @@ void fxBloodBits(DBloodActor* actor, int) // 14
if (pFX)
pFX->s().ang = nAngle;
}
gFX.remove(actor->s().index);
gFX.remove(actor);
}
@ -575,7 +575,7 @@ void fxPodBloodSplat(DBloodActor* actor, int) // 19
if (pFX)
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 }
};
void CFX::destroy(int nSprite)
void CFX::destroy(DBloodActor* actor)
{
if (nSprite < 0 || nSprite >= kMaxSprites)
return;
evKill_(nSprite, 3);
if (sprite[nSprite].extra > 0)
seqKill(3, sprite[nSprite].extra);
DeleteSprite(nSprite);
if (!actor) return;
evKill(actor);
if (actor->hasX()) seqKill(actor);
DeleteSprite(actor);
}
void CFX::remove(int nSprite)
void CFX::remove(DBloodActor* actor)
{
if (nSprite < 0 || nSprite >= kMaxSprites)
return;
spritetype *pSprite = &sprite[nSprite];
if (pSprite->extra > 0)
seqKill(3, pSprite->extra);
if (!actor) return;
spritetype *pSprite = &actor->s();
if (actor->hasX()) seqKill(actor);
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)
{
if (nSector < 0 || nSector >= numsectors)
return NULL;
return nullptr;
int nSector2 = nSector;
if (!FindSector(x, y, z, &nSector2))
return NULL;
return nullptr;
if (adult_lockout && gGameOptions.nGameType <= 0)
{
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_35:
case FX_36:
return NULL;
return nullptr;
default:
break;
}
}
if (nFx < 0 || nFx >= kFXMax)
return NULL;
return nullptr;
FXDATA *pFX = &gFXData[nFx];
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))
iactor = it.Next();
if (!iactor)
return NULL;
destroy(iactor->s().index);
return nullptr;
destroy(iactor);
}
auto actor = actSpawnSprite(nSector, x, y, z, 1, 0);
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)
{
int nSprite;
StatIterator it(kStatFX);
while ((nSprite = it.NextIndex()) >= 0)
BloodStatIterator it(kStatFX);
while (auto actor = it.Next())
{
spritetype *pSprite = &sprite[nSprite];
viewBackupSpriteLoc(nSprite, pSprite);
spritetype *pSprite = &actor->s();
viewBackupSpriteLoc(actor);
short nSector = pSprite->sectnum;
assert(nSector >= 0 && nSector < kMaxSectors);
assert(pSprite->type < kFXMax);
FXDATA *pFXData = &gFXData[pSprite->type];
actAirDrag(&bloodActors[pSprite->index], pFXData->drag);
if (xvel[nSprite])
pSprite->x += xvel[nSprite]>>12;
if (yvel[nSprite])
pSprite->y += yvel[nSprite]>>12;
if (zvel[nSprite])
pSprite->z += zvel[nSprite]>>8;
pSprite->x += actor->xvel()>>12;
pSprite->y += actor->yvel()>>12;
pSprite->z += actor->zvel()>>8;
// 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);
if (nSector == -1)
{
remove(nSprite);
remove(actor);
continue;
}
if (getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y) <= pSprite->z)
{
if (pFXData->funcID < 0 || pFXData->funcID >= kCallbackMax)
{
remove(nSprite);
remove(actor);
continue;
}
assert(gCallback[pFXData->funcID] != NULL);
gCallback[pFXData->funcID](&bloodActors[nSprite], 0);
assert(gCallback[pFXData->funcID] != nullptr);
gCallback[pFXData->funcID](actor, 0);
continue;
}
if (nSector != pSprite->sectnum)
{
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;
getzsofslope(nSector, pSprite->x, pSprite->y, &ceilZ, &floorZ);
if (ceilZ > pSprite->z && !(sector[nSector].ceilingstat&1))
{
remove(nSprite);
remove(actor);
continue;
}
if (floorZ < pSprite->z)
{
if (pFXData->funcID < 0 || pFXData->funcID >= kCallbackMax)
{
remove(nSprite);
remove(actor);
continue;
}
assert(gCallback[pFXData->funcID] != NULL);
gCallback[pFXData->funcID](&bloodActors[nSprite], 0);
assert(gCallback[pFXData->funcID] != nullptr);
gCallback[pFXData->funcID](actor, 0);
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)
return;
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)
return;
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 y = pSprite->y+MulScale(pSprite->clipdist-4, Sin(pSprite->ang), 28);
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 y = pSprite->y+MulScale(pSprite->clipdist-4, Sin(pSprite->ang), 28);
x += MulScale(a3, Cos(pSprite->ang+512), 30);

View file

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

View file

@ -3082,18 +3082,18 @@ void damageSprites(XSPRITE* pXSource, spritetype* pSprite)
case kDmgBurn:
if (pXSprite->burnTime > 0) break;
actBurnSprite(pSource->index, pXSprite, ClipLow(dmg >> 1, 128));
evKill_(pSprite->index, OBJ_SPRITE, kCallbackFXFlameLick);
evPost_(pSprite->index, OBJ_SPRITE, 0, kCallbackFXFlameLick); // show flames
evKill(actor, kCallbackFXFlameLick);
evPost(actor, 0, kCallbackFXFlameLick); // show flames
break;
case kDmgElectric:
forceRecoil = true; // show tesla recoil animation
break;
case kDmgBullet:
evKill_(pSprite->index, OBJ_SPRITE, kCallbackFXBloodSpurt);
evKill(actor, kCallbackFXBloodSpurt);
for (int i = 1; i < 6; i++) {
if (Chance(0x16000 >> i))
fxSpawnBlood(pSprite, dmg << 4);
fxSpawnBlood(actor, dmg << 4);
}
break;
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);
GibSprite(pSprite, GIBTYPE_27, &gibPos, &gibVel);
GibSprite(pSprite, GIBTYPE_7, NULL, NULL);
fxSpawnBlood(pSprite, nDamage<<4);
fxSpawnBlood(pSprite, nDamage<<4);
fxSpawnBlood(pActor, nDamage<<4);
fxSpawnBlood(pActor, nDamage<<4);
nDeathSeqID = 17;
break;
}

View file

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