feat(hero&config): 新增反伤属性与反伤结算逻辑
1. 新增反伤相关配置属性thorns_dmg和thorns_rate 2. 在HeroAttrsComp中添加反伤属性字段与初始化逻辑 3. 实现反伤伤害结算逻辑,支持固定值+比例混合反伤 4. 新增计时buff施加概率与目标覆写配置项
This commit is contained in:
@@ -192,6 +192,16 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpda
|
||||
this.checkAndTriggerAtkedSkills(TAttrsComp, targetView);
|
||||
}
|
||||
|
||||
// 反伤结算:实际受到伤害后,目标将自身 thorns_dmg 反弹给攻击者
|
||||
// 反伤值 = 实际受到伤害 * thorns_rate / 100 + thorns_dmg(固定值+比例混合)
|
||||
// DoT 不触发反伤(持续伤害类效果通常不触发荆棘)
|
||||
if (!isDot && damage > 0) {
|
||||
const thornsDmg = Math.floor(damage * TAttrsComp.thorns_rate / 100) + TAttrsComp.thorns_dmg;
|
||||
if (thornsDmg > 0) {
|
||||
this.applyThornsDamage(casterEid, thornsDmg);
|
||||
}
|
||||
}
|
||||
|
||||
mLogger.log(this.debugMode, 'HeroAtkSystem', ` 英雄${TAttrsComp.hero_name} (uuid: ${TAttrsComp.hero_uuid}) 受到 eid:${casterEid} 的 伤害 ${damage},${isCrit ? "暴击" : "普通"}攻击,技能ID ${damageEvent.s_uuid}`);
|
||||
|
||||
// 冰冻判定
|
||||
@@ -548,6 +558,44 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpda
|
||||
return { remainingDamage: damage - absorbed, absorbedDamage: absorbed };
|
||||
}
|
||||
|
||||
/**
|
||||
* 对攻击者施加反伤伤害
|
||||
*
|
||||
* 反伤为固定数值伤害,直接扣减攻击者 HP,不走暴击/防御/护盾等常规结算
|
||||
* (反伤通常是真实伤害或固定伤害,避免嵌套结算导致无限循环)
|
||||
*
|
||||
* @param casterEid 攻击者实体 ID
|
||||
* @param thornsDmg 反伤伤害值
|
||||
*/
|
||||
private applyThornsDamage(casterEid: number, thornsDmg: number): void {
|
||||
const caster = ecs.getEntityByEid(casterEid);
|
||||
if (!caster) return;
|
||||
|
||||
const casterAttrs = caster.get(HeroAttrsComp);
|
||||
if (!casterAttrs || casterAttrs.is_dead || casterAttrs.is_reviving) return;
|
||||
|
||||
// 反伤直接扣血,不经过护盾/防御结算(避免反伤-反伤无限循环)
|
||||
casterAttrs.add_hp(-thornsDmg);
|
||||
|
||||
// 反伤计入评分统计(仅英雄阵营的反伤被统计,怪物反伤通常源于英雄技能/天赋)
|
||||
if (casterAttrs.fac === FacSet.HERO) {
|
||||
smc.vmdata.scores.thorns_dmg += thornsDmg;
|
||||
}
|
||||
|
||||
mLogger.log(this.debugMode, 'HeroAtkSystem', ` 反伤: ${casterAttrs.hero_name} 受到 ${thornsDmg} 点反伤伤害`);
|
||||
|
||||
// 反伤致死检查
|
||||
if (casterAttrs.hp <= 0) {
|
||||
this.triggerDeadSkills(caster);
|
||||
casterAttrs.death_count++;
|
||||
this.doDead(caster);
|
||||
const casterView = caster.get(HeroViewComp);
|
||||
if (casterView) {
|
||||
casterView.do_dead();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析 timed_buff_id 的施加目标实体列表。
|
||||
* 缺省(undefined / BuffTarget.Hit)返回被命中者;显式配置可切换到施法者自身、全体友方或全体敌方。
|
||||
@@ -583,8 +631,10 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpda
|
||||
/**
|
||||
* 被攻击时触发的事件
|
||||
*
|
||||
* 预留的扩展点,用于处理被攻击时的特殊逻辑:
|
||||
* - 触发反伤效果(荆棘光环等)
|
||||
* 当前已实现的逻辑:
|
||||
* - 反伤效果:目标通过 thorns_dmg 属性对攻击者造成固定反伤(在 doAttack 中结算)
|
||||
*
|
||||
* 预留的扩展点:
|
||||
* - 触发被攻击天赋(如受击回血、受击反击等)
|
||||
* - 触发特殊状态(如受伤狂暴、受伤护盾等)
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user