- BuildAnim

This commit is contained in:
Christoph Oelckers 2021-11-22 23:35:11 +01:00
parent 2394420f48
commit b191bca49e
13 changed files with 42 additions and 40 deletions

View file

@ -29,7 +29,7 @@ BEGIN_PS_NS
void InitAnims();
void DestroyAnim(DExhumedActor* nAnim);
DExhumedActor* BuildAnim(DExhumedActor* actor, int val, int val2, int x, int y, int z, int nSector, int nRepeat, int nFlag);
DExhumedActor* BuildAnim(DExhumedActor* actor, int val, int val2, int x, int y, int z, sectortype* pSector, int nRepeat, int nFlag);
void FuncAnim(int, int, int, int);
void BuildExplosion(DExhumedActor* actor);
@ -218,7 +218,7 @@ void Gravity(DExhumedActor* actor);
DExhumedActor* UpdateEnemy(DExhumedActor** ppEnemy);
Collision MoveCreature(DExhumedActor* nSprite);
Collision MoveCreatureWithCaution(DExhumedActor* actor);
void WheresMyMouth(int nPlayer, vec3_t* pos, int *sectnum);
void WheresMyMouth(int nPlayer, vec3_t* pos, sectortype** sectnum);
int GetActorHeight(DExhumedActor* nSprite);
DExhumedActor* insertActor(int, int);
inline DExhumedActor* insertActor(sectortype* s, int st)

View file

@ -62,10 +62,10 @@ void DestroyAnim(DExhumedActor* pActor)
}
}
DExhumedActor* BuildAnim(DExhumedActor* pActor, int val, int val2, int x, int y, int z, int nSector, int nRepeat, int nFlag)
DExhumedActor* BuildAnim(DExhumedActor* pActor, int val, int val2, int x, int y, int z, sectortype* pSector, int nRepeat, int nFlag)
{
if (pActor == nullptr) {
pActor = insertActor(nSector, 500);
pActor = insertActor(pSector, 500);
}
auto pSprite = &pActor->s();
@ -252,7 +252,7 @@ void BuildExplosion(DExhumedActor* pActor)
edx = 34;
}
BuildAnim(nullptr, edx, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, pSprite->xrepeat, 4);
BuildAnim(nullptr, edx, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sector(), pSprite->xrepeat, 4);
}
void BuildSplash(DExhumedActor* actor, sectortype* pSector)
@ -286,7 +286,7 @@ void BuildSplash(DExhumedActor* actor, sectortype* pSector)
nFlag = 0;
}
auto pActor = BuildAnim(nullptr, edx, 0, pSprite->x, pSprite->y, pSector->floorz, sectnum(pSector), nRepeat, nFlag);
auto pActor = BuildAnim(nullptr, edx, 0, pSprite->x, pSprite->y, pSector->floorz, pSector, nRepeat, nFlag);
if (!bIsLava)
{

View file

@ -35,14 +35,14 @@ void DestroyBubble(DExhumedActor* pActor)
DeleteActor(pActor);
}
DExhumedActor* BuildBubble(vec3_t pos, int nSector)
DExhumedActor* BuildBubble(vec3_t pos, sectortype* pSector)
{
int nSize = RandomSize(3);
if (nSize > 4) {
nSize -= 4;
}
auto pActor = insertActor(nSector, 402);
auto pActor = insertActor(pSector, 402);
auto pSprite = &pActor->s();
pSprite->pos = pos;
@ -100,7 +100,7 @@ void AIBubble::Tick(RunListEvent* ev)
auto pSectAbove = pSector->pAbove;
if (pSprite->hitag > -1 && pSectAbove != nullptr) {
BuildAnim(nullptr, 70, 0, pSprite->x, pSprite->y, pSectAbove->floorz, sectnum(pSectAbove), 64, 0);
BuildAnim(nullptr, 70, 0, pSprite->x, pSprite->y, pSectAbove->floorz, pSectAbove, 64, 0);
}
DestroyBubble(pActor);
@ -129,7 +129,7 @@ void DoBubbleMachines()
pActor->nCount = (RandomWord() % pActor->nFrame) + 30;
auto pSprite = &pActor->s();
BuildBubble(pSprite->pos, pSprite->sectnum);
BuildBubble(pSprite->pos, pSprite->sector());
}
}
}
@ -147,11 +147,11 @@ void BuildBubbleMachine(DExhumedActor* pActor)
void DoBubbles(int nPlayer)
{
vec3_t pos;
int nSector;
sectortype* pSector;
WheresMyMouth(nPlayer, &pos, &nSector);
WheresMyMouth(nPlayer, &pos, &pSector);
auto pActor = BuildBubble(pos, nSector);
auto pActor = BuildBubble(pos, pSector);
pActor->s().hitag = nPlayer;
}
END_PS_NS

