diff --git a/assets/script/game/common/config/heroSet.ts b/assets/script/game/common/config/heroSet.ts index fa581364..7d97d559 100644 --- a/assets/script/game/common/config/heroSet.ts +++ b/assets/script/game/common/config/heroSet.ts @@ -67,6 +67,7 @@ export interface heroInfo { dead?:number[]; // 死亡后触发的技能uuid列表 fstart?:number[]; // 战斗开始时释放的技能uuid列表 fend?:number[]; // 战斗结束时释放的技能uuid列表 + atking?:{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/SCastSystem.ts b/assets/script/game/hero/SCastSystem.ts index 930d7a1d..708cc32b 100644 --- a/assets/script/game/hero/SCastSystem.ts +++ b/assets/script/game/hero/SCastSystem.ts @@ -5,7 +5,7 @@ import { HeroViewComp } from "./HeroViewComp"; import { DTType, RType, SkillConfig, SkillKind, SkillSet, SkillUpList, TGroup } from "../common/config/SkillSet"; import { Skill } from "../skill/Skill"; import { smc } from "../common/SingletonModuleComp"; -import { HType } from "../common/config/heroSet"; +import { HeroInfo, HType } from "../common/config/heroSet"; import { Attrs } from "../common/config/HeroAttrs"; import { BoxSet, FacSet, FightSet } from "../common/config/GameSet"; import { oops } from "db://oops-framework/core/Oops"; @@ -300,6 +300,14 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate //播放角色攻击动画 heroView.playSkillAnm(config.act); + // 因为 castSkill 只由 update 循环调用,处理的必然是 heroAttrs.skills 中的普通技能 + // 特殊触发技能(call/dead/atking等)走的是 forceCastTriggerSkill,不会调用 castSkill + const skillIds = heroAttrs.getSkillIds(); + if (skillIds.includes(s_uuid)) { + heroAttrs.atk_count++; + this.checkAndTriggerAtkingSkills(heroAttrs, heroView); + } + // 优先使用技能配置的前摇时间,否则使用全局默认值 // 注意:这里仍然是基于时间的延迟,受帧率波动影响。 // 若需精确同步,建议在动画中添加帧事件并在 HeroViewComp 中监听。 @@ -325,6 +333,23 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate heroAttrs.triggerSkillCD(s_uuid); } + /** 检查并触发攻击附加技能 (atking) */ + private checkAndTriggerAtkingSkills(heroAttrs: HeroAttrsComp, heroView: HeroViewComp) { + const heroInfo = HeroInfo[heroAttrs.hero_uuid]; + if (!heroInfo || !heroInfo.atking || heroInfo.atking.length === 0) return; + + heroInfo.atking.forEach(atkConfig => { + if (heroAttrs.atk_count > 0 && heroAttrs.atk_count % atkConfig.t_num === 0) { + oops.message.dispatchEvent(GameEvent.TriggerSkill, { + s_uuid: atkConfig.s_uuid, + heroAttrs: heroAttrs, + heroView: heroView, + triggerType: 'atking' + }); + } + }); + } + private resolveRepeatCastTargetPos(targetPos: Vec3 | null, castIndex: number): Vec3 | null { if (!targetPos) return null; if (castIndex === 1) return new Vec3(targetPos.x, targetPos.y + 15, targetPos.z);