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

解决战斗中我方和敌方释放技能,各个形象的渲染顺序不对的问题 #249

Conversation

liuzhier
Copy link
Contributor

@liuzhier liuzhier commented Jan 21, 2024

### 测试版本:
DOSBOX Ver 0.72.0.0 中运行仙剑 DOS 版

### 测试方法及结果:
将所有仙术的释放和 DOSBOX 下的 PAL.EXE 进行了比对,部分仙术进行了录屏逐帧对比,各种不同敌方组合的情况下仙术渲染全部正确。

### 源项目出现的问题:
在原始 PAL 中,不论是敌方还是我方,释放仙术的特效形象都是根据 Y 坐标计算出图层先后顺序,在根据这个图层高度决定每个对象的渲染顺序,并不是像 sdlpal 这样直接按照 4 3 2 1 0 对象索引顺序绘图,这导致了敌方和我方的图层顺序也全是错的。顺便也解决了 Issues #231 的问题。
程序测试结果可参考:https://www.bilibili.com/video/BV16K411a7y6/

### 该 PR 的解决方案:
将所有敌人的 Y 坐标和 Y 坐标偏移相加得到图层大小,再根据这组图层数据对敌人的渲染顺序进行排序。
将所有队员的Y坐标当作图层大小进行排序,并把有色调偏移(高光)的队员放在最后进行渲染(图层最高)。
将攻击型非召唤神仙术的 Y 坐标、Y 坐标偏移和图层偏移(其实 wSummonEffect 的另外一个意义就是图层偏移)相加。
渲染过程为两个函数,渲染比指定图层低的形象(一般用于渲染仙术特效之前),另一个是渲染比指定图层高的形象。
注意:这里的敌方和我方是分开渲染的,先渲染敌方,再渲染我方。

### 该 PR 的可能的潜在问题:
可能需要更多测试,会不会影响到其他部分,暂时不详

### 其他问题:
测试时还发现了其他问题,但应该很好解决,比如 sdlpal 召唤神的坐标与源 PAL.EXE 不同,我方封魔攻击队员时只会重复两遍举剑准备砍的动作帧,而 sdlpal 却重复了三次,我方被大义灭亲本该有受击帧,而 sdlpal 却没有。这些问题将会在以后的 PR 解决。

  • Have you checked to ensure there aren't other open Pull Requests for the same change?

  • Have you added an explanation of what your changes do and why you'd like us to include them?

  • How many dependencies was introduced in this PR? Did the minimal requirement changed, for which platform?

  • Have you written new tests for your changes?

  • Have you successfully run it with your changes locally?

  • Have you tested on following platforms?

    • Win32
    • UWP
    • Linux
    • Android
    • macOS
    • iOS
  • I certify that I have the right and agree to submit my contributions under the terms of GNU General Public License, version 3 (or any later version at the choice of the maintainers of the SDLPAL Project) as published by the Free Software Foundation.

@liuzhier liuzhier changed the title 解决战斗中我方和敌方释放技能渲染顺序不同的问题 解决战斗中我方和敌方释放技能,各个形象的渲染顺序不对的问题 Jan 21, 2024
@palxex
Copy link
Member

palxex commented Jan 21, 2024

感谢您的贡献。看起来不错,基本思路是在每次法术渲染前根据其层高(由本身的posy+yoffset再加上wSummonEffect)对敌我双方每个战斗形象分别分成高/低于其的两组先后渲染,用渲染次序来保证正确性。从视频看也更接近于原版的表现(特别是酒神)。
建议:wSummonEffect既然被发现有新的含义,应该改名,比如wSummonEffectOrMagicLayer(仅供建议)。
因为该pr涉及的面较广,先不急于合并,讨论区留做测试结果回报和原理讨论。

@liuzhier
Copy link
Contributor Author

liuzhier commented Jan 21, 2024

由于我方施展防守类仙术我没有急着跟攻击性仙术一并改掉,用的还是原来的按我方索引顺序渲染,故防守类仙术我方图层还是错的(细看我方第三次施法是给林月如时),这无疑是一个牵一发而动全身的解决方案,故整个战斗系统涉及到我方、敌方、仙术绘图的敌方全都要跟着优化掉,不然未修改的部分实现原理仍旧是错误的--

