From 91c18004ebadbda16c46e7f42e63fa5e6ea416c3 Mon Sep 17 00:00:00 2001 From: panw Date: Mon, 24 Nov 2025 16:58:04 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=8A=80=E8=83=BD=E7=B3=BB=E7=BB=9F):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A2=9D=E5=A4=96=E4=BC=A4=E5=AE=B3=E5=92=8C?= =?UTF-8?q?=E6=BA=85=E5=B0=84=E4=BC=A4=E5=AE=B3=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在技能组件中新增ext_dmg和splash字段用于处理额外伤害和溅射伤害 修改技能创建和伤害计算逻辑以支持新功能 --- assets/script/game/hero/HeroAtkSystem.ts | 15 ++++++++------- assets/script/game/hero/SACastSystem.ts | 10 ++++++---- assets/script/game/skill/SDataCom.ts | 4 ++++ assets/script/game/skill/Skill.ts | 4 +++- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/assets/script/game/hero/HeroAtkSystem.ts b/assets/script/game/hero/HeroAtkSystem.ts index 27c6af1f..7a891259 100644 --- a/assets/script/game/hero/HeroAtkSystem.ts +++ b/assets/script/game/hero/HeroAtkSystem.ts @@ -158,7 +158,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd const isCrit = this.checkChance(damageEvent.Attrs[Attrs.CRITICAL]); if (isCrit) attackerModel?.useValueTalByAttr(Attrs.CRITICAL); // 清除施法者的暴击buff // 计算伤害 - let damage = this.dmgCount(damageEvent.Attrs,targetAttrs.Attrs,damageEvent.s_uuid); + let damage = this.dmgCount(damageEvent,targetAttrs.Attrs); if (isCrit) { // 暴击伤害计算 // 使用施法者的暴击伤害加成属性(damageEvent.Attrs 快照) @@ -228,16 +228,17 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd * - 所有除法和乘法计算后都进行取整操作,确保游戏中的伤害值为整数 * - 元素伤害只应用于魔法伤害部分 */ - private dmgCount(CAttrs:any,TAttrs:any,s_uuid:number){ + private dmgCount(damageEvent:any,TAttrs:any){ // 1. 获取技能配置 - 如果技能不存在,直接返回0伤害 - let sConf = SkillSet[s_uuid]; + const CAttrs=damageEvent.Attrs; + let sConf = SkillSet[damageEvent.s_uuid]; if (!sConf) return 0; // 2. 计算原始物理伤害和魔法伤害 - // 物理伤害基础值 = 技能物理倍率 * 施法者物理攻击力 / 100 - let apBase = (sConf.ap||0)*CAttrs[Attrs.AP]/100; - // 魔法伤害基础值 = 技能魔法倍率 * 施法者魔法攻击力 / 100 - let mapBase = (sConf.map||0)*CAttrs[Attrs.MAP]/100; + // 物理伤害基础值 = 技能物理倍率 * (施法者物理攻击力 + 额外物理伤害) / 100 + let apBase = (sConf.ap||0)*(CAttrs[Attrs.AP]+damageEvent.ext_dmg)/100; + // 魔法伤害基础值 = 技能魔法倍率 * (施法者魔法攻击力 + 额外魔法伤害) / 100 + let mapBase = (sConf.map||0)*(CAttrs[Attrs.MAP]+damageEvent.ext_dmg)/100; // 3. 获取目标防御属性 const def = (TAttrs[Attrs.DEF]||0); // 目标物理防御 diff --git a/assets/script/game/hero/SACastSystem.ts b/assets/script/game/hero/SACastSystem.ts index 9549d64d..c0b5509a 100644 --- a/assets/script/game/hero/SACastSystem.ts +++ b/assets/script/game/hero/SACastSystem.ts @@ -161,17 +161,19 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat if (hset === HSSet.atk){ let delay = 0.3 let ext_dmg = heroAttrs.useCountValTal(TalEffet.ATK_DMG); + let splash = heroAttrs.useCountValTal(TalEffet.SPLASH); heroView.scheduleOnce(() => { - this.createSkill(s_uuid, heroView,targets,ext_dmg); + this.createSkill(s_uuid, heroView,targets,ext_dmg,splash); }, delay); //风怒wfuny 只针对 普通攻击起效 if (heroAttrs.useCountTal(TalEffet.WFUNY)){ let ext2_dmg = heroAttrs.useCountValTal(TalEffet.ATK_DMG); + let splash2 = heroAttrs.useCountValTal(TalEffet.SPLASH); let delay = 0.3 heroView.playSkillEffect(s_uuid); //需要再添加 风怒动画 heroView.scheduleOnce(() => { - this.createSkill(s_uuid, heroView,targets,ext2_dmg); + this.createSkill(s_uuid, heroView,targets,ext2_dmg,splash2); },delay); } } @@ -212,7 +214,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat /** * 创建技能实体 */ - private createSkill(s_uuid: number, caster: HeroViewComp,targets:Vec3[]=[],ext_dmg:number=0) { + private createSkill(s_uuid: number, caster: HeroViewComp,targets:Vec3[]=[],ext_dmg:number=0,splash:number=0) { // 检查节点有效性 if (!caster.node || !caster.node.isValid) { console.warn("[SACastSystem] 施法者节点无效"); @@ -237,7 +239,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat const targetPos = targets[0]; // 使用第一个目标位置 // console.log(`[SACastSystem]: ${s_uuid}, 起始位置: ${startPos}, 目标位置: ${targetPos}`); // 加载技能实体(包括预制体、组件初始化等) - skill.load(startPos, parent, s_uuid, targetPos, caster,ext_dmg); + skill.load(startPos, parent, s_uuid, targetPos, caster,ext_dmg,splash); } /** diff --git a/assets/script/game/skill/SDataCom.ts b/assets/script/game/skill/SDataCom.ts index 0a60ba56..d88c4c49 100644 --- a/assets/script/game/skill/SDataCom.ts +++ b/assets/script/game/skill/SDataCom.ts @@ -12,6 +12,8 @@ export class SDataCom extends ecs.Comp { group:BoxSet=BoxSet.HERO fac: number = 0; // 0:hero 1:monster s_uuid:number=0 + ext_dmg:number=0 //额外伤害 + splash:number=0 //溅射伤害 hit_count:number=0 //击中数量 reset() { this.Attrs=null @@ -20,6 +22,8 @@ export class SDataCom extends ecs.Comp { this.s_uuid=0 this.caster=null this.hit_count=0 + this.ext_dmg=0 + this.splash=0 } } diff --git a/assets/script/game/skill/Skill.ts b/assets/script/game/skill/Skill.ts index 7e83fcca..6b6d013b 100644 --- a/assets/script/game/skill/Skill.ts +++ b/assets/script/game/skill/Skill.ts @@ -29,7 +29,7 @@ export class Skill extends ecs.Entity { this.addComponents(SMoveDataComp); } load(startPos: Vec3, parent: Node, s_uuid: number, targetPos: Vec3, - caster:HeroViewComp,ext_dmg:number=0) { + caster:HeroViewComp,ext_dmg:number=0,splash:number=0) { const config = SkillSet[s_uuid]; if (!config) { @@ -93,6 +93,8 @@ export class Skill extends ecs.Entity { sDataCom.Attrs={...cAttrsComp.Attrs} sDataCom.s_uuid=s_uuid sDataCom.fac=cAttrsComp.fac + sDataCom.ext_dmg=ext_dmg + sDataCom.splash=splash } /** 模块资源释放 */