- actSpawnThing and actFireThing.

This commit is contained in:
Christoph Oelckers 2020-12-05 20:22:29 +01:00
parent 7c1826e909
commit 4526f4149b
9 changed files with 68 additions and 54 deletions

View file

@ -6534,33 +6534,31 @@ DBloodActor* actSpawnDude(DBloodActor* source, short nType, int a3, int a4)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
spritetype * actSpawnThing(int nSector, int x, int y, int z, int nThingType) DBloodActor* actSpawnThing(int nSector, int x, int y, int z, int nThingType)
{ {
assert(nThingType >= kThingBase && nThingType < kThingMax); assert(nThingType >= kThingBase && nThingType < kThingMax);
auto actor = actSpawnSprite(nSector, x, y, z, 4, 1); auto actor = actSpawnSprite(nSector, x, y, z, 4, 1);
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
int nType = nThingType-kThingBase; int nType = nThingType - kThingBase;
int nThing = pSprite->index; int nThing = pSprite->index;
int nXThing = pSprite->extra; int nXThing = pSprite->extra;
pSprite->type = nThingType; pSprite->type = nThingType;
assert(nXThing > 0 && nXThing < kMaxXSprites); assert(nXThing > 0 && nXThing < kMaxXSprites);
XSPRITE *pXThing = &xsprite[nXThing]; XSPRITE* pXThing = &xsprite[nXThing];
const THINGINFO *pThingInfo = &thingInfo[nType]; const THINGINFO* pThingInfo = &thingInfo[nType];
pXThing->health = pThingInfo->startHealth<<4; pXThing->health = pThingInfo->startHealth << 4;
pSprite->clipdist = pThingInfo->clipdist; pSprite->clipdist = pThingInfo->clipdist;
pSprite->flags = pThingInfo->flags; pSprite->flags = pThingInfo->flags;
if (pSprite->flags & 2) if (pSprite->flags & 2) pSprite->flags |= 4;
pSprite->flags |= 4;
pSprite->cstat |= pThingInfo->cstat; pSprite->cstat |= pThingInfo->cstat;
pSprite->picnum = pThingInfo->picnum; pSprite->picnum = pThingInfo->picnum;
pSprite->shade = pThingInfo->shade; pSprite->shade = pThingInfo->shade;
pSprite->pal = pThingInfo->pal; pSprite->pal = pThingInfo->pal;
if (pThingInfo->xrepeat) if (pThingInfo->xrepeat) pSprite->xrepeat = pThingInfo->xrepeat;
pSprite->xrepeat = pThingInfo->xrepeat; if (pThingInfo->yrepeat) pSprite->yrepeat = pThingInfo->yrepeat;
if (pThingInfo->yrepeat)
pSprite->yrepeat = pThingInfo->yrepeat;
show2dsprite.Set(pSprite->index); show2dsprite.Set(pSprite->index);
switch (nThingType) { switch (nThingType)
{
case kThingVoodooHead: case kThingVoodooHead:
pXThing->data1 = 0; pXThing->data1 = 0;
pXThing->data2 = 0; pXThing->data2 = 0;
@ -6570,10 +6568,11 @@ spritetype * actSpawnThing(int nSector, int x, int y, int z, int nThingType)
pXThing->triggerOnce = 1; pXThing->triggerOnce = 1;
pXThing->isTriggered = 0; pXThing->isTriggered = 0;
break; break;
case kThingDroppedLifeLeech: case kThingDroppedLifeLeech:
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
case kModernThingEnemyLifeLeech: case kModernThingEnemyLifeLeech:
#endif #endif
pXThing->data1 = 0; pXThing->data1 = 0;
pXThing->data2 = 0; pXThing->data2 = 0;
pXThing->data3 = 0; pXThing->data3 = 0;
@ -6582,74 +6581,87 @@ spritetype * actSpawnThing(int nSector, int x, int y, int z, int nThingType)
pXThing->triggerOnce = 0; pXThing->triggerOnce = 0;
pXThing->isTriggered = 0; pXThing->isTriggered = 0;
break; break;
case kThingZombieHead: case kThingZombieHead:
pXThing->data1 = 8; pXThing->data1 = 8;
pXThing->data2 = 0; pXThing->data2 = 0;
pXThing->data3 = 0; pXThing->data3 = 0;
pXThing->data4 = 318; pXThing->data4 = 318;
pXThing->targetX = PlayClock+180; pXThing->targetX = PlayClock + 180;
pXThing->locked = 1; pXThing->locked = 1;
pXThing->state = 1; pXThing->state = 1;
pXThing->triggerOnce = 0; pXThing->triggerOnce = 0;
pXThing->isTriggered = 0; pXThing->isTriggered = 0;
break; break;
case kThingBloodBits: case kThingBloodBits:
case kThingBloodChunks: case kThingBloodChunks:
pXThing->data1 = (nThingType == kThingBloodBits) ? 19 : 8; pXThing->data1 = (nThingType == kThingBloodBits) ? 19 : 8;
pXThing->data2 = 0; pXThing->data2 = 0;
pXThing->data3 = 0; pXThing->data3 = 0;
pXThing->data4 = 318; pXThing->data4 = 318;
pXThing->targetX = PlayClock+180; pXThing->targetX = PlayClock + 180;
pXThing->locked = 1; pXThing->locked = 1;
pXThing->state = 1; pXThing->state = 1;
pXThing->triggerOnce = 0; pXThing->triggerOnce = 0;
pXThing->isTriggered = 0; pXThing->isTriggered = 0;
break; break;
case kThingArmedTNTStick: case kThingArmedTNTStick:
evPost(nThing, 3, 0, kCallbackFXDynPuff); evPost(nThing, 3, 0, kCallbackFXDynPuff);
sfxPlay3DSound(pSprite, 450, 0, 0); sfxPlay3DSound(pSprite, 450, 0, 0);
break; break;
case kThingArmedTNTBundle: case kThingArmedTNTBundle:
sfxPlay3DSound(pSprite, 450, 0, 0); sfxPlay3DSound(pSprite, 450, 0, 0);
evPost(nThing, 3, 0, kCallbackFXDynPuff); evPost(nThing, 3, 0, kCallbackFXDynPuff);
break; break;
case kThingArmedSpray: case kThingArmedSpray:
evPost(nThing, 3, 0, kCallbackFXDynPuff); evPost(nThing, 3, 0, kCallbackFXDynPuff);
break; break;
} }
return pSprite; return actor;
} }
spritetype * actFireThing_(spritetype *pSprite, int a2, int a3, int a4, int thingType, int a6) //---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
DBloodActor* actFireThing(DBloodActor* actor, int a2, int a3, int a4, int thingType, int a6)
{ {
auto pSprite = &actor->s();
assert(thingType >= kThingBase && thingType < kThingMax); assert(thingType >= kThingBase && thingType < kThingMax);
int x = pSprite->x+MulScale(a2, Cos(pSprite->ang+512), 30); int x = pSprite->x+MulScale(a2, Cos(pSprite->ang+512), 30);
int y = pSprite->y+MulScale(a2, Sin(pSprite->ang+512), 30); int y = pSprite->y+MulScale(a2, Sin(pSprite->ang+512), 30);
int z = pSprite->z+a3; int z = pSprite->z+a3;
x += MulScale(pSprite->clipdist, Cos(pSprite->ang), 28); x += MulScale(pSprite->clipdist, Cos(pSprite->ang), 28);
y += MulScale(pSprite->clipdist, Sin(pSprite->ang), 28); y += MulScale(pSprite->clipdist, Sin(pSprite->ang), 28);
if (HitScan(pSprite, z, x-pSprite->x, y-pSprite->y, 0, CLIPMASK0, pSprite->clipdist) != -1) if (HitScan(pSprite, z, x - pSprite->x, y - pSprite->y, 0, CLIPMASK0, pSprite->clipdist) != -1)
{ {
x = gHitInfo.hitx-MulScale(pSprite->clipdist<<1, Cos(pSprite->ang), 28); x = gHitInfo.hitx-MulScale(pSprite->clipdist<<1, Cos(pSprite->ang), 28);
y = gHitInfo.hity-MulScale(pSprite->clipdist<<1, Sin(pSprite->ang), 28); y = gHitInfo.hity-MulScale(pSprite->clipdist<<1, Sin(pSprite->ang), 28);
} }
spritetype *pThing = actSpawnThing(pSprite->sectnum, x, y, z, thingType); auto fired = actSpawnThing(pSprite->sectnum, x, y, z, thingType);
spritetype* pThing = &fired->s();
pThing->owner = pSprite->index; pThing->owner = pSprite->index;
pThing->ang = pSprite->ang; pThing->ang = pSprite->ang;
xvel[pThing->index] = MulScale(a6, Cos(pThing->ang), 30); fired->xvel() = MulScale(a6, Cos(pThing->ang), 30);
yvel[pThing->index] = MulScale(a6, Sin(pThing->ang), 30); fired->yvel() = MulScale(a6, Sin(pThing->ang), 30);
zvel[pThing->index] = MulScale(a6, a4, 14); fired->zvel() = MulScale(a6, a4, 14);
xvel[pThing->index] += xvel[pSprite->index]/2; fired->xvel() += actor->xvel() / 2;
yvel[pThing->index] += yvel[pSprite->index]/2; fired->yvel() += actor->yvel() / 2;
zvel[pThing->index] += zvel[pSprite->index]/2; fired->zvel() += actor->zvel() / 2;
return pThing; return fired;
} }
DBloodActor* actFireThing(DBloodActor* pSprite, int a2, int a3, int a4, int thingType, int a6) //---------------------------------------------------------------------------
{ //
auto spr = actFireThing_(&pSprite->s(), a2, a3, a4, thingType, a6); //
return &bloodActors[spr->index]; //
} //---------------------------------------------------------------------------
spritetype* actFireMissile(spritetype *pSprite, int a2, int a3, int a4, int a5, int a6, int nType) spritetype* actFireMissile(spritetype *pSprite, int a2, int a3, int a4, int a5, int a6, int nType)
{ {

View file

@ -235,7 +235,7 @@ void actProcessSprites(void);
DBloodActor* actSpawnSprite(int nSector, int x, int y, int z, int nStat, bool a6); DBloodActor* actSpawnSprite(int nSector, int x, int y, int z, int nStat, bool a6);
DBloodActor* actSpawnDude(DBloodActor* pSource, short nType, int a3, int a4); DBloodActor* actSpawnDude(DBloodActor* pSource, short nType, int a3, int a4);
DBloodActor * actSpawnSprite(DBloodActor *pSource, int nStat); DBloodActor * actSpawnSprite(DBloodActor *pSource, int nStat);
spritetype * actSpawnThing(int nSector, int x, int y, int z, int nThingType); DBloodActor * actSpawnThing(int nSector, int x, int y, int z, int nThingType);
spritetype * actFireThing_(spritetype *pSprite, int a2, int a3, int a4, int thingType, int a6); spritetype * actFireThing_(spritetype *pSprite, int a2, int a3, int a4, int thingType, int a6);
DBloodActor* actFireThing(DBloodActor* pSprite, int a2, int a3, int a4, int thingType, int a6); DBloodActor* actFireThing(DBloodActor* pSprite, int a2, int a3, int a4, int thingType, int a6);

View file

@ -146,11 +146,11 @@ void cultThrowSeqCallback(int, DBloodActor* actor)
int nDist2 = nDist / 540; int nDist2 = nDist / 540;
if (nDist > 0x1e00) if (nDist > 0x1e00)
v4 = 0; v4 = 0;
spritetype *pMissile = actFireThing_(pSprite, 0, 0, dz/128-14500, nMissile, (nDist2<<23)/120); auto* pMissile = actFireThing(actor, 0, 0, dz/128-14500, nMissile, (nDist2<<23)/120);
if (v4) if (v4)
xsprite[pMissile->extra].Impact = 1; pMissile->x().Impact = 1;
else else
evPost(pMissile->index, 3, 120*(1+Random(2)), kCmdOn); evPost(pMissile, 120 * (1 + Random(2)), kCmdOn);
} }
void sub_68170(int, DBloodActor* actor) void sub_68170(int, DBloodActor* actor)
@ -161,8 +161,8 @@ void sub_68170(int, DBloodActor* actor)
if (gGameOptions.nDifficulty > 2) if (gGameOptions.nDifficulty > 2)
nMissile = kThingArmedTNTBundle; nMissile = kThingArmedTNTBundle;
sfxPlay3DSound(pSprite, 455, -1, 0); sfxPlay3DSound(pSprite, 455, -1, 0);
spritetype* pMissile = actFireThing_(pSprite, 0, 0, actor->dudeSlope - 9460, nMissile, 0x133333); auto pMissile = actFireThing(actor, 0, 0, actor->dudeSlope - 9460, nMissile, 0x133333);
evPost(pMissile->index, 3, 120*(2+Random(2)), kCmdOn); evPost(pMissile, 120 * (2 + Random(2)), kCmdOn);
} }
void sub_68230(int, DBloodActor* actor) void sub_68230(int, DBloodActor* actor)
@ -181,8 +181,8 @@ void sub_68230(int, DBloodActor* actor)
int dz = pTarget->z - pSprite->z; int dz = pTarget->z - pSprite->z;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
int nDist2 = nDist / 540; int nDist2 = nDist / 540;
spritetype *pMissile = actFireThing_(pSprite, 0, 0, dz/128-14500, nMissile, (nDist2<<17)/120); auto pMissile = actFireThing(actor, 0, 0, dz/128-14500, nMissile, (nDist2<<17)/120);
xsprite[pMissile->extra].Impact = 1; pMissile->x().Impact = 1;
} }
static char TargetNearExplosion(spritetype *pSprite) static char TargetNearExplosion(spritetype *pSprite)