@palxex
Copy link
Member

palxex commented Jan 21, 2024

我觉得这个(防御法术的排序)也可以一起写进来,方便大家一起测试。
另外有一点疑虑希望解惑,目前排序原理中强制的敌先我后,会不会造成敌方越过某人攻击另一人时,三方渲染顺序错误?还是说目前敌我站位和敌方攻击偏移这两点综合起来考虑其实可以保证这种情况不会出现。

@liuzhier
Copy link
Contributor Author

liuzhier commented Jan 21, 2024

sdlpal援护部分与原生PAL不同。在原生DOS中援护人为虚弱者格挡伤害时,挡空后击中虚弱者后,虚弱者后移一段会直接回到原位,而sdlpal则是每次受击都会往后退,回合结束才会回到原位......若sdlpal的敌方攻击位移与原生PAL一致则不会有问题。因此,需要把敌方攻击位移的代码纠正得与原生PAL一致了才可以进行测试。

@javaClazz javaClazz force-pushed the pr_fixed_battle_show_the_offensive_magic_animation branch from 7f84b69 to 5adf023 Compare January 24, 2024 14:57
@liuzhier
Copy link
Contributor Author

liuzhier commented Jan 24, 2024

之前不小心 merge master 了,我求助了另一位大佬 @javaClazz 帮我回滚了一下记录。
刚才提交了该 pr 分支的更新,经过漫长的测试发现敌方、仙术、我方是混杂在一起排序并绘制的,并没有三者分开绘制。
本次更新修复了这一问题。我方使用防守类仙术的绘制也修复了。
顺便删除了主干中的错误逻辑:每次施法都会重新把上一个玩家绘制在最上面,来达到图层效果。

@palxex
Copy link
Member

palxex commented Jan 25, 2024

既然已经更改了主要原理和实现,请将所有提交合一方便review。

@liuzhier liuzhier force-pushed the pr_fixed_battle_show_the_offensive_magic_animation branch 3 times, most recently from b4ce463 to 9dfa82e Compare January 25, 2024 15:57
@weimzh
Copy link
Member

weimzh commented Jan 26, 2024

为什么我直接往master提交的内容会出现在这个里面。。。

@palxex
Copy link
Member

palxex commented Jan 26, 2024

大抵是我昨天请他rebase时的时机不太巧- -回头再处理吧

@liuzhier
Copy link
Contributor Author

liuzhier commented Jan 26, 2024

@weimzh emmm,大概是因为您的前几个关于Linux的提交我直接rebase到这个分支了.........主干那边的提交合并提交了,以至于这边出现了尴尬的情景......

@liuzhier liuzhier force-pushed the pr_fixed_battle_show_the_offensive_magic_animation branch 4 times, most recently from 530f3d0 to c749937 Compare January 26, 2024 14:20
@palxex
Copy link
Member

palxex commented Jan 26, 2024

现在原理我感觉应该是对的,代码感觉也问题不大。但我对游戏内实际观感不是很熟悉,已邀请@PalAlexx 进行随机覆盖测试。

@liuzhier liuzhier force-pushed the pr_fixed_battle_show_the_offensive_magic_animation branch from 59b6b6a to 813a6bd Compare January 26, 2024 15:10
… battlefield objects according to Y coordinates.

Reconstructed the drawing scheme for the magical sprites of attack type magic, giving it a layer concept. It is no longer directly covering the screen, but calculating the number of layers. And sort enemies, players, and magic based on layer level. I have compared the playback effects of all the magics sprites in PAL.EXE and there are basically no problems.
Error logic in the sdlpal:master was removed: When the player uses defensive magic, redraw the player to the left of the beneficiary, to match the game's original layer relationships.
@liuzhier liuzhier force-pushed the pr_fixed_battle_show_the_offensive_magic_animation branch from 813a6bd to d5f175c Compare January 26, 2024 15:17
@palxex palxex merged commit 08117ee into sdlpal:master Jan 27, 2024
2 checks passed
@palxex
Copy link
Member

palxex commented Jan 27, 2024

随机覆盖测试未发现问题。已合并

@liuzhier
Copy link
Contributor Author

好的,感谢 @palxex 耐心审核,感谢 @PalAlexx 测试~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants