You are viewing a potentially older version of this package. View all versions.
ChineseCanFly-PerfectBlock-0.3.4 icon

PerfectBlock

学习每只怪物的攻击节奏,在命中前自动按下格挡触发原版完美格挡;不改伤害结算与格挡判定,挥刀时不会抢你的攻击。

Date uploaded 5 days ago
Version 0.3.4
Download link ChineseCanFly-PerfectBlock-0.3.4.zip
Downloads 22
Dependency string ChineseCanFly-PerfectBlock-0.3.4

README

Perfect Block — up to a 90% perfect-block rate

A block assist mod: it watches each enemy's attack, learns the exact moment the hit lands, and presses block for you just before it. Nothing in the damage pipeline is modified — the mod feeds the same block key and lets the game run its own perfect-block rule.

Measured 90.3% perfect blocks across 145 resolved hits (131 perfect / 10 ordinary / 4 missed, default settings); 91% with 0 misses in hold mode (the game's "Toggle Block" accessibility option turned off).

This mod has to learn before it can perfect-block. Each attack of each creature needs its own samples (5 by default, landing-point spread ≤ 5%) before the mod starts pressing for you. A creature you never fought will not be blocked — watching the wind-up is part of the deal.

Best feel: turn OFF the game's "Toggle Block" accessibility option and use hold-to-block. Measured: 0 misses in hold mode, vs ~4% in toggle mode (the toggle path flips on key edges and can turn the raised shield back off).

Perfect block

Multiple enemies

Combat text UI

Why it deliberately does not block while you are swinging

This is a self-imposed handicap, not an unfinished feature. An assist should not eat the player's attacks or every fight would play itself. Cancel Swing On Manual Block therefore only reacts to a block you press; the automatic press never interrupts your swing.

What it does

  • Learns (prefab, animation state) → animation progress at the moment damage fires, stored in BepInEx/config/PerfectBlock/learned.json
  • Presses block Lead Ms (70) before the learned landing point and keeps it down for Press Tail Ms (150) after it
  • Works with both block modes; hold mode is the recommended one
  • Optional: manual-block swing cancel, Reliable perfect block (no guard break on a perfect), on-screen PERFECT BLOCK !!!
  • Floating combat numbers: weapon icon 78 (Pierce), red for damage taken (left), yellow for damage dealt (right); position / size / font adjustable

Measured (2026-11-03, v0.3.x, defaults)

Block mode Resolved Perfect Ordinary Missed Perfect rate
Hold (Toggle Block off) 45 41 4 0 91%
Toggle (Toggle Block on) 100 90 6 4 90%
Total 145 131 10 4 90.3%

Install

Requires BepInEx 5.4.x. Drop ChineseCanFly.PerfectBlock.dll and both PerfectBlock.*.yml into BepInEx/plugins/ChineseCanFly-PerfectBlock/, start the game once, then edit BepInEx/config/ChineseCanFly.PerfectBlock.cfg (or use Configuration Manager).

Limitations

  • Learning is per prefab + animation state, so a new creature or a new attack starts at zero samples.
  • No auto block while you are swinging (by design).
  • Toggle-block mode misses ~4% of hits; hold mode does not.
  • Landing points come from animation progress, so lag or knockback can shift them; a late press is an ordinary block, never a free hit.

Config

[General]

Key Default Meaning
Enable Auto Block true Master switch. When off the mod only learns and logs
Detect Range 5 Only watch enemies within this many metres
Log Learning true One log line per recorded landing point
Log Attempts true One log line per simulated press (tuning)
Force Block Test false Diagnostic: hold the block key every frame

[Learning]

Key Default Meaning
Lead Ms 70 Press this many ms before the learned landing point. Fixed, no adaptation
Press Tail Ms 150 Keep pressing this long after the landing point
Min Samples 5 Samples needed before an attack counts as learned
Max Spread 0.05 Max spread of the landing points; wider = ignored

[Feedback]

Key Default Meaning
Reliable Perfect Block true Ignore the guard-break rule on a perfect block
Cancel Swing On Manual Block true Blocking mid-swing cancels the swing (manual presses only)
Release Block On Attack true Drop the forced block the moment you attack
Hold After Perfect (ms) 500 Must be 500. Upgraders: change it by hand, 0 makes blocking fail
After Perfect Block Release Release = let go after the hold; Keep = hold until you attack or tap block
Show Perfect Flash true PERFECT BLOCK !!! in the middle of the screen

[Combat]

Key Default Meaning
Show Combat Text true Draw our own damage numbers
Show Vanilla Numbers true Keep the game's floating numbers
Font Impact Number font (same as the PERFECT BLOCK flash)
Label Font Microsoft YaHei Font for the bracketed damage type, must carry Chinese glyphs
Base Font Size 27 Normal number size
Big Hit Scale 2.4 Size multiplier for heavy / finisher hits
Show Weapon Icon true Draw the weapon icon in front of each number
Taken / Dealt Position X/Y 0.2/0.6, 0.7/0.6 Screen-ratio anchors
Test Combat Text false Diagnostic: always draw three sample numbers

完美格挡(成功率高达 90%)

一个辅助模组:观察每只怪物的攻击动作,学出它真正命中的那一刻,然后在命中前替你按下格挡。不修改伤害结算,也不改写格挡判定——按下去的是同一个「格挡键」,剩下的交给游戏自己判。

实测完美格挡率 90.3%(145 次结算:完美 131 / 普通 10 / 漏挡 4,默认参数,训练假人 + 哥布林);其中关闭「切换格挡」的长按模式 91%、0 漏挡。

先说明一点:这个模组对抗打击的完美格挡是需要学习的,并不是一上来就能完美格挡。 每只怪物的每套攻击动作都要单独攒样本(默认 5 次、命中点离散度 ≤ 5%),凑够了才会开始替你按。没打过的怪,它不会挡——先看清招式,是这个模组的一部分。

最佳手感:关闭游戏「辅助功能」里的「切换格挡」,用长按模式。 实测长按模式 0 漏挡,切换模式因为靠按键边沿翻转,约 4% 的几率会把盾关掉(见下面的实测数据)。

设计意图

  • 不做代打。 目标是「提升格挡效率」,不是「替你打赢」。完美与否由原版 Humanoid.BlockAttack 的 0.25 秒规则判定,我们没有把这个窗口改长,也没有让伤害凭空消失。
  • 让学习成为进度。 每种怪、每套招式单独学:命中动画进度、样本数、离散度。样本够了才开始替你挡。
  • 帮玩家建立节奏感。 提前量固定 70ms、按压尾巴固定 150ms,刻意不做自适应:你能从屏幕和日志里看出自己该在哪一刻抬手。

为什么挥刀时故意不自动格挡

这是刻意留下的缺口,不是没做完:

  1. 不抢玩家的主动权。 玩家的攻击是玩家的事;每一刀都被系统接管,人就只是站在旁边看血条。
  2. 辅助的意义在于「时机」,不在于「覆盖」。 如果连挥刀途中都能自动打断你去完美格挡,它就不再是学习节奏的辅助,而是一个无敌开关。
  3. 所以 Cancel Swing On Manual Block 只作用于你手动按下的格挡。 自动格挡永远不会取消你的挥击,也永远不会在你挥刀时抢按键。

功能

功能 说明
学习 hook 非玩家实体的 OnAttackTrigger,记录 (预制体, 动画状态) → 命中瞬间的动画进度,存 BepInEx/config/PerfectBlock/learned.json
自动格挡 命中点前 Lead Ms 按下、命中后按满 Press Tail Ms,敌人中途被打断也会按完尾巴
两种格挡模式 自动识别游戏的「切换格挡」设置;长按模式效果最佳
手动格挡取消挥刀 挥刀途中按格挡 → 立即断招起盾(等价 AttackCancel)
Reliable Perfect Block 只在完美格挡那一下忽略「大伤害破防」规则
完美提示 屏幕中央 PERFECT BLOCK !!!,连续触发向上叠加
战斗数字 武器图标 78 (刺击),承伤红色在左、输出黄色在右;位置/字号/字体可调

实测数据

2026-11-03,v0.3.x,默认参数(Lead 70 / Tail 150),对象:训练假人 + 哥布林(Goblin / Goblin Shaman / Goblin Brute Bros)。

格挡模式 结算次数 完美 普通格挡 漏挡 完美率
长按(关闭「切换格挡」) 45 41 4 0 91%
切换(开启「切换格挡」) 100 90 6 4 90%
合计 145 131 10 4 90.3%
  • 4 次漏挡全部出现在切换模式,且命中时 blockTimer = -1(盾根本没举起来):切换模式靠「按键边沿」翻转,极端时序下会把已经开着的盾再关一次。所以推荐关闭「切换格挡」。
  • 长按模式那 4 次普通格挡里有 3 次的 blockTimer 在 0.02–0.04s(完美窗口内),说明不是按早了,是当时手里的东西没有招架加成(游戏自己就不给完美)。

安装

  1. 先装好 BepInEx 5.4.x(Valheim 1.0.x 用 5.4.2360 即可)。
  2. 把压缩包里的 ChineseCanFly.PerfectBlock.dll 和两个 PerfectBlock.*.yml 放进 BepInEx/plugins/ChineseCanFly-PerfectBlock/。
  3. 启动游戏,配置在 BepInEx/config/ChineseCanFly.PerfectBlock.cfg,也可以装 Configuration Manager 在游戏里调。

配置

[General]

键 默认 说明
Enable Auto Block true 总开关。关掉时只学习、只写日志
Detect Range 5 只观察这个距离(米)内的敌人
Log Learning true 每次学到命中点写一行日志
Log Attempts true 每次模拟按压写一行日志,调参用
Force Block Test false 诊断:每帧强制按住格挡键

[Learning]

键 默认 说明
Lead Ms 70 命中前多少毫秒按下。固定值,不做自适应
Press Tail Ms 150 命中后继续按多久,兜预测误差
Min Samples 5 同一动作要几次样本才算学会
Max Spread 0.05 命中点离散度上限,太散的动作不采用

[Feedback]

键 默认 说明
Reliable Perfect Block true 完美格挡无视破防规则
Cancel Swing On Manual Block true 手动格挡取消挥刀(自动格挡永不触发这条)
Release Block On Attack true 完美后你一攻击就立刻松盾
Hold After Perfect (ms) 500 完美命中后额外按住多久。必须是 500;从旧版本升级的玩家请手动改(旧 cfg 里可能是 0,会导致挡不住)
After Perfect Block Release Release = 按住上面那段时间就松;Keep = 一直挡到你攻击或再按格挡
Show Perfect Flash true 屏幕中央 PERFECT BLOCK

[Combat]

键 默认 说明
Show Combat Text true 显示我们自己的伤害数字
Show Vanilla Numbers true 保留游戏自带浮动数字(会和我们的重叠)
Font Impact 数字字体(与 PERFECT BLOCK 同一套)
Label Font Microsoft YaHei 括号里伤害类型的字体,必须有中文字形
Base Font Size 27 普通数字字号
Big Hit Scale 2.4 重击/连段末击的放大倍数
Show Weapon Icon true 数字前画武器图标(承伤用攻击者的武器)
Taken / Dealt Position X/Y 0.2/0.6、0.7/0.6 屏幕比例锚点,0~1
Test Combat Text false 诊断:常显三个示例数字,用来定位并确认渲染

已知限制

  • 学习按「预制体 + 动画状态」区分:同一只怪的不同招式分别计数,所以会看到 samples 慢慢涨到 learned。
  • 挥刀途中不会自动格挡(见「设计意图」)。
  • 切换格挡模式偶发漏挡(约 4%),长按模式没有这个问题。
  • 命中点由动画进度推算,网络延迟或怪物被击退时可能偏;偏晚的代价是普通格挡,不会白挨。

日志怎么看

搜索 Perfect Block:

  • attempt: … press at 57 ms before the learned hit — 这次按压的起点
  • [diag] perfect block #N / ordinary block (blockTimer …) / hit landed while NOT blocking … blockTimer=… — 三种结果
  • [stat] N blocks: perfect=… ordinary=… late=… — 每 10 次结算一行,完美率直接看这行

有问题或建议:https://github.com/tutu8420/PerfectBlock/issues


CHANGELOG

版本记录

1.6.8

代码审计后的一次集中清理,默认值全部改为作者实测配置(Font/Label Font = Norsebold、Base Font Size = 30、Animation Style = Static、Detect Range = 10、Flash 6 / 0.216 / 2s、Temp Buff 0.624 / 0.4、Buff Scale 1.5、Buff Max Rows 1、English Labels = true)。

  • 修复 Line Spacing 完全无效:行距变量算了没用,现在真正作用于叠放行距
  • Static2 不再是 Static 的复制品,改成真正的「固定向下」
  • Sprinkler 的角度扇只剩 2 个角度(公式恒为 0):改用 Max Lines 决定扇面切片
  • Sprinkler 不再被左右翻转二次镜像
  • Toggle 模式下不再每帧强制 m_blocking,与「只发边沿」的设计一致
  • 手动完美格挡也会弹 PERFECT BLOCK 闪字(统计与后摇仍只针对自动格挡)
  • 格挡数值只记录玩家/宠物那一侧,避免被怪物格挡的数字串台
  • 普通格挡的日志不再谎称「按早了」,改报 blockTimer 与格挡武器
  • 配置节顺序整理为 General / Feedback / Buff Panel / Combat / Learning,cfg 不再出现重复节标题
  • 补上缺失的 yml 键 PatchBlocked、PatchObjects;删掉废弃的 PatchVanilla、CancelAttack
  • 删除死代码 ReportShowTextDamage 及其专用字段;learned.json 版本号改为真实版本
  • 术语与描述修正:Scroll Size(像素)、Max Lines(仅 Static)、Show Vanilla Numbers(挖矿也归我们管)、Show Block Text(当前格式)
  • 反击窗口改用独立样式,不再和 BUFF 面板共用同一个 GUIStyle
  • 字体查找改为可重扫 + 字形缓存;SeenEffects 加上上限

1.6.6

  • 修复战斗数字完全不显示:PatchVanillaDamageText 在 1.6.2 删补丁时连注册一起删了,导致 Show Vanilla Numbers 控制的是个不存在的开关,我们的数字也从未被创建
  • 修复数值捕捉时机:原版在这版是在 Character.ApplyDamage 内部就调 DamageText.ShowText,而我们在 postfix 才记 pending,永远晚一步。改为在 ApplyDamage 前缀记录,ShowText 前缀消费
  • Test All UI 只在进入世界后生效,主菜单不再刷测试文字
  • 启动日志改为显示真实版本号(之前硬编码 0.3.3)
  • 新增诊断日志:damage text / blocked number / block text(受 Log Attempts 控制)

1.6.5

  • 伤害类型标签改用游戏自己的词条($inventory_*),和武器面板逐字一致,并跟随游戏语言:劈砍 / 戳刺 / 锤击 / 切剁 / 镐 / 火焰 / 冰霜 / 闪电 / 蛊毒 / 精神
  • 修正之前自编的词:Slash 是「劈砍」不是 Chop,Pierce 是「戳刺」,Poison 是「蛊毒」
  • 括号改全角并加空格:+12 (劈砍),与格挡行 + 格挡 (0.5) 同一套写法
  • 主伤害类型判定补上镐(Pickaxe)

1.6.4

  • 挖矿/砍树/砸建筑也使用我们的文字与动画:[图标] +12 (劈砍)
  • 标签取该击的主伤害类型,不拆分多类型伤害
  • 只接管玩家自己的伤害,环境伤害保留原版

1.6.3

  • 格挡提示并入受伤区:+ 格挡 (0.5),数值取自游戏自己的格挡数字
  • 完美格挡按暴击处理:更大字号 + Punch 动画
  • 删除独立的格挡/招架位置开关

1.6.2

  • Show Vanilla Numbers 移到 [General]
  • 修正隐藏逻辑:只隐藏被我们替换的那条伤害数字,治疗/制作奖励/“太硬了”等文本恢复显示
  • 挖矿、砍树的原版数字保留(我们的数字依赖 Character 命中信息)

1.6.1

  • 修复伤害数字不显示(ApplyDamage 与 ShowText 的时序搞反,改为先记录后由 ShowText 用原版数值创建)
  • 修复原版数字没被隐藏(1.6.0 的属性错位导致 隐藏原版数字 补丁失败)
  • 格挡/招架文本改为 +格挡 / +招架
  • Test All UI 改为每 0.8 秒生成真实条目,改动画样式立即生效

1.6.0

  • 伤害数字改为直接取原版 DamageText.ShowText 的数值,与游戏显示逐位一致
  • 移植 Parrot 全部 15 种滚动动画 + 方向/滚动距离/行距/层数/淡出/时长配置
  • 新增格挡与招架提示(左侧,抄 Parrot avoid 事件):格挡 / 招架!
  • Test All UI 移到 [General],一次画出全部 UI
  • 删除常驻 BUFF 列与相关配置;BUFF 面板只显示格挡临时 BUFF + 肾上腺素

1.5.1

  • Flash Animation 默认改为 Punch 并排在第一顺位
  • BUFF 面板拆成常驻 / 临时两列,位置分开可调;无持续时间的效果不再显示负数倒计时
  • 肾上腺素必定显示在临时列,不受“只显示格挡带来的 buff”影响
  • 新增 Hide Vanilla Buff Icons:面板开启时隐藏原版(含 My Little UI)状态图标
  • 伤害数字改为向右上缓出滑动并淡出;暴击/连击终结使用 Punch 缩放

1.5.0

反馈 UI 与格挡 BUFF 提示(战斗逻辑未改动):

  • 完美提示可调 位置 X/Y、字号(屏幕高度百分比)、颜色、停留时长,新增 5 种动画:Pop / Punch / Slam / Slide / Shake
  • 新增 BUFF 面板:完美格挡后出现的状态效果逐个显示(图标 + 本地化名称 + 剩余时间 + 层数),并显示肾上腺素增量
  • 新增反击窗口:进度条显示强制格挡剩余时间(连击保持段位的窗口),并显示当前连击段数
  • 新增诊断开关 Log Perfect Block Buffs
  • 新配置项全部带中英文说明

0.3.3

⚠️ 从 0.3.2 及更早版本升级的玩家:请手动把 Hold After Perfect (ms) 改成 500(配置里原来是多少就改成 500)。 升级不会重写你已生成的 cfg,旧值留在 0 的话格挡会失效/挡不住——这个值必须手动改。 全新安装的玩家不用管,默认已经是 500。

参数调整(默认值改成实测最顺手的一套):

  • Enable Auto Block 默认开启
  • Detect Range 25 → 5 米
  • Log Attempts 默认开启
  • Min Samples 3 → 5
  • Hold After Perfect (ms) 0 → 500(升级用户请手动改,见上)
  • Show Vanilla Numbers 默认开启
  • Lead Ms 70 / Press Tail Ms 150 / Base Font Size 27 / Big Hit Scale 2.4 / 数字位置 0.2,0.6 与 0.7,0.6 保持上一版

0.3.2

  • 文档:README 封面图改到 jsDelivr(固定 commit 地址),解决 GitHub / Thunderstore 页面上演示 GIF 裂图的问题(原图 19–38MB,超出图片代理与 CDN 的 20MB 上限,已重新编码到 2–4MB)
  • 文档:标题标注实测成功率,中英双语补齐实测数据与「关闭切换格挡最佳」的说明
  • 无功能改动

0.3.1

首次公开版本。

  • 学习:hook 非玩家实体的 OnAttackTrigger,按 (预制体, 动画状态) 记录命中瞬间的动画进度,存 BepInEx/config/PerfectBlock/learned.json;样本数与离散度达标后才开始自动格挡
  • 自动格挡:命中点前 Lead Ms(70)按下,命中后按满 Press Tail Ms(150);固定值,不做自适应(自适应会把提前量推到 0.25 秒窗口之外)
  • 两种格挡模式:自动识别游戏的「切换格挡」;长按模式实测 91% 完美率、0 漏挡,切换模式约 4% 漏挡
  • 手动格挡取消挥刀(等价 AttackCancel):只对你手动按下的格挡生效,自动格挡不会打断挥击
  • Reliable Perfect Block:只在完美格挡那一下忽略「大伤害破防」规则
  • 完美提示:屏幕中央 PERFECT BLOCK !!!,连续触发向上叠加
  • 战斗数字:武器图标 + 数字 + (伤害类型),承伤红色在左、输出黄色在右;位置/字号/字体/武器图标可调,带常显测试开关
  • 中英双语 yml,按游戏语言自动加载;配置项带完整说明
  • 修复早前版本:Release Delay 语义写反导致每次格挡后主动卸防 250ms;战斗数字取血量差值的位置错误(Character.Damage 只发 RPC,血量在 Character.ApplyDamage 里改)