From d1cc7403b38b3bfd9b4b9bd49cf56896efd04187 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 2 Dec 2020 22:33:14 +0100 Subject: [PATCH] - actNapalmMove - another previously unnamed function. # Conflicts: # source/games/blood/src/aiunicult.cpp --- source/games/blood/src/actor.cpp | 93 +++++++++++++++++++----------- source/games/blood/src/actor.h | 6 +- source/games/blood/src/aicult.cpp | 6 +- source/games/blood/src/aigarg.cpp | 4 +- source/games/blood/src/aighost.cpp | 2 +- source/games/blood/src/aipod.cpp | 4 +- source/games/blood/src/player.cpp | 2 +- source/games/blood/src/seq.cpp | 5 ++ source/games/blood/src/seq.h | 2 + 9 files changed, 78 insertions(+), 46 deletions(-) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index e64932564..bd8fe64de 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -2718,42 +2718,54 @@ void actRadiusDamage(DBloodActor* source, int x, int y, int z, int nSector, int } } -void sub_2AA94(DBloodActor* actor) -{ - auto pXSprite = &actor->x(); - auto pSprite = &actor->s(); - int nOwner = pSprite->owner; - actPostSprite(pSprite->index, kStatDecoration); - seqSpawn(9, 3, pSprite->extra); - if (Chance(0x8000)) - pSprite->cstat |= 4; +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- - sfxPlay3DSound(pSprite, 303, 24+(pSprite->flags&3), 1); - actRadiusDamage(actor->GetOwner(), pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, 128, 0, 60, DAMAGE_TYPE_3, 15, 120); - if (pXSprite->data4 > 1) - { - GibSprite(pSprite, GIBTYPE_5, NULL, NULL); - int v14[2]; - v14[0] = pXSprite->data4>>1; - v14[1] = pXSprite->data4-v14[0]; - int v4 = pSprite->ang; - xvel[pSprite->index] = 0; - yvel[pSprite->index] = 0; - zvel[pSprite->index] = 0; - for (int i = 0; i < 2; i++) - { - int t1 = Random(0x33333)+0x33333; - int t2 = Random2(0x71); - pSprite->ang = (t2+v4+2048)&2047; - spritetype *pSprite2 = actFireThing(pSprite, 0, 0, -0x93d0, kThingNapalmBall, t1); - XSPRITE *pXSprite2 = &xsprite[pSprite2->extra]; - pSprite2->owner = pSprite->owner; - seqSpawn(61, 3, pSprite2->extra, nNapalmClient); - pXSprite2->data4 = v14[i]; - } - } +static void actNapalmMove(DBloodActor* actor) +{ + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); + auto pOwner = actor->GetOwner(); + + actPostSprite(actor, kStatDecoration); + seqSpawn(9, actor); + if (Chance(0x8000)) pSprite->cstat |= 4; + + sfxPlay3DSound(pSprite, 303, 24 + (pSprite->flags & 3), 1); + actRadiusDamage(pOwner, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, 128, 0, 60, DAMAGE_TYPE_3, 15, 120); + + if (pXSprite->data4 > 1) + { + GibSprite(pSprite, GIBTYPE_5, NULL, NULL); + int spawnparam[2]; + spawnparam[0] = pXSprite->data4 >> 1; + spawnparam[1] = pXSprite->data4 - spawnparam[0]; + int ang = pSprite->ang; + actor->xvel() = 0; + actor->yvel() = 0; + actor->zvel() = 0; + for (int i = 0; i < 2; i++) + { + int t1 = Random(0x33333) + 0x33333; + int rndang = Random2(0x71); + pSprite->ang = (rndang + ang + 2048) & 2047; + auto spawned = actFireThing(actor, 0, 0, -0x93d0, kThingNapalmBall, t1); + spawned->SetOwner(actor->GetOwner()); + seqSpawn(61, spawned, nNapalmClient); + spawned->x().data4 = spawnparam[i]; + } + } } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + spritetype *actSpawnFloor(spritetype *pSprite) { short nSector = pSprite->sectnum; @@ -4431,7 +4443,7 @@ int MoveThing(spritetype *pSprite) switch (pSprite->type) { case kThingNapalmBall: - if (zvel[nSprite] == 0 || Chance(0xA000)) sub_2AA94(&bloodActors[pXSprite->reference]); + if (zvel[nSprite] == 0 || Chance(0xA000)) actNapalmMove(&bloodActors[pXSprite->reference]); break; case kThingZombieHead: if (abs(zvel[nSprite]) > 0x80000) { @@ -6258,7 +6270,7 @@ spritetype * actSpawnThing(int nSector, int x, int y, int z, int nThingType) return pSprite; } -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) { assert(thingType >= kThingBase && thingType < kThingMax); int x = pSprite->x+MulScale(a2, Cos(pSprite->ang+512), 30); @@ -6283,6 +6295,12 @@ spritetype * actFireThing(spritetype *pSprite, int a2, int a3, int a4, int thing return pThing; } +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) { @@ -6872,6 +6890,11 @@ void actPostSprite(int nSprite, int nStatus) gPost[n].status = nStatus; } +void actPostSprite(DBloodActor* actor, int status) +{ + actPostSprite(actor->s().index, status); +} + void actPostProcess(void) { for (int i = 0; i < gPostCount; i++) diff --git a/source/games/blood/src/actor.h b/source/games/blood/src/actor.h index a6101f798..ce68ba4d7 100644 --- a/source/games/blood/src/actor.h +++ b/source/games/blood/src/actor.h @@ -214,7 +214,6 @@ void actInit(bool bSaveLoad); int actWallBounceVector(int *x, int *y, int nWall, int a4); int actFloorBounceVector(int *x, int *y, int *z, int nSector, int a5); void actRadiusDamage(DBloodActor* source, int x, int y, int z, int nSector, int nDist, int a7, int a8, DAMAGE_TYPE a9, int a10, int a11); -void sub_2AA94(DBloodActor *actor); spritetype *actSpawnFloor(spritetype *pSprite); spritetype *actDropAmmo(spritetype *pSprite, int nType); spritetype *actDropWeapon(spritetype *pSprite, int nType); @@ -243,13 +242,16 @@ spritetype * actSpawnSprite(int nSector, int x, int y, int z, int nStat, char a6 spritetype *actSpawnDude(spritetype *pSource, short nType, int a3, int a4); spritetype * actSpawnSprite(spritetype *pSource, int nStat); spritetype * 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); + spritetype* actFireMissile(spritetype *pSprite, int a2, int a3, int a4, int a5, int a6, int nType); int actGetRespawnTime(spritetype *pSprite); bool actCheckRespawn(spritetype *pSprite); bool actCanSplatWall(int nWall); void actFireVector(spritetype *pShooter, int a2, int a3, int a4, int a5, int a6, VECTOR_TYPE vectorType); void actPostSprite(int nSprite, int nStatus); +void actPostSprite(DBloodActor* actor, int status); void actPostProcess(void); void MakeSplash(DBloodActor *actor); void actBuildMissile(spritetype* pMissile, int nXSprite, int nSprite); diff --git a/source/games/blood/src/aicult.cpp b/source/games/blood/src/aicult.cpp index e1e8f7ab0..ef19c51df 100644 --- a/source/games/blood/src/aicult.cpp +++ b/source/games/blood/src/aicult.cpp @@ -146,7 +146,7 @@ void cultThrowSeqCallback(int, DBloodActor* actor) int nDist2 = nDist / 540; if (nDist > 0x1e00) v4 = 0; - spritetype *pMissile = actFireThing(pSprite, 0, 0, dz/128-14500, nMissile, (nDist2<<23)/120); + spritetype *pMissile = actFireThing_(pSprite, 0, 0, dz/128-14500, nMissile, (nDist2<<23)/120); if (v4) xsprite[pMissile->extra].Impact = 1; else @@ -161,7 +161,7 @@ void sub_68170(int, DBloodActor* actor) if (gGameOptions.nDifficulty > 2) nMissile = kThingArmedTNTBundle; sfxPlay3DSound(pSprite, 455, -1, 0); - spritetype* pMissile = actFireThing(pSprite, 0, 0, actor->dudeSlope - 9460, nMissile, 0x133333); + spritetype* pMissile = actFireThing_(pSprite, 0, 0, actor->dudeSlope - 9460, nMissile, 0x133333); evPost(pMissile->index, 3, 120*(2+Random(2)), kCmdOn); } @@ -181,7 +181,7 @@ void sub_68230(int, DBloodActor* actor) int dz = pTarget->z - pSprite->z; int nDist = approxDist(dx, dy); int nDist2 = nDist / 540; - spritetype *pMissile = actFireThing(pSprite, 0, 0, dz/128-14500, nMissile, (nDist2<<17)/120); + spritetype *pMissile = actFireThing_(pSprite, 0, 0, dz/128-14500, nMissile, (nDist2<<17)/120); xsprite[pMissile->extra].Impact = 1; } diff --git a/source/games/blood/src/aigarg.cpp b/source/games/blood/src/aigarg.cpp index 176af80b8..d16563cba 100644 --- a/source/games/blood/src/aigarg.cpp +++ b/source/games/blood/src/aigarg.cpp @@ -102,7 +102,7 @@ void ThrowFSeqCallback(int, DBloodActor* actor) { XSPRITE* pXSprite = &actor->x(); spritetype* pSprite = &actor->s(); - actFireThing(&actor->s(), 0, 0, actor->dudeSlope-7500, kThingBone, 0xeeeee); + actFireThing_(&actor->s(), 0, 0, actor->dudeSlope-7500, kThingBone, 0xeeeee); } void BlastSSeqCallback(int, DBloodActor* actor) @@ -202,7 +202,7 @@ void BlastSSeqCallback(int, DBloodActor* actor) void ThrowSSeqCallback(int, DBloodActor* actor) { spritetype* pSprite = &actor->s(); - actFireThing(pSprite, 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) diff --git a/source/games/blood/src/aighost.cpp b/source/games/blood/src/aighost.cpp index d820cda3f..5b753d4eb 100644 --- a/source/games/blood/src/aighost.cpp +++ b/source/games/blood/src/aighost.cpp @@ -85,7 +85,7 @@ void ghostSlashSeqCallback(int, DBloodActor* actor) void ghostThrowSeqCallback(int, DBloodActor* actor) { - actFireThing(&actor->s(), 0, 0, actor->dudeSlope - 7500, kThingBone, 0xeeeee); + actFireThing_(&actor->s(), 0, 0, actor->dudeSlope - 7500, kThingBone, 0xeeeee); } void ghostBlastSeqCallback(int, DBloodActor* actor) diff --git a/source/games/blood/src/aipod.cpp b/source/games/blood/src/aipod.cpp index 731049870..4d8f1eb2a 100644 --- a/source/games/blood/src/aipod.cpp +++ b/source/games/blood/src/aipod.cpp @@ -97,7 +97,7 @@ void podAttack(int, DBloodActor* actor) sfxPlay3DSound(pSprite, 2474, -1, 0); else sfxPlay3DSound(pSprite, 2475, -1, 0); - pMissile = actFireThing(pSprite, 0, -8000, dz/128-14500, kThingPodGreenBall, (nDist2<<23)/120); + pMissile = actFireThing_(pSprite, 0, -8000, dz/128-14500, kThingPodGreenBall, (nDist2<<23)/120); } if (pMissile) seqSpawn(68, 3, pMissile->extra, -1); @@ -107,7 +107,7 @@ void podAttack(int, DBloodActor* actor) if (pDudeInfo->seeDist*0.1 < nDist) { sfxPlay3DSound(pSprite, 2454, -1, 0); - pMissile = actFireThing(pSprite, 0, -8000, dz/128-14500, kThingPodFireBall, (nDist2<<23)/120); + pMissile = actFireThing_(pSprite, 0, -8000, dz/128-14500, kThingPodFireBall, (nDist2<<23)/120); } if (pMissile) seqSpawn(22, 3, pMissile->extra, -1); diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index 9fb455f95..82dd2c16d 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -1740,7 +1740,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) { assert(thingType >= kThingBase && thingType < kThingMax); - return actFireThing(pPlayer->pSprite, a2, pPlayer->zWeapon-pPlayer->pSprite->z, pPlayer->slope+a3, thingType, a5); + return actFireThing_(pPlayer->pSprite, a2, pPlayer->zWeapon-pPlayer->pSprite->z, pPlayer->slope+a3, thingType, a5); } void playerFrag(PLAYER *pKiller, PLAYER *pVictim) diff --git a/source/games/blood/src/seq.cpp b/source/games/blood/src/seq.cpp index 7024d25ea..d85795527 100644 --- a/source/games/blood/src/seq.cpp +++ b/source/games/blood/src/seq.cpp @@ -586,6 +586,11 @@ void seqSpawn(int nSeqID, int type, int nXIndex, int callback) pInst->Update(); } +void seqSpawn(int a1, DBloodActor* actor, int a4) +{ + seqSpawn(a1, 3, actor->s().extra, a4); +} + //--------------------------------------------------------------------------- // // diff --git a/source/games/blood/src/seq.h b/source/games/blood/src/seq.h index 7e0baed6f..b1a6f49a1 100644 --- a/source/games/blood/src/seq.h +++ b/source/games/blood/src/seq.h @@ -100,6 +100,8 @@ void seqPrecacheId(int id, int palette); SEQINST* GetInstance(int a1, int a2); void UnlockInstance(SEQINST* pInst); void seqSpawn(int a1, int a2, int a3, int a4 = -1); +void seqSpawn(int a1, DBloodActor* actor, int a4 = -1); + void seqKill(int a1, int a2); void seqKillAll(void); int seqGetStatus(int a1, int a2);