From 0f5659137623905dd22c5376851022fb24b33c3f Mon Sep 17 00:00:00 2001 From: walkpan Date: Sun, 22 Mar 2026 16:25:46 +0800 Subject: [PATCH] =?UTF-8?q?refactor(skill):=20=E9=87=8D=E6=9E=84=E6=8A=80?= =?UTF-8?q?=E8=83=BD=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84=E5=B9=B6=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=8A=80=E8=83=BD=E7=AD=89=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 HeroAttrsComp 中的技能数组和独立 CD 映射重构为统一的 HSkillInfo 对象记录 - 在 SDataCom 中新增 skill_lv 字段,并在 Skill 加载时传入技能等级 - 更新 Hero 和 Monster 初始化逻辑以适配新的技能数据结构 - 修改 SCastSystem 以传递技能等级并影响技能效果 - 更新 heroSet 配置,将 skills 字段类型改为 Record --- assets/script/game/common/config/heroSet.ts | 62 +++++++++-------- assets/script/game/hero/Hero.ts | 8 ++- assets/script/game/hero/HeroAttrsComp.ts | 74 ++++++++------------- assets/script/game/hero/Mon.ts | 7 +- assets/script/game/hero/SCastSystem.ts | 28 ++++---- assets/script/game/skill/SDataCom.ts | 2 + assets/script/game/skill/Skill.ts | 4 +- 7 files changed, 92 insertions(+), 93 deletions(-) diff --git a/assets/script/game/common/config/heroSet.ts b/assets/script/game/common/config/heroSet.ts index 789f1939..56fb9f4f 100644 --- a/assets/script/game/common/config/heroSet.ts +++ b/assets/script/game/common/config/heroSet.ts @@ -67,12 +67,18 @@ export interface heroInfo { ap: number; // 攻击力 // dis: number; // 攻击距离(像素) speed: number; // 移动速度(像素/秒) - skills: number[]; // 携带技能ID列表 - slvs:number[]; // 技能等级 - cds:number[]; // 技能cd + skills: Record ; // 携带技能ID列表 info: string; // 描述文案 } - +/** + * 英雄/怪物基础信息接口 + */ +export interface HSkillInfo { + uuid: number; // 唯一标识(英雄5000段,怪物5200段) + lv:number; // 技能等级 + cd:number; // 技能cd + ccd:number; // 占位当前cd,用于cd计时 +} /* *=============英雄配置列表================ * 英雄规则设定 @@ -91,47 +97,47 @@ export interface heroInfo { export const HeroInfo: Record = { // ========== 近战英雄 ========== 5001:{uuid:5001,name:"盾战士",path:"hk1", fac:FacSet.HERO,cards_lv:1,lv:1,type:HType.Melee,hp:450,ap:25,speed:180, - skills:[6001,6301],slvs:[1,1],cds:[0.75,5],info:"近战,魔法盾 坦克"}, + skills:{6001:{uuid:6001,lv:1,cd:0.75,ccd:0},6301:{uuid:6301,lv:1,cd:5,ccd:0}},info:"近战,魔法盾 坦克"}, 5002:{uuid:5002,name:"圣骑士",path:"hk3", fac:FacSet.HERO,cards_lv:3,lv:1,type:HType.Melee,hp:1350,ap:75,speed:180, - skills:[6001,6305],slvs:[1,1],cds:[0.75,5],info:"近战,群体护盾 坦克"}, + skills:{6001:{uuid:6001,lv:1,cd:0.75,ccd:0},6305:{uuid:6305,lv:1,cd:5,ccd:0}},info:"近战,群体护盾 坦克"}, 5003:{uuid:5003,name:"风行剑士",path:"hk4", fac:FacSet.HERO,cards_lv:2,lv:1,type:HType.Melee,hp:500,ap:100,speed:180, - skills:[6001,6014],slvs:[1,1],cds:[1.1,5],info:"近战,闪击 近战dps"}, + skills:{6001:{uuid:6001,lv:1,cd:1.1,ccd:0},6014:{uuid:6014,lv:1,cd:5,ccd:0}},info:"近战,闪击 近战dps"}, 5004:{uuid:5004,name:"刺客",path:"hc1", fac:FacSet.HERO,cards_lv:4,lv:1,type:HType.Melee,hp:1000,ap:200,speed:180, - skills:[6001,6104],slvs:[1,1],cds:[1.1,5],info:"近战,火焰击 近战dps"}, + skills:{6001:{uuid:6001,lv:1,cd:1.1,ccd:0},6104:{uuid:6104,lv:1,cd:5,ccd:0}},info:"近战,火焰击 近战dps"}, // 5005:{uuid:5005,name:"自然骑士",path:"hk2", fac:FacSet.HERO,cards_lv:4,lv:1,type:HType.Melee,hp:1000,ap:200,speed:180, // skills:[6001,6302],slvs:[1,1],cds:[1.1,5],info:"治疗近战,火焰击 近战dps"}, // ========== 法师英雄 ========== 5101:{uuid:5101,name:"奥术法师",path:"hm2", fac:FacSet.HERO,cards_lv:1,lv:1,type:HType.Long,hp:150,ap:60,speed:100, - skills:[6005,6012],slvs:[1,1],cds:[1.4,5],info:"冰球,冰锥 远法dps"}, + skills:{6005:{uuid:6005,lv:1,cd:1.4,ccd:0},6012:{uuid:6012,lv:1,cd:5,ccd:0}},info:"冰球,冰锥 远法dps"}, 5102:{uuid:5012,name:"火焰法师",path:"hm1", fac:FacSet.HERO,cards_lv:2,lv:1,type:HType.Long,hp:300,ap:120,speed:100, - skills:[6004,6013],slvs:[1,1],cds:[1.4,5],info:"火击,火球 远法dps"}, + skills:{6004:{uuid:6004,lv:1,cd:1.4,ccd:0},6013:{uuid:6013,lv:1,cd:5,ccd:0}},info:"火击,火球 远法dps"}, 5103:{uuid:5013,name:"冰法法师",path:"hm4", fac:FacSet.HERO,cards_lv:3,lv:1,type:HType.Long,hp:450,ap:180,speed:100, - skills:[6003,6012],slvs:[1,1],cds:[1.4,5],info:"冰击,冰锥 远法dps"}, + skills:{6003:{uuid:6003,lv:1,cd:1.4,ccd:0},6012:{uuid:6012,lv:1,cd:5,ccd:0}},info:"冰击,冰锥 远法dps"}, 5104:{uuid:5104,name:"寒霜术士",path:"hm4", fac:FacSet.HERO,cards_lv:4,lv:1,type:HType.Long,hp:600,ap:240,speed:100, - skills:[6012,6202],slvs:[1,1],cds:[1.4,5],info:"冰锥,冰刺 远法dps"}, + skills:{6012:{uuid:6012,lv:1,cd:1.4,ccd:0},6202:{uuid:6202,lv:1,cd:5,ccd:0}},info:"冰锥,冰刺 远法dps"}, 5105:{uuid:5105,name:"炎爆法师",path:"hm3", fac:FacSet.HERO,cards_lv:5,lv:1,type:HType.Long,hp:750,ap:300,speed:100, - skills:[6013,6201],slvs:[1,1],cds:[1.4,5],info:"火球,陨石术 远法dps" }, + skills:{6013:{uuid:6013,lv:1,cd:1.4,ccd:0},6201:{uuid:6201,lv:1,cd:5,ccd:0}},info:"火球,陨石术 远法dps" }, // ========== 远程英雄 ========== 5201:{uuid:5201,name:"射手",path:"ha1", fac:FacSet.HERO,cards_lv:1,lv:1,type:HType.Long,hp:150,ap:60,speed:120, - skills:[6002,6011],slvs:[1,1],cds:[1.3,5],info:"普通射击,暴射 远dps"}, + skills:{6002:{uuid:6002,lv:1,cd:1.3,ccd:0},6011:{uuid:6011,lv:1,cd:5,ccd:0}},info:"普通射击,暴射 远dps"}, 5202:{uuid:5202,name:"游侠",path:"ha2", fac:FacSet.HERO,cards_lv:3,lv:1,type:HType.Long,hp:450,ap:180,speed:120, - skills:[6011,6101],slvs:[1,1],cds:[1.3,5],info:"暴射,光箭 远dps"}, + skills:{6011:{uuid:6011,lv:1,cd:1.3,ccd:0},6101:{uuid:6101,lv:1,cd:5,ccd:0}},info:"暴射,光箭 远dps"}, // ========== 腐竹英雄 ========== 5301:{uuid:5301,name:"牧师",path:"hh1", fac:FacSet.HERO,cards_lv:1,lv:1,type:HType.Long,hp:150,ap:20,speed:100, - skills:[6012,6302],slvs:[1,1],cds:[1,5],info:"冰锥1,治疗 远辅助" }, + skills:{6012:{uuid:6012,lv:1,cd:1,ccd:0},6302:{uuid:6302,lv:1,cd:5,ccd:0}},info:"冰锥1,治疗 远辅助" }, 5302:{uuid:5302,name:"战地医师",path:"hz1", fac:FacSet.HERO,cards_lv:2,lv:1,type:HType.Mid,hp:300,ap:40,speed:100, - skills:[6012,6304],slvs:[1,1],cds:[1,5],info:"冰锥1,群体治疗 远辅助"}, + skills:{6012:{uuid:6012,lv:1,cd:1,ccd:0},6304:{uuid:6304,lv:1,cd:5,ccd:0}},info:"冰锥1,群体治疗 远辅助"}, 5303:{uuid:5303,name:"守护祭司",path:"ha3", fac:FacSet.HERO,cards_lv:4,lv:1,type:HType.Mid,hp:600,ap:80,speed:100, - skills:[6002,6004],slvs:[1,1],cds:[1,5],info:"普通射击,单体攻击buff 射手辅助"}, + skills:{6002:{uuid:6002,lv:1,cd:1,ccd:0},6004:{uuid:6004,lv:1,cd:5,ccd:0}},info:"普通射击,单体攻击buff 射手辅助"}, 5304:{uuid:5304,name:"秘法精灵",path:"ha3", fac:FacSet.HERO,cards_lv:6,lv:1,type:HType.Long,hp:900,ap:120,speed:100, - skills:[6002,6105],slvs:[1,1],cds:[1,5],info:"普通射击,群体攻击buff 射手辅助"}, + skills:{6002:{uuid:6002,lv:1,cd:1,ccd:0},6105:{uuid:6105,lv:1,cd:5,ccd:0}},info:"普通射击,群体攻击buff 射手辅助"}, @@ -149,20 +155,20 @@ export const HeroInfo: Record = { //============== 兽人系列 =============== // 1. 基础近战型 - 6001:{uuid:6001,name:"兽人战士",path:"mo1", fac:FacSet.MON,cards_lv:1,lv:1,type:HType.Melee,hp:120,ap:12,speed:180,skills:[6001,6003],slvs:[1,1],cds:[0.65,10],info:""}, + 6001:{uuid:6001,name:"兽人战士",path:"mo1", fac:FacSet.MON,cards_lv:1,lv:1,type:HType.Melee,hp:120,ap:12,speed:180,skills:{6001:{uuid:6001,lv:1,cd:0.65,ccd:0},6003:{uuid:6003,lv:1,cd:10,ccd:0}},info:""}, // 2. 快速突击型 - 6002:{uuid:6002,name:"兽人斥候",path:"mo1", fac:FacSet.MON,cards_lv:1,lv:1,type:HType.Melee,hp:120,ap:12,speed:180,skills:[6001,6003],slvs:[1,1],cds:[0.65,10],info:""}, + 6002:{uuid:6002,name:"兽人斥候",path:"mo1", fac:FacSet.MON,cards_lv:1,lv:1,type:HType.Melee,hp:120,ap:12,speed:180,skills:{6001:{uuid:6001,lv:1,cd:0.65,ccd:0},6003:{uuid:6003,lv:1,cd:10,ccd:0}},info:""}, // 3. 重型坦克型 - 6003:{uuid:6003,name:"兽人卫士",path:"mo3", fac:FacSet.MON,cards_lv:1,lv:1,type:HType.Melee,hp:350,ap:30,speed:120,skills:[6001,6003],slvs:[1,1],cds:[2,10],info:""}, + 6003:{uuid:6003,name:"兽人卫士",path:"mo3", fac:FacSet.MON,cards_lv:1,lv:1,type:HType.Melee,hp:350,ap:30,speed:120,skills:{6001:{uuid:6001,lv:1,cd:2,ccd:0},6003:{uuid:6003,lv:1,cd:10,ccd:0}},info:""}, // 4. 远程骚扰型 - 6004:{uuid:6004,name:"兽人射手",path:"mo1", fac:FacSet.MON,cards_lv:1,lv:1,type:HType.Long,hp:80,ap:45,speed:80,skills:[6001,6003],slvs:[1,1],cds:[1.5,10],info:""}, + 6004:{uuid:6004,name:"兽人射手",path:"mo1", fac:FacSet.MON,cards_lv:1,lv:1,type:HType.Long,hp:80,ap:45,speed:80,skills:{6001:{uuid:6001,lv:1,cd:1.5,ccd:0},6003:{uuid:6003,lv:1,cd:10,ccd:0}},info:""}, // 5. 特殊机制型 - 6005:{uuid:6005,name:"兽人自爆兵",path:"mo1", fac:FacSet.MON,cards_lv:1,lv:1,type:HType.Melee,hp:120,ap:12,speed:180,skills:[6001,6003],slvs:[1,1],cds:[0.65,10],info:""}, - 6006:{uuid:6006,name:"兽人召唤师",path:"mo1", fac:FacSet.MON,cards_lv:1,lv:1,type:HType.Melee,hp:80,ap:20,speed:80,skills:[6001,6003],slvs:[1,1],cds:[1,10],info:""}, - 6007:{uuid:6007,name:"兽人祭司",path:"mo1", fac:FacSet.MON,cards_lv:1,lv:1,type:HType.Melee,hp:80,ap:20,speed:80,skills:[6001,6003],slvs:[1,1],cds:[1,10],info:""}, - 6008:{uuid:6008,name:"兽人图腾师",path:"mo1", fac:FacSet.MON,cards_lv:1,lv:1,type:HType.Melee,hp:80,ap:20,speed:80,skills:[6001,6003],slvs:[1,1],cds:[1,10],info:""}, + 6005:{uuid:6005,name:"兽人自爆兵",path:"mo1", fac:FacSet.MON,cards_lv:1,lv:1,type:HType.Melee,hp:120,ap:12,speed:180,skills:{6001:{uuid:6001,lv:1,cd:0.65,ccd:0},6003:{uuid:6003,lv:1,cd:10,ccd:0}},info:""}, + 6006:{uuid:6006,name:"兽人召唤师",path:"mo1", fac:FacSet.MON,cards_lv:1,lv:1,type:HType.Melee,hp:80,ap:20,speed:80,skills:{6001:{uuid:6001,lv:1,cd:1,ccd:0},6003:{uuid:6003,lv:1,cd:10,ccd:0}},info:""}, + 6007:{uuid:6007,name:"兽人祭司",path:"mo1", fac:FacSet.MON,cards_lv:1,lv:1,type:HType.Melee,hp:80,ap:20,speed:80,skills:{6001:{uuid:6001,lv:1,cd:1,ccd:0},6003:{uuid:6003,lv:1,cd:10,ccd:0}},info:""}, + 6008:{uuid:6008,name:"兽人图腾师",path:"mo1", fac:FacSet.MON,cards_lv:1,lv:1,type:HType.Melee,hp:80,ap:20,speed:80,skills:{6001:{uuid:6001,lv:1,cd:1,ccd:0},6003:{uuid:6003,lv:1,cd:10,ccd:0}},info:""}, // 6. 精英/BOSS型 - 6009:{uuid:6009,name:"兽人首领(BOSS)",path:"mo4", fac:FacSet.MON,cards_lv:1,lv:1,type:HType.Melee,hp:1500,ap:20,speed:100,skills:[6002,6004],slvs:[1,1],cds:[1,10],info:""}, + 6009:{uuid:6009,name:"兽人首领(BOSS)",path:"mo4", fac:FacSet.MON,cards_lv:1,lv:1,type:HType.Melee,hp:1500,ap:20,speed:100,skills:{6002:{uuid:6002,lv:1,cd:1,ccd:0},6004:{uuid:6004,lv:1,cd:10,ccd:0}},info:""}, }; diff --git a/assets/script/game/hero/Hero.ts b/assets/script/game/hero/Hero.ts index 0fcf179b..d74c51b0 100644 --- a/assets/script/game/hero/Hero.ts +++ b/assets/script/game/hero/Hero.ts @@ -79,8 +79,12 @@ export class Hero extends ecs.Entity { model.ap = hero.ap*model.lv; model.hp= model.hp_max = hero.hp*model.lv; model.speed = hero.speed; - model.setSkills(hero.skills, hero.cds); - model.skill_lvs=hero.slvs + model.skills = {}; + for (const key in hero.skills) { + const skill = hero.skills[key]; + if (!skill) continue; + model.skills[skill.uuid] = { ...skill, ccd: skill.cd }; + } model.updateSkillDistanceCache(); // 初始化 buff/debuff 系统 diff --git a/assets/script/game/hero/HeroAttrsComp.ts b/assets/script/game/hero/HeroAttrsComp.ts index 947befcc..675f6b6e 100644 --- a/assets/script/game/hero/HeroAttrsComp.ts +++ b/assets/script/game/hero/HeroAttrsComp.ts @@ -1,7 +1,7 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { Attrs } from "../common/config/HeroAttrs"; import { BuffConf } from "../common/config/SkillSet"; -import { HeroDisVal, HType } from "../common/config/heroSet"; +import { HeroDisVal, HSkillInfo, HType } from "../common/config/heroSet"; import { mLogger } from "../common/Logger"; import { Timer } from "db://oops-framework/core/common/timer/Timer"; import { FightSet } from "../common/config/GameSet"; @@ -26,10 +26,7 @@ export class HeroAttrsComp extends ecs.Comp { shield_max: number = 0; // 最大护盾值 // ==================== 攻击属性 (补充) ==================== - skills: number[] = []; - skill_max_cds: Record = {}; - skill_cds: Record = {}; - skill_lvs:Record = {}; + skills: Record = {}; // ==================== 特殊属性 ==================== critical: number = 0; // 暴击率 freeze_chance: number = 0; // 冰冻概率 @@ -159,72 +156,57 @@ export class HeroAttrsComp extends ecs.Comp { this.dirty_shield = true; } updateCD(dt: number){ - for (const skillId of this.skills) { - const maxCd = this.skill_max_cds[skillId] ?? 0; - if (maxCd <= 0) { - this.skill_cds[skillId] = 0; + for (const key in this.skills) { + const skill = this.skills[key]; + if (!skill) continue; + if (skill.cd <= 0) { + skill.ccd = 0; continue; } - const currentCd = this.skill_cds[skillId] ?? maxCd; - if (currentCd >= maxCd) { - this.skill_cds[skillId] = maxCd; + if (skill.ccd >= skill.cd) { + skill.ccd = skill.cd; continue; } - this.skill_cds[skillId] = Math.min(maxCd, currentCd + dt); + skill.ccd = Math.min(skill.cd, skill.ccd + dt); } } isFrost(): boolean { return this.frost_end_time > 0 } - setSkills(skills: number[], cds: number[]) { - this.skills = []; - this.skill_max_cds = {}; - this.skill_cds = {}; - if (!skills) return; - const len = skills.length; - for (let i = 0; i < len; i++) { - const skillId = skills[i]; - if (!skillId) continue; - const cd = cds[i] ?? cds[0] ?? 0; - const maxCd = Math.max(0, cd); - this.skills.push(skillId); - this.skill_max_cds[skillId] = maxCd; - this.skill_cds[skillId] = maxCd; - } + getSkillLevel(skillId: number): number { + if (!skillId) return 1; + return this.skills[skillId]?.lv ?? 1; } getSkillIds(): number[] { - return [...this.skills]; + return Object.values(this.skills).map(skill => skill.uuid); } isSkillReady(skillId: number): boolean { if (!skillId) return false; - const maxCd = this.skill_max_cds[skillId] ?? 0; - if (maxCd <= 0) return true; - const currentCd = this.skill_cds[skillId] ?? maxCd; - return currentCd >= maxCd; + const skill = this.skills[skillId]; + if (!skill) return false; + if (skill.cd <= 0) return true; + return skill.ccd >= skill.cd; } triggerSkillCD(skillId: number) { if (!skillId) return; - const maxCd = this.skill_max_cds[skillId] ?? 0; - if (maxCd <= 0) { - this.skill_cds[skillId] = 0; - return; - } - this.skill_cds[skillId] = 0; + const skill = this.skills[skillId]; + if (!skill) return; + skill.ccd = 0; } getSkillCdProgress(skillId: number): number { if (!skillId) return 1; - const maxCd = this.skill_max_cds[skillId] ?? 0; - if (maxCd <= 0) return 1; - const currentCd = this.skill_cds[skillId] ?? maxCd; - return Math.max(0, Math.min(1, currentCd / maxCd)); + const skill = this.skills[skillId]; + if (!skill || skill.cd <= 0) return 1; + return Math.max(0, Math.min(1, skill.ccd / skill.cd)); } getDisplaySkillCdProgress(): number { - const displaySkillId = this.skills[1] ?? this.skills[0] ?? 0; + const skillIds = this.getSkillIds(); + const displaySkillId = skillIds[1] ?? skillIds[0] ?? 0; return this.getSkillCdProgress(displaySkillId); } @@ -282,9 +264,7 @@ export class HeroAttrsComp extends ecs.Comp { this.shield_max = 0; // 重置新增属性 - this.skills = []; - this.skill_max_cds = {}; - this.skill_cds = {}; + this.skills = {}; this.critical = 0; this.freeze_chance = 0; this.back_chance = 0; diff --git a/assets/script/game/hero/Mon.ts b/assets/script/game/hero/Mon.ts index 8225c460..976ca386 100644 --- a/assets/script/game/hero/Mon.ts +++ b/assets/script/game/hero/Mon.ts @@ -141,7 +141,12 @@ export class Monster extends ecs.Entity { if(!model.is_boss){ model.is_kalami = true; } - model.setSkills(hero.skills, hero.cds); + model.skills = {}; + for (const key in hero.skills) { + const skill = hero.skills[key]; + if (!skill) continue; + model.skills[skill.uuid] = { ...skill, ccd: skill.cd }; + } model.updateSkillDistanceCache(); //根据刷怪控制脚本对ap和hp进行加强 diff --git a/assets/script/game/hero/SCastSystem.ts b/assets/script/game/hero/SCastSystem.ts index 454a6ac1..8801d3a2 100644 --- a/assets/script/game/hero/SCastSystem.ts +++ b/assets/script/game/hero/SCastSystem.ts @@ -23,7 +23,7 @@ import { HType } from "../common/config/heroSet"; @ecs.register('SCastSystem') export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate { debugMode: boolean = false; // 是否启用调试模式 - private readonly emptyCastPlan = { skillId: 0, isFriendly: false, targetPos: null as Vec3 | null, targetEids: [] as number[] }; + private readonly emptyCastPlan = { skillId: 0, skillLv: 1, isFriendly: false, targetPos: null as Vec3 | null, targetEids: [] as number[] }; private readonly meleeCastRange = 64; private heroMatcher: ecs.IMatcher | null = null; private getHeroMatcher(): ecs.IMatcher { @@ -52,7 +52,7 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate this.castSkill(castPlan, heroAttrs, heroView); } - private pickCastSkill(heroAttrs: HeroAttrsComp, heroView: HeroViewComp): { skillId: number; isFriendly: boolean; targetPos: Vec3 | null; targetEids: number[] } { + private pickCastSkill(heroAttrs: HeroAttrsComp, heroView: HeroViewComp): { skillId: number; skillLv: number; isFriendly: boolean; targetPos: Vec3 | null; targetEids: number[] } { const type = heroAttrs.type as HType; const maxRange = this.resolveMaxCastRange(heroAttrs, type); const target = this.findNearestEnemyInRange(heroAttrs, heroView, maxRange); @@ -63,26 +63,28 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate const config = SkillSet[s_uuid]; if (!config) continue; if (!heroAttrs.isSkillReady(s_uuid)) continue; + const skillLv = heroAttrs.getSkillLevel(s_uuid); if (this.isSelfSkill(config.TGroup)) { if (typeof selfEid !== "number") continue; - return { skillId: s_uuid, isFriendly: true, targetPos: null, targetEids: [selfEid] }; + return { skillId: s_uuid, skillLv, isFriendly: true, targetPos: null, targetEids: [selfEid] }; } if (this.isFriendlySkill(config.TGroup)) { const includeSelf = config.TGroup === TGroup.Ally; const friendlyEids = this.collectFriendlyTargetEids(heroAttrs.fac, selfEid, includeSelf); if (friendlyEids.length === 0) continue; - return { skillId: s_uuid, isFriendly: true, targetPos: null, targetEids: friendlyEids }; + return { skillId: s_uuid, skillLv, isFriendly: true, targetPos: null, targetEids: friendlyEids }; } if (!target || !heroView.node || !target.node) continue; const targetPos = this.resolveEnemyCastTargetPos(config, heroAttrs, heroView, target, maxRange); if (!targetPos) continue; - return { skillId: s_uuid, isFriendly: false, targetPos, targetEids: [] }; + return { skillId: s_uuid, skillLv, isFriendly: false, targetPos, targetEids: [] }; } return this.emptyCastPlan; } - private castSkill(castPlan: { skillId: number; isFriendly: boolean; targetPos: Vec3 | null; targetEids: number[] }, heroAttrs: HeroAttrsComp, heroView: HeroViewComp) { + private castSkill(castPlan: { skillId: number; skillLv: number; isFriendly: boolean; targetPos: Vec3 | null; targetEids: number[] }, heroAttrs: HeroAttrsComp, heroView: HeroViewComp) { const s_uuid = castPlan.skillId; + const skillLv = castPlan.skillLv; const config = SkillSet[s_uuid]; if (!config) return; //播放前摇技能动画 @@ -100,11 +102,11 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate if (castPlan.isFriendly) { const friendlyTargets = this.resolveFriendlyTargets(castPlan.targetEids, heroAttrs.fac); if (friendlyTargets.length === 0) return; - this.applyPrimaryEffect(s_uuid, config, heroView,heroAttrs, friendlyTargets, null); + this.applyPrimaryEffect(s_uuid, skillLv, config, heroView,heroAttrs, friendlyTargets, null); this.applyExtraEffects(config, friendlyTargets); return; } - this.applyPrimaryEffect(s_uuid, config, heroView,heroAttrs, [], castPlan.targetPos); + this.applyPrimaryEffect(s_uuid, skillLv, config, heroView,heroAttrs, [], castPlan.targetPos); }, delay); heroAttrs.triggerSkillCD(s_uuid); } @@ -115,19 +117,19 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate return [...skillIds.slice(1), skillIds[0]]; } - private createSkillEntity(s_uuid: number, caster: HeroViewComp,cAttrsComp: HeroAttrsComp, targetPos: Vec3) { + private createSkillEntity(s_uuid: number, skillLv: number, caster: HeroViewComp,cAttrsComp: HeroAttrsComp, targetPos: Vec3) { if (!caster.node || !caster.node.isValid) return; const parent = caster.node.parent; if (!parent) return; const skill = ecs.getEntity(Skill); - skill.load(caster.node.position.clone(), parent, s_uuid, targetPos.clone(), caster,cAttrsComp, 0); + skill.load(caster.node.position.clone(), parent, s_uuid, targetPos.clone(), caster, cAttrsComp, skillLv, 0); } - private applyPrimaryEffect(s_uuid: number, config: SkillConfig, heroView: HeroViewComp, cAttrsComp: HeroAttrsComp,targets: HeroViewComp[], targetPos: Vec3 | null) { + private applyPrimaryEffect(s_uuid: number, skillLv: number, config: SkillConfig, heroView: HeroViewComp, cAttrsComp: HeroAttrsComp,targets: HeroViewComp[], targetPos: Vec3 | null) { const kind = config.kind ?? SkillKind.Damage; if (kind === SkillKind.Damage) { if (config.ap <= 0 || !targetPos) return; - this.createSkillEntity(s_uuid, heroView,cAttrsComp, targetPos); + this.createSkillEntity(s_uuid, skillLv, heroView,cAttrsComp, targetPos); return; } for (const target of targets) { @@ -189,7 +191,7 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate return eids; } - private hasCastTarget(castPlan: { skillId: number; isFriendly: boolean; targetPos: Vec3 | null; targetEids: number[] }): boolean { + private hasCastTarget(castPlan: { skillId: number; skillLv: number; isFriendly: boolean; targetPos: Vec3 | null; targetEids: number[] }): boolean { if (castPlan.skillId === 0) return false; if (castPlan.isFriendly) return castPlan.targetEids.length > 0; return !!castPlan.targetPos; diff --git a/assets/script/game/skill/SDataCom.ts b/assets/script/game/skill/SDataCom.ts index 8249a632..586db0aa 100644 --- a/assets/script/game/skill/SDataCom.ts +++ b/assets/script/game/skill/SDataCom.ts @@ -11,6 +11,7 @@ export class SDataCom extends ecs.Comp { group:BoxSet=BoxSet.HERO fac: number = 0; // 0:hero 1:monster s_uuid:number=0 + skill_lv:number=1 ext_dmg:number=0 //额外伤害 dmg_ratio:number=1 //伤害比例 hit_count:number=0 //击中数量 @@ -20,6 +21,7 @@ export class SDataCom extends ecs.Comp { this.group=BoxSet.HERO this.fac=0 this.s_uuid=0 + this.skill_lv=1 this.casterEid = -1; this.hit_count=0 this.max_hit_count=0 diff --git a/assets/script/game/skill/Skill.ts b/assets/script/game/skill/Skill.ts index 963ea66f..1adc531a 100644 --- a/assets/script/game/skill/Skill.ts +++ b/assets/script/game/skill/Skill.ts @@ -101,7 +101,7 @@ export class Skill extends ecs.Entity { this.addComponents(SMoveDataComp); } load(startPos: Vec3, parent: Node, s_uuid: number, targetPos: Vec3, - caster:HeroViewComp,cAttrsComp:HeroAttrsComp, ext_dmg:number=0) { + caster:HeroViewComp,cAttrsComp:HeroAttrsComp, skill_lv:number=1, ext_dmg:number=0) { const config = SkillSet[s_uuid]; if (!config) { mLogger.error(this.debugMode, 'Skill', "[Skill] 技能配置不存在:", s_uuid); @@ -212,6 +212,7 @@ export class Skill extends ecs.Entity { sDataCom.Attrs[Attrs.freeze_chance] = cAttrsComp.freeze_chance + addFrz; sDataCom.Attrs[Attrs.back_chance] = cAttrsComp.back_chance + addBck; sDataCom.s_uuid=s_uuid + sDataCom.skill_lv = Math.max(1, skill_lv); sDataCom.fac=cAttrsComp.fac sDataCom.ext_dmg=ext_dmg sDataCom.hit_count = 0 @@ -241,4 +242,3 @@ export class Skill extends ecs.Entity { } } -