fix(技能): 修复技能升级配置和属性计算错误
- 将 SkillUpList 中的 buff_max 字段更正为 buff_hp - 移除 add_hp 和 add_shield 方法的 isValue 参数,改为直接使用数值 - 在 SCastSystem 中应用技能升级加成计算 AP、命中次数和 buff 值 - 为 HeroAttrsComp 添加 add_hp_max 和 add_ap 方法,替换原有的通用 buff 处理逻辑 - 简化伤害和技能效果应用逻辑,确保属性计算正确
This commit is contained in:
@@ -150,7 +150,7 @@ export interface SkillConfig {
|
||||
}
|
||||
|
||||
export const SkillUpList = {
|
||||
6001:{ap:0,hit_count:0,buff_ap:0,buff_max:0,bck:0,frz:0,crt:0,num:0}
|
||||
6001:{ap:0,hit_count:0,buff_ap:0,buff_hp:0,bck:0,frz:0,crt:0,num:0}
|
||||
}
|
||||
|
||||
/******
|
||||
|
||||
@@ -139,7 +139,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
||||
if (damage <= 0) return reDate;
|
||||
|
||||
// TAttrsComp.hp -= damage; // 应用伤害到数据层
|
||||
TAttrsComp.add_hp(-damage, true); // 使用 add_hp 以触发 dirty_hp 和 UI 更新
|
||||
TAttrsComp.add_hp(-damage); // 使用 add_hp 以触发 dirty_hp 和 UI 更新
|
||||
|
||||
// 受击者产生击退效果
|
||||
// if (damage > 0 && targetView) {
|
||||
|
||||
@@ -80,19 +80,9 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
}
|
||||
/*******************基础属性管理********************/
|
||||
|
||||
add_hp(value:number,isValue:boolean){
|
||||
add_hp(value:number){
|
||||
const oldHp = this.hp;
|
||||
let addValue = value;
|
||||
if(!isValue){
|
||||
addValue = value * this.hp_max / 100;
|
||||
}
|
||||
|
||||
// ✅ 数据层只负责数据修改,不调用视图层
|
||||
// let heroView = this.ent.get(HeroViewComp);
|
||||
// if(heroView && addValue > 0){
|
||||
// heroView.health(addValue);
|
||||
// }
|
||||
|
||||
this.hp += addValue;
|
||||
this.hp = Math.max(0, Math.min(this.hp, this.hp_max));
|
||||
this.dirty_hp = true; // ✅ 仅标记需要更新
|
||||
@@ -101,13 +91,9 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
}
|
||||
return addValue;
|
||||
}
|
||||
|
||||
add_shield(value:number,isValue:boolean){
|
||||
add_shield(value:number){
|
||||
const oldShield = this.shield;
|
||||
let addValue = value;
|
||||
if(!isValue){
|
||||
addValue = value * this.hp_max / 100;
|
||||
}
|
||||
this.shield += addValue;
|
||||
this.shield_max += addValue;
|
||||
if (this.shield < 0) this.shield = 0;
|
||||
@@ -117,44 +103,23 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
mLogger.log(this.debugMode, 'HeroAttrs', ` 护盾变更: ${this.hero_name}, 变化=${addValue.toFixed(1)}, ${oldShield.toFixed(1)} -> ${this.shield.toFixed(1)}`);
|
||||
}
|
||||
}
|
||||
// ==================== BUFF 管理 ====================
|
||||
/**
|
||||
* 添加 buff 效果
|
||||
* @param buffConf buff 配置
|
||||
*/
|
||||
addBuff(buffConf: BuffConf) {
|
||||
this.applyAttrChange(buffConf.buff, buffConf.value);
|
||||
if (this.debugMode) {
|
||||
mLogger.log(this.debugMode, 'HeroAttrs', `属性:${buffConf.buff}, 值:${buffConf.value}`);
|
||||
}
|
||||
add_hp_max(value:number){
|
||||
this.hp_max+=value
|
||||
this.hp+=value
|
||||
this.dirty_hp = true; // ✅ 仅标记需要更新
|
||||
return value
|
||||
}
|
||||
|
||||
|
||||
add_ap(value:number){
|
||||
this.ap +=value
|
||||
return value
|
||||
}
|
||||
|
||||
|
||||
toFrost(time: number=1) {
|
||||
this.frost_end_time += FightSet.FROST_TIME*time;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用属性修改应用
|
||||
* @param attr 属性名
|
||||
* @param value 变化值
|
||||
*/
|
||||
private applyAttrChange(attr: Attrs, value: number,) {
|
||||
const mappedAttr = attr === Attrs.hp ? Attrs.hp_max : (attr === Attrs.shield ? Attrs.shield_max : attr);
|
||||
if (mappedAttr !== Attrs.ap && mappedAttr !== Attrs.hp_max && mappedAttr !== Attrs.shield_max) return;
|
||||
if (mappedAttr === Attrs.ap) {
|
||||
this.ap = Math.max(0, this.ap + value);
|
||||
return;
|
||||
}
|
||||
if (mappedAttr === Attrs.hp_max) {
|
||||
this.hp_max = Math.max(1, this.hp_max + value);
|
||||
if (this.hp > this.hp_max) this.hp = this.hp_max;
|
||||
this.dirty_hp = true;
|
||||
return;
|
||||
}
|
||||
this.shield_max = Math.max(0, this.shield_max + value);
|
||||
this.shield = Math.max(0, Math.min(this.shield + value, this.shield_max));
|
||||
this.dirty_shield = true;
|
||||
}
|
||||
updateCD(dt: number){
|
||||
for (const key in this.skills) {
|
||||
const skill = this.skills[key];
|
||||
|
||||
@@ -7,6 +7,7 @@ import { Skill } from "../skill/Skill";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { GameConst } from "../common/config/GameConst";
|
||||
import { HType } from "../common/config/heroSet";
|
||||
import { Attrs } from "../common/config/HeroAttrs";
|
||||
|
||||
/**
|
||||
* ==================== 自动施法系统 ====================
|
||||
@@ -173,20 +174,32 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
||||
*/
|
||||
private applyFriendlySkillEffects(_s_uuid: number, _skillLv: number, config: SkillConfig, _heroView: HeroViewComp, _cAttrsComp: HeroAttrsComp, targets: HeroViewComp[], _targetPos: Vec3 | null) {
|
||||
const kind = config.kind ?? SkillKind.Support;
|
||||
const sUp=SkillUpList[_skillLv]
|
||||
const sAp =config.ap+sUp.ap*_skillLv;
|
||||
const sHit=config.hit_count+sUp.hit_count*_skillLv
|
||||
for (const target of targets) {
|
||||
if (!target.ent) continue;
|
||||
const model = target.ent.get(HeroAttrsComp);
|
||||
if (!model || model.is_dead) continue;
|
||||
if (kind === SkillKind.Heal && config.ap !== 0) {
|
||||
const addHp = model.add_hp(config.ap, false);
|
||||
const addHp = model.add_hp(sAp*_cAttrsComp.ap);
|
||||
target.health(addHp);
|
||||
} else if (kind === SkillKind.Shield && config.ap !== 0) {
|
||||
model.add_shield(config.ap, false);
|
||||
} else if (kind === SkillKind.Shield && sAp !== 0) {
|
||||
model.add_shield(sAp*_cAttrsComp.ap);
|
||||
}
|
||||
if (!config.buffs || config.buffs.length === 0) continue;
|
||||
for (const buffConf of config.buffs) {
|
||||
if (!buffConf) continue;
|
||||
model.addBuff(buffConf);
|
||||
const sBuffAp=buffConf.value+sUp.buff_ap
|
||||
const sBuffHp=buffConf.value+sUp.buff_hp
|
||||
switch (buffConf.buff){
|
||||
case Attrs.ap:
|
||||
model.add_ap(sBuffAp)
|
||||
break
|
||||
case Attrs.hp_max:
|
||||
model.add_hp_max(sBuffHp)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user