From 5f6f6f0bfbf4b48af4bff4cd63c8f99e307ad8ea Mon Sep 17 00:00:00 2001 From: panw Date: Wed, 22 Apr 2026 20:56:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=88=98=E6=96=97):=20=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E8=8B=B1=E9=9B=84=E5=A4=8D=E6=B4=BB=E4=B8=8E=E6=88=98=E6=96=97?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=E6=97=B6=E7=9A=84=E7=94=9F=E5=91=BD=E5=80=BC?= =?UTF-8?q?=E6=81=A2=E5=A4=8D=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除英雄复活时直接设置固定生命值的硬编码,改为在战斗结束阶段统一恢复所有英雄(包括墓地英雄)70%最大生命值。这确保了生命值恢复机制的一致性和可维护性,并避免了状态同步问题。 --- assets/script/game/hero/HeroViewComp.ts | 1 - assets/script/game/map/MissionComp.ts | 24 +++++++++++++++++++++++ assets/script/game/map/MissionHeroComp.ts | 1 - 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index b4776e3a..a3e621e5 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -395,7 +395,6 @@ export class HeroViewComp extends CCComp { this.deadCD = 0; this.as.do_buff(); this.status_change("idle"); - this.model.hp =this.model.hp_max*50/100; this.top_node.active=true this.setTopBarOpacity(false); this.lastBarUpdateTime=0 diff --git a/assets/script/game/map/MissionComp.ts b/assets/script/game/map/MissionComp.ts index 5fc44347..2656f434 100644 --- a/assets/script/game/map/MissionComp.ts +++ b/assets/script/game/map/MissionComp.ts @@ -372,6 +372,9 @@ export class MissionComp extends CCComp { smc.mission.stop_spawn_mon = true; // 触发战斗结束技能(fend) this.triggerHeroBattleSkills(false); + + // 战斗结束阶段,给予所有英雄恢复70%血量的技能效果 + this.healAllHeroes(); break; case MissionPhase.Settle: @@ -481,6 +484,27 @@ export class MissionComp extends CCComp { }); } + /** + * 战斗结束阶段治疗所有英雄(包括墓地英雄),恢复70%最大生命值 + */ + private healAllHeroes() { + ecs.query(this.heroAttrsMatcher).forEach(entity => { + const attrs = entity.get(HeroAttrsComp); + const view = entity.get(HeroViewComp); + if (!attrs || !view || attrs.fac !== FacSet.HERO) return; + + // 计算恢复量:70% 的最大生命值 + const healAmount = Math.floor(attrs.hp_max * 0.7); + + // 应用恢复量,不超过最大生命值 + attrs.hp = Math.min(attrs.hp_max, attrs.hp + healAmount); + attrs.dirty_hp = true; + + // 触发治疗动画,即使在墓地的英雄也触发(会在其当前位置播放) + view.health(healAmount); + }); + } + /** 开始战斗按钮点击回调 */ private onStartFightBtnClick() { if (!smc.mission.play) return; diff --git a/assets/script/game/map/MissionHeroComp.ts b/assets/script/game/map/MissionHeroComp.ts index 03c60f36..3f62ae7c 100644 --- a/assets/script/game/map/MissionHeroComp.ts +++ b/assets/script/game/map/MissionHeroComp.ts @@ -133,7 +133,6 @@ export class MissionHeroCompComp extends CCComp { view.node.setPosition(spawnPos); hero.playDropAnim(spawnPos, landingPos.y); } - model.hp = model.hp_max; model.dirty_hp = true; } }