- movesprite family mostly done.

This commit is contained in:
Christoph Oelckers 2021-10-21 20:25:15 +02:00
parent 30541b09a4
commit 2b8893762c
4 changed files with 54 additions and 66 deletions

View file

@ -226,16 +226,8 @@ DExhumedActor* UpdateEnemy(DExhumedActor** ppEnemy)
return v == -1 ? nullptr : &exhumedActors[v];
}
int MoveCreature(short nSprite);
Collision MoveCreature(DExhumedActor* nSprite)
{
return Collision(MoveCreature(nSprite->GetSpriteIndex()));
}
int MoveCreatureWithCaution(int nSprite);
inline Collision MoveCreatureWithCaution(DExhumedActor* actor)
{
return Collision(MoveCreatureWithCaution(actor->GetSpriteIndex()));
}
Collision MoveCreature(DExhumedActor* nSprite);
Collision MoveCreatureWithCaution(DExhumedActor* actor);
void WheresMyMouth(int nPlayer, int *x, int *y, int *z, short *sectnum);
int GetSpriteHeight(int nSprite);
int GetActorHeight(DExhumedActor* nSprite);

View file

@ -37,11 +37,7 @@ enum
};
int movesprite(short spritenum, int dx, int dy, int dz, int ceildist, int flordist, unsigned int clipmask);
inline Collision movesprite(DExhumedActor* spritenum, int dx, int dy, int dz, int ceildist, int flordist, unsigned int clipmask)
{
return Collision(movesprite(spritenum->GetSpriteIndex(), dx, dy, dz, ceildist, flordist, clipmask));
}
Collision movesprite(DExhumedActor* spritenum, int dx, int dy, int dz, int ceildist, int flordist, unsigned int clipmask);
void precache();
void resettiming();

View file

