PEAK
You are viewing a potentially older version of this package. View Latest Version
Install with App

Details

Date Uploaded
Downloads
781
Size
24KB

PeakStaminaHost

English

Host-controlled stamina cap, extra affliction bar, infinite stamina, no-hunger and god-mode for PEAK (Steam), built on BepInEx 5. The host configures everything in MOD SETTINGS and broadcasts it to the whole room over Photon RPC; it also works in single-player.

Changelog

v1.10.2

  • Re-upload of v1.10.1 with the same features and no code change; the previous upload was incorrectly flagged as NSFW (not safe for work), which hid it from normal browsing. This version is published with the correct content rating.

v1.10.1

  • The extra affliction bar now uses absolute mapping: length and number are fixed to the cap — at cap=50 the empty bar takes half the frame and shows 50 (previously it always filled the frame and showed 100 regardless of the cap).
  • Fix affliction bars overflowing the UI in multi-status / over-cap cases (e.g. TrueFinalAscent): the cloned outer MaxStamina container is now driven, affliction bars no longer divide by the cap, and when the total exceeds 1 they scale proportionally to fit the frame.
  • The white outline hugs the content with no empty gap; once sum exceeds the cap it extends from the right edge and shows an overflow line at the full-value right boundary (mirrors the vanilla statusSum > 1 behavior).
  • Each affliction bar shows its own value (percentage, game font); it is no longer only the orange master bar that has a number.
  • Fix the v1.10.0 PeakStatsEx compatibility patch not attaching: the real namespace is PeakStatsEx.MonoBehaviours (the previous typo made TypeByName fail).

v1.10.0

  • Multiplayer authority lock: only the host can change settings. Non-host changes in MOD SETTINGS are ignored (SyncState is not overwritten), and after receiving the host RPC the menu is rewritten to the host values, avoiding display/state mismatch.
  • Fix petrify not showing: the petrify bar (isPetrify) is exempt from hiding in extra mode, restoring the native StaminaBar shared extraBar for petrify / extra stamina; the orange clone no longer duplicates petrify.
  • PeakStatsEx compatibility: manually attach a Postfix to its internal CharacterStaminaBar.UpdateStaminaBar, clamping teammates' stamina / max bars to the frame so multipliers above 1 no longer break the UI.

v1.9.0

  • Rewrote stamina-bar visual driving: the vanilla desired = currentStamina × frame width assumes full value = 1, so the Lerp target overshoots at multipliers above 1. The plugin uses self-maintained smoothing fields that Lerp toward absolute-mapped targets (Clamp01(currentStamina), Clamp01(GetMaxStamina), i.e. the ratio against the vanilla full value of 1, not divided by the multiplier), then directly overwrites sizeDelta — it is not chained with the vanilla Lerp (chaining pulls the width between the two targets and drifts with frame rate). Low multipliers shrink proportionally, high ones clamp to the frame; no jitter after convergence.
  • The Postfix uses HarmonyPriority(600) (above the default 400) and runs before PeakStatsEx so it reads the correct widths.
  • The private desiredStaminaSize is untouched, so PeakStatsEx still shows the absolute stamina number (e.g. 500); the visual bar and the number are separated.
  • Toggles such as no-hunger now use polling that does not rely on SettingChanged: ConfigEntry.Value is compared every frame and synced as soon as BoxedValue is written, with [poll] logs.
  • Jitter diagnostics are throttled (0.25 s) and log the real visual width even when static.

v1.8.0

  • Fix the extra bar still being green: the recolor target changed to the real Stamina/Fill Image (recoloring the imageless Stamina had no effect).
  • Fix the infinite-stamina number growing forever: instead of setting infiniteStam, Character.UseStamina is intercepted.
  • The extra bar gets a number (game font, remaining capacity as a percentage).
  • Added config-source and per-frame stamina diagnostics.

