diff --git a/assets/script/game/common/config/heroSet.ts b/assets/script/game/common/config/heroSet.ts index 18c9969f..fdb76c49 100644 --- a/assets/script/game/common/config/heroSet.ts +++ b/assets/script/game/common/config/heroSet.ts @@ -148,37 +148,37 @@ export const CanSelectHeros: Record = { export const HeroInfo: Record = { // ========== 英雄角色 ========== - 5001:{uuid:5001,name:"盾战士",icon:"1001",path:"hk1", fac:FacSet.HERO, kind:1,as:1.5, + 5001:{uuid:5001,name:"盾战士",icon:"1001",path:"hk1", fac:FacSet.HERO, kind:1,as:1, type:HType.warrior,lv:1,hp:300,mp:200,def:5,ap:25,speed:120,skills:[6001,6004], rangeType: SkillRange.Melee, buff:[],tal:[],info:"盾战士"}, - 5002:{uuid:5002,name:"奥术法师",icon:"1001",path:"hm2", fac:FacSet.HERO, kind:2,as:1.5, + 5002:{uuid:5002,name:"奥术法师",icon:"1001",path:"hm2", fac:FacSet.HERO, kind:2,as:1, type:HType.mage,lv:1,hp:150,mp:135,def:0,ap:40,speed:95,skills:[6003,6101], rangeType: SkillRange.Long, buff:[],tal:[],info:"奥术法师"}, - 5003:{uuid:5003,name:"射手",icon:"1001",path:"ha1", fac:FacSet.HERO, kind:2,as:1.2, + 5003:{uuid:5003,name:"射手",icon:"1001",path:"ha1", fac:FacSet.HERO, kind:2,as:1, type:HType.remote,lv:1,hp:180,mp:80,def:0,ap:30,speed:140,skills:[6002,6100], rangeType: SkillRange.Long, buff:[],tal:[],info:"射手"}, - 5005:{uuid:5005,name:"牧师",icon:"1001",path:"hh1", fac:FacSet.HERO, kind:2,as:1.5, + 5005:{uuid:5005,name:"牧师",icon:"1001",path:"hh1", fac:FacSet.HERO, kind:2,as:1, type:HType.mage,lv:1,hp:160,mp:135,def:0,ap:25,speed:100,skills:[6003,6100], rangeType: SkillRange.Mid, buff:[],tal:[],info:"牧师"}, - 5004:{uuid:5004,name:"火焰法师",icon:"1001",path:"hm1", fac:FacSet.HERO, kind:2,as:1.5, + 5004:{uuid:5004,name:"火焰法师",icon:"1001",path:"hm1", fac:FacSet.HERO, kind:2,as:1, type:HType.mage,lv:1,hp:150,mp:140,def:0,ap:45,speed:90,skills:[6003,6101], rangeType: SkillRange.Mid, buff:[],tal:[],info:"火焰法师"}, - 5006:{uuid:5006,name:"召唤法师",icon:"1001",path:"hz1", fac:FacSet.HERO, kind:2,as:1.5, + 5006:{uuid:5006,name:"召唤法师",icon:"1001",path:"hz1", fac:FacSet.HERO, kind:2,as:1, type:HType.support,lv:1,hp:200,mp:145,def:0,ap:20,speed:105,skills:[6003,6101], rangeType: SkillRange.Mid, buff:[],tal:[],info:"召唤法师"}, - 5007:{uuid:5007,name:"刺客",icon:"1001",path:"hc1", fac:FacSet.HERO, kind:1,as:1.2, + 5007:{uuid:5007,name:"刺客",icon:"1001",path:"hc1", fac:FacSet.HERO, kind:1,as:1, type:HType.assassin,lv:1,hp:140,mp:60,def:0,ap:50,speed:180,skills:[6001,6004], rangeType: SkillRange.Melee, buff:[],tal:[],info:"刺客"}, diff --git a/assets/script/game/skill/SkillView.ts b/assets/script/game/skill/SkillView.ts index c0d24a1a..c580a769 100644 --- a/assets/script/game/skill/SkillView.ts +++ b/assets/script/game/skill/SkillView.ts @@ -153,6 +153,8 @@ export class SkillView extends CCComp { //伤害应用 apply_damage(target:HeroViewComp,is_range:boolean=false){ if(target == null) return; + // 安全检查:如果目标实体已不存在,直接返回 + if (!target.ent) return; if (!this.SConf) return; // 对于非持续碰撞类型的技能,在造成伤害后立即关闭碰撞检测 @@ -161,7 +163,12 @@ export class SkillView extends CCComp { this.collider.enabled = false; mLogger.log(this.debugMode, 'SkillView', `[SkillView] [${this.SConf.name}] 伤害后关闭碰撞检测`); } - mLogger.log(this.debugMode, 'SkillView', `[skillView] 伤害 [${this.group}][${this.sData.caster.ent.get(HeroAttrsComp).hero_name}][${this.sData.caster.ent.eid}]的 [${this.SConf.name}]对 [${target.box_group}][ ${target.ent.get(HeroAttrsComp).hero_name}][${target.ent.eid}]`); + + // 安全获取名称,防止实体销毁导致的空指针异常 + const casterName = this.sData.caster?.ent?.get(HeroAttrsComp)?.hero_name ?? "未知施法者"; + const targetName = target.ent.get(HeroAttrsComp)?.hero_name ?? "未知目标"; + + mLogger.log(this.debugMode, 'SkillView', `[skillView] 伤害 [${this.group}][${casterName}][${this.sData.casterEid}]的 [${this.SConf.name}]对 [${target.box_group}][ ${targetName}][${target.ent.eid}]`); // if(this.sData.hit_count > this.SConf.hit_num) return 不能超出 最大伤害数量 // 使用伤害队列系统处理伤害 DamageQueueHelper.addDamageToEntity(