@ -532,16 +532,16 @@ DExhumedActor* insertActor(int sect, int stat)
}
int movesprite(short nSprite, int dx, int dy, int dz, int, int flordist, unsigned int clipmask)
Collision movesprite(DExhumedActor* pActor, int dx, int dy, int dz, int ceildist, int flordist, unsigned int clipmask)
{
spritetype *pSprite = &sprite[nSprite];
spritetype *pSprite = &pActor->s();
bTouchFloor = false;
int x = pSprite->x;
int y = pSprite->y;
int z = pSprite->z;
int nSpriteHeight = GetSpriteHeight(nSprite);
int nSpriteHeight = GetActorHeight(pActor);
int nClipDist = (int8_t)pSprite->clipdist << 2;
@ -558,13 +558,13 @@ int movesprite(short nSprite, int dx, int dy, int dz, int, int flordist, unsigne
dy >>= 1;
}
nRet |= movespritez(nSprite, dz, nSpriteHeight, flordist, nClipDist);
nRet |= movespritez(pActor->GetSpriteIndex(), dz, nSpriteHeight, flordist, nClipDist);
nSector = pSprite->sectnum; // modified in movespritez so re-grab this variable
if (pSprite->statnum == 100)
{
short nPlayer = GetPlayerFromSprite(nSprite);
short nPlayer = GetPlayerFromActor(pActor);
int varA = 0;
int varB = 0;
@ -600,7 +600,7 @@ int movesprite(short nSprite, int dx, int dy, int dz, int, int flordist, unsigne
}
else
{
mychangespritesect(nSprite, nSector);
ChangeActorSect(pActor, nSector);
if (pSprite->pal < 5 && !pSprite->hitag)
{
@ -609,7 +609,7 @@ int movesprite(short nSprite, int dx, int dy, int dz, int, int flordist, unsigne
}
}
return nRet;
return Collision(nRet);
}
void Gravity(DExhumedActor* actor)
@ -659,21 +659,21 @@ void Gravity(DExhumedActor* actor)
}
}
int MoveCreature(short nSprite)
Collision MoveCreature(DExhumedActor* pActor)
{
auto pSprite = &sprite[nSprite];
return movesprite(nSprite, pSprite->xvel << 8, pSprite->yvel << 8, pSprite->zvel, 15360, -5120, CLIPMASK0);
auto pSprite = &pActor->s();
return movesprite(pActor, pSprite->xvel << 8, pSprite->yvel << 8, pSprite->zvel, 15360, -5120, CLIPMASK0);
}
int MoveCreatureWithCaution(int nSprite)
Collision MoveCreatureWithCaution(DExhumedActor* pActor)
{
auto pSprite = &sprite[nSprite];
auto pSprite = &pActor->s();
int x = pSprite->x;
int y = pSprite->y;
int z = pSprite->z;
short nSectorPre = pSprite->sectnum;
int ecx = MoveCreature(nSprite);
auto ecx = MoveCreature(pActor);
short nSector = pSprite->sectnum;
@ -690,12 +690,12 @@ int MoveCreatureWithCaution(int nSprite)
pSprite->y = y;
pSprite->z = z;
mychangespritesect(nSprite, nSectorPre);
ChangeActorSect(pActor, nSectorPre);
pSprite->ang = (pSprite->ang + 256) & kAngleMask;
pSprite->xvel = bcos(pSprite->ang, -2);
pSprite->yvel = bsin(pSprite->ang, -2);
return 0;
return Collision(0);
}
}
@ -1507,7 +1507,7 @@ void AICreatureChunk::Tick(RunListEvent* ev)
int nSector = pSprite->sectnum;
pSprite->pal = sector[nSector].ceilingpal;
int nVal = movesprite(nSprite, pSprite->xvel << 10, pSprite->yvel << 10, pSprite->zvel, 2560, -2560, CLIPMASK1);
auto nVal = movesprite(pActor, pSprite->xvel << 10, pSprite->yvel << 10, pSprite->zvel, 2560, -2560, CLIPMASK1);
if (pSprite->z >= sector[nSector].floorz)
{
@ -1521,31 +1521,31 @@ void AICreatureChunk::Tick(RunListEvent* ev)
}
else
{
if (!nVal)
if (!nVal.type && !nVal.exbits)
return;
short nAngle;
if (nVal & 0x20000)
if (nVal.exbits & kHitAux2)
{
pSprite->cstat = 0x8000;
}
else
{
if ((nVal & 0x3C000) == 0x10000)
if (nVal.exbits & kHitAux1)
{
pSprite->xvel >>= 1;
pSprite->yvel >>= 1;
pSprite->zvel = -pSprite->zvel;
return;
}
else if ((nVal & 0x3C000) == 0xC000)
else if (nVal.type == kHitSprite)
{
nAngle = sprite[nVal & 0x3FFF].ang;
nAngle = nVal.actor->s().ang;
}
else if ((nVal & 0x3C000) == 0x8000)
else if (nVal.type == kHitWall)
{
nAngle = GetWallNormal(nVal & 0x3FFF);
nAngle = GetWallNormal(nVal.index);
}
else
{
@ -1566,7 +1566,7 @@ void AICreatureChunk::Tick(RunListEvent* ev)
runlist_FreeRun(pSprite->lotag - 1);
runlist_SubRunRec(pSprite->hitag);
changespritestat(nSprite, 0);
ChangeActorStat(pActor, 0);
pSprite->hitag = 0;
pSprite->lotag = 0;
}

View file

@ -897,12 +897,9 @@ void AIPlayer::Tick(RunListEvent* ev)
zVel = pPlayerSprite->zvel;
int nMove = 0; // TEMP
Collision nMove(0);
if (bSlipMode)
{
nMove = 0;
pPlayerSprite->x += (x >> 14);
pPlayerSprite->y += (y >> 14);
@ -913,20 +910,20 @@ void AIPlayer::Tick(RunListEvent* ev)
}
else
{
nMove = movesprite(nPlayerSprite, x, y, z, 5120, -5120, CLIPMASK0);
nMove = movesprite(pPlayerActor, x, y, z, 5120, -5120, CLIPMASK0);
short var_54 = pPlayerSprite->sectnum;
pushmove_old(&pPlayerSprite->x, &pPlayerSprite->y, &pPlayerSprite->z, &var_54, pPlayerSprite->clipdist << 2, 5120, -5120, CLIPMASK0);
if (var_54 != pPlayerSprite->sectnum) {
mychangespritesect(nPlayerSprite, var_54);
ChangeActorSect(pPlayerActor, var_54);
}
}
// loc_1A6E4
if (inside(pPlayerSprite->x, pPlayerSprite->y, pPlayerSprite->sectnum) != 1)
{
mychangespritesect(nPlayerSprite, spr_sectnum);
ChangeActorSect(pPlayerActor, spr_sectnum);
pPlayerSprite->x = spr_x;
pPlayerSprite->y = spr_y;
@ -982,7 +979,7 @@ void AIPlayer::Tick(RunListEvent* ev)
return;
}
if (nMove & 0x3C000)
if (nMove.type || nMove.exbits)
{
if (bTouchFloor)
{
@ -1025,24 +1022,26 @@ void AIPlayer::Tick(RunListEvent* ev)
}
}
if (((nMove & 0xC000) == 0x4000) || ((nMove & 0xC000) == 0x8000))
if (nMove.type == kHitSector || nMove.type == kHitWall)
{
int sectnum = 0;
int nNormal = 0;
if ((nMove & 0xC000) == 0x4000)
if (nMove.type == kHitSector)
{
sectnum = nMove & 0x3FFF;
sectnum = nMove.index;
// Hm... Normal calculation here was broken.
}
else if ((nMove & 0xC000) == 0x8000)
else if (nMove.type == kHitWall)
{
sectnum = wall[nMove & 0x3FFF].nextsector;
sectnum = wall[nMove.index].nextsector;
nNormal = GetWallNormal(nMove.index);
}
if (sectnum >= 0)
{
if ((sector[sectnum].hitag == 45) && bTouchFloor)
{
int nNormal = GetWallNormal(nMove & 0x3FFF);
int nDiff = AngleDiff(nNormal, (pPlayerSprite->ang + 1024) & kAngleMask);
if (nDiff < 0) {
@ -1074,10 +1073,10 @@ void AIPlayer::Tick(RunListEvent* ev)
pPlayerSprite->y = spr_y;
pPlayerSprite->z = spr_z;
mychangespritesect(nPlayerSprite, spr_sectnum);
ChangeActorSect(pPlayerActor, spr_sectnum);
}
movesprite(nPlayerSprite, xvel, yvel, z, 5120, -5120, CLIPMASK0);
movesprite(pPlayerActor, xvel, yvel, z, 5120, -5120, CLIPMASK0);
goto sectdone;
}
}
@ -1138,13 +1137,13 @@ sectdone:
{
if (nViewSect != pPlayerSprite->sectnum)
{
if ((nMove & 0xC000) == 0x8000)
if (nMove.type == kHitWall)
{
int var_C4 = pPlayerSprite->x;
int var_D4 = pPlayerSprite->y;
int var_C8 = pPlayerSprite->z;
mychangespritesect(nPlayerSprite, nViewSect);
ChangeActorSect(pPlayerActor, nViewSect);
pPlayerSprite->x = spr_x;
pPlayerSprite->y = spr_y;
@ -1153,9 +1152,10 @@ sectdone:
pPlayerSprite->z = var_FC;
if ((movesprite(nPlayerSprite, x, y, 0, 5120, 0, CLIPMASK0) & 0xC000) == 0x8000)
auto coll = movesprite(pPlayerActor, x, y, 0, 5120, 0, CLIPMASK0);
if (coll.type == kHitWall)
{
mychangespritesect(nPlayerSprite, pPlayerSprite->sectnum);
ChangeActorSect(pPlayerActor, pPlayerSprite->sectnum);
pPlayerSprite->x = var_C4;
pPlayerSprite->y = var_D4;
@ -1164,7 +1164,7 @@ sectdone:
else
{
pPlayerSprite->z = var_FC - 256;
D3PlayFX(StaticSound[kSound42], nPlayerSprite);
D3PlayFX(StaticSound[kSound42], pPlayerActor);
}
}
}
@ -1206,7 +1206,7 @@ sectdone:
{
if (PlayerList[nPlayer].nMaskAmount > 0)
{
D3PlayFX(StaticSound[kSound30], nPlayerSprite);
D3PlayFX(StaticSound[kSound30], pPlayerActor);
PlayerList[nPlayer].nAir = 100;
}
@ -1215,7 +1215,7 @@ sectdone:
PlayerList[nPlayer].nAir -= 25;
if (PlayerList[nPlayer].nAir > 0)
{
D3PlayFX(StaticSound[kSound25], nPlayerSprite);
D3PlayFX(StaticSound[kSound25], pPlayerActor);
}
else
{
@ -1230,11 +1230,11 @@ sectdone:
if (PlayerList[nPlayer].nHealth < 300)
{
D3PlayFX(StaticSound[kSound79], nPlayerSprite);
D3PlayFX(StaticSound[kSound79], pPlayerActor);
}
else
{
D3PlayFX(StaticSound[kSound19], nPlayerSprite);
D3PlayFX(StaticSound[kSound19], pPlayerActor);
}
}
}
@ -1261,7 +1261,7 @@ sectdone:
{
if (SectDepth[nTmpSectNum] && !SectSpeed[nTmpSectNum] && !SectDamage[nTmpSectNum])
{
D3PlayFX(StaticSound[kSound42], nPlayerSprite);
D3PlayFX(StaticSound[kSound42], pPlayerActor);
}
}
@ -1270,7 +1270,7 @@ sectdone:
{
if (PlayerList[nPlayer].nAir < 50)
{
D3PlayFX(StaticSound[kSound14], nPlayerSprite);
D3PlayFX(StaticSound[kSound14], pPlayerActor);
}
PlayerList[nPlayer].nBreathTimer = 1;