Repository navigation
fix(基础库): 修复缘起版本多管血目标气血百分比显示错误 - #118
Merged
Merged
Conversation
GetCharacterLife 原先只在重制版走 fCurrentLife64 / fMaxLife64,缘起分支退回单管 nMaxLife。而多管血(nMaxLifeCount)与版本无关:KNpc::getMaxLife64 返回的是 (nMaxLifeCount + 1) * nMaxLife,气血上限被拆成多管的 NPC 在缘起会用单管值当 总量,百分比被放大 (nMaxLifeCount + 1) 倍。 64 位字段在 KLuaNpc / KLuaPlayer 上均无条件注册,客户端收包时也按同一口径 维护当前值,因此直接统一取 fCurrentLife64 / fMaxLife64,不再区分版本,也不再 自行拼接管数。
ZhaoQisi
force-pushed
the
fix/classic-multi-life-bar
branch
from
October 21, 2026 03:53
0d4b87d to
dfd8df0
Compare
yefansky
approved these changes
Oct 21, 2026
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.
问题现象
缘起服中,气血上限被拆成多管血的 NPC,茗伊插件显示的气血百分比被放大了整数倍。
以柳哲为例(同一时刻截图):
Target.lua2748.75万 / 7456.71万 (36.9%)2748.7万 (73%)当前气血的绝对值两边完全一致,只有百分比对不上,且 73 / 36.9 ≈ 2。这说明问题不在当前血量,而在最大气血取错了字段。
根因
KNpc::getMaxLife64()返回的是展开后的总血池:而
X.GetCharacterLife原先只在重制版走fMaxLife64,缘起分支退回单管nMaxLife:多管血(
nMaxLifeCount)是独立机制,与游戏版本无关。原代码把它误当成重制版专属特性,导致缘起服在nMaxLifeCount > 0时用单管值当总量,百分比被放大(nMaxLifeCount + 1)倍。并且 64 位字段在所有版本都已注册,不存在取不到的问题:
KLuaNpc.cpp:2253-2254:REGISTER_LUA_DOUBLE(KNpc, CurrentLife64)/MaxLife64,无条件注册KLuaPlayer.cpp:42544-42545:同上(count + 1)展开:KPlayerClient.cpp:13161-13177、16439-16456修改内容
去掉版本分支,统一取总血池字段。管数与 int32 溢出由引擎侧统一处理,插件不再自行拼接,避免同一语义在两处各算一遍。
影响面:
MY_Focus(焦点列表)、MY_LifeBar(头顶血条)、MY_ThreatRank、MY_TeamMon、MY_CombatText都经X.GetCharacterLife取气血,一处修改全部生效。CHANGELOG.md增加了一条*(classic)*记录。验证
静态与逻辑验证均已通过:
!src-dist/bin/lua-5.1语法检查通过nil安全尚未在游戏内真机验证,需要一台缘起客户端实测确认。
备注
nMaxLifeCount > 0时展开,但那样会与引擎已有的getMaxLife64口径重复实现,不推荐。