- CFX::fxSpawnActor

This commit is contained in:
Christoph Oelckers 2021-11-24 01:02:42 +01:00
parent 331a7654bf
commit e4e5bd0966
4 changed files with 11 additions and 15 deletions

View file

@ -124,12 +124,12 @@ void CFX::remove(DBloodActor* actor)
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, sectortype* pSector, int x, int y, int z, unsigned int a6)
{
if (nSector < 0 || nSector >= numsectors)
if (pSector == nullptr)
return nullptr;
int nSector2 = nSector;
if (!FindSector(x, y, z, &nSector2))
auto pSector2 = pSector;
if (!FindSector(x, y, z, &pSector2))
return nullptr;
if (adult_lockout && gGameOptions.nGameType <= 0)
{
@ -161,7 +161,7 @@ DBloodActor* CFX::fxSpawnActor(FX_ID nFx, int nSector, int x, int y, int z, unsi
return nullptr;
destroy(iactor);
}
auto actor = actSpawnSprite(&sector[nSector], x, y, z, 1, 0);
auto actor = actSpawnSprite(pSector, x, y, z, 1, 0);
spritetype* pSprite = &actor->s();
pSprite->type = nFx;
pSprite->picnum = pFX->picnum;

View file

@ -93,11 +93,7 @@ class CFX {
public:
void destroy(DBloodActor*);
void remove(DBloodActor*);
DBloodActor* fxSpawnActor(FX_ID, int, int, int, int, unsigned int);
DBloodActor* fxSpawnActor(FX_ID a, sectortype* b, int c, int d, int e, unsigned int f)
{
return fxSpawnActor(a, sectnum(b), c, d, e, f);
}
DBloodActor* fxSpawnActor(FX_ID a, sectortype* b, int c, int d, int e, unsigned int f);
void fxProcess(void);
};

View file

@ -266,14 +266,14 @@ int ChanceToCount(int a1, int a2)
void GibFX(DBloodActor* actor, GIBFX *pGFX, CGibPosition *pPos, CGibVelocity *pVel)
{
spritetype* pSprite = &actor->s();
int nSector = pSprite->sectnum;
auto pSector = pSprite->sector();
if (adult_lockout && gGameOptions.nGameType == 0 && pGFX->fxId == FX_13)
return;
CGibPosition gPos(pSprite->x, pSprite->y, pSprite->z);
if (pPos)
gPos = *pPos;
int32_t ceilZ, floorZ;
getzsofslope(nSector, gPos.x, gPos.y, &ceilZ, &floorZ);
getzsofslopeptr(pSector, gPos.x, gPos.y, &ceilZ, &floorZ);
int nCount = ChanceToCount(pGFX->chance, pGFX->at9);
int dz1 = floorZ-gPos.z;
int dz2 = gPos.z-ceilZ;
@ -288,7 +288,7 @@ void GibFX(DBloodActor* actor, GIBFX *pGFX, CGibPosition *pPos, CGibVelocity *pV
gPos.y = pSprite->y+MulScale(pSprite->clipdist<<2, Sin(nAngle), 30);
gPos.z = bottom-Random(bottom-top);
}
auto pFX = gFX.fxSpawnActor(pGFX->fxId, nSector, gPos.x, gPos.y, gPos.z, 0);
auto pFX = gFX.fxSpawnActor(pGFX->fxId, pSector, gPos.x, gPos.y, gPos.z, 0);
if (pFX)
{
if (pGFX->at1 < 0)

View file

@ -1833,7 +1833,7 @@ void debrisMove(int listIndex)
switch (tileGetSurfType(floorColl))
{
case kSurfLava:
if ((pFX = gFX.fxSpawnActor(FX_10, pSprite->sectnum, pSprite->x, pSprite->y, floorZ, 0)) == NULL) break;
if ((pFX = gFX.fxSpawnActor(FX_10, pSprite->sector(), pSprite->x, pSprite->y, floorZ, 0)) == NULL) break;
for (i = 0; i < 7; i++)
{
if ((pFX2 = gFX.fxSpawnActor(FX_14, pFX->s().sector(), pFX->s().x, pFX->s().y, pFX->s().z, 0)) == NULL) continue;
@ -6282,7 +6282,7 @@ void useRandomItemGen(DBloodActor* actor)
spritetype* pItem = &iactor->s();
if ((unsigned int)pItem->type == pXSource->dropMsg && pItem->x == pSource->x && pItem->y == pSource->y && pItem->z == pSource->z)
{
gFX.fxSpawnActor((FX_ID)29, pSource->sectnum, pSource->x, pSource->y, pSource->z, 0);
gFX.fxSpawnActor((FX_ID)29, pSource->sector(), pSource->x, pSource->y, pSource->z, 0);
pItem->type = kSpriteDecoration;
actPostSprite(iactor, kStatFree);
break;