fix(hero): 修复复活后治疗未重置复活计数的问题并支持配置复活恢复百分比
- 在MissionComp中,英雄被治疗后重置复活计数,防止下回合无法复活 - 在HeroAtkSystem中,从技能配置读取复活恢复生命值百分比,替代硬编码的50%
This commit is contained in:
@@ -190,23 +190,32 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
|||||||
// 复活机制:如果玩家属性内的复活属性值>=1 则执行复活,原地50%血量复活
|
// 复活机制:如果玩家属性内的复活属性值>=1 则执行复活,原地50%血量复活
|
||||||
let canRevive = false;
|
let canRevive = false;
|
||||||
let maxReviveCount = 0;
|
let maxReviveCount = 0;
|
||||||
|
let reviveHpPercent = 50; // 默认恢复50%
|
||||||
if (TAttrsComp.revive && TAttrsComp.revive.length > 0) {
|
if (TAttrsComp.revive && TAttrsComp.revive.length > 0) {
|
||||||
const reviveConf = TAttrsComp.revive[0];
|
const reviveConf = TAttrsComp.revive[0];
|
||||||
maxReviveCount = reviveConf.r_num + Math.floor((TAttrsComp.lv - 1) * reviveConf.upr);
|
maxReviveCount = reviveConf.r_num + Math.floor((TAttrsComp.lv - 1) * reviveConf.upr);
|
||||||
if (TAttrsComp.revived_count < maxReviveCount) {
|
if (TAttrsComp.revived_count < maxReviveCount) {
|
||||||
canRevive = true;
|
canRevive = true;
|
||||||
|
// 从配置表中读取对应的复活技能配置,ap 字段代表恢复生命值的百分比
|
||||||
|
const skillConf = SkillSet[reviveConf.s_uuid];
|
||||||
|
if (skillConf && skillConf.ap) {
|
||||||
|
reviveHpPercent = skillConf.ap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canRevive) {
|
if (canRevive) {
|
||||||
TAttrsComp.revived_count++;
|
TAttrsComp.revived_count++;
|
||||||
TAttrsComp.is_reviving = true; // 标记为正在复活
|
TAttrsComp.is_reviving = true; // 标记为正在复活
|
||||||
// 触发死亡动画(假死)
|
// 根据技能配置恢复生命值
|
||||||
if (targetView) {
|
TAttrsComp.hp = Math.floor(TAttrsComp.hp_max * (reviveHpPercent / 100));
|
||||||
targetView.do_dead();
|
TAttrsComp.dirty_hp = true;
|
||||||
|
|
||||||
|
// 触发复活动画
|
||||||
|
if (targetView) {
|
||||||
|
targetView.playReady(skillConf.readyAnm);
|
||||||
}
|
}
|
||||||
mLogger.log(this.debugMode, 'HeroAtkSystem', ` Hero waiting to revive! Lives revived: ${TAttrsComp.revived_count}/${maxReviveCount}`);
|
mLogger.log(this.debugMode, 'HeroAtkSystem', ` Hero waiting to revive! Lives revived: ${TAttrsComp.revived_count}/${maxReviveCount}, Hp restored: ${reviveHpPercent}%`);
|
||||||
return reDate;
|
return reDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -514,6 +514,9 @@ export class MissionComp extends CCComp {
|
|||||||
attrs.hp = Math.min(attrs.hp_max, attrs.hp + healAmount);
|
attrs.hp = Math.min(attrs.hp_max, attrs.hp + healAmount);
|
||||||
attrs.dirty_hp = true;
|
attrs.dirty_hp = true;
|
||||||
|
|
||||||
|
// 重置复活次数,使得下回合可以继续复活
|
||||||
|
attrs.revived_count = 0;
|
||||||
|
|
||||||
// 触发治疗动画,即使在墓地的英雄也触发(会在其当前位置播放)
|
// 触发治疗动画,即使在墓地的英雄也触发(会在其当前位置播放)
|
||||||
view.health(healAmount);
|
view.health(healAmount);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user