From b9f7a66faea3d1354b87e454d1f67fe04b5e6e01 Mon Sep 17 00:00:00 2001 From: panw Date: Thu, 23 Apr 2026 09:41:50 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=8B=B1=E9=9B=84):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E5=A4=8D=E6=B4=BB=E6=9C=BA=E5=88=B6=E4=B8=BA=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将固定的复活次数属性改为从英雄配置中动态计算。移除 `revive_count` 静态属性,新增 `revive` 数组用于存储复活配置(包含基础次数和等级成长),并添加 `revived_count` 记录已复活次数。在 `Hero` 和 `Monster` 的初始化中同步此属性,并在战斗系统中根据配置和英雄等级计算最大可复活次数。 --- assets/script/game/common/config/HeroAttrs.ts | 1 - assets/script/game/hero/Hero.ts | 1 + assets/script/game/hero/HeroAtkSystem.ts | 16 +++++++++++++--- assets/script/game/hero/HeroAttrsComp.ts | 6 ++++-- assets/script/game/hero/Mon.ts | 1 + 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/assets/script/game/common/config/HeroAttrs.ts b/assets/script/game/common/config/HeroAttrs.ts index eaeea701..08a743fe 100644 --- a/assets/script/game/common/config/HeroAttrs.ts +++ b/assets/script/game/common/config/HeroAttrs.ts @@ -26,7 +26,6 @@ export enum Attrs { // ==================== 特殊效果属性 ==================== freeze_chance = "freeze_chance", // 冰冻概率 - revive_count = "revive_count", // 复活次数 invincible_time = "invincible_time",// 无敌时间 puncture = "puncture", // 穿刺次数 wfuny = "wfuny", // 风怒 diff --git a/assets/script/game/hero/Hero.ts b/assets/script/game/hero/Hero.ts index 3c68703a..f1d6a9a1 100644 --- a/assets/script/game/hero/Hero.ts +++ b/assets/script/game/hero/Hero.ts @@ -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))) diff --git a/assets/script/game/hero/HeroAtkSystem.ts b/assets/script/game/hero/HeroAtkSystem.ts index feb0c683..5be6d535 100644 --- a/assets/script/game/hero/HeroAtkSystem.ts +++ b/assets/script/game/hero/HeroAtkSystem.ts @@ -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; } diff --git a/assets/script/game/hero/HeroAttrsComp.ts b/assets/script/game/hero/HeroAttrsComp.ts index 0e641e32..4cd46ddc 100644 --- a/assets/script/game/hero/HeroAttrsComp.ts +++ b/assets/script/game/hero/HeroAttrsComp.ts @@ -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; diff --git a/assets/script/game/hero/Mon.ts b/assets/script/game/hero/Mon.ts index dd595a52..d9aa2876 100644 --- a/assets/script/game/hero/Mon.ts +++ b/assets/script/game/hero/Mon.ts @@ -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