feat(英雄系统): 添加英雄复活机制并控制怪物行为

实现英雄复活功能,当英雄死亡且有复活次数时延迟复活
新增is_reviving状态标记复活中状态
英雄死亡或复活时通过stop_mon_action控制怪物停止刷新和移动
This commit is contained in:
walkpan
2026-01-03 11:17:04 +08:00
parent 56452795bb
commit 1cce4ce361
11 changed files with 88 additions and 11 deletions

View File

@@ -125,7 +125,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
isCrit:false,
isDodge:false,
}
if (!TAttrsComp || TAttrsComp.is_dead) return reDate;
if (!TAttrsComp || TAttrsComp.is_dead || TAttrsComp.is_reviving) return reDate;
const caster = damageEvent.caster;
const CAttrsComp = caster?.ent?.get(HeroAttrsComp);
@@ -197,8 +197,34 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
// 检查死亡
if (TAttrsComp.hp <= 0) {
// 复活机制:如果玩家属性内的复活属性值>=1 则执行复活,原地50%血量复活
if (TAttrsComp.fac === FacSet.HERO && TAttrsComp.Attrs[Attrs.REVIVE_COUNT] >= 1) {
TAttrsComp.Attrs[Attrs.REVIVE_COUNT]--;
TAttrsComp.is_reviving = true; // 标记为正在复活
// 停止怪物行动
smc.mission.stop_mon_action = true;
// 触发死亡动画(假死)
if (targetView) {
targetView.do_dead();
// 延迟1秒复活
targetView.scheduleRevive(1.0);
}
console.log(`[HeroAtkSystem] Hero waiting to revive! Lives left: ${TAttrsComp.Attrs[Attrs.REVIVE_COUNT]}`);
return reDate;
}
// 增加被击杀计数
if (caster) CAttrsComp.Attrs.killed_count++;
// 玩家英雄死亡后,怪物停止刷新和移动
if (TAttrsComp.fac === FacSet.HERO) {
smc.mission.stop_mon_action = true;
console.log("[HeroAtkSystem] Hero died, stopping monster action (spawn/move)");
}
this.doDead(target);
// ✅ 触发死亡视图表现
if (targetView) {
@@ -228,6 +254,28 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
if (CView) CView.do_atked(thornsDmg, false, SkillSet[5000].uuid, false);
// 检查死亡
if (CAttrs.hp <= 0) {
// 复活机制
if (CAttrs.fac === FacSet.HERO && CAttrs.Attrs[Attrs.REVIVE_COUNT] >= 1) {
CAttrs.Attrs[Attrs.REVIVE_COUNT]--;
CAttrs.is_reviving = true;
smc.mission.stop_mon_action = true;
if (CView) {
CView.do_dead();
CView.scheduleRevive(1.0);
}
console.log(`[HeroAtkSystem] Hero waiting to revive from Thorns! Lives left: ${CAttrs.Attrs[Attrs.REVIVE_COUNT]}`);
return;
}
// 玩家英雄死亡后,怪物停止刷新和移动
if (CAttrs.fac === FacSet.HERO) {
smc.mission.stop_mon_action = true;
console.log("[HeroAtkSystem] Hero died from thorns, stopping monster action (spawn/move)");
}
this.doDead(caster);
// 增加击杀计数
if (caster) TAttrsComp.Attrs.killed_count++;