View file

@ -102,7 +102,7 @@ void ThrowFSeqCallback(int, DBloodActor* actor)
{ {
XSPRITE* pXSprite = &actor->x(); XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
actFireThing_(&actor->s(), 0, 0, actor->dudeSlope-7500, kThingBone, 0xeeeee); actFireThing(actor, 0, 0, actor->dudeSlope-7500, kThingBone, 0xeeeee);
} }
void BlastSSeqCallback(int, DBloodActor* actor) void BlastSSeqCallback(int, DBloodActor* actor)
@ -201,8 +201,7 @@ void BlastSSeqCallback(int, DBloodActor* actor)
void ThrowSSeqCallback(int, DBloodActor* actor) void ThrowSSeqCallback(int, DBloodActor* actor)
{ {
spritetype* pSprite = &actor->s(); actFireThing(actor, 0, 0, actor->dudeSlope - 7500, kThingBone, Chance(0x6000) ? 0x133333 : 0x111111);
actFireThing_(pSprite, 0, 0, actor->dudeSlope - 7500, kThingBone, Chance(0x6000) ? 0x133333 : 0x111111);
} }
static void gargThinkTarget(DBloodActor* actor) static void gargThinkTarget(DBloodActor* actor)

View file

@ -85,7 +85,7 @@ void ghostSlashSeqCallback(int, DBloodActor* actor)
void ghostThrowSeqCallback(int, DBloodActor* actor) void ghostThrowSeqCallback(int, DBloodActor* actor)
{ {
actFireThing_(&actor->s(), 0, 0, actor->dudeSlope - 7500, kThingBone, 0xeeeee); actFireThing(actor, 0, 0, actor->dudeSlope - 7500, kThingBone, 0xeeeee);
} }
void ghostBlastSeqCallback(int, DBloodActor* actor) void ghostBlastSeqCallback(int, DBloodActor* actor)

