feat(英雄系统): 添加击杀计数并优化攻击系统变量命名

添加英雄击杀计数功能,用于统计英雄击杀敌人数量
优化HeroAtkSystem中变量命名,将attackerTAttrsComp改为更清晰的CAttrsComp
修复荆棘伤害可能导致英雄死亡时未触发死亡表现的问题
This commit is contained in:
2025-11-27 16:31:22 +08:00
parent b2cc25b32b
commit 40c430546c
2 changed files with 18 additions and 5 deletions

View File

@@ -134,7 +134,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
if (!TAttrsComp || TAttrsComp.is_dead) return reDate; if (!TAttrsComp || TAttrsComp.is_dead) return reDate;
const caster = damageEvent.caster; const caster = damageEvent.caster;
const attackerTAttrsComp = caster?.ent?.get(HeroAttrsComp); const CAttrsComp = caster?.ent?.get(HeroAttrsComp);
// 获取技能配置 // 获取技能配置
const skillConf = SkillSet[damageEvent.s_uuid]; const skillConf = SkillSet[damageEvent.s_uuid];
@@ -165,7 +165,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
const casterCritDmg = damageEvent.Attrs[Attrs.CRITICAL_DMG] || 0; const casterCritDmg = damageEvent.Attrs[Attrs.CRITICAL_DMG] || 0;
damage = Math.floor(damage * (1 + (FightSet.CRIT_DAMAGE + casterCritDmg) / 100)); damage = Math.floor(damage * (1 + (FightSet.CRIT_DAMAGE + casterCritDmg) / 100));
reDate.isCrit=true; reDate.isCrit=true;
attackerTAttrsComp?.useValueTalByAttr(Attrs.CRITICAL); // 清除施法者的暴击buff CAttrsComp?.useValueTalByAttr(Attrs.CRITICAL); // 清除施法者的暴击buff
} }
// 护盾吸收 // 护盾吸收
@@ -180,7 +180,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
// 使用施法者的击退概率属性damageEvent.Attrs 快照) // 使用施法者的击退概率属性damageEvent.Attrs 快照)
// 击退成功后需要清理施法者的相关天赋buff // 击退成功后需要清理施法者的相关天赋buff
const isBack = this.checkChance(damageEvent.Attrs[Attrs.BACK_CHANCE] || 0); const isBack = this.checkChance(damageEvent.Attrs[Attrs.BACK_CHANCE] || 0);
if (isBack) attackerTAttrsComp?.useValueTalByAttr(Attrs.BACK_CHANCE); if (isBack) CAttrsComp?.useValueTalByAttr(Attrs.BACK_CHANCE);
// ✅ 触发视图层表现(伤害数字、受击动画、后退) // ✅ 触发视图层表现(伤害数字、受击动画、后退)
@@ -189,6 +189,8 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
// 检查死亡 // 检查死亡
if (TAttrsComp.hp <= 0) { if (TAttrsComp.hp <= 0) {
// 增加被击杀计数
if (caster) CAttrsComp.Attrs.killed_count++;
this.doDead(target); this.doDead(target);
// ✅ 触发死亡视图表现 // ✅ 触发死亡视图表现
if (targetView) { if (targetView) {
@@ -204,7 +206,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
return reDate; return reDate;
} }
check_thorns(TAttrsComp:HeroAttrsComp, caster: ecs.Entity, damage:number) { check_thorns(TAttrsComp:HeroAttrsComp, caster: ecs.Entity, damage:number) {
// 检查目标是否有反伤属性 // 检查目标是否有反伤属性,这里受伤的时时施法者
if (!caster||damage<=0) return; if (!caster||damage<=0) return;
let thornsDamage=0; let thornsDamage=0;
thornsDamage=TAttrsComp.Attrs[Attrs.THORNS]||0+TAttrsComp.useCountValTal(Attrs.THORNS); thornsDamage=TAttrsComp.Attrs[Attrs.THORNS]||0+TAttrsComp.useCountValTal(Attrs.THORNS);
@@ -217,6 +219,16 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
let CView=caster.get(HeroViewComp); let CView=caster.get(HeroViewComp);
// ✅ 触发视图层表现(伤害数字、受击动画、后退) // ✅ 触发视图层表现(伤害数字、受击动画、后退)
if (CView) CView.do_atked(thornsDmg, false, SkillSet[5000].uuid, false); if (CView) CView.do_atked(thornsDmg, false, SkillSet[5000].uuid, false);
// 检查死亡
if (CAttrs.hp <= 0) {
this.doDead(caster);
// 增加击杀计数
if (caster) TAttrsComp.Attrs.killed_count++;
// ✅ 触发死亡视图表现
if (CView) {
CView.do_dead();
}
}
} }
/** /**
* 详细伤害计算核心方法 * 详细伤害计算核心方法

View File

@@ -65,7 +65,7 @@ export class HeroAttrsComp extends ecs.Comp {
// ==================== 计数统计 ==================== // ==================== 计数统计 ====================
atk_count: number = 0; // 攻击次数 atk_count: number = 0; // 攻击次数
atked_count: number = 0; // 被攻击次数 atked_count: number = 0; // 被攻击次数
killed_count:number=0;
// 注意:技能数据已迁移到 HeroSkillsComp不再存储在这里 // 注意:技能数据已迁移到 HeroSkillsComp不再存储在这里
start(){ start(){
@@ -561,6 +561,7 @@ export class HeroAttrsComp extends ecs.Comp {
this.is_kalami = false; this.is_kalami = false;
this.atk_count = 0; this.atk_count = 0;
this.atked_count = 0; this.atked_count = 0;
this.killed_count =0;
} }