diff --git a/assets/script/game/common/config/heroSet.ts b/assets/script/game/common/config/heroSet.ts index 7d97d559..93628835 100644 --- a/assets/script/game/common/config/heroSet.ts +++ b/assets/script/game/common/config/heroSet.ts @@ -68,6 +68,7 @@ export interface heroInfo { fstart?:number[]; // 战斗开始时释放的技能uuid列表 fend?:number[]; // 战斗结束时释放的技能uuid列表 atking?:{s_uuid:number, t_num:number}[]; // 普通攻击后触发的技能配置,s_uuid: 技能id, t_num: 触发所需的普攻次数 + atked?:{s_uuid:number, t_num:number}[]; // 受击后触发的技能配置,s_uuid: 技能id, t_num: 触发所需的受击次数 // dis: number; // 攻击距离(像素) speed: number; // 移动速度(像素/秒) skills: Record ; // 携带技能ID列表 diff --git a/assets/script/game/hero/HeroAtkSystem.ts b/assets/script/game/hero/HeroAtkSystem.ts index 130aa466..ddbd1095 100644 --- a/assets/script/game/hero/HeroAtkSystem.ts +++ b/assets/script/game/hero/HeroAtkSystem.ts @@ -91,6 +91,23 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd } + /** 检查并触发受击附加技能 (atked) */ + private checkAndTriggerAtkedSkills(heroAttrs: HeroAttrsComp, heroView: HeroViewComp) { + const heroInfo = HeroInfo[heroAttrs.hero_uuid]; + if (!heroInfo || !heroInfo.atked || heroInfo.atked.length === 0) return; + + heroInfo.atked.forEach(atkConfig => { + if (heroAttrs.atked_count > 0 && heroAttrs.atked_count % atkConfig.t_num === 0) { + oops.message.dispatchEvent(GameEvent.TriggerSkill, { + s_uuid: atkConfig.s_uuid, + heroAttrs: heroAttrs, + heroView: heroView, + triggerType: 'atked' + }); + } + }); + } + /** * 执行攻击计算 - 核心伤害计算逻辑 * @@ -143,6 +160,10 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd // TAttrsComp.hp -= damage; // 应用伤害到数据层 TAttrsComp.add_hp(-damage); // 使用 add_hp 以触发 dirty_hp 和 UI 更新 + // 增加受击计数并触发 atked 技能 + TAttrsComp.atked_count++; + this.checkAndTriggerAtkedSkills(TAttrsComp, targetView); + // 受击者产生击退效果 // if (damage > 0 && targetView) { // targetView.back();