View file

@ -86,7 +86,7 @@ void podAttack(int, DBloodActor* actor)
y += Random2(1000); y += Random2(1000);
int nDist = approxDist(x, y); int nDist = approxDist(x, y);
int nDist2 = nDist / 540; int nDist2 = nDist / 540;
spritetype *pMissile = NULL; DBloodActor* pMissile = nullptr;
switch (pSprite->type) switch (pSprite->type)
{ {
case kDudePodGreen: case kDudePodGreen:
@ -97,20 +97,20 @@ void podAttack(int, DBloodActor* actor)
sfxPlay3DSound(pSprite, 2474, -1, 0); sfxPlay3DSound(pSprite, 2474, -1, 0);
else else
sfxPlay3DSound(pSprite, 2475, -1, 0); sfxPlay3DSound(pSprite, 2475, -1, 0);
pMissile = actFireThing_(pSprite, 0, -8000, dz/128-14500, kThingPodGreenBall, (nDist2<<23)/120); pMissile = actFireThing(actor, 0, -8000, dz/128-14500, kThingPodGreenBall, (nDist2<<23)/120);
} }
if (pMissile) if (pMissile)
seqSpawn(68, 3, pMissile->extra, -1); seqSpawn(68, pMissile, -1);
break; break;
case kDudePodFire: case kDudePodFire:
dz += 8000; dz += 8000;
if (pDudeInfo->seeDist*0.1 < nDist) if (pDudeInfo->seeDist*0.1 < nDist)
{ {
sfxPlay3DSound(pSprite, 2454, -1, 0); sfxPlay3DSound(pSprite, 2454, -1, 0);
pMissile = actFireThing_(pSprite, 0, -8000, dz/128-14500, kThingPodFireBall, (nDist2<<23)/120); pMissile = actFireThing(actor, 0, -8000, dz/128-14500, kThingPodFireBall, (nDist2<<23)/120);
} }
if (pMissile) if (pMissile)
seqSpawn(22, 3, pMissile->extra, -1); seqSpawn(22, pMissile, -1);
break; break;
} }
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)

