fix(技能): 修复技能等级计算错误,默认等级从1改为0

将技能相关计算的默认等级从1统一修正为0,确保等级计算逻辑的一致性。具体包括:
- HeroAttrsComp.getSkillLevel() 方法在无效技能ID时返回0
- Hero实体构建技能模型时使用Math.max确保最低等级为0
- SDataCom组件初始化skill_lv为0
- Skill实体加载时skill_lv参数默认值改为0,计算时使用Math.max(0, skill_lv)
This commit is contained in:
panw
2026-03-24 10:25:12 +08:00
parent abcbeff9ab
commit 382f6d2b32
4 changed files with 13 additions and 13 deletions

View File

@@ -83,8 +83,8 @@ export class Hero extends ecs.Entity {
for (const key in hero.skills) { for (const key in hero.skills) {
const skill = hero.skills[key]; const skill = hero.skills[key];
if (!skill) continue; if (!skill) continue;
//用于增量 计算最终技能等级英雄等级与技能初始等级均从1开始需各减1抵消故-2 //用于增量 计算最终技能等级英雄等级与技能初始等级均从1开始需各减1抵消故-2最低等级时0
model.skills[skill.uuid] = { ...skill, lv: skill.lv + hero_lv - 2, ccd: skill.cd }; model.skills[skill.uuid] = { ...skill, lv: Math.max(0,skill.lv + hero_lv - 2), ccd: skill.cd };
} }
model.updateSkillDistanceCache(); model.updateSkillDistanceCache();

View File

@@ -139,8 +139,8 @@ export class HeroAttrsComp extends ecs.Comp {
return this.frost_end_time > 0 return this.frost_end_time > 0
} }
getSkillLevel(skillId: number): number { getSkillLevel(skillId: number): number {
if (!skillId) return 1; if (!skillId) return 0;
return this.skills[skillId]?.lv ?? 1; return this.skills[skillId]?.lv ?? 0;
} }
getSkillIds(): number[] { getSkillIds(): number[] {

View File

@@ -11,7 +11,7 @@ export class SDataCom extends ecs.Comp {
group:BoxSet=BoxSet.HERO group:BoxSet=BoxSet.HERO
fac: number = 0; // 0:hero 1:monster fac: number = 0; // 0:hero 1:monster
s_uuid:number=0 s_uuid:number=0
skill_lv:number=1 skill_lv:number=0
ext_dmg:number=0 //额外伤害 ext_dmg:number=0 //额外伤害
dmg_ratio:number=1 //伤害比例 dmg_ratio:number=1 //伤害比例
hit_count:number=0 //击中数量 hit_count:number=0 //击中数量
@@ -21,7 +21,7 @@ export class SDataCom extends ecs.Comp {
this.group=BoxSet.HERO this.group=BoxSet.HERO
this.fac=0 this.fac=0
this.s_uuid=0 this.s_uuid=0
this.skill_lv=1 this.skill_lv=0
this.casterEid = -1; this.casterEid = -1;
this.hit_count=0 this.hit_count=0
this.max_hit_count=0 this.max_hit_count=0

View File

@@ -101,7 +101,7 @@ export class Skill extends ecs.Entity {
this.addComponents<SMoveDataComp>(SMoveDataComp); this.addComponents<SMoveDataComp>(SMoveDataComp);
} }
load(startPos: Vec3, parent: Node, s_uuid: number, targetPos: Vec3, load(startPos: Vec3, parent: Node, s_uuid: number, targetPos: Vec3,
caster:HeroViewComp,cAttrsComp:HeroAttrsComp, skill_lv:number=1, ext_dmg:number=0) { caster:HeroViewComp,cAttrsComp:HeroAttrsComp, skill_lv:number=0, ext_dmg:number=0) {
const config = SkillSet[s_uuid]; const config = SkillSet[s_uuid];
if (!config) { if (!config) {
mLogger.error(this.debugMode, 'Skill', "[Skill] 技能配置不存在:", s_uuid); mLogger.error(this.debugMode, 'Skill', "[Skill] 技能配置不存在:", s_uuid);
@@ -205,17 +205,17 @@ export class Skill extends ecs.Entity {
sDataCom.casterEid=caster.ent.eid sDataCom.casterEid=caster.ent.eid
sDataCom.Attrs = {}; sDataCom.Attrs = {};
const SUp=SkillUpList[s_uuid] ? SkillUpList[s_uuid]:SkillUpList[1001]; const SUp=SkillUpList[s_uuid] ? SkillUpList[s_uuid]:SkillUpList[1001];
const sCrt = (config.crt ?? 0)+SUp.crt*skill_lv; const sCrt = (config.crt ?? 0)+(SUp.crt*skill_lv);
const sFrz = (config.frz ?? 0)+SUp.frz*skill_lv; const sFrz = (config.frz ?? 0)+(SUp.frz*skill_lv);
const sBck = (config.bck ?? 0)+SUp.bck*skill_lv; const sBck = (config.bck ?? 0)+(SUp.bck*skill_lv);
const sAp =config.ap+SUp.ap*skill_lv; const sAp =config.ap+(SUp.ap*skill_lv);
const sHit=config.hit_count+SUp.hit_count*skill_lv + cAttrsComp.puncture const sHit=config.hit_count+(SUp.hit_count*skill_lv) + cAttrsComp.puncture
sDataCom.Attrs[Attrs.ap] = Math.floor(cAttrsComp.ap*sAp/100); sDataCom.Attrs[Attrs.ap] = Math.floor(cAttrsComp.ap*sAp/100);
sDataCom.Attrs[Attrs.critical] = cAttrsComp.critical + sCrt; sDataCom.Attrs[Attrs.critical] = cAttrsComp.critical + sCrt;
sDataCom.Attrs[Attrs.freeze_chance] = cAttrsComp.freeze_chance + sFrz; sDataCom.Attrs[Attrs.freeze_chance] = cAttrsComp.freeze_chance + sFrz;
sDataCom.Attrs[Attrs.back_chance] = cAttrsComp.back_chance + sBck; sDataCom.Attrs[Attrs.back_chance] = cAttrsComp.back_chance + sBck;
sDataCom.s_uuid=s_uuid sDataCom.s_uuid=s_uuid
sDataCom.skill_lv = Math.max(1, skill_lv); sDataCom.skill_lv = Math.max(0, skill_lv);
sDataCom.fac=cAttrsComp.fac sDataCom.fac=cAttrsComp.fac
sDataCom.ext_dmg=ext_dmg sDataCom.ext_dmg=ext_dmg
sDataCom.hit_count = 0 sDataCom.hit_count = 0