View file

@ -157,7 +157,7 @@ void IgniteSprite(DExhumedActor* pActor)
pSprite->hitag += 2;
auto pAnimActor = BuildAnim(nullptr, 38, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, 40, 20);
auto pAnimActor = BuildAnim(nullptr, 38, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sector(), 40, 20);
if (pAnimActor)
{
@ -175,6 +175,7 @@ void IgniteSprite(DExhumedActor* pActor)
void BulletHitsSprite(Bullet *pBullet, DExhumedActor* pBulletActor, DExhumedActor* pHitActor, int x, int y, int z, int nSector)
{
assert(validSectorIndex(nSector));
auto pSector = &sector[nSector];
bulletInfo *pBulletInfo = &BulletInfo[pBullet->nType];
@ -196,7 +197,7 @@ void BulletHitsSprite(Bullet *pBullet, DExhumedActor* pBulletActor, DExhumedActo
}
if (!RandomSize(2)) {
BuildAnim(nullptr, pBulletInfo->field_C, 0, x, y, z, nSector, 40, pBulletInfo->nFlags);
BuildAnim(nullptr, pBulletInfo->field_C, 0, x, y, z, pSector, 40, pBulletInfo->nFlags);
}
return;
@ -266,7 +267,7 @@ void BulletHitsSprite(Bullet *pBullet, DExhumedActor* pBulletActor, DExhumedActo
if (nStat <= 90 || nStat >= 199)
{
BuildAnim(nullptr, pBulletInfo->field_C, 0, x, y, z, nSector, 40, pBulletInfo->nFlags);
BuildAnim(nullptr, pBulletInfo->field_C, 0, x, y, z, pSector, 40, pBulletInfo->nFlags);
return;
}
@ -278,13 +279,13 @@ void BulletHitsSprite(Bullet *pBullet, DExhumedActor* pBulletActor, DExhumedActo
case 102:
case kStatExplodeTrigger:
case kStatExplodeTarget:
BuildAnim(nullptr, 12, 0, x, y, z, nSector, 40, 0);
BuildAnim(nullptr, 12, 0, x, y, z, pSector, 40, 0);
break;
default:
BuildAnim(nullptr, 39, 0, x, y, z, nSector, 40, 0);
BuildAnim(nullptr, 39, 0, x, y, z, pSector, 40, 0);
if (pBullet->nType > 2)
{
BuildAnim(nullptr, pBulletInfo->field_C, 0, x, y, z, nSector, 40, pBulletInfo->nFlags);
BuildAnim(nullptr, pBulletInfo->field_C, 0, x, y, z, pSector, 40, pBulletInfo->nFlags);
}
break;
}
@ -502,9 +503,9 @@ HITSPRITE:
if (hitsect > -1) // NOTE: hitsect can be -1. this check wasn't in original code. TODO: demo compatiblity?
{
auto pHitSect = &sector[hitsect];
if (hitactor == nullptr && hitwall < 0)
{
auto pHitSect = &sector[hitsect];
if ((pHitSect->pBelow != nullptr && (pHitSect->pBelow->Flag & kSectUnderwater)) || pHitSect->Depth)
{
pSprite->x = x2;
@ -514,7 +515,7 @@ HITSPRITE:
}
else
{
BuildAnim(nullptr, pBulletInfo->field_C, 0, x2, y2, z2, hitsect, 40, pBulletInfo->nFlags);
BuildAnim(nullptr, pBulletInfo->field_C, 0, x2, y2, z2, pHitSect, 40, pBulletInfo->nFlags);
}
}
else
@ -532,7 +533,7 @@ HITSPRITE:
}
// draws bullet puff on walls when they're shot
BuildAnim(nullptr, pBulletInfo->field_C, 0, x2, y2, z2 + zOffset + -4096, hitsect, 40, pBulletInfo->nFlags);
BuildAnim(nullptr, pBulletInfo->field_C, 0, x2, y2, z2 + zOffset + -4096, pHitSect, 40, pBulletInfo->nFlags);
}
}
else
@ -832,7 +833,7 @@ void AIBullet::Tick(RunListEvent* ev)
if (nFlag & 0x80)
{
BuildAnim(nullptr, 45, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, pSprite->xrepeat, 0);
BuildAnim(nullptr, 45, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sector(), pSprite->xrepeat, 0);
}
BulletList[nBullet].nFrame++;

View file

@ -77,9 +77,9 @@ void BuildFishLimb(DExhumedActor* pActor, int anim)
pSprite2->hitag = runlist_AddRunRec(NewRun, pChunkActor, 0x200000);
}
void BuildBlood(int x, int y, int z, int nSector)
void BuildBlood(int x, int y, int z, sectortype* pSector)
{
BuildAnim(nullptr, kSeqFish, 36, x, y, z, nSector, 75, 128);
BuildAnim(nullptr, kSeqFish, 36, x, y, z, pSector, 75, 128);
}
void AIFishLimb::Tick(RunListEvent* ev)
@ -101,7 +101,7 @@ void AIFishLimb::Tick(RunListEvent* ev)
{
pActor->nFrame = 0;
if (RandomBit()) {
BuildBlood(pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum);
BuildBlood(pSprite->x, pSprite->y, pSprite->z, pSprite->sector());
}
}