View file

@ -315,9 +315,11 @@ static void ThrowThing(DBloodActor* actor, bool impact)
break; break;
} }
spritetype* pThing = NULL; DBloodActor* spawned = nullptr;
if ((pThing = actFireThing_(pSprite, 0, 0, (dz / 128) - zThrow, curWeapon, DivScale(dist / 540, 120, 23))) == NULL) return; if ((spawned = actFireThing(actor, 0, 0, (dz / 128) - zThrow, curWeapon, DivScale(dist / 540, 120, 23))) == nullptr) return;
else if (pThinkInfo->picnum < 0 && pThing->type != kModernThingThrowableRock) pThing->picnum = 0;
spritetype* pThing = &spawned->s();
if (pThinkInfo->picnum < 0 && pThing->type != kModernThingThrowableRock) pThing->picnum = 0;
pThing->owner = pSprite->index; pThing->owner = pSprite->index;

View file

@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "build.h" #include "build.h"
#include "blood.h" #include "blood.h"
#include "bloodactor.h"
BEGIN_BLD_NS BEGIN_BLD_NS
@ -381,7 +382,7 @@ void GibThing(spritetype *pSprite, GIBTHING *pGThing, CGibPosition *pPos, CGibVe
getzsofslope(nSector, x, y, &ceilZ, &floorZ); getzsofslope(nSector, x, y, &ceilZ, &floorZ);
int dz1 = floorZ-z; int dz1 = floorZ-z;
int dz2 = z-ceilZ; int dz2 = z-ceilZ;
spritetype *pGib = actSpawnThing(nSector, x, y, z, pGThing->type); spritetype *pGib = &actSpawnThing(nSector, x, y, z, pGThing->type)->s();
assert(pGib != NULL); assert(pGib != NULL);
if (pGThing->Kills > -1) if (pGThing->Kills > -1)
pGib->picnum = pGThing->Kills; pGib->picnum = pGThing->Kills;

View file

@ -1784,7 +1784,7 @@ spritetype *playerFireMissile(PLAYER *pPlayer, int a2, int a3, int a4, int a5, i
spritetype * playerFireThing(PLAYER *pPlayer, int a2, int a3, int thingType, int a5) spritetype * playerFireThing(PLAYER *pPlayer, int a2, int a3, int thingType, int a5)
{ {
assert(thingType >= kThingBase && thingType < kThingMax); assert(thingType >= kThingBase && thingType < kThingMax);
return actFireThing_(pPlayer->pSprite, a2, pPlayer->zWeapon-pPlayer->pSprite->z, pPlayer->slope+a3, thingType, a5); return &actFireThing(&bloodActors[pPlayer->pSprite->index], a2, pPlayer->zWeapon-pPlayer->pSprite->z, pPlayer->slope+a3, thingType, a5)->s();
} }
void playerFrag(PLAYER *pKiller, PLAYER *pVictim) void playerFrag(PLAYER *pKiller, PLAYER *pVictim)