refactor(技能系统): 移除技能MP消耗相关逻辑

技能系统不再需要处理MP消耗,简化了技能施放和检查逻辑
This commit is contained in:
walkpan
2026-01-02 23:10:44 +08:00
parent 7d947db6b5
commit 2c7a628921
3 changed files with 25 additions and 33 deletions

View File

@@ -153,57 +153,57 @@ interface IEndAnm {
// 技能配置接口 - 按照6001格式排列 // 技能配置接口 - 按照6001格式排列
export interface SkillConfig { export interface SkillConfig {
uuid:number,name:string,sp_name:string,icon:string,TGroup:TGroup,SType:SType,act:string,DTType:DTType,DType:DType, uuid:number,name:string,sp_name:string,icon:string,TGroup:TGroup,SType:SType,act:string,DTType:DTType,DType:DType,
ap:number,cd:number,t_num:number,hit_num:number,hit:number,hitcd:number,speed:number,cost:number,with:number,dis:Number,ready:number,EAnm:number,DAnm:number,RType:RType,EType:EType, ap:number,cd:number,t_num:number,hit_num:number,hit:number,hitcd:number,speed:number,with:number,dis:Number,ready:number,EAnm:number,DAnm:number,RType:RType,EType:EType,
buffs:BuffConf[],neAttrs:NeAttrsConf[],info:string,hero?:number , buffs:BuffConf[],neAttrs:NeAttrsConf[],info:string,hero?:number ,
} }
export const SkillSet: Record<number, SkillConfig> = { export const SkillSet: Record<number, SkillConfig> = {
5000:{uuid:5000,name:"反伤",sp_name:"thorns",icon:"3036",TGroup:TGroup.Enemy,SType:SType.damage,act:"atk",DTType:DTType.single,DType:DType.ATK, 5000:{uuid:5000,name:"反伤",sp_name:"thorns",icon:"3036",TGroup:TGroup.Enemy,SType:SType.damage,act:"atk",DTType:DTType.single,DType:DType.ATK,
ap:0,cd:60,t_num:1,hit_num:1,hit:1,hitcd:0.2,speed:720,cost:0,with:0,dis:80, ap:0,cd:60,t_num:1,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,dis:80,
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd, ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
buffs:[],neAttrs:[],info:"反伤", buffs:[],neAttrs:[],info:"反伤",
}, },
// ========== 基础攻击 ========== 6001-6099 // ========== 基础攻击 ========== 6001-6099
6001: { 6001: {
uuid:6001,name:"挥击",sp_name:"atk_s1",icon:"3036",TGroup:TGroup.Enemy,SType:SType.damage,act:"atk",DTType:DTType.single,DType:DType.ATK, uuid:6001,name:"挥击",sp_name:"atk_s1",icon:"3036",TGroup:TGroup.Enemy,SType:SType.damage,act:"atk",DTType:DTType.single,DType:DType.ATK,
ap:100,cd:1,t_num:1,hit_num:1,hit:1,hitcd:0.2,speed:720,cost:0,with:0,dis:80, ap:100,cd:1,t_num:1,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,dis:80,
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd, ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
buffs:[],neAttrs:[],info:"向最前方敌人扔出石斧,造成100%攻击的伤害", buffs:[],neAttrs:[],info:"向最前方敌人扔出石斧,造成100%攻击的伤害",
}, },
6002: { 6002: {
uuid:6002,name:"挥砍",sp_name:"atk_s4",icon:"3036",TGroup:TGroup.Enemy,SType:SType.damage,act:"atk",DTType:DTType.single,DType:DType.ATK, uuid:6002,name:"挥砍",sp_name:"atk_s4",icon:"3036",TGroup:TGroup.Enemy,SType:SType.damage,act:"atk",DTType:DTType.single,DType:DType.ATK,
ap:100,cd:1,t_num:1,hit_num:1,hit:1,hitcd:0.2,speed:720,cost:10,with:0,dis:80, ap:100,cd:1,t_num:1,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,dis:80,
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd, ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
buffs:[],neAttrs:[],info:"向最前方敌人扔出石斧,造成100%攻击的伤害", buffs:[],neAttrs:[],info:"向最前方敌人扔出石斧,造成100%攻击的伤害",
}, },
6005: { 6005: {
uuid:6005,name:"水球",sp_name:"m_water_ball_1",icon:"3039",TGroup:TGroup.Enemy,SType:SType.damage,act:"atk",DTType:DTType.single,DType:DType.ICE, uuid:6005,name:"水球",sp_name:"m_water_ball_1",icon:"3039",TGroup:TGroup.Enemy,SType:SType.damage,act:"atk",DTType:DTType.single,DType:DType.ICE,
ap:100,cd:5,t_num:1,hit_num:1,hit:2,hitcd:0.3,speed:720,cost:0,with:90,dis:360, ap:100,cd:5,t_num:1,hit_num:1,hit:2,hitcd:0.3,speed:720,with:90,dis:360,
ready:8001,EAnm:0,DAnm:9001,RType:RType.linear,EType:EType.collision, ready:8001,EAnm:0,DAnm:9001,RType:RType.linear,EType:EType.collision,
buffs:[],neAttrs:[],info:"召唤水球攻击前方敌人,造成100%魔法攻击的伤害", buffs:[],neAttrs:[],info:"召唤水球攻击前方敌人,造成100%魔法攻击的伤害",
}, },
// ========== 基础buff ========== 6100-6199 // ========== 基础buff ========== 6100-6199
6100: { 6100: {
uuid:6100,name:"治疗",sp_name:"buff_wind",icon:"3036",TGroup:TGroup.Self,SType:SType.heal,act:"atk",DTType:DTType.single,DType:DType.ATK, uuid:6100,name:"治疗",sp_name:"buff_wind",icon:"3036",TGroup:TGroup.Self,SType:SType.heal,act:"atk",DTType:DTType.single,DType:DType.ATK,
ap:30,cd:5,t_num:1,hit_num:1,hit:1,hitcd:0.2,speed:720,cost:10,with:0,dis:720, ap:30,cd:5,t_num:1,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,dis:720,
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd, ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
buffs:[],neAttrs:[],info:"治疗自己,回复30%最大生命值", buffs:[],neAttrs:[],info:"治疗自己,回复30%最大生命值",
}, },
6101:{ 6101:{
uuid:6101,name:"魔法盾",sp_name:"buff_wind",icon:"3036",TGroup:TGroup.Self,SType:SType.shield,act:"atk",DTType:DTType.single,DType:DType.WIND, uuid:6101,name:"魔法盾",sp_name:"buff_wind",icon:"3036",TGroup:TGroup.Self,SType:SType.shield,act:"atk",DTType:DTType.single,DType:DType.WIND,
ap:30,cd:7,t_num:1,hit_num:1,hit:1,hitcd:0.2,speed:720,cost:10,with:0,dis:720, ap:30,cd:7,t_num:1,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,dis:720,
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd, ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
buffs:[],neAttrs:[],info:"获得30%最大生命值的护盾,持续60秒", buffs:[],neAttrs:[],info:"获得30%最大生命值的护盾,持续60秒",
}, },
6102:{ 6102:{
uuid:6102,name:"强壮",sp_name:"buff_wind",icon:"3036",TGroup:TGroup.Team,SType:SType.buff,act:"atk",DTType:DTType.single,DType:DType.WIND, uuid:6102,name:"强壮",sp_name:"buff_wind",icon:"3036",TGroup:TGroup.Team,SType:SType.buff,act:"atk",DTType:DTType.single,DType:DType.WIND,
ap:30,cd:10,t_num:1,hit_num:1,hit:1,hitcd:0.2,speed:720,cost:10,with:0,dis:720, ap:30,cd:10,t_num:1,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,dis:720,
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd, ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
buffs:[{buff:Attrs.AP,BType:BType.VALUE,value:10,time:30,chance:1}],neAttrs:[],info:"增加目标10%攻击力,持续30秒", buffs:[{buff:Attrs.AP,BType:BType.VALUE,value:10,time:30,chance:1}],neAttrs:[],info:"增加目标10%攻击力,持续30秒",
}, },
6103:{ 6103:{
uuid:6103,name:"群体强壮",sp_name:"buff_wind",icon:"3036",TGroup:TGroup.Team,SType:SType.buff,act:"atk",DTType:DTType.range,DType:DType.WIND, uuid:6103,name:"群体强壮",sp_name:"buff_wind",icon:"3036",TGroup:TGroup.Team,SType:SType.buff,act:"atk",DTType:DTType.range,DType:DType.WIND,
ap:30,cd:10,t_num:3,hit_num:1,hit:1,hitcd:0.2,speed:720,cost:10,with:0,dis:720, ap:30,cd:10,t_num:3,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,dis:720,
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd, ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
buffs:[{buff:Attrs.AP,BType:BType.RATIO,value:10,time:30,chance:1}],neAttrs:[],info:"增加目标10%攻击力,持续30秒", buffs:[{buff:Attrs.AP,BType:BType.RATIO,value:10,time:30,chance:1}],neAttrs:[],info:"增加目标10%攻击力,持续30秒",
}, },
@@ -211,7 +211,7 @@ export const SkillSet: Record<number, SkillConfig> = {
6201: { 6201: {
uuid:6201, name:"怪物近战", sp_name:"atk_s1", icon:"3036", uuid:6201, name:"怪物近战", sp_name:"atk_s1", icon:"3036",
TGroup:TGroup.Enemy, SType:SType.damage, act:"atk", DTType:DTType.single, DType:DType.ATK, TGroup:TGroup.Enemy, SType:SType.damage, act:"atk", DTType:DTType.single, DType:DType.ATK,
ap:100, cd:1, t_num:1, hit_num:1, hit:1, hitcd:0.2, speed:0, cost:0, with:0, ap:100, cd:1, t_num:1, hit_num:1, hit:1, hitcd:0.2, speed:0, with:0,
dis:50, // 近战距离 dis:50, // 近战距离
ready:0, EAnm:0, DAnm:9001, RType:RType.fixed, EType:EType.animationEnd, ready:0, EAnm:0, DAnm:9001, RType:RType.fixed, EType:EType.animationEnd,
buffs:[], neAttrs:[], info:"怪物基础近战攻击", buffs:[], neAttrs:[], info:"怪物基础近战攻击",
@@ -219,7 +219,7 @@ export const SkillSet: Record<number, SkillConfig> = {
6203: { 6203: {
uuid:6203, name:"怪物射击", sp_name:"arrow_1", icon:"3039", uuid:6203, name:"怪物射击", sp_name:"arrow_1", icon:"3039",
TGroup:TGroup.Enemy, SType:SType.damage, act:"atk", DTType:DTType.single, DType:DType.ATK, TGroup:TGroup.Enemy, SType:SType.damage, act:"atk", DTType:DTType.single, DType:DType.ATK,
ap:80, cd:2, t_num:1, hit_num:1, hit:1, hitcd:0.2, speed:800, cost:0, with:0, ap:80, cd:2, t_num:1, hit_num:1, hit:1, hitcd:0.2, speed:800, with:0,
dis:600, // 远程距离 dis:600, // 远程距离
ready:0, EAnm:0, DAnm:9001, RType:RType.linear, EType:EType.collision, ready:0, EAnm:0, DAnm:9001, RType:RType.linear, EType:EType.collision,
buffs:[], neAttrs:[], info:"怪物基础远程攻击", buffs:[], neAttrs:[], info:"怪物基础远程攻击",
@@ -238,4 +238,4 @@ export const EAnmConf: Record<number, IEndAnm> = {
9001:{uuid:9001,path:"atked",loop:false,time:0}, 9001:{uuid:9001,path:"atked",loop:false,time:0},
}; };

View File

@@ -12,7 +12,6 @@ export interface SkillSlot {
s_uuid: number; // 技能配置ID s_uuid: number; // 技能配置ID
cd: number; // 当前CD时间递减 cd: number; // 当前CD时间递减
cd_max: number; // 最大CD时间 cd_max: number; // 最大CD时间
cost: number; // MP消耗
level: number; // 技能等级(预留) level: number; // 技能等级(预留)
dis: number; // 攻击距离 dis: number; // 攻击距离
hset: HSSet; // 技能设定, 0:普通攻击, 1:一般技能, 2:必杀技 hset: HSSet; // 技能设定, 0:普通攻击, 1:一般技能, 2:必杀技
@@ -66,7 +65,6 @@ export class HeroSkillsComp extends ecs.Comp {
s_uuid: config.uuid, s_uuid: config.uuid,
cd: 0, cd: 0,
cd_max: cdMax, cd_max: cdMax,
cost: config.cost,
level: 1, level: 1,
dis: Number(config.dis), dis: Number(config.dis),
hset: hset, hset: hset,
@@ -97,7 +95,6 @@ export class HeroSkillsComp extends ecs.Comp {
s_uuid: config.uuid, s_uuid: config.uuid,
cd: 0, cd: 0,
cd_max: config.cd, cd_max: config.cd,
cost: config.cost,
level: 1, level: 1,
dis: Number(config.dis), dis: Number(config.dis),
hset: hset, hset: hset,
@@ -126,14 +123,13 @@ export class HeroSkillsComp extends ecs.Comp {
/** /**
* 检查技能是否可施放通过s_uuid * 检查技能是否可施放通过s_uuid
* @param s_uuid 技能配置ID * @param s_uuid 技能配置ID
* @param currentMp 当前MP值
*/ */
canCast(s_uuid: number, currentMp: number): boolean { canCast(s_uuid: number): boolean {
const skill = this.getSkill(s_uuid); const skill = this.getSkill(s_uuid);
if (!skill) return false; if (!skill) return false;
// 检查CD和MP // 检查CD
return skill.cd <= 0 && currentMp >= skill.cost; return skill.cd <= 0;
} }
/** /**
@@ -172,10 +168,10 @@ export class HeroSkillsComp extends ecs.Comp {
/** /**
* 获取所有可施放的技能索引 * 获取所有可施放的技能索引
*/ */
getReadySkills(currentMp: number): number[] { getReadySkills(): number[] {
const ready: number[] = []; const ready: number[] = [];
for (const s_uuid in this.skills) { for (const s_uuid in this.skills) {
if (this.canCast(Number(s_uuid), currentMp)) { if (this.canCast(Number(s_uuid))) {
ready.push(Number(s_uuid)); ready.push(Number(s_uuid));
} }
} }
@@ -208,11 +204,10 @@ export class HeroSkillsComp extends ecs.Comp {
/** /**
* 获取可施放技能中的最远攻击距离 * 获取可施放技能中的最远攻击距离
* @param mp 当前MP值
* @returns 最远攻击距离如果没有可用技能返回0 * @returns 最远攻击距离如果没有可用技能返回0
*/ */
getMaxSkillDistance(mp: number): number { getMaxSkillDistance(): number {
const readySkills = this.getReadySkills(mp); const readySkills = this.getReadySkills();
if (readySkills.length === 0) return 0; if (readySkills.length === 0) return 0;
let maxDistance = 0; let maxDistance = 0;
@@ -227,11 +222,10 @@ export class HeroSkillsComp extends ecs.Comp {
/** /**
* 获取可施放技能中的最近攻击距离 * 获取可施放技能中的最近攻击距离
* @param mp 当前MP值
* @returns 最近攻击距离如果没有可用技能返回0 * @returns 最近攻击距离如果没有可用技能返回0
*/ */
getMinSkillDistance(mp: number): number { getMinSkillDistance(): number {
const readySkills = this.getReadySkills(mp); const readySkills = this.getReadySkills();
if (readySkills.length === 0) return 0; if (readySkills.length === 0) return 0;
let minDistance = Number.MAX_VALUE; let minDistance = Number.MAX_VALUE;

View File

@@ -47,7 +47,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
if (!heroAttrs.is_atking) return; if (!heroAttrs.is_atking) return;
const readySkills = skills.getReadySkills(heroAttrs.mp); const readySkills = skills.getReadySkills();
if (readySkills.length === 0) return; if (readySkills.length === 0) return;
// 选择第一个可施放的技能(支持伤害/治疗/护盾) // 选择第一个可施放的技能(支持伤害/治疗/护盾)
@@ -89,9 +89,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
if (castSucess) { if (castSucess) {
// 🔥 怪物不消耗蓝 // 🔥 怪物不消耗蓝
if (heroAttrs.fac !== FacSet.MON) { if (heroAttrs.fac !== FacSet.MON) {
// 使用 add_mp 确保 MP 不会变成负数,并触发相关更新 // 手动更新技能距离缓存
heroAttrs.add_mp(-skill.cost, true);
// 手动更新技能距离缓存,因为 HeroAttrSystem 无法检测到跨帧的 MP 变化
heroAttrs.updateSkillDistanceCache(skills); heroAttrs.updateSkillDistanceCache(skills);
} }
skills.resetCD(skill.s_uuid); skills.resetCD(skill.s_uuid);
@@ -134,8 +132,8 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
return false; return false;
} }
// 检查CD和MP // 检查CD
if (!skills.canCast(s_uuid, heroAttrs.mp)) { if (!skills.canCast(s_uuid)) {
return false; return false;
} }