feat(战斗系统): 完善伤害计算逻辑并添加元素伤害支持

修改 HeroAtkSystem 的 dmgCount 方法,增加目标属性参数并实现完整的伤害计算逻辑,包括物理/魔法伤害区分、防御减免和元素伤害计算。同时在 SkillSet 配置中新增 map 属性和元素伤害配置,支持冰/火/风三种元素伤害类型。
This commit is contained in:
2025-11-21 10:23:35 +08:00
parent 8a0cfb78dd
commit df23e3787d
2 changed files with 25 additions and 9 deletions

View File

@@ -152,26 +152,28 @@ 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,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 , buffs:BuffConf[],neAttrs:NeAttrsConf[],info:string,hero?:number ,
elem?: { ice?: number; fire?: number; wind?: number }
} }
export const SkillSet: Record<number, SkillConfig> = { export const SkillSet: Record<number, SkillConfig> = {
// ========== 基础攻击 ========== 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,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%攻击的伤害", 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: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%攻击的伤害", 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.MAGE, 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, 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:"召唤大火球攻击前方所有敌人,造成300%攻击的伤害,有一定几率施加灼烧", buffs:[],neAttrs:[],info:"召唤球攻击前方敌人,造成100%魔法攻击的伤害",
elem:{ ice:30 }
}, },
}; };

View File

@@ -158,7 +158,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
const isCrit = this.checkChance(damageEvent.Attrs[Attrs.CRITICAL]); const isCrit = this.checkChance(damageEvent.Attrs[Attrs.CRITICAL]);
if (isCrit) attackerModel?.clearTalBuffByAttr(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) { if (isCrit) {
// 暴击伤害计算 // 暴击伤害计算
// 使用施法者的暴击伤害加成属性damageEvent.Attrs 快照) // 使用施法者的暴击伤害加成属性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]; let sConf = SkillSet[s_uuid];
if (!sConf) return 0; if (!sConf) return 0;
let AP = sConf.ap*CAttrs[Attrs.AP]/100; let apBase = (sConf.ap||0)*CAttrs[Attrs.AP]/100;
return AP; 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);
} }
/** /**
* 处理角色死亡 * 处理角色死亡