feat(英雄): 重构复活机制为动态配置

将固定的复活次数属性改为从英雄配置中动态计算。移除 `revive_count` 静态属性,新增 `revive` 数组用于存储复活配置(包含基础次数和等级成长),并添加 `revived_count` 记录已复活次数。在 `Hero` 和 `Monster` 的初始化中同步此属性,并在战斗系统中根据配置和英雄等级计算最大可复活次数。
This commit is contained in:
panw
2026-04-23 09:41:50 +08:00
parent 0676412a5a
commit b9f7a66fae
5 changed files with 19 additions and 6 deletions

View File

@@ -26,7 +26,6 @@ export enum Attrs {
// ==================== 特殊效果属性 ====================
freeze_chance = "freeze_chance", // 冰冻概率
revive_count = "revive_count", // 复活次数
invincible_time = "invincible_time",// 无敌时间
puncture = "puncture", // 穿刺次数
wfuny = "wfuny", // 风怒

View File

@@ -116,6 +116,7 @@ export class Hero extends ecs.Entity {
model.fend = hero.fend;
model.atking = hero.atking;
model.atked = hero.atked;
model.revive = hero.revive;
// 基础属性按等级倍率初始化
// 使用指数增长公式等级2时为原来的3倍等级3时为原来的9倍 (若需线性增长可改为 hero.ap * (1 + (model.lv - 1) * (FightSet.H_HERO_POW - 1)))

View File

@@ -188,15 +188,25 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
// 检查死亡
if (TAttrsComp.hp <= 0) {
// 复活机制:如果玩家属性内的复活属性值>=1 则执行复活,原地50%血量复活
if (TAttrsComp.revive_count >= 1) {
TAttrsComp.revive_count--;
let canRevive = false;
let maxReviveCount = 0;
if (TAttrsComp.revive && TAttrsComp.revive.length > 0) {
const reviveConf = TAttrsComp.revive[0];
maxReviveCount = reviveConf.r_num + Math.floor((TAttrsComp.lv - 1) * reviveConf.upr);
if (TAttrsComp.revived_count < maxReviveCount) {
canRevive = true;
}
}
if (canRevive) {
TAttrsComp.revived_count++;
TAttrsComp.is_reviving = true; // 标记为正在复活
// 触发死亡动画(假死)
if (targetView) {
targetView.do_dead();
}
mLogger.log(this.debugMode, 'HeroAtkSystem', ` Hero waiting to revive! Lives left: ${TAttrsComp.revive_count}`);
mLogger.log(this.debugMode, 'HeroAtkSystem', ` Hero waiting to revive! Lives revived: ${TAttrsComp.revived_count}/${maxReviveCount}`);
return reDate;
}

View File

@@ -34,6 +34,7 @@ export class HeroAttrsComp extends ecs.Comp {
fend?: number[];
atking?: {s_uuid: number, t_num: number}[];
atked?: {s_uuid: number, t_num: number}[];
revive?: {s_uuid: number, r_num: number, upr: number}[];
// ==================== 特殊属性 ====================
critical: number = 0; // 暴击率
@@ -41,7 +42,7 @@ export class HeroAttrsComp extends ecs.Comp {
puncture: number = 0; // 穿刺次数
wfuny: number = 0; // 风怒
revive_count: number = 0; // 复活次数
revived_count: number = 0; // 复活次数
invincible_time: number = 0;// 无敌时间
@@ -244,9 +245,10 @@ export class HeroAttrsComp extends ecs.Comp {
this.fend = undefined;
this.atking = undefined;
this.atked = undefined;
this.revive = undefined;
this.critical = 0;
this.freeze_chance = 0;
this.revive_count = 0;
this.revived_count = 0;
this.invincible_time = 0;
this.puncture = 0;
this.wfuny = 0;

View File

@@ -174,6 +174,7 @@ export class Monster extends ecs.Entity {
model.fend = hero.fend;
model.atking = hero.atking;
model.atked = hero.atked;
model.revive = hero.revive;
// 标记是否 Boss非 Boss 默认记作杂兵
model.is_boss =is_boss