Fixed frame overflow in DaggerfallMobileUnit. #2571
Merged
KABoissonneault merged 2 commits intoInterkarma:masterfrom Feb 7, 2024
Merged
Fixed frame overflow in DaggerfallMobileUnit. #2571KABoissonneault merged 2 commits intoInterkarma:masterfrom
KABoissonneault merged 2 commits intoInterkarma:masterfrom
Conversation
…ebug mobile errors
Collaborator
|
It's hard to talk about a "best solution" without knowing the original intent (and checking what's going on in Daggerfall classic will probably be difficult), but at least for the record, since both 4 and 8 frame cycles picture a single walking cycle (left foot forward, right foot forward), another solution would be to apply cross-multiplication when orientation changes |
KABoissonneault
added a commit
to KABoissonneault/WIP-villainvariety
that referenced
this pull request
Feb 3, 2024
Interkarma
reviewed
Feb 6, 2024
| // If you change orientation from a back diagonal during frame 4, 5, 6, or 7, you overflow the other anims, where only 0 to 3 are valid | ||
| if (lastOrientation >= 0) | ||
| { | ||
| currentFrame = currentFrame * summary.StateAnims[orientation].NumFrames / summary.StateAnims[lastOrientation].NumFrames; |
Owner
There was a problem hiding this comment.
This is really clever, I like this
Interkarma
approved these changes
Feb 6, 2024
numidium
approved these changes
Feb 7, 2024
This was referenced Feb 7, 2024
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes for #2569.
I found an issue where archive 288 has 4 frames for record 0, 1, 2, and 4, but 8 frames for record 3. Record 3 is the "back diagonal" sprites (both left and right). Normally, all mobile archives have the same number of frames on each orientation, but the Ancient Lich is an exception. When changing orientation, the
currentFrameis preserved so that the animation keeps playing from where it was. However, for the Ancient Lich, if you change orientation from the back diagonal while on frame 4, 5, 6, or 7 is playing, thecurrentFramewill now be past the allowed frames for the new orientation (back or side). On unmodded DFU, this reaches into a "Casting spell" frame insummary.AtlasRect(becauserectIndexhas enough room to overflow into the next records, rather than go out of bounds of the AtlasRect). When using texture replacements from mods (ex: Vanilla Enhanced), you get the exception shown in #2569 (because we don't use the atlas anymore).The fix is on line 371 - I simply reset
currentFrameto 0 if the frame is not valid for the new orientation. A bit jarring, but better than the current behavior.The rest of the changes are more bounds checking and error logs for these issues. I find DaggerfallMobileUnit has lots of moving parts and lots of arrays to go out of bounds, so it helps to have better logs there.
The output looks like this:
Hopefully this will help diagnose future issues with mobiles, if any remain. In any case, with mods like Daggerfall Enemy Expansion, it's easy to accidentally create invalid MobileEnemy data that creates random errors in DaggerfallMobileUnit, and this will help mod development.