Features

  • Adjustable stamina cap (free percentage text box) — type a percentage directly: 2.5 = 2.5% of vanilla (a sliver), 100 = vanilla, 200 = 2×, 500 = 5×; every 2.5 increment works, with no slider or dropdown.
  • Extra affliction bar (weight included, on by default) — it clones the vanilla stamina-bar layout, is recolored orange, and sits directly under the stamina bar. All vanilla statuses (weight, hunger, damage, etc.) appear on it and eat into the orange master bar. It gives a default of 50 extra capacity (adjustable 10–100) that never uses the stamina bar. Length/number are fixed to the cap (at cap=50 the empty bar is half the frame and shows 50); the white outline hugs the content and extends right past the cap; each affliction shows its own value.
  • The original stamina bar stays clean — with the extra bar on, the colored afflictions on the original bar are hidden (the white outline and overflow line are kept); turn it off to restore vanilla.
  • No more pass-out loop (root fix, no hysteresis) — the stand-up and pass-out thresholds are unified: you pass out only when the total affliction reaches the extra capacity, and stand up normally once it drops below it; this applies to every affliction type.
  • Stick-to-stamina mode (extra bar off) — vanilla behavior: afflictions press on the stamina cap and you pass out when stamina drops below them.
  • Infinite stamina (fixes the runaway number) — it no longer writes infiniteStam (which makes currentStamina only grow and breaks clamping); Harmony intercepts Character.UseStamina, so when on every consumption action returns success without draining, and switching at runtime applies immediately.
  • Numbers on both the orange bar and every affliction — using the game font (heroDayText.font): the orange bar shows remaining capacity (at cap=50, full = 50 and pass-out = 0), and each affliction shows its value as a percentage; no third-party number mod is needed.
  • No-hunger / god mode — hunger no longer accumulates; you are immune to damaging statuses and cannot die.
  • Correct bar length, no overflow — the bar length follows the absolute value against the vanilla cap (full = 1): low multipliers shrink (50% → half, 2.5% → very short), high ones clamp to the frame.

Installation

Mod manager (recommended)

  • Online: click Install on the Thunderstore page; dependencies are added automatically.
  • Local zip: profile → Import local mod → select PeakStaminaHost.zip → Start modded.

Manual

  • Requires BepInEx 5. Extract the BepInEx folder from the zip into the game root (Steam\steamapps\common\PEAK) and merge; the dll lands in BepInEx/plugins/PeakStaminaHost.dll.

Dependencies (BepInEx-BepInExPack_PEAK-5.4.2403, PEAKModding-ModConfig-1.8.2) are installed automatically by managers; manual users must have them present.

Usage

Pause menu → MOD SETTINGS → PeakStaminaHost (auto-collected by PEAKLib.ModConfig):

Setting Control Explanation
Stamina cap (%) Text percentage, e.g. 2.5 / 100 / 200 / 500
Extra bar On/Off on (default): orange bar, no stamina press, pass out at cap; off: vanilla
Extra bar cap (%) Text pass-out threshold, 10–100, default 50
No-hunger On/Off hunger no longer accumulates
God mode On/Off immune to damaging statuses, cannot die
Infinite stamina On/Off climbing costs no stamina

Multiplayer

  • Every player in the room needs the mod (PEAK is peer-to-peer and stamina is computed locally).
  • Only the host (MasterClient) can change settings; changes are broadcast over Photon RPC to unify the room; non-host changes are ignored and the menu is pulled back to the host values.
  • All gameplay settings (cap, extra bar, no-hunger, god mode, infinite stamina) are broadcast.

How it works

