refactor(skill/hero): 重构技能buff系统,优化属性处理与技能加成逻辑
- 新增HeroAttrsComp的add_special_attr方法,实现动态累加任意数字类型的英雄属性 - 废弃旧的BuffConf数组配置格式,改用单一buff_type字段简化技能buff配置 - 修复金币类技能加成未随技能等级提升的问题,调整计算逻辑为baseGold + sUp.ap * skillLv - 重构applyActualFriendlyEffect方法,添加技能等级参数,按buff类型匹配对应升级加成 - 更新所有内置技能配置为新的格式规范
This commit is contained in:
@@ -412,13 +412,13 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
||||
: this.pickRandomFriendlyTargets(targets, sHit);
|
||||
|
||||
for (const target of applyTargets) {
|
||||
this.applyActualFriendlyEffect(target, kind, sAp, _cAttrsComp, config, sUp);
|
||||
this.applyActualFriendlyEffect(target, kind, sAp, _cAttrsComp, config, sUp, _skillLv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private applyActualFriendlyEffect(target: HeroViewComp, kind: SkillKind, sAp: number, _cAttrsComp: HeroAttrsComp, config: SkillConfig, sUp: any) {
|
||||
private applyActualFriendlyEffect(target: HeroViewComp, kind: SkillKind, sAp: number, _cAttrsComp: HeroAttrsComp, config: SkillConfig, sUp: any, _skillLv: number = 1) {
|
||||
if (!target.ent) return;
|
||||
const model = target.ent.get(HeroAttrsComp);
|
||||
if (!model || model.is_dead) return;
|
||||
@@ -440,23 +440,35 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
||||
model.add_shield(addShield);
|
||||
} else if (kind === SkillKind.Gold) {
|
||||
const baseGold = config.gold ?? config.ap;
|
||||
const addGold = baseGold + (sUp.ap);
|
||||
const addGold = baseGold + (sUp.ap * _skillLv);
|
||||
if (addGold > 0) {
|
||||
MissionEconomy.addCoin(addGold);
|
||||
}
|
||||
}
|
||||
if (!config.buffs || config.buffs.length === 0) return;
|
||||
for (const buffConf of config.buffs) {
|
||||
if (!buffConf) continue;
|
||||
const sBuffAp=buffConf.value+sUp.buff_ap
|
||||
const sBuffHp=buffConf.value+sUp.buff_hp
|
||||
switch (buffConf.buff){
|
||||
|
||||
if (config.buff_type !== undefined) {
|
||||
const baseValue = config.ap;
|
||||
let upgradeValue = 0;
|
||||
|
||||
// 根据 buff 类型选择对应的升级加成
|
||||
if (config.buff_type === Attrs.ap) upgradeValue = sUp.buff_ap || 0;
|
||||
else if (config.buff_type === Attrs.hp_max) upgradeValue = sUp.buff_hp || 0;
|
||||
else if (config.buff_type === Attrs.critical) upgradeValue = sUp.crt || 0;
|
||||
// 如果后续有冰冻等,在这里加上对应的 sUp 字段即可,如 sUp.frz
|
||||
|
||||
const totalBuffValue = baseValue + upgradeValue;
|
||||
|
||||
switch (config.buff_type){
|
||||
case Attrs.ap:
|
||||
model.add_ap(sBuffAp)
|
||||
break
|
||||
model.add_ap(totalBuffValue);
|
||||
break;
|
||||
case Attrs.hp_max:
|
||||
model.add_hp_max(sBuffHp)
|
||||
break
|
||||
model.add_hp_max(totalBuffValue);
|
||||
break;
|
||||
default:
|
||||
// 除了 hp_max 和 ap,其他固定属性走统一的 add_special_attr 方法
|
||||
model.add_special_attr(config.buff_type, totalBuffValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user