Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better frame skipping Fix #691 #1024

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Client/MirObjects/Effect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public virtual void Process()

if (CMain.Time <= NextFrame) return;

if (Owner != null && Owner.SkipFrames) CurrentFrame++;
var skip = (Owner != null && Owner.SkipFrames);

if (++CurrentFrame >= Count)
{
Expand All @@ -89,11 +89,20 @@ public virtual void Process()
CurrentFrame = 0;
Start = CMain.Time + Delay;
NextFrame = Start + (Duration / Count) * (CurrentFrame + 1);

if (skip)
NextFrame = NextFrame / 2;
}
else
Remove();
}
else NextFrame = Start + (Duration / Count) * (CurrentFrame + 1);
else
{
NextFrame = Start + (Duration / Count) * (CurrentFrame + 1);

if (skip)
NextFrame = NextFrame / 2;
}

GameScene.Scene.MapControl.TextureValid = false;
}
Expand Down
123 changes: 57 additions & 66 deletions Client/MirObjects/MonsterObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,11 @@ public bool SetAction()
if (Frame == null) return false;

FrameInterval = Frame.Interval;

if (SkipFrames)
{
FrameInterval = FrameInterval / 2;
}
}
else
{
Expand Down Expand Up @@ -631,6 +636,11 @@ public bool SetAction()

FrameInterval = Frame.Interval;

if (SkipFrames)
{
FrameInterval = FrameInterval / 2;
}

Point front = Functions.PointMove(CurrentLocation, Direction, 1);

switch (CurrentAction)
Expand Down Expand Up @@ -1250,66 +1260,80 @@ private void ProcessFrames()
{
if (Frame == null) return;

if (!GameScene.CanMove && !SkipFrames)
{
switch (CurrentAction)
{
case MirAction.Walking:
case MirAction.Running:
case MirAction.Pushed:
return;
}
}

switch (CurrentAction)
{
case MirAction.Walking:
if (!GameScene.CanMove) return;

GameScene.Scene.MapControl.TextureValid = false;

if (SkipFrames) UpdateFrame();

if (UpdateFrame() >= Frame.Count)
{
FrameIndex = Frame.Count - 1;
SetAction();
}
else
if (CMain.Time >= NextMotion)
{
switch (FrameIndex)
if (UpdateFrame() >= Frame.Count)
{
case 1:
PlayWalkSound(true);
break;
case 4:
PlayWalkSound(false);
break;
FrameIndex = Frame.Count - 1;
SetAction();
}
else
{
switch (FrameIndex)
{
case 1:
PlayWalkSound(true);
break;
case 4:
PlayWalkSound(false);
break;
}

NextMotion += FrameInterval;
}
}
break;
case MirAction.Running:
if (!GameScene.CanMove) return;

GameScene.Scene.MapControl.TextureValid = false;

if (SkipFrames) UpdateFrame();

if (UpdateFrame() >= Frame.Count)
if (CMain.Time >= NextMotion)
{
FrameIndex = Frame.Count - 1;
SetAction();
if (UpdateFrame() >= Frame.Count)
{
FrameIndex = Frame.Count - 1;
SetAction();
}
else
NextMotion += FrameInterval;
}
break;
case MirAction.Pushed:
if (!GameScene.CanMove) return;

GameScene.Scene.MapControl.TextureValid = false;

FrameIndex -= 2;

if (FrameIndex < 0)
if (CMain.Time >= NextMotion)
{
FrameIndex = 0;
SetAction();
FrameIndex -= 2;

if (FrameIndex < 0)
{
FrameIndex = 0;
SetAction();
}
else
NextMotion += FrameInterval;
}
break;
case MirAction.Jump:
if (CMain.Time >= NextMotion)
{
GameScene.Scene.MapControl.TextureValid = false;

if (SkipFrames) UpdateFrame();

if (UpdateFrame() >= Frame.Count)
{
FrameIndex = Frame.Count - 1;
Expand All @@ -1326,8 +1350,6 @@ private void ProcessFrames()
{
GameScene.Scene.MapControl.TextureValid = false;

if (SkipFrames) UpdateFrame();

if (UpdateFrame() >= Frame.Count)
{
FrameIndex = Frame.Count - 1;
Expand Down Expand Up @@ -1357,8 +1379,6 @@ private void ProcessFrames()
{
GameScene.Scene.MapControl.TextureValid = false;

if (SkipFrames) UpdateFrame();

if (UpdateFrame() >= Frame.Count)
{
switch (BaseImage)
Expand Down Expand Up @@ -1417,8 +1437,6 @@ private void ProcessFrames()
{
GameScene.Scene.MapControl.TextureValid = false;

if (SkipFrames) UpdateFrame();

if (UpdateFrame() >= Frame.Count)
{
switch (BaseImage)
Expand Down Expand Up @@ -1469,8 +1487,6 @@ private void ProcessFrames()
{
GameScene.Scene.MapControl.TextureValid = false;

if (SkipFrames) UpdateFrame();

if (UpdateFrame() >= Frame.Count)
{
if (CurrentAction == MirAction.Standing)
Expand Down Expand Up @@ -1505,8 +1521,6 @@ private void ProcessFrames()

Point front = Functions.PointMove(CurrentLocation, Direction, 1);

if (SkipFrames) UpdateFrame();

if (UpdateFrame() >= Frame.Count)
{
FrameIndex = Frame.Count - 1;
Expand Down Expand Up @@ -1819,8 +1833,6 @@ private void ProcessFrames()
{
GameScene.Scene.MapControl.TextureValid = false;

if (SkipFrames) UpdateFrame();

if (UpdateFrame() >= Frame.Count)
{
FrameIndex = Frame.Count - 1;
Expand All @@ -1837,8 +1849,6 @@ private void ProcessFrames()
{
GameScene.Scene.MapControl.TextureValid = false;

if (SkipFrames) UpdateFrame();

Point front = Functions.PointMove(CurrentLocation, Direction, 1);

if (UpdateFrame() >= Frame.Count)
Expand Down Expand Up @@ -2125,8 +2135,6 @@ private void ProcessFrames()
{
GameScene.Scene.MapControl.TextureValid = false;

if (SkipFrames) UpdateFrame();

if (UpdateFrame() >= Frame.Count)
{
FrameIndex = Frame.Count - 1;
Expand Down Expand Up @@ -2276,11 +2284,8 @@ private void ProcessFrames()
{
GameScene.Scene.MapControl.TextureValid = false;

if (SkipFrames) UpdateFrame();

if (UpdateFrame() >= Frame.Count)
{

FrameIndex = Frame.Count - 1;
SetAction();
}
Expand Down Expand Up @@ -2341,8 +2346,6 @@ private void ProcessFrames()
{
GameScene.Scene.MapControl.TextureValid = false;

if (SkipFrames) UpdateFrame();

if (UpdateFrame() >= Frame.Count)
{
FrameIndex = Frame.Count - 1;
Expand Down Expand Up @@ -2373,8 +2376,6 @@ private void ProcessFrames()
{
GameScene.Scene.MapControl.TextureValid = false;

if (SkipFrames) UpdateFrame();

if (UpdateFrame() >= Frame.Count)
{
switch (BaseImage)
Expand Down Expand Up @@ -3356,8 +3357,6 @@ private void ProcessFrames()
{
GameScene.Scene.MapControl.TextureValid = false;

if (SkipFrames) UpdateFrame();

if (UpdateFrame() >= Frame.Count)
{
FrameIndex = Frame.Count - 1;
Expand Down Expand Up @@ -3588,8 +3587,6 @@ private void ProcessFrames()
{
GameScene.Scene.MapControl.TextureValid = false;

if (SkipFrames) UpdateFrame();

if (UpdateFrame() >= Frame.Count)
{
FrameIndex = Frame.Count - 1;
Expand Down Expand Up @@ -3624,8 +3621,6 @@ private void ProcessFrames()
{
GameScene.Scene.MapControl.TextureValid = false;

if (SkipFrames) UpdateFrame();

if (UpdateFrame() >= Frame.Count)
{
FrameIndex = Frame.Count - 1;
Expand All @@ -3643,8 +3638,6 @@ private void ProcessFrames()
{
GameScene.Scene.MapControl.TextureValid = false;

if (SkipFrames) UpdateFrame();

if (UpdateFrame() >= Frame.Count)
{
FrameIndex = Frame.Count - 1;
Expand Down Expand Up @@ -3743,8 +3736,6 @@ private void ProcessFrames()
{
GameScene.Scene.MapControl.TextureValid = false;

if (SkipFrames) UpdateFrame();

if (UpdateFrame() >= Frame.Count)
{
FrameIndex = Frame.Count - 1;
Expand Down
17 changes: 13 additions & 4 deletions Client/MirObjects/NPCObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public void LoadLibrary()
public override void Process()
{
bool update = CMain.Time >= NextMotion || GameScene.CanMove;
SkipFrames = ActionFeed.Count > 1;

ProcessFrames();

Expand Down Expand Up @@ -178,8 +179,6 @@ public virtual void ProcessFrames()
{
GameScene.Scene.MapControl.TextureValid = false;

if (SkipFrames) UpdateFrame();

if (UpdateFrame() >= Frame.Count)
{
FrameIndex = Frame.Count - 1;
Expand All @@ -196,8 +195,6 @@ public virtual void ProcessFrames()
{
GameScene.Scene.MapControl.TextureValid = false;

if (SkipFrames) UpdateFrame2();

if (UpdateFrame2() >= Frame.EffectCount)
EffectFrameIndex = Frame.EffectCount - 1;
else
Expand Down Expand Up @@ -261,6 +258,12 @@ public virtual void SetAction(bool randomStartFrame = false)

FrameInterval = Frame.Interval;
EffectFrameInterval = Frame.EffectInterval;

if (SkipFrames)
{
FrameInterval = FrameInterval / 2;
EffectFrameInterval = EffectFrameInterval / 2;
}
}
else
{
Expand All @@ -280,6 +283,12 @@ public virtual void SetAction(bool randomStartFrame = false)

FrameInterval = Frame.Interval;
EffectFrameInterval = Frame.EffectInterval;

if (SkipFrames)
{
FrameInterval = FrameInterval / 2;
EffectFrameInterval = EffectFrameInterval / 2;
}
}

NextMotion = CMain.Time + FrameInterval;
Expand Down
Loading