diff --git a/assets/script/game/common/config/HeroAttrs.ts b/assets/script/game/common/config/HeroAttrs.ts index 7ff44aae..23174fe7 100644 --- a/assets/script/game/common/config/HeroAttrs.ts +++ b/assets/script/game/common/config/HeroAttrs.ts @@ -1,3 +1,4 @@ +import * as exp from "constants"; import { HType } from "./heroSet"; /** @@ -10,51 +11,115 @@ export enum BType { RATIO = 1 //百分比型 } +export enum NeAttrs { + IN_FROST = 0, + IN_STUN = 1, + IN_BURN = 2, + IN_POISON = 3, +} +export const getNeAttrs = () => { + let reAttrs = {}; + Object.keys(NeAttrs).forEach(key => { + if (!isNaN(Number(key))) { + reAttrs[Number(key)] = { + value: 0, + time: 0, + }; + } + }); + return reAttrs; +} // ========== 属性枚举 ========== /** * 英雄属性枚举 * 定义所有可用的战斗属性类型 + * 按逻辑分组排序:基础生存 → 攻击属性 → 防御属性 → 特殊效果 → 基础属性 */ export enum Attrs { - HP_MAX = 0, //生命值 - MP_MAX = 1, //魔法值 - SHIELD_MAX = 2, //护盾 - AP = 3, //攻击力 - MAP = 4, //魔法攻击力 - DEF = 5, //防御 - MDEF = 6, //魔法防御 - CRITICAL = 7, //暴击率 - CRITICAL_DMG = 8, //暴击伤害 - DODGE = 9, //闪避 - HIT = 10, //命中 - WFUNY = 11, // 风怒 - AS = 12, //攻击速度,直接减技能cd - REFLICT = 13, //反伤比率 - LIFESTEAL = 14, //吸血比率 - BACK = 15, //攻击带击退概率 - DEBACK = 16, //被攻击击退概率 - CON_RES = 17, //控制抗性 - ICE_RES = 18, //冰冻抗性 - FIRE_RES = 19, //火抗性 - WIND_RES = 20, //风抗性 - ICE_POWER = 21, //冰冻伤害效果提升 - FIRE_POWER = 22, //火伤害效果提升 - WIND_POWER = 23, //风伤害效果提升 - BUFF_UP = 24, //buff效果提升 - DBUFF_UP = 25, //debuff效果提升 - DIS = 26, //攻击距离 - SPEED = 27, //移动速度加成,默认都是百分比 - SHIELD_UP = 28, //护盾效果提升 - BURN = 29, //攻击带易伤 - DEBURN = 30, //被攻击易伤 - PUNCTURE = 31, // 穿刺次数 - PUNCTURE_DMG = 32, //穿刺伤害加成 - // 基础属性 - STRENGTH = 33, //力量 - INTELLIGENCE = 34, //智力 - AGILITY = 35, //敏捷 - SPIRIT = 36, //精神 - LUCK = 37, //幸运 + // ========== 基础生存属性 (0-9) ========== + HP_MAX = 0, // 最大生命值 + MP_MAX = 1, // 最大魔法值 + SHIELD_MAX = 2, // 最大护盾值 + HP_REGEN = 3, // 生命回复 + MP_REGEN = 4, // 魔法回复 + HEAL_EFFECT = 5, // 治疗效果 + + // ========== 攻击属性 (10-19) ========== + AP = 10, // 攻击力 + MAP = 11, // 魔法攻击力 + DIS = 12, // 攻击距离 + AS = 13, // 攻击速度(减少技能CD) + SKILL_DURATION = 14, // 技能持续时间 + AREA_OF_EFFECT = 15, // 作用范围 + PIERCE = 16, // 穿透次数 + + // ========== 防御属性 (20-29) ========== + DEF = 20, // 物理防御 + MDEF = 21, // 魔法防御 + DODGE = 22, // 闪避率 + BLOCK = 23, // 格挡率 + DAMAGE_REDUCTION = 24, // 伤害减免 + THORNS = 25, // 反伤 + CRITICAL_RESIST = 26, // 暴击抗性 + CON_RES = 27, // 控制抗性 + MAGIC_RES = 28, // 魔法抗性 + + // ========== 暴击与命中属性 (30-39) ========== + CRITICAL = 30, // 暴击率 + CRITICAL_DMG = 31, // 暴击伤害 + HIT = 32, // 命中率 + + // ========== 元素属性 (40-49) ========== + ICE_RES = 40, // 冰冻抗性 + FIRE_RES = 41, // 火焰抗性 + WIND_RES = 42, // 自然抗性 + ICE_POWER = 43, // 冰冻伤害加成 + FIRE_POWER = 44, // 火焰伤害加成 + WIND_POWER = 45, // 自然伤害加成 + + + // ========== 特殊效果属性 (50-59) ========== + LIFESTEAL = 50, // 吸血比率 + MANASTEAL = 51, // 吸蓝比率 + FREEZE_CHANCE = 52, // 冰冻概率 + BURN_CHANCE = 53, // 燃烧概率 + STUN_CHANCE = 54, // 眩晕概率 + KNOCKBACK = 55, // 击退概率 + SLOW_CHANCE = 56, // 减速概率 + POISON_CHANCE = 57, // 中毒概率 + CHAIN_CHANCE = 58, // 连锁概率 + EXPLOSION_CHANCE = 59, // 爆炸概率 + + // ========== 增益效果属性 (60-69) ========== + BUFF_UP = 60, // Buff效果提升 + DBUFF_UP = 61, // Debuff效果提升 + SHIELD_UP = 62, // 护盾效果提升 + SPEED = 63, // 移动速度加成 + EXP_GAIN = 64, // 经验获取 + GOLD_GAIN = 65, // 金币获取 + DROP_CHANCE = 66, // 掉落率 + REVIVE_COUNT = 67, // 复活次数 + REVIVE_TIME = 68, // 复活时间 + INVINCIBLE_TIME = 69, // 无敌时间 + + // ========== 武器进化相关 (70-79) ========== + PUNCTURE = 70, // 穿刺次数 + PUNCTURE_DMG = 71, // 穿刺伤害 + BACK = 73, // 被击退概率(兼容旧代码) + MOVE_SPEED = 74, // 移动速度 + BURN = 75, // 易伤效果 + WFUNY = 77, // 风怒 + + // ========== 生存与恢复相关 (80-89) ========== + + // ========== 负面状态相关 (90-99) ========== + + // ========== 基础属性(影响其他属性)(100-104) ========== + STRENGTH = 90, // 力量(影响物理相关) + INTELLIGENCE = 91, // 智力(影响魔法相关) + AGILITY = 92, // 敏捷(影响速度和闪避) + SPIRIT = 93, // 精神(影响抗性和特殊效果) + LUCK = 94, // 幸运(影响暴击和特殊概率) } /** @@ -78,49 +143,92 @@ export const getAttrs = () => { * 用于区分每个属性是数值型还是百分比型 * - VALUE: 数值型属性(如生命值、攻击力等绝对数值) * - RATIO: 百分比型属性(如暴击率、闪避率等百分比数值) + * 按新的Attrs枚举顺序重新组织 */ export const AttrsType: Record = { - // ========== 数值型属性 ========== + // ========== 基础生存属性(数值型) ========== [Attrs.HP_MAX]: BType.VALUE, // 最大生命值 - 数值型 [Attrs.MP_MAX]: BType.VALUE, // 最大魔法值 - 数值型 [Attrs.SHIELD_MAX]: BType.VALUE, // 最大护盾值 - 数值型 + [Attrs.HP_REGEN]: BType.VALUE, // 生命回复 - 数值型 + [Attrs.MP_REGEN]: BType.VALUE, // 魔法回复 - 数值型 + [Attrs.HEAL_EFFECT]: BType.RATIO, // 治疗效果 - 百分比型 + + // ========== 攻击属性(数值型) ========== [Attrs.AP]: BType.VALUE, // 攻击力 - 数值型 [Attrs.MAP]: BType.VALUE, // 魔法攻击力 - 数值型 - [Attrs.DEF]: BType.VALUE, // 防御 - 数值型 - [Attrs.MDEF]: BType.VALUE, // 魔法防御 - 数值型 [Attrs.DIS]: BType.VALUE, // 攻击距离 - 数值型 - [Attrs.BURN]: BType.VALUE, // 易伤 - 数值型 - [Attrs.DEBURN]: BType.VALUE, // 被攻击易伤 - 数值型 - [Attrs.PUNCTURE]: BType.VALUE, // 穿刺次数 - 数值型 + [Attrs.AS]: BType.RATIO, // 攻击速度 - 百分比型 + [Attrs.SKILL_DURATION]: BType.RATIO, // 技能持续时间 - 百分比型 + [Attrs.AREA_OF_EFFECT]: BType.VALUE, // 作用范围 - 数值型 + [Attrs.PIERCE]: BType.VALUE, // 穿透次数 - 数值型 + + // ========== 防御属性(混合类型) ========== + [Attrs.DEF]: BType.VALUE, // 物理防御 - 数值型 + [Attrs.MDEF]: BType.VALUE, // 魔法防御 - 数值型 + [Attrs.DODGE]: BType.RATIO, // 闪避率 - 百分比型 + [Attrs.BLOCK]: BType.RATIO, // 格挡率 - 百分比型 + [Attrs.DAMAGE_REDUCTION]: BType.RATIO, // 伤害减免 - 百分比型 + [Attrs.THORNS]: BType.RATIO, // 反伤 - 百分比型 + + // ========== 暴击与命中属性(百分比型) ========== + [Attrs.CRITICAL]: BType.RATIO, // 暴击率 - 百分比型 + [Attrs.CRITICAL_DMG]: BType.RATIO, // 暴击伤害 - 百分比型 + [Attrs.HIT]: BType.RATIO, // 命中率 - 百分比型 + [Attrs.CRITICAL_RESIST]: BType.RATIO, // 暴击抗性 - 百分比型 + [Attrs.CON_RES]: BType.RATIO, // 控制抗性 - 百分比型 + [Attrs.MAGIC_RES]: BType.RATIO, // 魔法抗性 - 百分比型 + + // ========== 元素属性(百分比型) ========== + [Attrs.ICE_RES]: BType.RATIO, // 冰冻抗性 - 百分比型 + [Attrs.FIRE_RES]: BType.RATIO, // 火焰抗性 - 百分比型 + [Attrs.WIND_RES]: BType.RATIO, // 风抗性 - 百分比型 + [Attrs.ICE_POWER]: BType.RATIO, // 冰冻伤害加成 - 百分比型 + [Attrs.FIRE_POWER]: BType.RATIO, // 火焰伤害加成 - 百分比型 + [Attrs.WIND_POWER]: BType.RATIO, // 风伤害加成 - 百分比型 + + // ========== 特殊效果属性(百分比型) ========== + [Attrs.LIFESTEAL]: BType.RATIO, // 吸血比率 - 百分比型 + [Attrs.MANASTEAL]: BType.RATIO, // 吸蓝 - 百分比型 + [Attrs.FREEZE_CHANCE]: BType.RATIO, // 冰冻概率 - 百分比型 + [Attrs.BURN_CHANCE]: BType.RATIO, // 燃烧概率 - 百分比型 + [Attrs.STUN_CHANCE]: BType.RATIO, // 眩晕概率 - 百分比型 + [Attrs.KNOCKBACK]: BType.RATIO, // 击退 - 百分比型 + [Attrs.SLOW_CHANCE]: BType.RATIO, // 减速概率 - 百分比型 + [Attrs.POISON_CHANCE]: BType.RATIO, // 中毒概率 - 百分比型 + [Attrs.CHAIN_CHANCE]: BType.RATIO, // 连锁概率 - 百分比型 + [Attrs.EXPLOSION_CHANCE]: BType.RATIO, // 爆炸概率 - 百分比型 + + // ========== 增益效果属性(百分比型) ========== + [Attrs.BUFF_UP]: BType.RATIO, // Buff效果提升 - 百分比型 + [Attrs.DBUFF_UP]: BType.RATIO, // Debuff效果提升 - 百分比型 + [Attrs.SHIELD_UP]: BType.RATIO, // 护盾效果提升 - 百分比型 + [Attrs.SPEED]: BType.RATIO, // 移动速度加成 - 百分比型 + [Attrs.EXP_GAIN]: BType.RATIO, // 经验获取 - 百分比型 + [Attrs.GOLD_GAIN]: BType.RATIO, // 金币获取 - 百分比型 + [Attrs.DROP_CHANCE]: BType.RATIO, // 掉落率 - 百分比型 + [Attrs.REVIVE_COUNT]: BType.VALUE, // 复活次数 - 数值型 + [Attrs.REVIVE_TIME]: BType.RATIO, // 复活时间 - 百分比型 + [Attrs.INVINCIBLE_TIME]: BType.RATIO, // 无敌时间 - 百分比型 + + // ========== 武器进化相关(混合类型) ========== + [Attrs.PUNCTURE]: BType.VALUE, // 穿刺次数 - 数值型 + [Attrs.PUNCTURE_DMG]: BType.RATIO, // 穿刺伤害 - 百分比型 + [Attrs.BACK]: BType.RATIO, // 被击退概率(兼容)- 百分比型 + [Attrs.MOVE_SPEED]: BType.VALUE, // 移动速度 - 数值型 + [Attrs.BURN]: BType.RATIO, // 易伤效果 - 百分比型 + [Attrs.WFUNY]: BType.RATIO, // 未知特殊属性 - 百分比型 + + // ========== 生存与恢复相关(混合类型) ========== + + // ========== 负面状态相关(混合类型) ========== + + // ========== 基础属性(数值型) ========== [Attrs.STRENGTH]: BType.VALUE, // 力量 - 数值型 [Attrs.INTELLIGENCE]: BType.VALUE, // 智力 - 数值型 [Attrs.AGILITY]: BType.VALUE, // 敏捷 - 数值型 [Attrs.SPIRIT]: BType.VALUE, // 精神 - 数值型 [Attrs.LUCK]: BType.VALUE, // 幸运 - 数值型 - - // ========== 百分比型属性 ========== - [Attrs.CRITICAL]: BType.RATIO, // 暴击率 - 百分比型 - [Attrs.CRITICAL_DMG]: BType.RATIO, // 暴击伤害 - 百分比型 - [Attrs.DODGE]: BType.RATIO, // 闪避 - 百分比型 - [Attrs.HIT]: BType.RATIO, // 命中 - 百分比型 - [Attrs.WFUNY]: BType.RATIO, // 风怒 - 百分比型 - [Attrs.AS]: BType.RATIO, // 攻击速度 - 百分比型 - [Attrs.REFLICT]: BType.RATIO, // 反伤比率 - 百分比型 - [Attrs.LIFESTEAL]: BType.RATIO, // 吸血比率 - 百分比型 - [Attrs.BACK]: BType.RATIO, // 击退概率 - 百分比型 - [Attrs.CON_RES]: BType.RATIO, // 控制抗性 - 百分比型 - [Attrs.ICE_RES]: BType.RATIO, // 冰冻抗性 - 百分比型 - [Attrs.FIRE_RES]: BType.RATIO, // 火抗性 - 百分比型 - [Attrs.WIND_RES]: BType.RATIO, // 风抗性 - 百分比型 - [Attrs.ICE_POWER]: BType.RATIO, // 冰冻伤害效果提升 - 百分比型 - [Attrs.FIRE_POWER]: BType.RATIO, // 火伤害效果提升 - 百分比型 - [Attrs.WIND_POWER]: BType.RATIO, // 风伤害效果提升 - 百分比型 - [Attrs.DEBACK]: BType.RATIO, // 被击退概率 - 百分比型 - [Attrs.BUFF_UP]: BType.RATIO, // buff效果提升 - 百分比型 - [Attrs.DBUFF_UP]: BType.RATIO, // debuff效果提升 - 百分比型 - [Attrs.SPEED]: BType.RATIO, // 移动速度加成 - 百分比型 - [Attrs.SHIELD_UP]: BType.RATIO, // 护盾效果提升 - 百分比型 - [Attrs.PUNCTURE_DMG]: BType.RATIO, // 穿刺伤害加成 - 百分比型 }; /** @@ -177,6 +285,8 @@ export const HeroTypeGrowthConfig: Record = { [Attrs.MP_MAX]: 0.5, // 精神 -> 魔法值 [Attrs.LIFESTEAL]: 0.4, // 精神 -> 吸血 (战士较高) [Attrs.MDEF]: 0.3, // 精神 -> 魔法防御 + [Attrs.HP_REGEN]: 0.2, // 精神 -> 生命回复 + [Attrs.MP_REGEN]: 0.3, // 精神 -> 魔法回复 }, [Attrs.LUCK]: { [Attrs.CRITICAL]: 0.8, // 幸运 -> 暴击率 @@ -225,6 +335,7 @@ export const HeroTypeGrowthConfig: Record = { [Attrs.MP_MAX]: 2, // 智力 -> 魔法值 (法师最高) [Attrs.MAP]: 1.8, // 智力 -> 魔法攻击 (法师最高) [Attrs.MDEF]: 0.8, // 智力 -> 魔法防御 + [Attrs.AREA_OF_EFFECT]: 0.3, // 智力 -> 作用范围 }, [Attrs.AGILITY]: { [Attrs.CRITICAL]: 0.4, // 敏捷 -> 暴击率 diff --git a/assets/script/game/common/config/SkillSet.ts b/assets/script/game/common/config/SkillSet.ts index 985e4c3e..e108e4fd 100644 --- a/assets/script/game/common/config/SkillSet.ts +++ b/assets/script/game/common/config/SkillSet.ts @@ -1,3 +1,5 @@ +// ========== 从 HeroAttrs.ts 导入属性相关定义 ========== +import { Attrs, NeAttrs,BType, getAttrs, AttrsType, isRatioAttr } from "./HeroAttrs"; export enum TGroup { Self = 0, // 自身 Ally = 1, // 所有敌人 @@ -70,72 +72,7 @@ export enum EType { } //debuff类型 -export enum DBuff { - STUN = 1, //眩晕 - 对应Attrs.CON_RES (控制抗性), BType.RATIO - SLOW = 2, //减速 - 对应Attrs.AS (攻击速度), BType.RATIO - FROST = 3, //冰冻 - 对应Attrs.ICE_RES (冰冻抗性), BType.RATIO - BURN = 4, //易伤 - 对应Attrs.DEF/MDEF (防御/魔防), BType.RATIO, 默认次数是5, 技能配置的devC是额外次数 - AS = 5, //减速 - 对应Attrs.AS (攻击速度), BType.RATIO, 直接+技能cd - HP_MAX = 6, //减hp - 对应Attrs.HP_MAX (最大生命值), BType.RATIO - AP = 7, //减atk - 对应Attrs.AP (攻击力), BType.RATIO - MGP = 8, //减魔法伤害 - 对应Attrs.MAP (魔法攻击力), BType.RATIO - DEBACK = 9, //击退概率 - 对应Attrs.BACK (击退概率), BType.RATIO - CRITICAL = 10, //-暴击率 - 对应Attrs.CRITICAL (暴击率), BType.RATIO - CRIT_DAMAGE = 11, //-暴击伤害 - 对应Attrs.CRITICAL_DMG (暴击伤害), BType.RATIO - DODGE = 12, //-闪避 - 对应Attrs.DODGE (闪避), BType.RATIO - DBUFFUP = 13, //edbuff效果提升 - BUFF_DOWN = 14,// buff效果减弱 - SPEED = 15, //移动速度下降 - 对应Attrs.MOVE_SPEED (移动速度), BType.RATIO - DEBURN = 16, //被攻击带易伤 -} -// ========== 从 HeroAttrs.ts 导入属性相关定义 ========== -import { Attrs, BType, getAttrs, AttrsType, isRatioAttr } from "./HeroAttrs"; - -// ========== 为向后兼容性重新导出 ========== -export { Attrs, BType, getAttrs, AttrsType, isRatioAttr }; - - -/** - * DBuff 与 Attrs 的双向映射关系表 - * 格式:[DBuff, Attrs 或 -1(状态类)] - */ -const DEBUFF_ATTR_MAP: [DBuff, number][] = [ - [DBuff.STUN, -1], // 眩晕 - 状态类 - [DBuff.SLOW, Attrs.SPEED], // 减速 -> 速度 - [DBuff.FROST, -1], // 冰冻 - 状态类 - [DBuff.DEBURN, Attrs.DEBURN], // 被易伤 -> 被易伤 - [DBuff.BURN, Attrs.BURN], // 易伤 -> 易伤效果 - [DBuff.AS, Attrs.AS], // 减cd -> 攻击速度 - [DBuff.HP_MAX, Attrs.HP_MAX], // 减hp -> 最大生命值 - [DBuff.AP, Attrs.AP], // 减atk -> 攻击力 - [DBuff.MGP, Attrs.MAP], // 减魔法 -> 魔法攻击力 - [DBuff.DEBACK, Attrs.DEBACK], // 被击退 -> 被击退概率 - [DBuff.CRITICAL, Attrs.CRITICAL], // -暴击率 -> 暴击率 - [DBuff.CRIT_DAMAGE, Attrs.CRITICAL_DMG], // -暴击伤害 -> 暴击伤害 - [DBuff.DODGE, Attrs.DODGE], // -闪避 -> 闪避 - [DBuff.DBUFFUP, Attrs.DBUFF_UP], // debuff提升 -> debuff提升 - [DBuff.BUFF_DOWN, Attrs.BUFF_UP], // buff减弱 -> buff效果 - [DBuff.SPEED, Attrs.SPEED], // 移动速度下降 -> 移动速度 -]; - -/** - * 双向转换:DBuff ⇄ Attrs - * @param key DBuff 或 Attrs 枚举值 - * @param isDebuff true: key 是 DBuff, false: key 是 Attrs - * @returns 对应的转换值,未找到则返回 -1 - */ -export const TransformBuffs = (key: number, isDebuff: boolean): number => { - if (isDebuff) { - // DBuff → Attrs - const found = DEBUFF_ATTR_MAP.find(([debuff]) => debuff === key); - return found ? found[1] : -1; - } else { - // Attrs → DBuff(只返回第一个匹配) - const found = DEBUFF_ATTR_MAP.find(([, attr]) => attr === key); - return found ? found[0] : -1; - } -}; /* === 技能配置系统使用说明 === @@ -166,24 +103,15 @@ export const TransformBuffs = (key: number, isDebuff: boolean): number => { - hitcd: 持续伤害的伤害间隔 - speed: 移动速度 - cost: 消耗值 - - */ export enum DType { ATK= 0, // 物理 MAGE=1, // 魔法 } - export const HeroSkillList = [6001,6001,6001,6001,6001,6001] // Debuff配置接口 -export interface DbuffConf { - debuff: DBuff; // debuff类型 - BType:BType //buff是数值型还是百分比型 - value: number; // 效果值 - time: number; // 持续时间 - chance: number; // 触发概率 -} + export interface BuffConf { buff:Attrs; BType:BType @@ -191,11 +119,16 @@ export interface BuffConf { time:number; // 持续时间 chance:number; // 触发概率 } +export interface NeAttrsConf { + neAttrs:NeAttrs; + value:number; + time:number; +} // 技能配置接口 - 按照6001格式排列 export interface SkillConfig { uuid:number,name:string,sp_name:string,AtkedName:AtkedName,path:string,TGroup:TGroup,SType:SType,act:string,DTType:DTType,DType:DType, ap:number,cd:number,t_num:number,hit_num:number,hit:number,hitcd:number,speed:number,cost:number,with:number, - buffs:BuffConf[],debuffs:DbuffConf[],info:string,hero?:number + buffs:BuffConf[],neAttrs:NeAttrsConf[],info:string,hero?:number } @@ -204,12 +137,12 @@ export const SkillSet: Record = { 6001: { uuid:6001,name:"挥击",sp_name:"atk_s1",AtkedName:AtkedName.atked,path:"3036",TGroup:TGroup.Enemy,SType:SType.damage,act:"atk",DTType:DTType.single,DType:DType.ATK, ap:100,cd:1,t_num:1,hit_num:1,hit:1,hitcd:0.2,speed:720,cost:0,with:0, - buffs:[],debuffs:[],info:"向最前方敌人扔出石斧,造成100%攻击的伤害" + buffs:[],neAttrs:[],info:"向最前方敌人扔出石斧,造成100%攻击的伤害" }, 6005: { uuid:6005,name:"火球术",sp_name:"atk_fires",AtkedName:AtkedName.atked,path:"3039",TGroup:TGroup.Enemy,SType:SType.damage,act:"atk",DTType:DTType.single,DType:DType.MAGE, ap:100,cd:5,t_num:1,hit_num:1,hit:2,hitcd:0.3,speed:720,cost:20,with:90, - buffs:[],debuffs:[],info:"召唤大火球攻击前方所有敌人,造成300%攻击的伤害,有一定几率施加灼烧" + buffs:[],neAttrs:[],info:"召唤大火球攻击前方所有敌人,造成300%攻击的伤害,有一定几率施加灼烧" }, }; \ No newline at end of file diff --git a/assets/script/game/common/ecs/position/BattleMoveSystem.ts b/assets/script/game/common/ecs/position/BattleMoveSystem.ts index 837cd415..8e0249aa 100644 --- a/assets/script/game/common/ecs/position/BattleMoveSystem.ts +++ b/assets/script/game/common/ecs/position/BattleMoveSystem.ts @@ -4,7 +4,7 @@ import { ecs } from "../../../../../../extensions/oops-plugin-framework/assets/l import { smc } from "../../SingletonModuleComp"; import { FacSet } from "../../config/BoxSet"; import { HType } from "../../config/heroSet"; -import { Attrs, DBuff } from "../../config/SkillSet"; +import { Attrs } from "../../config/HeroAttrs"; @ecs.register('BattleMoveSystem') export class BattleMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate { diff --git a/assets/script/game/hero/Hero.ts b/assets/script/game/hero/Hero.ts index 7d377044..6f3c2bea 100644 --- a/assets/script/game/hero/Hero.ts +++ b/assets/script/game/hero/Hero.ts @@ -8,8 +8,9 @@ import { BoxSet, FacSet } from "../common/config/BoxSet"; import { HeroInfo, HeroPos, HType } from "../common/config/heroSet"; import { BattleMoveComp } from "../common/ecs/position/BattleMoveComp"; import { GameEvent } from "../common/config/GameEvent"; -import { Attrs, getAttrs, SkillSet } from "../common/config/SkillSet"; +import { SkillSet } from "../common/config/SkillSet"; import { time } from "console"; +import { getNeAttrs, getAttrs ,Attrs} from "../common/config/HeroAttrs"; /** 角色实体 */ @ecs.register(`Hero`) @@ -84,6 +85,7 @@ export class Hero extends ecs.Entity { hv.base_dis=hero.dis hv.base_speed=hero.speed hv.Attrs=getAttrs() + hv.NeAttrs=getNeAttrs() hv.hp=hv.Attrs[Attrs.HP_MAX]=hv.base_hp hv.mp=hv.Attrs[Attrs.MP_MAX]=hv.base_mp hv.Attrs[Attrs.DEF]=hv.base_def diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index f7ccf73b..d58e02ab 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -5,13 +5,14 @@ import { HeroSpine } from "./HeroSpine"; import { BoxSet, FacSet } from "../common/config/BoxSet"; import { smc } from "../common/SingletonModuleComp"; import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer"; -import { Attrs, DBuff, SkillSet, BType, BuffConf, DbuffConf, TransformBuffs, AttrsType } from "../common/config/SkillSet"; +import { SkillSet,BuffConf,} from "../common/config/SkillSet"; import { BuffComp } from "./BuffComp"; import { oops } from "db://oops-framework/core/Oops"; import { GameEvent } from "../common/config/GameEvent"; import { FightSet, TooltipTypes } from "../common/config/Mission"; import { RandomManager } from "db://oops-framework/core/common/random/RandomManager"; import { AttrSet, HeroInfo, HeroUpSet } from "../common/config/heroSet"; +import { Attrs, AttrsType, BType, NeAttrs } from "../common/config/HeroAttrs"; const { ccclass, property } = _decorator; /** @@ -30,6 +31,11 @@ const { ccclass, property } = _decorator; * */ /** 角色显示组件 */ +export interface BuffInfo { + attr: Attrs; + value: number; + remainTime?: number; +} @ccclass('HeroViewComp') // 定义Cocos Creator 组件 @ecs.register('HeroView', false) // 定义ECS 组件 export class HeroViewComp extends CCComp { @@ -66,15 +72,12 @@ export class HeroViewComp extends CCComp { base_speed: number = 100; /** 角色移动速度 */ base_dis: number = 100; Attrs:any=[] - // Buff/Debuff 字典结构,通过属性索引直接访 + NeAttrs:any=[] + // Buff debuff 统一管理, value是正,debuff 是负数 // 结构: { [attrIndex: number]: { value: number, remainTime?: number } } - DBUFF_V: Record = {} // 持久型数debuff - DBUFF_R: Record = {} // 持久型百分比 debuff BUFF_V: Record = {} // 持久型数buff BUFF_R: Record = {} // 持久型百分比 buff - DBUFFS_V: Record = {} // 临时型数debuff - DBUFFS_R: Record = {} // 临时型百分比 debuff BUFFS_V: Record = {} // 临时型数buff BUFFS_R: Record = {} // 临时型百分比 buff @@ -82,8 +85,6 @@ export class HeroViewComp extends CCComp { atked_count: number = 0; - - private damageQueue: Array<{ damage: number, isCrit: boolean, @@ -126,14 +127,14 @@ export class HeroViewComp extends CCComp { */ initAttrs() { // 清空现有 buff/debuff - this.BUFF_V = {}; - this.BUFFS_V = {}; - this.BUFF_R = {}; - this.BUFFS_R = {}; - this.DBUFF_V = {}; - this.DBUFFS_V = {}; - this.DBUFF_R = {}; - this.DBUFFS_R = {}; + this.BUFF_V = { + }; + this.BUFFS_V = { + }; + this.BUFF_R = { + }; + this.BUFFS_R = { + }; // 获取英雄配置 const heroInfo = HeroInfo[this.hero_uuid]; if (!heroInfo) return; @@ -170,12 +171,6 @@ export class HeroViewComp extends CCComp { this.addBuff(buffConf); } } - // 加载初始 debuff - if (heroInfo.debuff && heroInfo.debuff.length > 0) { - for (const dbuffConf of heroInfo.debuff) { - this.addDebuff(dbuffConf); - } - } } // ==================== BUFF管理 ==================== /** @@ -238,76 +233,6 @@ export class HeroViewComp extends CCComp { this.recalculateSingleAttr(buffConf.buff); } - // ==================== DEBUFF管理 ==================== - /** - * 添加 debuff 效果(智能覆盖) - * @param dbuffConf debuff 配置 (来自 SkillSet.DbuffConf heroSet.debuff) - * - * 支持两种 debuff - * 1. 属性型 debuff:直接修改属性值(有对应的 Attrs - * 2. 状态型 debuff:只缓存状态(无对应的 Attrs,用于状态检查) - * - * 智能覆盖规则 - * 1. 值更小:不添 - * 2. 值相同且都是临时:叠加时 - * 3. 值更大:更新为新值(临时则更新值和时间 - */ - addDebuff(dbuffConf: DbuffConf) { - // 获取 debuff 对应的属性字 - - const isValue = dbuffConf.BType === BType.VALUE; - const isPermanent = dbuffConf.time === 0; - - // 根据类型选择对应debuff 字典 - const permanentDebuffs = isValue ? this.DBUFF_V : this.DBUFF_R; - const temporaryDebuffs = isValue ? this.DBUFFS_V : this.DBUFFS_R; - // 状态类 debuff 使用 debuff 类型作为 key,属性类 debuff 使用 attrField 作为 key - const key = dbuffConf.debuff; - - if (isPermanent) { - // 添加持久debuff - const existing = permanentDebuffs[key]; - if (existing) { - // 值更小,不添 - if (dbuffConf.value <= existing.value) { - return; - } - // 值更大,更新 - existing.value = dbuffConf.value; - } else { - // 没有同类型,直接添加 - permanentDebuffs[key] = { value: dbuffConf.value }; - } - } else { - // 添加临时debuff - const existing = temporaryDebuffs[key]; - if (existing) { - if (dbuffConf.value < existing.value) { - // 值更小,不添 - return; - } else if (dbuffConf.value === existing.value) { - // 值相同,叠加时间 - existing.remainTime += dbuffConf.time; - return; // 时间叠加不需要重算属 - } else { - // 值更大,更新值和时间 - existing.value = dbuffConf.value; - existing.remainTime = dbuffConf.time; - } - } else { - // 没有同类型,直接添加 - temporaryDebuffs[key] = { - value: dbuffConf.value, - remainTime: dbuffConf.time - }; - } - } - let attrField = TransformBuffs(dbuffConf.debuff,true); - // 只重新计算受影响的属性(状态类 debuff 不需要计算) - if (attrField > 0 ) { - this.recalculateSingleAttr(attrField); - } - } // ==================== 属性计算系==================== /** @@ -343,16 +268,7 @@ export class HeroViewComp extends CCComp { totalValue += this.BUFFS_V[attrIndex].value; } - // Debuff:需要通过 DBuff key 查找 - const deKey = TransformBuffs(attrIndex, false); - if (deKey !== -1) { - if (this.DBUFF_V[deKey]) { - totalValue -= this.DBUFF_V[deKey].value; - } - if (this.DBUFFS_V[deKey]) { - totalValue -= this.DBUFFS_V[deKey].value; - } - } + // 3. 收集所有百分比型 buff/debuff let totalRatio = 0; // 总百分比(可正可负) @@ -364,17 +280,7 @@ export class HeroViewComp extends CCComp { totalRatio += this.BUFFS_R[attrIndex].value; } - // Debuff:需要通过 DBuff key 查找 - if (deKey !== -1) { - if (this.DBUFF_R[deKey]) { - totalRatio -= this.DBUFF_R[deKey].value; - } - if (this.DBUFFS_R[deKey]) { - totalRatio -= this.DBUFFS_R[deKey].value; - } - } - - + // 4. 根据属性类型计算最终值 const attrType = AttrsType[attrIndex]; const isRatioAttr = attrType === BType.RATIO; @@ -439,27 +345,12 @@ export class HeroViewComp extends CCComp { } } - // 更新临时型数debuff - for (const key in this.DBUFFS_V) { - const debuff = this.DBUFFS_V[key]; + // 负面状态更新 + for (const key in this.NeAttrs) { + const debuff = this.NeAttrs[key]; debuff.remainTime -= dt; if (debuff.remainTime <= 0) { - delete this.DBUFFS_V[key]; - const keyNum = parseInt(key); - const attrField = TransformBuffs(keyNum,true) - if(attrField > 0) affectedAttrs.add(attrField); - } - } - - // 更新临时型百分比 debuff - for (const key in this.DBUFFS_R) { - const debuff = this.DBUFFS_R[key]; - debuff.remainTime -= dt; - if (debuff.remainTime <= 0) { - delete this.DBUFFS_R[key]; - const keyNum = parseInt(key); - const attrField = TransformBuffs(keyNum,true) - if(attrField > 0) affectedAttrs.add(attrField); + debuff.remainTime = 0; } } @@ -470,10 +361,10 @@ export class HeroViewComp extends CCComp { } public isStun() { - return this.DBUFFS_V[DBuff.STUN] !== undefined?true:false + return this.NeAttrs[NeAttrs.IN_STUN].time > 0; } public isFrost() { - return this.DBUFFS_V[DBuff.FROST] !== undefined?true:false + return this.NeAttrs[NeAttrs.IN_FROST].time > 0; } update(dt: number){ diff --git a/assets/script/game/hero/Mon.ts b/assets/script/game/hero/Mon.ts index f58a1ef5..f3eda510 100644 --- a/assets/script/game/hero/Mon.ts +++ b/assets/script/game/hero/Mon.ts @@ -8,7 +8,8 @@ import { HeroInfo } from "../common/config/heroSet"; import { MonModelComp } from "./MonModelComp"; import { BattleMoveComp } from "../common/ecs/position/BattleMoveComp"; import { SkillConComp } from "./SkillConComp"; -import { Attrs, getAttrs, SkillSet } from "../common/config/SkillSet"; +import { SkillSet } from "../common/config/SkillSet"; +import { getNeAttrs, getAttrs ,Attrs} from "../common/config/HeroAttrs"; /** 角色实体 */ @ecs.register(`Monster`) export class Monster extends ecs.Entity { @@ -89,7 +90,8 @@ export class Monster extends ecs.Entity { hv.base_mp=hero.mp hv.hp=hv.base_hp hv.mp=hv.base_mp - hv.Attrs=getAttrs() + hv.Attrs=getAttrs() + hv.NeAttrs=getNeAttrs() hv.Attrs[Attrs.HP_MAX]=hv.base_hp hv.Attrs[Attrs.MP_MAX]=hv.base_mp hv.Attrs[Attrs.DEF]=hv.base_def diff --git a/assets/script/game/hero/SkillConComp.ts b/assets/script/game/hero/SkillConComp.ts index 08ce5aa4..611cd761 100644 --- a/assets/script/game/hero/SkillConComp.ts +++ b/assets/script/game/hero/SkillConComp.ts @@ -1,6 +1,6 @@ import { _decorator, Component, Node, ProgressBar, v3, Vec3 } from 'cc'; import { HeroViewComp } from './HeroViewComp'; -import { Attrs, DBuff, SkillSet, SType, TGroup, } from '../common/config/SkillSet'; +import { SkillSet, SType, TGroup, } from '../common/config/SkillSet'; import { ecs } from 'db://oops-framework/libs/ecs/ECS'; import { GameEvent } from '../common/config/GameEvent'; import { FacSet } from '../common/config/BoxSet'; @@ -9,6 +9,7 @@ import { CCComp } from 'db://oops-framework/module/common/CCComp'; import { MonModelComp } from './MonModelComp'; import { HeroModelComp } from './HeroModelComp'; import { SkillEnt } from '../skill/SkillEnt'; +import { Attrs } from '../common/config/HeroAttrs'; const { ccclass, property } = _decorator; @ccclass('SkillCon') diff --git a/assets/script/game/skill/AtkConCom.ts b/assets/script/game/skill/AtkConCom.ts index 9d1e2970..735b7870 100644 --- a/assets/script/game/skill/AtkConCom.ts +++ b/assets/script/game/skill/AtkConCom.ts @@ -2,11 +2,12 @@ import { _decorator, Animation, CCBoolean, Collider2D, Contact2DType, Tween, UIT import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { BezierMove } from "../BezierMove/BezierMove"; -import { Attrs, DTType, EType, SkillSet, SType } from "../common/config/SkillSet"; +import { DTType, EType, SkillSet, SType } from "../common/config/SkillSet"; import { BoxSet, FacSet } from "../common/config/BoxSet"; import { HeroViewComp } from "../hero/HeroViewComp"; import { GameEvent } from "../common/config/GameEvent"; import { smc } from "../common/SingletonModuleComp"; +import { Attrs } from "../common/config/HeroAttrs"; const { ccclass, property } = _decorator; /** 视图层对象 */