From df23e3787df8a4ddfb4365ac0b6392472db4c08a Mon Sep 17 00:00:00 2001 From: panw Date: Fri, 21 Nov 2025 10:23:35 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=88=98=E6=96=97=E7=B3=BB=E7=BB=9F):=20?= =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BC=A4=E5=AE=B3=E8=AE=A1=E7=AE=97=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=B9=B6=E6=B7=BB=E5=8A=A0=E5=85=83=E7=B4=A0=E4=BC=A4?= =?UTF-8?q?=E5=AE=B3=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改 HeroAtkSystem 的 dmgCount 方法,增加目标属性参数并实现完整的伤害计算逻辑,包括物理/魔法伤害区分、防御减免和元素伤害计算。同时在 SkillSet 配置中新增 map 属性和元素伤害配置,支持冰/火/风三种元素伤害类型。 --- assets/script/game/common/config/SkillSet.ts | 12 ++++++----- assets/script/game/hero/HeroAtkSystem.ts | 22 ++++++++++++++++---- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/assets/script/game/common/config/SkillSet.ts b/assets/script/game/common/config/SkillSet.ts index d14f2d68..fa5ed097 100644 --- a/assets/script/game/common/config/SkillSet.ts +++ b/assets/script/game/common/config/SkillSet.ts @@ -152,26 +152,28 @@ interface IEndAnm { // 技能配置接口 - 按照6001格式排列 export interface SkillConfig { 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,map: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, buffs:BuffConf[],neAttrs:NeAttrsConf[],info:string,hero?:number , + elem?: { ice?: number; fire?: number; wind?: number } } export const SkillSet: Record = { // ========== 基础攻击 ========== 6001-6099 6001: { 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,ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd, + ap:100,map:0,cd:1,t_num:1,hit_num:1,hit:1,hitcd:0.2,speed:720,cost:0,with:0,dis:80,ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd, buffs:[],neAttrs:[],info:"向最前方敌人扔出石斧,造成100%攻击的伤害", }, 6002: { 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:0,with:0,dis:80,ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd, + ap:100,map:0,cd:1,t_num:1,hit_num:1,hit:1,hitcd:0.2,speed:720,cost:0,with:0,dis:80,ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd, buffs:[],neAttrs:[],info:"向最前方敌人扔出石斧,造成100%攻击的伤害", }, 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.MAGE, - ap:100,cd:5,t_num:1,hit_num:1,hit:2,hitcd:0.3,speed:720,cost:0,with:90,dis:360,ready:8001,EAnm:0,DAnm:9001,RType:RType.linear,EType:EType.collision, - buffs:[],neAttrs:[],info:"召唤大火球攻击前方所有敌人,造成300%攻击的伤害,有一定几率施加灼烧", + ap:0,map:100,cd:5,t_num:1,hit_num:1,hit:2,hitcd:0.3,speed:720,cost:0,with:90,dis:360,ready:8001,EAnm:0,DAnm:9001,RType:RType.linear,EType:EType.collision, + buffs:[],neAttrs:[],info:"召唤水球攻击前方敌人,造成100%魔法攻击的伤害", + elem:{ ice:30 } }, }; diff --git a/assets/script/game/hero/HeroAtkSystem.ts b/assets/script/game/hero/HeroAtkSystem.ts index d4b80274..1479df91 100644 --- a/assets/script/game/hero/HeroAtkSystem.ts +++ b/assets/script/game/hero/HeroAtkSystem.ts @@ -158,7 +158,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd const isCrit = this.checkChance(damageEvent.Attrs[Attrs.CRITICAL]); if (isCrit) attackerModel?.clearTalBuffByAttr(Attrs.CRITICAL); // 计算伤害 - let damage = this.dmgCount(damageEvent.Attrs,damageEvent.s_uuid); + let damage = this.dmgCount(damageEvent.Attrs,targetAttrs.Attrs,damageEvent.s_uuid); if (isCrit) { // 暴击伤害计算 // 使用施法者的暴击伤害加成属性(damageEvent.Attrs 快照) @@ -215,11 +215,25 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd * - 元素伤害计算 * - 真实伤害/魔法伤害/物理伤害区分 */ - private dmgCount(CAttrs:any,s_uuid:number){ + private dmgCount(CAttrs:any,TAttrs:any,s_uuid:number){ let sConf = SkillSet[s_uuid]; if (!sConf) return 0; - let AP = sConf.ap*CAttrs[Attrs.AP]/100; - return AP; + let apBase = (sConf.ap||0)*CAttrs[Attrs.AP]/100; + let mapBase = (sConf.map||0)*CAttrs[Attrs.MAP]/100; + let apAfter = Math.max(0, Math.floor(apBase - (TAttrs[Attrs.DEF]||0))); + let mapAfter = Math.max(0, Math.floor(mapBase - (TAttrs[Attrs.MDEF]||0))); + mapAfter = Math.floor(mapAfter * (1 - ((TAttrs[Attrs.MAGIC_RES]||0)/100))); + let total = apAfter + mapAfter; + if (sConf.elem){ + const iceR = sConf.elem.ice||0; + if (iceR) total += Math.floor(total * iceR/100 * (1 + ((CAttrs[Attrs.ICE_POWER]||0)/100)) * (1 - ((TAttrs[Attrs.ICE_RES]||0)/100))); + const fireR = sConf.elem.fire||0; + if (fireR) total += Math.floor(total * fireR/100 * (1 + ((CAttrs[Attrs.FIRE_POWER]||0)/100)) * (1 - ((TAttrs[Attrs.FIRE_RES]||0)/100))); + const windR = sConf.elem.wind||0; + if (windR) total += Math.floor(total * windR/100 * (1 + ((CAttrs[Attrs.WIND_POWER]||0)/100)) * (1 - ((TAttrs[Attrs.WIND_RES]||0)/100))); + } + total = Math.floor(total * (1 - ((TAttrs[Attrs.DAMAGE_REDUCTION]||0)/100))); + return Math.max(0,total); } /** * 处理角色死亡