Everything is verified against an Assembly-CSharp.dll decompile; no invented APIs.

  • Character.GetMaxStamina() is vanilla 1 − statusSum; in extra mode it ignores statusSum and returns a constant 1 × multiplier, so carrying heavy objects does not shrink the cap and the value stays stable.
  • The extra bar Object.Instantiates the whole native StaminaBar object (background, white outline, icon slots, all BarAffliction children), removes the cloned StaminaBar and BarAffliction scripts, and drives it with absolute mapping (no division by cap): the orange master / outer MaxStamina width = Clamp01(cap−sum) × frame, each affliction width = val × frame (proportionally scaled to the frame when the total exceeds 1), so the total is always cap × frame and never overflows. The white outline width = 14 + max(cap,sum) × frame (hugs the content, extends right past the cap), and the overflow line sits at the full-value right boundary cap × frame; the orange bar and each affliction get a TMP using the game heroDayText.font. The green fill Image is actually at Stamina/Fill, so recoloring targets that Fill; native anchors and layout are preserved with no hand-written RectTransform values.
  • Infinite stamina does not write Character.infiniteStam: that field makes the currentStamina setter only grow and disables ClampStamina, so the number grows forever. A Prefix intercepts the internal Character.UseStamina; when on it sets __result = true and skips the original, and all 12 active consumption paths (climb, sprint, jump, grip, rope, vine, glide, Exhaustion, etc.) go through it.
  • The original bar hides colored afflictions through a BarAffliction.ChangeAffliction Postfix (the white outline / overflow stay untouched), but the petrify bar (isPetrify) is exempt: StaminaBar.Update relies on petrifyAffliction.activeSelf to pop the shared extraBar, and hiding it would break petrify.
  • PeakStatsEx: the teammate bar PeakStatsEx.MonoBehaviours.CharacterStaminaBar.UpdateStaminaBar uses unclamped currentStamina/GetMaxStamina × frame, which breaks the UI at multipliers above 1. Since the class is internal, AccessTools.TypeByName (the correct .MonoBehaviours, with the old name as a fallback) gets the type and a manual Postfix clamps both bars to fullBar (it only clamps the result, with no extra Lerp).
  • Pass-out: vanilla shouldPassOut = statusSum > 0.99; extra mode changes it to statusSum > ExtraBarCap; the HandlePassedOut Prefix refreshes lastPassedOut while the total is not below the cap, preventing stand-up — a root fix without hysteresis.
  • Weight goes through SetStatus(Weight, …) rather than AddStatus; extra mode separates weight/hunger/damage from the stamina cap.
  • The cap and extra capacity are string configs, so ModConfig renders plain text boxes (no slider/dropdown).
  • Vanilla stamina width = currentStamina × fullBar width assumes full = 1 and overshoots at multipliers above 1. The high-priority (600) Postfix uses self-maintained static smoothing fields (_smoothStam/_smoothMax) that Lerp toward absolute targets — stamina Clamp01(currentStamina) × frame, max Clamp01(GetMaxStamina()) × frame (no division) — then directly overwrites sizeDelta. Because it is not chained with the vanilla Lerp, the width converges precisely, and Lerp(B,B,t) = B is frame-rate independent with no jitter. The private desiredStaminaSize stays unchanged and PeakStatsEx shows the absolute number.
  • The host broadcasts with photonView.RPC("RPC_SetStaminaMultiplier", All, cap, infinite, noHunger, godMode, extraBar, extraCap).

Known limitations

  • All players must install it; only the host changes settings and they are broadcast.
  • No-hunger reuses the native authority property canGetHungry (the campfire uses a NoHunger affliction to make it false): a Postfix hijacks get_canGetHungry and forces false when on, and AddStatus natively blocks hunger; on the enable edge it calls SetStatus(Hunger,0) to clear existing hunger.
  • Number/width jitter is removed by self-maintained smoothing plus direct sizeDelta overwrite, frame-rate independent.
  • God mode covers status accumulation and the death entry; special instant-damage paths may not be covered (the source is included so you can extend it).
  • Visual bars are proportional; above 1× the bar itself cannot read the absolute cap — use the PeakStatsEx number for absolute stamina and the extra bar number for remaining capacity.
  • If a game update changes these hooks, recompile with the included source.

Source

The package includes the full C# source (Harmony + Photon, net472).

License

MIT — free to use and modify.


中文

面向 PEAK(Steam)的 BepInEx 5 插件。房主在 MOD SETTINGS 里配置体力上限、独立负面条、无限体力、免饥饿、免伤,经 Photon RPC 广播全房;单机同样生效。

更新日志

v1.10.2

  • 重新发布 v1.10.1,功能与代码完全相同、无逻辑改动;上一版上传时被误标为成人内容(NSFW),导致正常浏览搜不到。本版按正确内容分级重新发布。

v1.10.1

  • 独立负面条改为绝对映射:长度/数字随设置固定——cap=50 时空状态只占半框、数字显 50(此前无论 cap 多少都撑满、恒显 100)。
  • 修复天阶模式(TFA)等多状态/超容时状态条突破 UI:补上副本外层 MaxStamina 容器驱动,各状态条不再除以 cap,总和超 1 时等比缩到框宽。
  • 白色外框贴合内容、不空余;sum 超 cap 后外框从右侧延伸,并在满值右边界显示溢出竖线(对应原版 statusSum > 1 的溢出表现)。
  • 每个状态条各带数值(该状态值百分制,游戏自带字体),不再只有橙色总条有数字。
  • 修复 v1.10.0 的 PeakStatsEx 兼容补丁未挂载:该类真实命名空间为 PeakStatsEx.MonoBehaviours(此前误写导致 TypeByName 找不到)。

v1.10.0

  • 联机权限锁定:仅房主可改设置。非房主在 MOD SETTINGS 的改动被忽略(不覆盖 SyncState),且收到房主 RPC 后菜单显示回写为房主值,避免“显示与实际不一致”。
  • 修复石化不显示:石化条(isPetrify)从独立模式的负面条隐藏中豁免,恢复 StaminaBar 原生的石化/额外体力共用 extraBar 显示;独立橙色条不再重复显示石化。
  • 兼容 PeakStatsEx:对其 internal 类 CharacterStaminaBar.UpdateStaminaBar 手动挂载 Postfix,把队友头顶体力条/上限条宽度钳到框内,倍率 >1 不再突破 UI。

v1.9.0

  • 重写体力条视觉驱动:原版 desired = currentStamina × 框宽 假设满值 = 1,倍率 >1 时 Lerp 目标过冲。本插件用自维护的平滑字段朝绝对映射目标(Clamp01(currentStamina)、Clamp01(GetMaxStamina),即相对原版满值 = 1 的比例,不除倍率)Lerp,再直接覆盖 sizeDelta——不与原版 Lerp 串联(串联会把宽度拉到两个目标之间、且随帧率漂移导致抖动)。低倍率随倍率缩短、高倍率钳满不超框,收敛后与帧率无关故不抖。
  • 该 Postfix 设 HarmonyPriority(600)(高于默认 400),先于 PeakStatsEx 执行,使其读到正确宽度。
  • 不修改私有 desiredStaminaSize,PeakStatsEx 数字仍按它显示绝对体力值(如 500),视觉条与数字分离。
  • 免饥饿等开关新增不依赖 SettingChanged 事件的轮询:每帧直接比对 ConfigEntry.Value,只要 BoxedValue 被写回即同步,并记录 [轮询检测] 日志。
  • 抖动诊断改为限频(0.25s)且静止时也记录真实视觉宽度,覆盖此前“静止完全静默”的观察盲区。

v1.8.0

  • 修复独立条仍是绿色:改色目标改为真实的 Stamina/Fill Image(此前对无 Image 的 Stamina 改色无效)。
  • 修复无限体力数字无限增长:不再写 infiniteStam,改为拦截 Character.UseStamina。
  • 独立条新增数字(游戏自带字体,显示剩余容量百分制)。
  • 新增配置变更来源 / 每帧体力变化诊断。

功能

  • 可调节的体力上限(文本框输入百分数) — 直接输入百分比:2.5 = 原版 2.5%(一丝)、100 = 原版、200 = 2 倍、500 = 5 倍;每 2.5 都能调,无滑块、无下拉。
  • 独立负面条(含负重条,默认开启) — 复制游戏原生体力条的 UI 结构、内部改橙色、对齐显示在体力条正下方。负重 / 饥饿 / 伤害等全部原生状态都显示在下方这条上,出现后挤占橙色总条。默认提供 50(可在 10–100 之间调节) 的额外负面容量且不占用体力条。条的长度/数字随设置固定(cap=50 空状态只占半框、显 50),白框贴合不空余、超 cap 后从右侧延伸,每个状态条各带数值。
  • 原体力条保持干净 — 独立负面条开启时,原体力条上的彩色负面条隐藏(保留白色外框与溢出线);关闭该功能后原版负面条恢复显示。
  • 不再反复倒地起身(根本修复,无滞回) — 起身条件与倒地阈值统一:负面总量达到额外容量才倒地,降到容量以下后正常起身;对火烤、负重、饥饿、伤害等所有负面类型通用。
  • 贴体力条模式(关闭独立负面条) — 回到原版行为:负面条压体力上限,体力条低于负面条就倒地。
  • 无限体力(修复数字无限增长) — 不再写游戏的 infiniteStam 字段(该字段会让 currentStamina 只增不减、钳制失效导致数字一路涨),改为 Harmony 拦截 Character.UseStamina:开启时所有消耗动作直接返回成功、不扣体力,运行时切换即时生效。
  • 独立条与每个状态条都带数字 — 用游戏自带字体(heroDayText.font):橙色总条显示剩余容量(cap=50 满 = 50、倒地 = 0),每个状态条显示该状态值百分制,不依赖第三方数值 mod。
  • 免饥饿 / 免伤无敌 — 饥饿不再累加;免疫伤害性状态且不会死亡。
  • 体力条长度正确、不溢出 — 条长按绝对体力值相对原版满值(=1)的比例显示:低倍率随倍率缩短(50%→半框、2.5%→很短),高倍率钳满框、不超框。

安装

模组管理器(推荐)

  • 在线安装:在雷霆商店页面点击 Install,依赖自动配齐。
  • 本地 zip:profile → Import local mod → 选择 PeakStaminaHost.zip → Start modded。

手动安装

  • 需先装 BepInEx 5。把 zip 内 BepInEx 文件夹解压到游戏根目录(Steam\steamapps\common\PEAK)并合并,dll 落入 BepInEx/plugins/PeakStaminaHost.dll。

依赖(BepInEx-BepInExPack_PEAK-5.4.2403、PEAKModding-ModConfig-1.8.2)管理器会自动安装,手动安装需自行确认。

使用

暂停菜单 → MOD SETTINGS → PeakStaminaHost(由 PEAKLib.ModConfig 自动收集):

配置项 控件 说明
上限倍率 (%) 文本框 百分数,如 2.5 / 100 / 200 / 500
独立负面条 On/Off 开(默认):独立橙色条、不压体力、到容量才倒地;关:贴体力条(原版)
独立负面条上限 (%) 文本框 倒地阈值,10–100,默认 50
免饥饿 On/Off 饥饿不再累加
免伤无敌 On/Off 免疫伤害性状态、不会死亡
全房无限体力 On/Off 攀爬不消耗体力

联机

  • 全房玩家都需安装本 mod(PEAK 为点对点,体力在本地计算)。
  • 仅房主(MasterClient)可修改设置,修改后经 Photon RPC 广播统一全房;非房主的改动被忽略,且菜单显示会回拉为房主值。
  • 全部玩法设置(上限、独立负面条、免饥饿、免伤、无限体力)均会广播。

原理

全部依据 Assembly-CSharp.dll 反编译核实,无编造接口。

  • Character.GetMaxStamina() 原版为 1 − statusSum;独立负面条模式下让其忽略 statusSum,返回恒定的 1 × 倍率,因此拿重物体力上限不缩、数值稳定。
  • 独立负面条在运行时 Object.Instantiate 复制整个原生 StaminaBar 游戏对象(含背景框、白色外框、图标位与全部 BarAffliction 子节点),删除副本上的 StaminaBar 与各 BarAffliction 脚本后由本插件驱动,采用绝对映射(不除 cap):橙色总条/外层 MaxStamina 宽 = Clamp01(cap−sum) × 框宽,各状态条宽 = val × 框宽(总和超 1 时等比缩到框宽),故总宽恒 = cap × 框宽 不超框。白色外框宽 = 14 + max(cap,sum) × 框宽(贴合不空余、超 cap 从右侧延伸),溢出竖线定位满值右边界 cap × 框宽;橙色总条与每个状态条各建一个 TMP(游戏自带 heroDayText.font)显示数值。绿色填充 Image 实际位于 Stamina/Fill,改色针对该 Fill;复制保留原生锚点与布局,不手写任何 RectTransform 数值。
  • 无限体力不写 Character.infiniteStam:该字段会让 currentStamina setter 只允许上升、ClampStamina 失效而数字无限增长。改为 Prefix 拦截 internal Character.UseStamina,开启时 __result = true 并跳过原方法,所有 12 处主动消耗(攀爬/冲刺/跳跃/抓握/绳索/藤蔓/滑翔/Exhaustion)均经此方法。
  • 原体力条通过 BarAffliction.ChangeAffliction 的 Postfix 在额外模式下隐藏彩色条(白色外框/溢出线保持不动),但石化条(isPetrify)豁免:StaminaBar.Update 依赖 petrifyAffliction.activeSelf 弹出石化/额外体力共用的 extraBar,隐藏它会导致石化不显示。
  • PeakStatsEx 兼容:其队友头顶条 PeakStatsEx.MonoBehaviours.CharacterStaminaBar.UpdateStaminaBar 用未钳制的 currentStamina/GetMaxStamina 乘框宽,倍率 >1 会突破 UI。因该类是 internal,用 AccessTools.TypeByName(正确命名空间 .MonoBehaviours,并保留旧名兜底)取类型、手动 Patch 一个 Postfix,把两条宽度钳到 fullBar 内(只钳结果、不额外 Lerp)。
  • 倒地:原版 shouldPassOut = statusSum > 0.99,额外模式改为 statusSum > ExtraBarCap;HandlePassedOut 的 Prefix 在总量未降到容量以下时刷新 lastPassedOut,使起身条件不成立,从根本上消除循环,而非加滞回。
  • 负重走 SetStatus(Weight, …) 而非 AddStatus;额外模式把负重/饥饿/伤害与体力上限分离,统一由独立条承载。
  • 上限与额外容量为 string 配置,ModConfig 据此渲染纯文本框(无滑块/下拉)。
  • 原版体力条宽度 = currentStamina × fullBar 宽,假设满值 = 1;倍率 >1 时该目标过冲。本插件在 StaminaBar.Update 的高优先级(600)Postfix 中,用自维护的静态平滑字段(_smoothStam/_smoothMax)朝绝对映射目标 Lerp——体力条 Clamp01(currentStamina) × fullBar 宽、上限条 Clamp01(GetMaxStamina()) × fullBar 宽(不除倍率)——再直接覆盖 sizeDelta。因不与原版 Lerp 串联,宽度精确收敛,且收敛后 Lerp(B,B,t) = B 与帧率无关、不抖动。私有 desiredStaminaSize 保持原版值不变,PeakStatsEx 据此显示绝对数字。
  • 房主通过 photonView.RPC("RPC_SetStaminaMultiplier", All, cap, infinite, noHunger, godMode, extraBar, extraCap) 广播。

已知限制

  • 全房必须安装;仅房主可修改、会被广播。
  • 免饥饿复用游戏原生权威属性 canGetHungry(营火即靠 NoHunger 状态让它为 false):Postfix 劫持 get_canGetHungry 在开启时强制 false,由 AddStatus 原生拦截饥饿;开启边沿调用 SetStatus(Hunger,0) 清除存量。
  • 数字/宽度抖动已由自维护平滑字段 + 直接覆盖 sizeDelta 消除,收敛后与帧率无关。
  • 免伤覆盖状态累加与死亡入口;特殊即时伤害路径可能未覆盖(附源码可自行扩展)。
  • 视觉条按比例显示,>1 倍时条体本身读不出绝对上限,绝对体力值看 PeakStatsEx 数字、独立条数字看剩余负面容量。
  • 若游戏更新改动这些 hook,需用附带源码重新编译。

源码

交付包含完整 C# 源码(Harmony + Photon,net472)。

许可

MIT — 可自由使用与修改。

Thunderstore development is made possible with ads. Please consider making an exception to your adblock.