refactor(战斗系统): 修改防御属性为百分比类型并优化伤害计算
- 将物理防御属性从数值型改为百分比型 - 使用 add_hp 方法替代直接修改 hp 以触发 UI 更新 - 重构伤害计算公式,明确防御减免和易伤的计算逻辑 - 调整测试英雄配置,统一使用远程攻击技能
This commit is contained in:
@@ -146,7 +146,7 @@ export const AttrsType: Record<Attrs, BType> = {
|
||||
[Attrs.AREA_OF_EFFECT]: BType.VALUE, // 作用范围 - 数值型
|
||||
|
||||
// ========== 防御属性(混合类型) ==========
|
||||
[Attrs.DEF]: BType.VALUE, // 物理防御 - 数值型
|
||||
[Attrs.DEF]: BType.RATIO, // 物理防御 - 百分比型
|
||||
[Attrs.DODGE]: BType.RATIO, // 闪避率 - 百分比型
|
||||
[Attrs.THORNS]: BType.RATIO, // 反伤 - 百分比型
|
||||
|
||||
|
||||
@@ -177,18 +177,18 @@ export const HeroInfo: Record<number, heroInfo> = {
|
||||
|
||||
// 1. 基础近战型
|
||||
5201:{uuid:5201,name:"兽人战士",icon:"1001",path:"mo1", fac:FacSet.MON, kind:1,as:3.0,
|
||||
type:HType.warrior,lv:1,hp:60,mp:100,def:0,ap:8,speed:180,skills:[6001],
|
||||
rangeType: SkillRange.Melee,
|
||||
type:HType.warrior,lv:1,hp:60,mp:100,def:0,ap:8,speed:180,skills:[6003],
|
||||
rangeType: SkillRange.Long,
|
||||
buff:[],tal:[],info:"标准炮灰:确保英雄能完成3次普攻积累天赋计数"},
|
||||
// 2. 快速突击型
|
||||
5301:{uuid:5301,name:"兽人斥候",icon:"1001",path:"mo1", fac:FacSet.MON, kind:1,as:1.2,
|
||||
type:HType.assassin,lv:1,hp:40,mp:100,def:0,ap:12,speed:400,skills:[6001],
|
||||
rangeType: SkillRange.Melee,
|
||||
type:HType.assassin,lv:1,hp:40,mp:100,def:0,ap:12,speed:400,skills:[6003],
|
||||
rangeType: SkillRange.Long,
|
||||
buff:[],tal:[],info:"快速突击:极高移速贴脸,检测护盾(7102)刷新率"},
|
||||
// 3. 重型坦克型
|
||||
5401:{uuid:5401,name:"兽人卫士",icon:"1001",path:"mo1", fac:FacSet.MON, kind:1,as:5.0,
|
||||
type:HType.warrior,lv:1,hp:200,mp:100,def:5,ap:15,speed:60,skills:[6001],
|
||||
rangeType: SkillRange.Melee,
|
||||
type:HType.warrior,lv:1,hp:200,mp:100,def:5,ap:15,speed:60,skills:[6003],
|
||||
rangeType: SkillRange.Long,
|
||||
buff:[],tal:[],info:"重型坦克:数值墙,检测玩家破甲(7008)与持续输出"},
|
||||
|
||||
// 4. 远程骚扰型
|
||||
@@ -199,28 +199,28 @@ export const HeroInfo: Record<number, heroInfo> = {
|
||||
|
||||
// 5. 特殊机制型
|
||||
5601:{uuid:5601,name:"兽人自爆兵",icon:"1001",path:"mo1", fac:FacSet.MON, kind:1,as:3.0,
|
||||
type:HType.assassin,lv:1,hp:80,mp:100,def:0,ap:200,speed:220,skills:[6001],
|
||||
rangeType: SkillRange.Melee,
|
||||
type:HType.assassin,lv:1,hp:80,mp:100,def:0,ap:200,speed:220,skills:[6003],
|
||||
rangeType: SkillRange.Long,
|
||||
buff:[],tal:[],info:"特殊机制:极端伤害,漏怪即秒杀,检测减伤(7103)"},
|
||||
// 召唤师:持续召唤小怪(后续可在技能系统中实现 SType.zhaohuan)
|
||||
5602:{uuid:5602,name:"兽人召唤师",icon:"1001",path:"mo1", fac:FacSet.MON, kind:1,as:3.0,
|
||||
type:HType.mage,lv:1,hp:150,mp:300,def:5,ap:10,speed:100,skills:[6001],
|
||||
rangeType: SkillRange.Mid,
|
||||
type:HType.mage,lv:1,hp:150,mp:300,def:5,ap:10,speed:100,skills:[6003],
|
||||
rangeType: SkillRange.Long,
|
||||
buff:[],tal:[],info:"战术目标:持续召唤小怪,检测英雄大招清场频率"},
|
||||
// 治疗者:为周围怪物回血(此处以提升治疗效果和生命回复为基础被动)
|
||||
5603:{uuid:5603,name:"兽人祭司",icon:"1001",path:"mo1", fac:FacSet.MON, kind:1,as:3.0,
|
||||
type:HType.support,lv:1,hp:150,mp:300,def:5,ap:10,speed:105,skills:[6001],
|
||||
rangeType: SkillRange.Melee,
|
||||
type:HType.support,lv:1,hp:150,mp:300,def:5,ap:10,speed:105,skills:[6003],
|
||||
rangeType: SkillRange.Long,
|
||||
buff:[],tal:[],info:"战术目标:为怪群回血,检测玩家沉默(7006)覆盖率"},
|
||||
// 光环怪:为周围怪物提供增益(此处以Buff效果提升与移动速度提升为基础被动)
|
||||
// Attrs.BUFF_UP=60 (RATIO=1),Attrs.SPEED=63 (RATIO=1)
|
||||
5604:{uuid:5604,name:"兽人图腾师",icon:"1001",path:"mo1", fac:FacSet.MON, kind:1,as:3.0,
|
||||
type:HType.support,lv:1,hp:150,mp:250,def:5,ap:10,speed:110,skills:[6001],
|
||||
rangeType: SkillRange.Melee,
|
||||
type:HType.support,lv:1,hp:150,mp:250,def:5,ap:10,speed:110,skills:[6003],
|
||||
rangeType: SkillRange.Long,
|
||||
buff:[],tal:[],info:"战术目标:提供加速光环,改变怪群推进节奏"},
|
||||
// 6. 精英/BOSS型
|
||||
5701:{uuid:5701,name:"兽人首领(BOSS)",icon:"1001",path:"mo1", fac:FacSet.MON, kind:1,as:2.5,
|
||||
type:HType.warrior,lv:3,hp:2000,mp:500,def:10,ap:60,speed:120,skills:[6001],
|
||||
rangeType: SkillRange.Melee,
|
||||
type:HType.warrior,lv:3,hp:2000,mp:500,def:10,ap:60,speed:120,skills:[6003],
|
||||
rangeType: SkillRange.Long,
|
||||
buff:[],tal:[],info:"终极考验:极高HP,检测大招重置与辐射协同输出"},
|
||||
};
|
||||
|
||||
@@ -178,7 +178,8 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
||||
}
|
||||
if (damage <= 0) return reDate;
|
||||
|
||||
TAttrsComp.hp -= damage; // 应用伤害到数据层
|
||||
// TAttrsComp.hp -= damage; // 应用伤害到数据层
|
||||
TAttrsComp.add_hp(-damage, true); // 使用 add_hp 以触发 dirty_hp 和 UI 更新
|
||||
|
||||
// 受击者产生击退效果
|
||||
// if (damage > 0 && targetView) {
|
||||
@@ -257,7 +258,8 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
||||
// 计算反伤伤害
|
||||
let thornsDmg=Math.floor(thornsDamage*damage/100);
|
||||
// 应用反伤伤害到数据层
|
||||
CAttrs.hp -= thornsDmg;
|
||||
// CAttrs.hp -= thornsDmg;
|
||||
CAttrs.add_hp(-thornsDmg, true);
|
||||
CAttrs.atked_count++;
|
||||
let CView=caster.get(HeroViewComp);
|
||||
// ✅ 触发视图层表现(伤害数字、受击动画、后退)
|
||||
@@ -326,16 +328,23 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
||||
let apBase = (sConf.ap||0)*(CAttrs[Attrs.AP]+damageEvent.ext_dmg)/100*damageEvent.dmg_ratio;
|
||||
if (this.debugMode) console.log(`[HeroAtkSystem] 物理伤害基础值: ${apBase}, 技能ap=${sConf.ap},施法者物理攻击力: ${CAttrs[Attrs.AP]},}
|
||||
额外伤害:${damageEvent.ext_dmg}, 额外伤害比例:${damageEvent.dmg_ratio}`);
|
||||
//3.1 易伤
|
||||
// 易伤
|
||||
let DMG_INVUL = TAttrs[Attrs.DMG_INVUL]||0
|
||||
//3.2 免伤 属性免伤+天赋免伤
|
||||
let DMG_RED =TAttrs[Attrs.DEF]||0+TAttrsComp.useCountValTal(Attrs.DEF);
|
||||
//4. 确保伤害值非负,返回最终伤害
|
||||
let total = Math.max(0,apBase);
|
||||
//5. 易伤减免 免伤属性免伤+天赋免伤
|
||||
total = Math.floor(total * (1 + ((DMG_INVUL-DMG_RED)/100)));
|
||||
if (this.debugMode) console.log(`[HeroAtkSystem] 易伤减免后: ${total}`);
|
||||
return Math.max(0,total);
|
||||
// 免伤 属性免伤+天赋免伤
|
||||
let DMG_RED = (TAttrs[Attrs.DEF]||0) + TAttrsComp.useCountValTal(Attrs.DEF);
|
||||
// 4. 确保伤害值非负
|
||||
let total = Math.max(0, apBase);
|
||||
|
||||
// 5. 应用防御减免 (百分比型)
|
||||
// 计算公式:基础伤害 * (1 + (易伤% - 免伤%) / 100)
|
||||
// 易伤增加伤害,免伤减少伤害
|
||||
let damageRatio = 1 + (DMG_INVUL - DMG_RED) / 100;
|
||||
damageRatio = Math.max(0, damageRatio); // 确保伤害系数不为负(即最多减免至0伤害)
|
||||
|
||||
total = Math.floor(total * damageRatio);
|
||||
|
||||
if (this.debugMode) console.log(`[HeroAtkSystem] 最终伤害: ${total} (Base: ${apBase}, Def: ${DMG_RED}%, Invul: ${DMG_INVUL}%, Ratio: ${damageRatio})`);
|
||||
return total;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user