View file

@ -201,7 +201,7 @@ void ExplodeGrenade(DExhumedActor* pActor)
runlist_RadialDamageEnemy(pActor, nDamage, BulletInfo[kWeaponGrenade].nRadius);
BuildAnim(nullptr, var_28, 0, pGrenadeSprite->x, pGrenadeSprite->y, pGrenadeSprite->z, pGrenadeSprite->sectnum, var_20, 4);
BuildAnim(nullptr, var_28, 0, pGrenadeSprite->x, pGrenadeSprite->y, pGrenadeSprite->z, pGrenadeSprite->sector(), var_20, 4);
AddFlash(pGrenadeSprite->sector(), pGrenadeSprite->x, pGrenadeSprite->y, pGrenadeSprite->z, 128);
DestroyGrenade(pActor);

View file

@ -718,6 +718,7 @@ loc_flag:
}
auto cRange = CheckCloseRange(nPlayer, &theX, &theY, &theZ, &nSectorB);
auto pSectorB = &sector[nSectorB];
if (cRange.type != kHitNone)
{
@ -753,7 +754,7 @@ loc_flag:
else if (pSprite2->statnum == 102)
{
// loc_27370:
BuildAnim(nullptr, 12, 0, theX, theY, theZ, nSectorB, 30, 0);
BuildAnim(nullptr, 12, 0, theX, theY, theZ, pSectorB, 30, 0);
}
else if (pSprite2->statnum == kStatExplodeTrigger) {
var_28 += 2;
@ -765,7 +766,7 @@ loc_flag:
else
{
// loc_27370:
BuildAnim(nullptr, 12, 0, theX, theY, theZ, nSectorB, 30, 0);
BuildAnim(nullptr, 12, 0, theX, theY, theZ, pSectorB, 30, 0);
}
}
}

View file

