refactor(skill): 重构命中次数计算逻辑,移除冗余字段

- 将命中次数计算从 SkillView 移至 Skill 初始化,统一计算逻辑
- 移除 SkillConfig 接口中的 hit 字段,使用 hit_count 统一表示可命中次数
- 更新注释说明,hit_count 表示可命中次数而非攻击目标数量
- 清理 SkillView 中冗余的命中次数初始化代码
- 调整技能配置数据,移除所有 hit 字段值
This commit is contained in:
panw
2026-03-16 10:08:54 +08:00
parent 4e393b48b9
commit d4eeedb2f6
3 changed files with 21 additions and 26 deletions

View File

@@ -123,9 +123,8 @@ export enum EType {
4. 数值参数:
- ap: 攻击力百分比
- cd: 冷却时间
- hit_count: 范围攻击 伤害敌人数量
- hit_count: 可命中次数
- t_num: 目标数量
- hit: 穿刺个数
- hitcd: 持续伤害的伤害间隔
- speed: 移动速度
- cost: 消耗值
@@ -183,8 +182,7 @@ export interface SkillConfig {
act:string, // 角色执行的动画
DTType:DTType, // 伤害类型(单体/范围)
ap:number, // 攻击百分比(角色攻击力)
hit_count:number, // 可攻击目标数量
hit:number, // 穿刺个数
hit_count:number, // 可命中次数
hitcd:number, // 持续伤害的伤害间隔(秒)
speed:number, // 移动速度
with:number, // 宽度(暂时无用)
@@ -205,56 +203,56 @@ export interface SkillConfig {
export const SkillSet: Record<number, SkillConfig> = {
5000:{uuid:5000,name:"反伤",sp_name:"thorns",icon:"1168",TGroup:TGroup.Enemy,TType:TType.Frontline,readyAnm:"",endAnm:"",act:"atk",DTType:DTType.single,
ap:0,hit_count:1,hit:1,hitcd:0.2,speed:720,with:0,
ap:0,hit_count:1,hitcd:0.2,speed:720,with:0,
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
buffs:[],debuffs:[],info:"反伤",
},
// ========== 基础攻击 ========== 6001-6099
6001: {
uuid:6001,name:"空挥",sp_name:"atk_s1",icon:"1026",TGroup:TGroup.Enemy,TType:TType.Frontline,readyAnm:"",endAnm:"",act:"atk",DTType:DTType.single,
ap:100,hit_count:1,hit:1,hitcd:0.2,speed:720,with:0,
ap:100,hit_count:1,hitcd:0.2,speed:720,with:0,
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.collision,
buffs:[],debuffs:[],info:"对前方目标造成100%攻击的伤害",
},
6002: {
uuid:6002,name:"电击",sp_name:"atk_s4",icon:"1173",TGroup:TGroup.Enemy,TType:TType.Frontline,readyAnm:"",endAnm:"",act:"max",DTType:DTType.single,
ap:100,hit_count:1,hit:1,hitcd:0.2,speed:720,with:0,
ap:100,hit_count:1,hitcd:0.2,speed:720,with:0,
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
buffs:[],debuffs:[],info:"对前方目标造成150%攻击的伤害",
},
6003: {
uuid:6003,name:"闪击",sp_name:"atk_s1",icon:"1173",TGroup:TGroup.Enemy,TType:TType.Frontline,readyAnm:"",endAnm:"",act:"max",DTType:DTType.single,
ap:100,hit_count:1,hit:1,hitcd:0.2,speed:720,with:0,
ap:100,hit_count:1,hitcd:0.2,speed:720,with:0,
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
buffs:[],debuffs:[],info:"对前方目标造成150%攻击的伤害",
},
6004: {
uuid:6004,name:"火焰击",sp_name:"atk_f2",icon:"1173",TGroup:TGroup.Enemy,TType:TType.Frontline,readyAnm:"",endAnm:"",act:"max",DTType:DTType.single,
ap:100,hit_count:6,hit:1,hitcd:0.2,speed:720,with:0,
ap:100,hit_count:6,hitcd:0.2,speed:720,with:0,
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
buffs:[],debuffs:[],info:"对前方目标造成150%攻击的伤害",
},
6005: {
uuid:6005,name:"蓝箭",sp_name:"arrow_blue",icon:"1135",TGroup:TGroup.Enemy,TType:TType.Frontline,readyAnm:"",endAnm:"",act:"atk",DTType:DTType.single,
ap:100,hit_count:1,hit:1,hitcd:0.2,speed:720,with:0,
ap:100,hit_count:1,hitcd:0.2,speed:720,with:0,
ready:0,EAnm:0,DAnm:9001,RType:RType.linear,EType:EType.collision,
buffs:[],debuffs:[],info:"对前方单个目标造成100%攻击的伤害",
},
6006: {
uuid:6006,name:"绿箭",sp_name:"arrow_green",icon:"1135",TGroup:TGroup.Enemy,TType:TType.Frontline,readyAnm:"",endAnm:"",act:"atk",DTType:DTType.single,
ap:100,hit_count:1,hit:1,hitcd:0.2,speed:720,with:0,
ap:100,hit_count:1,hitcd:0.2,speed:720,with:0,
ready:0,EAnm:0,DAnm:9001,RType:RType.linear,EType:EType.animationEnd,
buffs:[],debuffs:[],info:"对前方单个目标造成100%攻击的伤害",
},
6007: {
uuid:6007,name:"红箭",sp_name:"arrow_red",icon:"1135",TGroup:TGroup.Enemy,TType:TType.Frontline,readyAnm:"",endAnm:"",act:"atk",DTType:DTType.single,
ap:100,hit_count:1,hit:1,hitcd:0.2,speed:720,with:0,
ap:100,hit_count:1,hitcd:0.2,speed:720,with:0,
ready:0,EAnm:0,DAnm:9001,RType:RType.linear,EType:EType.animationEnd,
buffs:[],debuffs:[],info:"对前方单个目标造成100%攻击的伤害",
},
6008: {
uuid:6008,name:"水球",sp_name:"ball_water",icon:"1126",TGroup:TGroup.Enemy,TType:TType.Frontline,readyAnm:"",endAnm:"",act:"atk",DTType:DTType.single,
ap:100,hit_count:1,hit:2,hitcd:0.3,speed:720,with:90,
ap:100,hit_count:2,hitcd:0.3,speed:720,with:90,
ready:8001,EAnm:0,DAnm:9001,RType:RType.linear,EType:EType.collision,
buffs:[],debuffs:[],info:"对前方单个目标造成100%攻击的伤害",
},
@@ -262,25 +260,25 @@ export const SkillSet: Record<number, SkillConfig> = {
//============================= ====== 基础buff ====== ========================== 6100-6199
6100: {
uuid:6100,name:"治疗",sp_name:"buff_wind",icon:"1292",TGroup:TGroup.Self,TType:TType.LowestHP,readyAnm:"",endAnm:"",act:"atk",DTType:DTType.single,
ap:30,hit_count:1,hit:1,hitcd:0.2,speed:720,with:0,
ap:30,hit_count:1,hitcd:0.2,speed:720,with:0,
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
kind:SkillKind.Heal,buffs:[],debuffs:[],info:"治疗自己,回复30%最大生命值",
},
6101:{
uuid:6101,name:"魔法盾",sp_name:"buff_wind",icon:"1255",TGroup:TGroup.Self,TType:TType.LowestHP,readyAnm:"",endAnm:"",act:"atk",DTType:DTType.single,
ap:30,hit_count:1,hit:1,hitcd:0.2,speed:720,with:0,
ap:30,hit_count:1,hitcd:0.2,speed:720,with:0,
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
kind:SkillKind.Shield,buffs:[],debuffs:[],info:"获得30%最大生命值的护盾,持续60秒",
},
6102:{
uuid:6102,name:"强壮",sp_name:"buff_wind",icon:"3036",TGroup:TGroup.Team,TType:TType.HighestAP,readyAnm:"",endAnm:"",act:"atk",DTType:DTType.single,
ap:30,hit_count:1,hit:1,hitcd:0.2,speed:720,with:0,
ap:30,hit_count:1,hitcd:0.2,speed:720,with:0,
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
kind:SkillKind.Support,buffs:[10001],debuffs:[],info:"增加目标10%攻击力,持续30秒",
},
6103:{
uuid:6103,name:"群体强壮",sp_name:"buff_wind",icon:"3036",TGroup:TGroup.Team,TType:TType.HighestAP,readyAnm:"",endAnm:"",act:"atk",DTType:DTType.range,
ap:30,hit_count:1,hit:1,hitcd:0.2,speed:720,with:0,
ap:30,hit_count:1,hitcd:0.2,speed:720,with:0,
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
kind:SkillKind.Support,buffs:[10011],debuffs:[],info:"增加目标10%攻击力,持续30秒",
},
@@ -288,14 +286,14 @@ export const SkillSet: Record<number, SkillConfig> = {
6201: {
uuid:6201, name:"怪物近战", sp_name:"atk_s1", icon:"3036",
TGroup:TGroup.Enemy, TType:TType.Frontline, readyAnm:"",endAnm:"",act:"atk", DTType:DTType.single,
ap:100, hit_count:1, hit:1, hitcd:0.2, speed:0, with:0, // 怪物近战特殊距离
ap:100, hit_count:1, hitcd:0.2, speed:0, with:0, // 怪物近战特殊距离
ready:0, EAnm:0, DAnm:9001, RType:RType.fixed, EType:EType.animationEnd,
buffs:[], debuffs:[], info:"怪物基础近战攻击",
},
6203: {
uuid:6203, name:"怪物射击", sp_name:"arrow_1", icon:"3039",
TGroup:TGroup.Enemy, TType:TType.Frontline, readyAnm:"",endAnm:"",act:"atk", DTType:DTType.single,
ap:80, hit_count:1, hit:1, hitcd:0.2, speed:800, with:0, // 怪物远程特殊距离
ap:80, hit_count:1, hitcd:0.2, speed:800, with:0, // 怪物远程特殊距离
ready:0, EAnm:0, DAnm:9001, RType:RType.linear, EType:EType.collision,
buffs:[], debuffs:[], info:"怪物基础远程攻击",
},

View File

@@ -182,6 +182,8 @@ export class Skill extends ecs.Entity {
sDataCom.s_uuid=s_uuid
sDataCom.fac=cAttrsComp.fac
sDataCom.ext_dmg=ext_dmg
sDataCom.hit_count = 0
sDataCom.max_hit_count = Math.max(1, config.hit_count + cAttrsComp.puncture)
SView.init();
}

View File

@@ -4,7 +4,6 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu
import { HeroViewComp } from "../hero/HeroViewComp";
import { BuffsList, DTType, EType, RType, SkillConfig, SkillSet } from "../common/config/SkillSet";
import { SDataCom } from "./SDataCom";
import { Attrs } from "../common/config/HeroAttrs";
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
import { DamageQueueHelper } from "../hero/DamageQueueComp";
import { mLogger } from "../common/Logger";
@@ -58,12 +57,6 @@ export class SkillView extends CCComp {
anim.play(anim.defaultClip.name);
}
}
if (this.sData) {
this.sData.hit_count = 0;
const punctureCount = this.sData.Attrs?.[Attrs.puncture] ?? 0;
const baseHitCount = this.SConf?.hit ?? 0;
this.sData.max_hit_count = baseHitCount + punctureCount;
}
}
onBeginContact (seCol: Collider2D, oCol: Collider2D) {
if (!this.sData || !this.SConf) {
@@ -105,6 +98,8 @@ export class SkillView extends CCComp {
}
// //动画帧事件 atk 触发
public atk(args:any){
if(!this.SConf) return;
if(this.SConf.EType==EType.collision) return
if (this.enable_collider_safely()) {
mLogger.log(this.debugMode, 'SkillView', `[SkillView] [${this.SConf?.name}] 开启碰撞检测`);
this.scheduleOnce(() => {