feat(技能系统): 添加额外伤害和溅射伤害功能

在技能组件中新增ext_dmg和splash字段用于处理额外伤害和溅射伤害
修改技能创建和伤害计算逻辑以支持新功能
This commit is contained in:
2025-11-24 16:58:04 +08:00
parent 6df4abadd1
commit 91c18004eb
4 changed files with 21 additions and 12 deletions

View File

@@ -158,7 +158,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
const isCrit = this.checkChance(damageEvent.Attrs[Attrs.CRITICAL]); const isCrit = this.checkChance(damageEvent.Attrs[Attrs.CRITICAL]);
if (isCrit) attackerModel?.useValueTalByAttr(Attrs.CRITICAL); // 清除施法者的暴击buff 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) { if (isCrit) {
// 暴击伤害计算 // 暴击伤害计算
// 使用施法者的暴击伤害加成属性damageEvent.Attrs 快照) // 使用施法者的暴击伤害加成属性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伤害 // 1. 获取技能配置 - 如果技能不存在直接返回0伤害
let sConf = SkillSet[s_uuid]; const CAttrs=damageEvent.Attrs;
let sConf = SkillSet[damageEvent.s_uuid];
if (!sConf) return 0; if (!sConf) return 0;
// 2. 计算原始物理伤害和魔法伤害 // 2. 计算原始物理伤害和魔法伤害
// 物理伤害基础值 = 技能物理倍率 * 施法者物理攻击力 / 100 // 物理伤害基础值 = 技能物理倍率 * (施法者物理攻击力 + 额外物理伤害) / 100
let apBase = (sConf.ap||0)*CAttrs[Attrs.AP]/100; let apBase = (sConf.ap||0)*(CAttrs[Attrs.AP]+damageEvent.ext_dmg)/100;
// 魔法伤害基础值 = 技能魔法倍率 * 施法者魔法攻击力 / 100 // 魔法伤害基础值 = 技能魔法倍率 * (施法者魔法攻击力 + 额外魔法伤害) / 100
let mapBase = (sConf.map||0)*CAttrs[Attrs.MAP]/100; let mapBase = (sConf.map||0)*(CAttrs[Attrs.MAP]+damageEvent.ext_dmg)/100;
// 3. 获取目标防御属性 // 3. 获取目标防御属性
const def = (TAttrs[Attrs.DEF]||0); // 目标物理防御 const def = (TAttrs[Attrs.DEF]||0); // 目标物理防御

View File

@@ -161,17 +161,19 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
if (hset === HSSet.atk){ if (hset === HSSet.atk){
let delay = 0.3 let delay = 0.3
let ext_dmg = heroAttrs.useCountValTal(TalEffet.ATK_DMG); let ext_dmg = heroAttrs.useCountValTal(TalEffet.ATK_DMG);
let splash = heroAttrs.useCountValTal(TalEffet.SPLASH);
heroView.scheduleOnce(() => { heroView.scheduleOnce(() => {
this.createSkill(s_uuid, heroView,targets,ext_dmg); this.createSkill(s_uuid, heroView,targets,ext_dmg,splash);
}, delay); }, delay);
//风怒wfuny 只针对 普通攻击起效 //风怒wfuny 只针对 普通攻击起效
if (heroAttrs.useCountTal(TalEffet.WFUNY)){ if (heroAttrs.useCountTal(TalEffet.WFUNY)){
let ext2_dmg = heroAttrs.useCountValTal(TalEffet.ATK_DMG); let ext2_dmg = heroAttrs.useCountValTal(TalEffet.ATK_DMG);
let splash2 = heroAttrs.useCountValTal(TalEffet.SPLASH);
let delay = 0.3 let delay = 0.3
heroView.playSkillEffect(s_uuid); heroView.playSkillEffect(s_uuid);
//需要再添加 风怒动画 //需要再添加 风怒动画
heroView.scheduleOnce(() => { heroView.scheduleOnce(() => {
this.createSkill(s_uuid, heroView,targets,ext2_dmg); this.createSkill(s_uuid, heroView,targets,ext2_dmg,splash2);
},delay); },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) { if (!caster.node || !caster.node.isValid) {
console.warn("[SACastSystem] 施法者节点无效"); console.warn("[SACastSystem] 施法者节点无效");
@@ -237,7 +239,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
const targetPos = targets[0]; // 使用第一个目标位置 const targetPos = targets[0]; // 使用第一个目标位置
// console.log(`[SACastSystem]: ${s_uuid}, 起始位置: ${startPos}, 目标位置: ${targetPos}`); // 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);
} }
/** /**

View File

@@ -12,6 +12,8 @@ export class SDataCom extends ecs.Comp {
group:BoxSet=BoxSet.HERO group:BoxSet=BoxSet.HERO
fac: number = 0; // 0:hero 1:monster fac: number = 0; // 0:hero 1:monster
s_uuid:number=0 s_uuid:number=0
ext_dmg:number=0 //额外伤害
splash:number=0 //溅射伤害
hit_count:number=0 //击中数量 hit_count:number=0 //击中数量
reset() { reset() {
this.Attrs=null this.Attrs=null
@@ -20,6 +22,8 @@ export class SDataCom extends ecs.Comp {
this.s_uuid=0 this.s_uuid=0
this.caster=null this.caster=null
this.hit_count=0 this.hit_count=0
this.ext_dmg=0
this.splash=0
} }
} }

View File

@@ -29,7 +29,7 @@ export class Skill extends ecs.Entity {
this.addComponents<SMoveDataComp>(SMoveDataComp); this.addComponents<SMoveDataComp>(SMoveDataComp);
} }
load(startPos: Vec3, parent: Node, s_uuid: number, targetPos: Vec3, 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]; const config = SkillSet[s_uuid];
if (!config) { if (!config) {
@@ -93,6 +93,8 @@ export class Skill extends ecs.Entity {
sDataCom.Attrs={...cAttrsComp.Attrs} sDataCom.Attrs={...cAttrsComp.Attrs}
sDataCom.s_uuid=s_uuid sDataCom.s_uuid=s_uuid
sDataCom.fac=cAttrsComp.fac sDataCom.fac=cAttrsComp.fac
sDataCom.ext_dmg=ext_dmg
sDataCom.splash=splash
} }
/** 模块资源释放 */ /** 模块资源释放 */