@ -119,7 +119,7 @@ void BuildItemAnim(DExhumedActor* pActor)
if (nItemAnimInfo[nItem].a >= 0)
{
auto pAnimActor = BuildAnim(pActor, 41, nItemAnimInfo[nItem].a, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, nItemAnimInfo[nItem].repeat, 20);
auto pAnimActor = BuildAnim(pActor, 41, nItemAnimInfo[nItem].a, pSprite->x, pSprite->y, pSprite->z, pSprite->sector(), nItemAnimInfo[nItem].repeat, 20);
if (nItem == 44) {
pAnimActor->s().cstat |= 2;
@ -340,7 +340,7 @@ void DropMagic(DExhumedActor* pActor)
pSprite->x,
pSprite->y,
pSprite->z,
pSprite->sectnum,
pSprite->sector(),
48,
4);
@ -403,7 +403,7 @@ void DoRegenerates()
if (pSprite->extra <= 0)
{
BuildAnim(nullptr, 38, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, 64, 4);
BuildAnim(nullptr, 38, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sector(), 64, 4);
D3PlayFX(StaticSound[kSoundTorchOn], pActor);
}
else {

View file

@ -643,7 +643,7 @@ Collision MoveCreatureWithCaution(DExhumedActor* pActor)
pSprite->y = y;
pSprite->z = z;
ChangeActorSect(pActor, sectnum(pSectorPre));
ChangeActorSect(pActor, pSectorPre);
pSprite->ang = (pSprite->ang + 256) & kAngleMask;
pSprite->xvel = bcos(pSprite->ang, -2);
@ -1251,14 +1251,14 @@ int GetWallNormal(walltype* pWall)
return (nAngle + 512) & kAngleMask;
}
void WheresMyMouth(int nPlayer, vec3_t* pos, int *sectnum)
void WheresMyMouth(int nPlayer, vec3_t* pos, sectortype **sectnum)
{
auto pActor = PlayerList[nPlayer].Actor();
auto pSprite = &pActor->s();
int height = GetActorHeight(pActor) >> 1;
*sectnum = pSprite->sectnum;
*sectnum = pSprite->sector();
*pos = pSprite->pos;
pos->z -= height;

View file

@ -1959,7 +1959,7 @@ void AIObject::Tick(RunListEvent* ev)
}
AddFlash(pSprite->sector(), pSprite->x, pSprite->y, pSprite->z, 128);
BuildAnim(nullptr, var_18, 0, pSprite->x, pSprite->y, pSprite->sector()->floorz, pSprite->sectnum, 240, 4);
BuildAnim(nullptr, var_18, 0, pSprite->x, pSprite->y, pSprite->sector()->floorz, pSprite->sector(), 240, 4);
// int edi = nSprite | 0x4000;

View file

@ -2540,7 +2540,7 @@ sectdone:
if (!RandomSize(5))
{
vec3_t pos;
int mouthSect;
sectortype* mouthSect;
WheresMyMouth(nPlayer, &pos, &mouthSect);
BuildAnim(nullptr, 71, 0, pos.x, pos.y, pPlayerSprite->z + 3840, mouthSect, 75, 128);

View file

@ -234,7 +234,7 @@ void DestroyEgg(int nEgg)
if (QueenEgg[nEgg].nAction != 4)
{
BuildAnim(nullptr, 34, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, pSprite->xrepeat, 4);
BuildAnim(nullptr, 34, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sector(), pSprite->xrepeat, 4);
}
else
{
@ -1476,7 +1476,7 @@ void AIQueen::Damage(RunListEvent* ev)
QueenList[nQueen].nHealth = 4000;
QueenList[nQueen].nAction = 7;
BuildAnim(nullptr, 36, 0, pSprite->x, pSprite->y, pSprite->z - 7680, pSprite->sectnum, pSprite->xrepeat, 4);
BuildAnim(nullptr, 36, 0, pSprite->x, pSprite->y, pSprite->z - 7680, pSprite->sector(), pSprite->xrepeat, 4);
break;
case 2:
QueenList[nQueen].nHealth = 4000;

View file

@ -108,7 +108,7 @@ void ExplodeSnakeSprite(DExhumedActor* pActor, int nPlayer)
pActor->pTarget = nOwner;
BuildAnim(nullptr, 23, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, 40, 4);
BuildAnim(nullptr, 23, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sector(), 40, 4);
AddFlash(pSprite->sector(), pSprite->x, pSprite->y, pSprite->z, 128);