diff --git a/assets/script/game/common/config/GameSet.ts b/assets/script/game/common/config/GameSet.ts index 4c6ce59e..fc6515bc 100644 --- a/assets/script/game/common/config/GameSet.ts +++ b/assets/script/game/common/config/GameSet.ts @@ -26,6 +26,7 @@ export enum FightSet { MERGE_MAX=3, //英雄最大等级 MERGE_NEED=3, //英雄升级需要的英雄数 // BACK_RANG=30,//后退范围 + BACK_RANG=30,//后退范围 FiIGHT_TIME=30,//战斗时间 // BACK_CHANCE=40,//击退概率 FROST_TIME=3,//冰冻时间 diff --git a/assets/script/game/common/config/HeroAttrs.ts b/assets/script/game/common/config/HeroAttrs.ts index 00a4843c..ae9b962e 100644 --- a/assets/script/game/common/config/HeroAttrs.ts +++ b/assets/script/game/common/config/HeroAttrs.ts @@ -27,6 +27,9 @@ export enum Attrs { // ==================== 特殊效果属性 ==================== freeze_chance = "freeze_chance", // 冰冻概率 + knockback_chance = "knockback_chance", // 击退概率 + knockback_distance = "knockback_distance", // 击退距离强化 + knockback_res = "knockback_res", // 击退抗性 invincible_time = "invincible_time",// 无敌时间 puncture = "puncture", // 穿刺次数 wfuny = "wfuny", // 风怒 diff --git a/assets/script/game/hero/HeroAtkSystem.ts b/assets/script/game/hero/HeroAtkSystem.ts index 6dde7051..5d87ce35 100644 --- a/assets/script/game/hero/HeroAtkSystem.ts +++ b/assets/script/game/hero/HeroAtkSystem.ts @@ -191,7 +191,12 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd // 冰冻判定 const freezeChance = damageEvent.Attrs[Attrs.freeze_chance] || 0; const isFrost = !TAttrsComp.isFrost() && this.checkChance(freezeChance); - // ✅ 触发视图层表现(伤害数字、受击动画、冰冻) + + // 击退判定 + const knockbackChance = (damageEvent.Attrs[Attrs.knockback_chance] || 0) - (TAttrsComp.knockback_res || 0); + const isKnockback = this.checkChance(knockbackChance); + + // ✅ 触发视图层表现(伤害数字、受击动画、冰冻、击退) if (targetView) { targetView.do_atked(damage, isCrit, damageEvent.s_uuid, false); targetView.playEnd(skillConf.endAnm); @@ -199,6 +204,9 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd TAttrsComp.toFrost(); targetView.in_iced(TAttrsComp.frost_end_time); } + if (isKnockback) { + targetView.back(damageEvent.Attrs[Attrs.knockback_distance] || 0); + } } diff --git a/assets/script/game/hero/HeroAttrsComp.ts b/assets/script/game/hero/HeroAttrsComp.ts index c02b2acd..d5abadf2 100644 --- a/assets/script/game/hero/HeroAttrsComp.ts +++ b/assets/script/game/hero/HeroAttrsComp.ts @@ -43,6 +43,9 @@ export class HeroAttrsComp extends ecs.Comp { // ==================== 特殊属性 ==================== critical: number = 0; // 暴击率 freeze_chance: number = 0; // 冰冻概率 + knockback_chance: number = 0; // 击退概率 + knockback_distance: number = 0; // 击退距离强化 + knockback_res: number = 0; // 击退抗性 crit_damage: number = 0; // 额外暴击伤害 puncture: number = 0; // 穿刺次数 wfuny: number = 0; // 风怒 @@ -297,6 +300,9 @@ export class HeroAttrsComp extends ecs.Comp { this.revive = undefined; this.critical = 0; this.freeze_chance = 0; + this.knockback_chance = 0; + this.knockback_distance = 0; + this.knockback_res = 0; this.crit_damage = 0; this.revived_count = 0; this.invincible_time = 0; diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index 6102b2f2..bfdb3b99 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -483,32 +483,35 @@ export class HeroViewComp extends CCComp { private isBackingUp: boolean = false; // 🔥 添加后退状态标记 //后退 - back(){ + back(distance: number = 0){ // 🔥 防止重复调用后退动画 - // if (this.isBackingUp) return; - // this.isBackingUp = true; // 🔥 设置后退状态 + if (this.isBackingUp) return; + this.isBackingUp = true; // 🔥 设置后退状态 - // if(this.model.fac==FacSet.MON) { - // let tx=this.node.position.x+FightSet.BACK_RANG - // if(tx > 320) tx=320 - // tween(this.node) - // .to(0.1, { position:v3(tx,this.node.position.y,0)}) - // .call(() => { - // this.isBackingUp = false; // 🔥 动画完成后重置状态 - // }) - // .start() - // } + if(this.model.fac==FacSet.MON) { + // 基础击退距离,加上额外的距离强化 + let dist = FightSet.BACK_RANG + distance; + let tx=this.node.position.x + dist; + if(tx > 320) tx=320; + tween(this.node) + .to(0.1, { position:v3(tx,this.node.position.y,0)}) + .call(() => { + this.isBackingUp = false; // 🔥 动画完成后重置状态 + }) + .start(); + } - // if(this.model.fac==FacSet.HERO) { - // let tx=this.node.position.x-5 - // if(tx < -320) tx=-320 - // tween(this.node) - // .to(0.1, { position:v3(tx,this.node.position.y,0)}) - // .call(() => { - // this.isBackingUp = false; // 🔥 动画完成后重置状态 - // }) - // .start() - // } + if(this.model.fac==FacSet.HERO) { + let dist = 5 + distance; + let tx=this.node.position.x - dist; + if(tx < -320) tx=-320; + tween(this.node) + .to(0.1, { position:v3(tx,this.node.position.y,0)}) + .call(() => { + this.isBackingUp = false; // 🔥 动画完成后重置状态 + }) + .start(); + } } // 伤害计算和战斗逻辑已迁移到 HeroBattleSystem diff --git a/assets/script/game/skill/Skill.ts b/assets/script/game/skill/Skill.ts index 1effe190..a4e23f93 100644 --- a/assets/script/game/skill/Skill.ts +++ b/assets/script/game/skill/Skill.ts @@ -216,6 +216,8 @@ export class Skill extends ecs.Entity { sDataCom.Attrs[Attrs.critical] = cAttrsComp.getRuntimeCritical() + sCrt; sDataCom.Attrs[Attrs.critical_damage] = cAttrsComp.getRuntimeCritDamageBonus(); sDataCom.Attrs[Attrs.freeze_chance] = cAttrsComp.getRuntimeFreezeChance() + sFrz; + sDataCom.Attrs[Attrs.knockback_chance] = cAttrsComp.knockback_chance || 0; + sDataCom.Attrs[Attrs.knockback_distance] = cAttrsComp.knockback_distance || 0; sDataCom.s_uuid=s_uuid sDataCom.skill_lv = Math.max(0, skill_lv); sDataCom.fac=cAttrsComp.fac