ADL: Advance skipped Frames in SetNewAnimation and remove logic from PM_XYZ
This commit is contained in:
parent
2365b5f440
commit
b94e599f5e
4 changed files with 14 additions and 60 deletions
|
|
@ -64,7 +64,7 @@ void AnimationInfo::SetNewAnimation(byte *pData, int numberOfFrames, int delayLe
|
|||
|
||||
this->pData = pData;
|
||||
NumberOfFrames = numberOfFrames;
|
||||
CurrentFrame = 1;
|
||||
CurrentFrame = 1 + numSkippedFrames;
|
||||
DelayCounter = 0;
|
||||
DelayLen = delayLen;
|
||||
TicksSinceSequenceStarted = 0;
|
||||
|
|
|
|||
|
|
@ -2808,26 +2808,13 @@ bool PlrHitObj(int pnum, int mx, int my)
|
|||
|
||||
bool PM_DoAttack(int pnum)
|
||||
{
|
||||
int frame, dx, dy, m;
|
||||
int dx, dy, m;
|
||||
bool didhit = false;
|
||||
|
||||
if ((DWORD)pnum >= MAX_PLRS) {
|
||||
app_fatal("PM_DoAttack: illegal player %d", pnum);
|
||||
}
|
||||
|
||||
frame = plr[pnum].AnimInfo.CurrentFrame;
|
||||
if (plr[pnum]._pIFlags & ISPL_QUICKATTACK && frame == 1) {
|
||||
plr[pnum].AnimInfo.CurrentFrame++;
|
||||
}
|
||||
if (plr[pnum]._pIFlags & ISPL_FASTATTACK && (frame == 1 || frame == 3)) {
|
||||
plr[pnum].AnimInfo.CurrentFrame++;
|
||||
}
|
||||
if (plr[pnum]._pIFlags & ISPL_FASTERATTACK && (frame == 1 || frame == 3 || frame == 5)) {
|
||||
plr[pnum].AnimInfo.CurrentFrame++;
|
||||
}
|
||||
if (plr[pnum]._pIFlags & ISPL_FASTESTATTACK && (frame == 1 || frame == 4)) {
|
||||
plr[pnum].AnimInfo.CurrentFrame += 2;
|
||||
}
|
||||
if (plr[pnum].AnimInfo.CurrentFrame == plr[pnum]._pAFNum - 1) {
|
||||
PlaySfxLoc(PS_SWING, plr[pnum].position.tile.x, plr[pnum].position.tile.y);
|
||||
}
|
||||
|
|
@ -2919,22 +2906,12 @@ bool PM_DoAttack(int pnum)
|
|||
|
||||
bool PM_DoRangeAttack(int pnum)
|
||||
{
|
||||
int origFrame, mistype;
|
||||
int mistype;
|
||||
|
||||
if ((DWORD)pnum >= MAX_PLRS) {
|
||||
app_fatal("PM_DoRangeAttack: illegal player %d", pnum);
|
||||
}
|
||||
|
||||
if (!gbIsHellfire) {
|
||||
origFrame = plr[pnum].AnimInfo.CurrentFrame;
|
||||
if (plr[pnum]._pIFlags & ISPL_QUICKATTACK && origFrame == 1) {
|
||||
plr[pnum].AnimInfo.CurrentFrame++;
|
||||
}
|
||||
if (plr[pnum]._pIFlags & ISPL_FASTATTACK && (origFrame == 1 || origFrame == 3)) {
|
||||
plr[pnum].AnimInfo.CurrentFrame++;
|
||||
}
|
||||
}
|
||||
|
||||
int arrows = 0;
|
||||
if (plr[pnum].AnimInfo.CurrentFrame == plr[pnum]._pAFNum) {
|
||||
arrows = 1;
|
||||
|
|
@ -3041,10 +3018,6 @@ bool PM_DoBlock(int pnum)
|
|||
app_fatal("PM_DoBlock: illegal player %d", pnum);
|
||||
}
|
||||
|
||||
if (plr[pnum]._pIFlags & ISPL_FASTBLOCK && plr[pnum].AnimInfo.CurrentFrame != 1) {
|
||||
plr[pnum].AnimInfo.CurrentFrame = plr[pnum]._pBFrames;
|
||||
}
|
||||
|
||||
if (plr[pnum].AnimInfo.CurrentFrame >= plr[pnum]._pBFrames) {
|
||||
StartStand(pnum, plr[pnum]._pdir);
|
||||
ClearPlrPVars(pnum);
|
||||
|
|
@ -3148,23 +3121,10 @@ bool PM_DoSpell(int pnum)
|
|||
|
||||
bool PM_DoGotHit(int pnum)
|
||||
{
|
||||
int frame;
|
||||
|
||||
if ((DWORD)pnum >= MAX_PLRS) {
|
||||
app_fatal("PM_DoGotHit: illegal player %d", pnum);
|
||||
}
|
||||
|
||||
frame = plr[pnum].AnimInfo.CurrentFrame;
|
||||
if (plr[pnum]._pIFlags & ISPL_FASTRECOVER && frame == 3) {
|
||||
plr[pnum].AnimInfo.CurrentFrame++;
|
||||
}
|
||||
if (plr[pnum]._pIFlags & ISPL_FASTERRECOVER && (frame == 3 || frame == 5)) {
|
||||
plr[pnum].AnimInfo.CurrentFrame++;
|
||||
}
|
||||
if (plr[pnum]._pIFlags & ISPL_FASTESTRECOVER && (frame == 1 || frame == 3 || frame == 5)) {
|
||||
plr[pnum].AnimInfo.CurrentFrame++;
|
||||
}
|
||||
|
||||
if (plr[pnum].AnimInfo.CurrentFrame >= plr[pnum]._pHFrames) {
|
||||
StartStand(pnum, plr[pnum]._pdir);
|
||||
ClearPlrPVars(pnum);
|
||||
|
|
|
|||
|
|
@ -37,12 +37,10 @@ struct SetNewAnimationData : TestData {
|
|||
struct GameTickData : TestData {
|
||||
int _ExpectedAnimationFrame;
|
||||
int _ExpectedAnimationCnt;
|
||||
int _FramesToSkip;
|
||||
GameTickData(int expectedAnimationFrame, int expectedAnimationCnt, int framesToSkip = 0)
|
||||
GameTickData(int expectedAnimationFrame, int expectedAnimationCnt)
|
||||
{
|
||||
_ExpectedAnimationFrame = expectedAnimationFrame;
|
||||
_ExpectedAnimationCnt = expectedAnimationCnt;
|
||||
_FramesToSkip = framesToSkip;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -84,8 +82,6 @@ void RunAnimationTest(const std::vector<TestData *> &vecTestData)
|
|||
auto gameTickData = dynamic_cast<GameTickData *>(x);
|
||||
if (gameTickData != nullptr) {
|
||||
currentGameTick += 1;
|
||||
if (gameTickData->_FramesToSkip != 0)
|
||||
animInfo.CurrentFrame += gameTickData->_FramesToSkip;
|
||||
animInfo.ProcessAnimation();
|
||||
EXPECT_EQ(animInfo.CurrentFrame, gameTickData->_ExpectedAnimationFrame);
|
||||
EXPECT_EQ(animInfo.DelayCounter, gameTickData->_ExpectedAnimationCnt);
|
||||
|
|
@ -176,22 +172,22 @@ TEST(AnimationInfo, AttackSwordWarriorWithFastestAttack) // Skipped frames and P
|
|||
{
|
||||
new SetNewAnimationData(16, 0, AnimationDistributionFlags::ProcessAnimationPending, 2, 9),
|
||||
// ProcessAnimation directly after StartAttack (in same GameTick). So we don't see any rendering before.
|
||||
new GameTickData(2, 0),
|
||||
new GameTickData(4, 0),
|
||||
new RenderingData(0.0f, 1),
|
||||
new RenderingData(0.3f, 1),
|
||||
new RenderingData(0.6f, 1),
|
||||
new RenderingData(0.8f, 2),
|
||||
new GameTickData(3, 0),
|
||||
new GameTickData(5, 0),
|
||||
new RenderingData(0.0f, 2),
|
||||
new RenderingData(0.3f, 3),
|
||||
new RenderingData(0.6f, 3),
|
||||
new RenderingData(0.8f, 3),
|
||||
new GameTickData(4, 0),
|
||||
new GameTickData(6, 0),
|
||||
new RenderingData(0.0f, 4),
|
||||
new RenderingData(0.3f, 4),
|
||||
new RenderingData(0.6f, 5),
|
||||
new RenderingData(0.8f, 5),
|
||||
new GameTickData(7, 0, 2),
|
||||
new GameTickData(7, 0),
|
||||
new RenderingData(0.0f, 5),
|
||||
new RenderingData(0.3f, 6),
|
||||
new RenderingData(0.6f, 6),
|
||||
|
|
@ -371,17 +367,17 @@ TEST(AnimationInfo, BlockingSorcererWithFastBlock) // Skipped frames and ignored
|
|||
new RenderingData(0.3f, 1),
|
||||
new RenderingData(0.6f, 1),
|
||||
new RenderingData(0.8f, 2),
|
||||
new GameTickData(1, 1),
|
||||
new GameTickData(5, 1),
|
||||
new RenderingData(0.0f, 2),
|
||||
new RenderingData(0.3f, 2),
|
||||
new RenderingData(0.6f, 3),
|
||||
new RenderingData(0.8f, 3),
|
||||
new GameTickData(1, 2),
|
||||
new GameTickData(5, 2),
|
||||
new RenderingData(0.0f, 4),
|
||||
new RenderingData(0.3f, 4),
|
||||
new RenderingData(0.6f, 4),
|
||||
new RenderingData(0.8f, 5),
|
||||
new GameTickData(2, 0),
|
||||
new GameTickData(6, 0),
|
||||
new RenderingData(0.0f, 5),
|
||||
new RenderingData(0.3f, 5),
|
||||
new RenderingData(0.6f, 6),
|
||||
|
|
@ -399,12 +395,12 @@ TEST(AnimationInfo, HitRecoverySorcererZenMode) // Skipped frames and ignored de
|
|||
new RenderingData(0.3f, 1),
|
||||
new RenderingData(0.6f, 2),
|
||||
new RenderingData(0.8f, 2),
|
||||
new GameTickData(3, 0, 1),
|
||||
new GameTickData(6, 0),
|
||||
new RenderingData(0.0f, 3),
|
||||
new RenderingData(0.3f, 3),
|
||||
new RenderingData(0.6f, 4),
|
||||
new RenderingData(0.8f, 4),
|
||||
new GameTickData(7, 0, 3),
|
||||
new GameTickData(7, 0),
|
||||
new RenderingData(0.0f, 5),
|
||||
new RenderingData(0.3f, 5),
|
||||
new RenderingData(0.6f, 6),
|
||||
|
|
|
|||
|
|
@ -11,12 +11,10 @@ extern bool PM_DoGotHit(int pnum);
|
|||
int RunBlockTest(int frames, int flags)
|
||||
{
|
||||
int pnum = 0;
|
||||
plr[pnum].AnimInfo.CurrentFrame = 1;
|
||||
plr[pnum]._pHFrames = frames;
|
||||
plr[pnum].actionFrame = 1;
|
||||
plr[pnum]._pIFlags = flags;
|
||||
plr[pnum]._pmode = PM_GOTHIT;
|
||||
plr[pnum]._pGFXLoad = -1;
|
||||
StartPlrHit(pnum, 5, direction::DIR_S);
|
||||
|
||||
int i = 1;
|
||||
for (; i < 100; i++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue