refactor(hero): 重构额外属性加成系统,统一为bonus字段
1. 将原ap_bonus/hp_bonus/def_bonus三个字段合并为通用的bonus数组结构 2. 新增多属性同时配置能力,支持hp/ap/def百分比加成与crt/frz/stun/para固定百分点加成 3. 更新所有前端编辑器、服务端渲染与游戏运行时逻辑适配新配置格式 4. 添加数据兼容迁移逻辑,自动处理旧版英雄配置数据
This commit is contained in:
@@ -2142,7 +2142,7 @@ export class MissionCardComp extends CCComp {
|
||||
* 1. 同步刷新 base_ap/base_hp 快照,下游 UI/复活读到当前 lv 的基础值
|
||||
* 2. 走 getRuntimeAp/getRuntimeHp 应用驻场光环乘区
|
||||
* 3. 重新解析 runtime_* 触发缓存与光环/复活,避免升级后停在旧等级快照
|
||||
* 4. 按 ≤nextLv 累加 hp_bonus/ap_bonus
|
||||
* 4. 按 ≤nextLv 累加 bonus 档位(hp/ap/def 百分比 + crt/frz/stun/para 百分点)
|
||||
*/
|
||||
public applyHeroLevel(model: HeroAttrsComp, targetLv: number) {
|
||||
const hero = HeroInfo[model.hero_uuid];
|
||||
@@ -2167,28 +2167,38 @@ export class MissionCardComp extends CCComp {
|
||||
model.hp_max = base_hp;
|
||||
}
|
||||
|
||||
// 按 ≤nextLv 累加:成长类型每级递增 + hp/ap/def_bonus 一次性奖励(沿用 Hero.load 的加法区规则)
|
||||
// 按 ≤nextLv 累加:成长类型每级递增 + bonus 档位(与 Hero.load 同口径:hp/ap 百分比、基数取"基础+成长"快照)
|
||||
const grow = calcGrowBonus(hero, nextLv);
|
||||
model.hp_max += grow.hp;
|
||||
model.ap += grow.ap;
|
||||
if (model.hp_bonus) {
|
||||
let hpExtra = 0;
|
||||
for (const e of model.hp_bonus) { if (e.lv <= nextLv) hpExtra += e.value; }
|
||||
model.hp_max += hpExtra;
|
||||
}
|
||||
if (model.ap_bonus) {
|
||||
let apExtra = 0;
|
||||
for (const e of model.ap_bonus) { if (e.lv <= nextLv) apExtra += e.value; }
|
||||
model.ap += apExtra;
|
||||
let bonusHpP = 0, bonusApP = 0, bonusDefP = 0;
|
||||
if (model.bonus) {
|
||||
for (const e of model.bonus) {
|
||||
if (e.lv > nextLv) continue;
|
||||
bonusHpP += e.attrs.hp ?? 0;
|
||||
bonusApP += e.attrs.ap ?? 0;
|
||||
bonusDefP += e.attrs.def ?? 0;
|
||||
}
|
||||
model.hp_max += Math.round((base_hp + grow.hp) * bonusHpP / 100);
|
||||
model.ap += Math.round((base_ap + grow.ap) * bonusApP / 100);
|
||||
}
|
||||
|
||||
// 天赋加成层(与 Hero.load 对齐):先重置天赋可能修改的字段,避免升级重算时重复叠加
|
||||
// Why: ap/hp_max 已由上方公式从 base 重算(天然幂等),但 defense 与概率类字段是累加语义,必须先归零再注入
|
||||
if (model.fac === FacSet.HERO) {
|
||||
// defense 从品质系数后的基础值重算,叠加 def 成长 + def_bonus + lv12 专项,幂等
|
||||
// defense 从品质系数后的基础值重算,叠加 def 成长 + def 百分比 bonus + lv12 专项,幂等
|
||||
let base_def = Math.round(hero.def * qualityCoef) + grow.def;
|
||||
if (model.def_bonus) {
|
||||
for (const e of model.def_bonus) { if (e.lv <= nextLv) base_def += e.value; }
|
||||
base_def += Math.round(base_def * bonusDefP / 100);
|
||||
// bonus 概率类:固定百分点累加(在下方归零后注入,避免重复叠加)
|
||||
let bonusCrt = 0, bonusFrz = 0, bonusStun = 0, bonusPara = 0;
|
||||
if (model.bonus) {
|
||||
for (const e of model.bonus) {
|
||||
if (e.lv > nextLv) continue;
|
||||
bonusCrt += e.attrs.crt ?? 0;
|
||||
bonusFrz += e.attrs.frz ?? 0;
|
||||
bonusStun += e.attrs.stun ?? 0;
|
||||
bonusPara += e.attrs.para ?? 0;
|
||||
}
|
||||
}
|
||||
// lv12 职业属性专项:达到 12 级时按职业对单项基础属性 +50%(基数为 lv11 有效值)
|
||||
if (nextLv >= HERO_LV12_SPECIAL_LV && model.role !== undefined) {
|
||||
@@ -2199,10 +2209,11 @@ export class MissionCardComp extends CCComp {
|
||||
else if (attr === "ap") model.ap += Math.round(lv11.ap * 0.5);
|
||||
}
|
||||
model.defense = base_def;
|
||||
model.critical = 0;
|
||||
model.critical = bonusCrt;
|
||||
model.critical_damage = 0;
|
||||
model.stun_chance = 0;
|
||||
model.freeze_chance = 0;
|
||||
model.stun_chance = bonusStun;
|
||||
model.freeze_chance = bonusFrz;
|
||||
model.paralyze_chance = bonusPara;
|
||||
// 风怒机制已停用: 升级重算不再重置风怒
|
||||
// model.wfuny = 0;
|
||||
model.puncture_chance = 0;
|
||||
|
||||
Reference in New Issue
Block a user