Compare commits
7 Commits
94d5aa8920
...
oh/0.1.112
| Author | SHA1 | Date | |
|---|---|---|---|
| 1c49649c00 | |||
| 51f32b1d29 | |||
| b4fd807ddc | |||
| ff4ce76482 | |||
| 8113ec671f | |||
| 5a81704379 | |||
| f2ec48bd2b |
@@ -108,7 +108,6 @@ export enum Attrs {
|
|||||||
// ========== 武器进化相关 (70-79) ==========
|
// ========== 武器进化相关 (70-79) ==========
|
||||||
PUNCTURE = 70, // 穿刺次数
|
PUNCTURE = 70, // 穿刺次数
|
||||||
PUNCTURE_DMG = 71, // 穿刺伤害
|
PUNCTURE_DMG = 71, // 穿刺伤害
|
||||||
BACK = 73, // 被击退概率(兼容旧代码)
|
|
||||||
MOVE_SPEED = 74, // 移动速度
|
MOVE_SPEED = 74, // 移动速度
|
||||||
BURN = 75, // 易伤效果
|
BURN = 75, // 易伤效果
|
||||||
WFUNY = 77, // 风怒
|
WFUNY = 77, // 风怒
|
||||||
@@ -220,7 +219,6 @@ export const AttrsType: Record<Attrs, BType> = {
|
|||||||
// ========== 武器进化相关(混合类型) ==========
|
// ========== 武器进化相关(混合类型) ==========
|
||||||
[Attrs.PUNCTURE]: BType.VALUE, // 穿刺次数 - 数值型
|
[Attrs.PUNCTURE]: BType.VALUE, // 穿刺次数 - 数值型
|
||||||
[Attrs.PUNCTURE_DMG]: BType.RATIO, // 穿刺伤害 - 百分比型
|
[Attrs.PUNCTURE_DMG]: BType.RATIO, // 穿刺伤害 - 百分比型
|
||||||
[Attrs.BACK]: BType.RATIO, // 被击退概率(兼容)- 百分比型
|
|
||||||
[Attrs.MOVE_SPEED]: BType.VALUE, // 移动速度 - 数值型
|
[Attrs.MOVE_SPEED]: BType.VALUE, // 移动速度 - 数值型
|
||||||
[Attrs.BURN]: BType.RATIO, // 易伤效果 - 百分比型
|
[Attrs.BURN]: BType.RATIO, // 易伤效果 - 百分比型
|
||||||
[Attrs.WFUNY]: BType.RATIO, // 未知特殊属性 - 百分比型
|
[Attrs.WFUNY]: BType.RATIO, // 未知特殊属性 - 百分比型
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { count } from "console";
|
import { count } from "console";
|
||||||
import { Attrs } from "./HeroAttrs";
|
import { Attrs, BType } from "./HeroAttrs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 天赋类型枚举,也是触发条件
|
* 天赋类型枚举,也是触发条件
|
||||||
@@ -28,6 +28,9 @@ export enum TalEffet {
|
|||||||
D_SKILL=8, //两次技能
|
D_SKILL=8, //两次技能
|
||||||
SHIELD=9, // 护盾
|
SHIELD=9, // 护盾
|
||||||
LDMG=10, // 减伤
|
LDMG=10, // 减伤
|
||||||
|
C_ATK=11, // 普工必爆
|
||||||
|
C_SKILL=12, // 一般技能必暴
|
||||||
|
C_MSKILL=13, // 必杀技能必暴
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum TalTarget {
|
export enum TalTarget {
|
||||||
@@ -56,10 +59,12 @@ export interface ItalConf {
|
|||||||
triType: TriType;
|
triType: TriType;
|
||||||
target: TalTarget;
|
target: TalTarget;
|
||||||
effet: TalEffet;
|
effet: TalEffet;
|
||||||
|
vType:BType; //数值型还是百分比型
|
||||||
value: number; // 触发的效果值(如增加10%攻击力, 触发的技能uuid,增加1个技能uuid)
|
value: number; // 触发的效果值(如增加10%攻击力, 触发的技能uuid,增加1个技能uuid)
|
||||||
attrs?:TalAttrs //触发的attrs效果的对应attrs
|
attrs?:TalAttrs //触发的attrs效果的对应attrs
|
||||||
Trigger:number //触发值
|
Trigger:number //触发值
|
||||||
desc: string; // 天赋描述(说明触发条件和效果)
|
desc: string; // 天赋描述(说明触发条件和效果)
|
||||||
|
count:number //执行次数,及可以触发的次数
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 天赋配置表 ==========
|
// ========== 天赋配置表 ==========
|
||||||
@@ -80,42 +85,42 @@ export interface ItalConf {
|
|||||||
*/
|
*/
|
||||||
export const talConf: Record<number, ItalConf> = {
|
export const talConf: Record<number, ItalConf> = {
|
||||||
/*** 普通攻击触发 ***/
|
/*** 普通攻击触发 ***/
|
||||||
7001:{uuid:7001,name:"风怒",triType:TriType.ATK,Trigger:3,target:TalTarget.ENEMY,effet:TalEffet.WFUNY,value:50,attrs:TalAttrs.NON,
|
7001:{uuid:7001,name:"风怒",triType:TriType.ATK,Trigger:3,count:1,target:TalTarget.ENEMY,effet:TalEffet.WFUNY,vType:BType.RATIO, value:50,attrs:TalAttrs.NON,
|
||||||
desc:"普通攻击3次后, 立即给与目标150%伤害的额外打击"},
|
desc:"普通攻击3次后, 立即给与目标150%伤害的额外打击"},
|
||||||
7002:{uuid:7002,name:"溅射",triType:TriType.ATK,Trigger:3,target:TalTarget.ENEMY,effet:TalEffet.SPLASH,value:50,attrs:TalAttrs.NON,
|
7002:{uuid:7002,name:"溅射",triType:TriType.ATK,Trigger:3,count:1,target:TalTarget.ENEMY,effet:TalEffet.SPLASH,vType:BType.RATIO, value:50,attrs:TalAttrs.NON,
|
||||||
desc:"普通攻击3次后, 会对目标100码内的敌人造成30%伤害"},
|
desc:"普通攻击3次后, 会对目标100码内的敌人造成30%伤害"},
|
||||||
7003:{uuid:7003,name:"回血",triType:TriType.ATK,Trigger:3,target:TalTarget.SELF,effet:TalEffet.HP,value:1,attrs:TalAttrs.NON,
|
7003:{uuid:7003,name:"回血",triType:TriType.ATK,Trigger:3,count:1,target:TalTarget.SELF,effet:TalEffet.HP,vType:BType.RATIO, value:1,attrs:TalAttrs.NON,
|
||||||
desc:"普通攻击3次后, 会回复10%的生命值"},
|
desc:"普通攻击3次后, 会回复10%的生命值"},
|
||||||
7004:{uuid:7004,name:"回蓝",triType:TriType.ATK,Trigger:3,target:TalTarget.SELF,effet:TalEffet.MP,value:1,attrs:TalAttrs.NON,
|
7004:{uuid:7004,name:"回蓝",triType:TriType.ATK,Trigger:3,count:1,target:TalTarget.SELF,effet:TalEffet.MP,vType:BType.RATIO, value:1,attrs:TalAttrs.NON,
|
||||||
desc:"普通攻击3次后, 会回复10%的蓝值"},
|
desc:"普通攻击3次后, 会回复10%的蓝值"},
|
||||||
7005:{uuid:7005,name:"冰冻",triType:TriType.ATK,Trigger:3,target:TalTarget.ENEMY,effet:TalEffet.BUFF,value:5,attrs:TalAttrs.FREEZE_CHANCE,
|
7005:{uuid:7005,name:"冰冻",triType:TriType.ATK,Trigger:3,count:1,target:TalTarget.ENEMY,effet:TalEffet.BUFF,vType:BType.RATIO, value:5,attrs:TalAttrs.FREEZE_CHANCE,
|
||||||
desc:"普通攻击3次后, 获得5%的冻结率"},
|
desc:"普通攻击3次后, 获得5%的冻结率"},
|
||||||
7006:{uuid:7006,name:"沉默",triType:TriType.ATK,Trigger:3,target:TalTarget.ENEMY,effet:TalEffet.BUFF,value:5,attrs:TalAttrs.SILENCE_CHANCE,
|
7006:{uuid:7006,name:"沉默",triType:TriType.ATK,Trigger:3,count:1,target:TalTarget.ENEMY,effet:TalEffet.BUFF,vType:BType.RATIO, value:5,attrs:TalAttrs.SILENCE_CHANCE,
|
||||||
desc:"普通攻击3次后, 获得5%的沉默率"},
|
desc:"普通攻击3次后, 获得5%的沉默率"},
|
||||||
7007:{uuid:7007,name:"击退",triType:TriType.ATK,Trigger:3,target:TalTarget.ENEMY,effet:TalEffet.BUFF,value:5,attrs:TalAttrs.BACK_CHANCE,
|
7007:{uuid:7007,name:"击退",triType:TriType.ATK,Trigger:3,count:1,target:TalTarget.ENEMY,effet:TalEffet.BUFF,vType:BType.RATIO, value:5,attrs:TalAttrs.BACK_CHANCE,
|
||||||
desc:"普通攻击3次后, 获得5%的击退率"},
|
desc:"普通攻击3次后, 获得5%的击退率"},
|
||||||
7008:{uuid:7008,name:"会心",triType:TriType.ATK,Trigger:3,target:TalTarget.SELF,effet:TalEffet.BUFF,value:5,attrs:TalAttrs.CRITICAL,
|
7008:{uuid:7008,name:"会心",triType:TriType.ATK,Trigger:3,count:1,target:TalTarget.SELF,effet:TalEffet.BUFF,vType:BType.RATIO, value:5,attrs:TalAttrs.CRITICAL,
|
||||||
desc:"普通攻击3次后, 获得5%的暴击率"},
|
desc:"普通攻击3次后, 获得5%的暴击率"},
|
||||||
7009:{uuid:7009,name:"眩晕",triType:TriType.ATK,Trigger:3,target:TalTarget.ENEMY,effet:TalEffet.BUFF,value:5,attrs:TalAttrs.STUN_CHANCE,
|
7009:{uuid:7009,name:"眩晕",triType:TriType.ATK,Trigger:3,count:1,target:TalTarget.ENEMY,effet:TalEffet.BUFF,vType:BType.RATIO, value:5,attrs:TalAttrs.STUN_CHANCE,
|
||||||
desc:"普通攻击3次后, 获得5%的眩晕率"},
|
desc:"普通攻击3次后, 获得5%的眩晕率"},
|
||||||
7010:{uuid:7010,name:"熟练",triType:TriType.ATK,Trigger:10,target:TalTarget.SELF,effet:TalEffet.D_SKILL,value:0,attrs:TalAttrs.NON,
|
7010:{uuid:7010,name:"熟练",triType:TriType.ATK,Trigger:10,count:1,target:TalTarget.SELF,effet:TalEffet.D_SKILL,vType:BType.RATIO, value:0,attrs:TalAttrs.NON,
|
||||||
desc:"普通攻击10次后, 下次一般技能额外释放1次,伤害100%"},
|
desc:"普通攻击10次后, 下次一般技能额外释放1次,伤害100%"},
|
||||||
|
|
||||||
/*** 受伤触发 ***/
|
/*** 受伤触发 ***/
|
||||||
7101:{uuid:7101,name:"反击",triType:TriType.DMG,Trigger:3,target:TalTarget.ENEMY,effet:TalEffet.DMG,value:50,attrs:TalAttrs.NON,
|
7101:{uuid:7101,name:"反击",triType:TriType.DMG,Trigger:3,count:1,target:TalTarget.ENEMY,effet:TalEffet.DMG,vType:BType.RATIO, value:50,attrs:TalAttrs.NON,
|
||||||
desc:"被攻击3次后, 给于目标50%的伤害"},
|
desc:"被攻击3次后, 给于目标50%的伤害"},
|
||||||
7102:{uuid:7102,name:"护盾",triType:TriType.DMG,Trigger:3,target:TalTarget.SELF,effet:TalEffet.SHIELD,value:20,attrs:TalAttrs.NON,
|
7102:{uuid:7102,name:"护盾",triType:TriType.DMG,Trigger:3,count:1,target:TalTarget.SELF,effet:TalEffet.SHIELD,vType:BType.RATIO, value:20,attrs:TalAttrs.NON,
|
||||||
desc:"被攻击3次后, 获得20%的生命值护盾"},
|
desc:"被攻击3次后, 获得20%的生命值护盾"},
|
||||||
7103:{uuid:7103,name:"减伤",triType:TriType.DMG,Trigger:3,target:TalTarget.ENEMY,effet:TalEffet.LDMG,value:50,attrs:TalAttrs.NON,
|
7103:{uuid:7103,name:"减伤",triType:TriType.DMG,Trigger:3,count:1,target:TalTarget.ENEMY,effet:TalEffet.LDMG,vType:BType.RATIO, value:50,attrs:TalAttrs.NON,
|
||||||
desc:"被攻击3次后, 下1次伤害减50%"},
|
desc:"被攻击3次后, 下1次伤害减50%"},
|
||||||
|
|
||||||
|
|
||||||
/*** 失去血量触发 ***/ //需要重新设计,触发类型
|
/*** 失去血量触发 ***/
|
||||||
7201:{uuid:7201,name:"背水",triType:TriType.HPL,Trigger:50,target:TalTarget.SELF,effet:TalEffet.BUFF,value:10,attrs:TalAttrs.AP,
|
7201:{uuid:7201,name:"背水",triType:TriType.HPL,Trigger:50,count:10,target:TalTarget.SELF,effet:TalEffet.C_ATK,vType:BType.VALUE, value:0,attrs:TalAttrs.NON,
|
||||||
desc:"每失去50%生命值,获得下10次普通攻击暴击"},
|
desc:"每失去50%生命值,获得下10次普通攻击暴击"},
|
||||||
|
|
||||||
/*** 升级触发 ***/ //需要重新设计,触发类型
|
/*** 升级触发 ***/
|
||||||
7301:{uuid:7301,name:"勤勉",triType:TriType.LUP,Trigger:1,target:TalTarget.SELF,effet:TalEffet.BUFF,value:5,attrs:TalAttrs.AP,
|
7301:{uuid:7301,name:"勤勉",triType:TriType.LUP,Trigger:1,count:5,target:TalTarget.SELF,effet:TalEffet.C_SKILL,vType:BType.VALUE, value:0,attrs:TalAttrs.NON,
|
||||||
desc:"每升1级,获得下5次技能暴击"},
|
desc:"每升1级,获得下5次技能暴击"},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,14 +8,7 @@ import { HeroViewComp } from "./HeroViewComp";
|
|||||||
import { DamageQueueComp, DamageEvent, DamageQueueHelper } from "./DamageQueueComp";
|
import { DamageQueueComp, DamageEvent, DamageQueueHelper } from "./DamageQueueComp";
|
||||||
import { smc } from "../common/SingletonModuleComp";
|
import { smc } from "../common/SingletonModuleComp";
|
||||||
|
|
||||||
/** 业务层对象 */
|
|
||||||
@ecs.register('HeroAtk')
|
|
||||||
export class HeroAtkComp extends ecs.Comp {
|
|
||||||
/** 业务层组件移除时,重置所有数据为默认值 */
|
|
||||||
reset() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/** 最终伤害数据接口 */
|
/** 最终伤害数据接口 */
|
||||||
interface FinalData {
|
interface FinalData {
|
||||||
damage: number;
|
damage: number;
|
||||||
@@ -94,19 +87,17 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
|||||||
* @returns 最终伤害数据
|
* @returns 最终伤害数据
|
||||||
*/
|
*/
|
||||||
private doAttack(target: ecs.Entity, damageEvent: DamageEvent): FinalData {
|
private doAttack(target: ecs.Entity, damageEvent: DamageEvent): FinalData {
|
||||||
const targetModel = target.get(HeroAttrsComp);
|
const targetAttrs = target.get(HeroAttrsComp);
|
||||||
const targetView = target.get(HeroViewComp);
|
const targetView = target.get(HeroViewComp);
|
||||||
let reDate:FinalData={
|
let reDate:FinalData={
|
||||||
damage:0,
|
damage:0,
|
||||||
isCrit:false,
|
isCrit:false,
|
||||||
isDodge:false,
|
isDodge:false,
|
||||||
}
|
}
|
||||||
if (!targetModel || targetModel.is_dead) return reDate;
|
if (!targetAttrs || targetAttrs.is_dead) return reDate;
|
||||||
|
|
||||||
// 获取攻击者数据
|
|
||||||
const caster = damageEvent.caster;
|
const caster = damageEvent.caster;
|
||||||
const casterModel = caster.ent.get(HeroAttrsComp);
|
const attackerModel = caster?.ent?.get(HeroAttrsComp);
|
||||||
if (!casterModel) return reDate;
|
|
||||||
|
|
||||||
// 获取技能配置
|
// 获取技能配置
|
||||||
const skillConf = SkillSet[damageEvent.s_uuid];
|
const skillConf = SkillSet[damageEvent.s_uuid];
|
||||||
@@ -116,38 +107,40 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
|||||||
this.onAttacked(target);
|
this.onAttacked(target);
|
||||||
|
|
||||||
// 闪避判定
|
// 闪避判定
|
||||||
if (this.checkDodge(targetModel)) {
|
const isDodge =this.checkChance(targetAttrs.Attrs[Attrs.DODGE] || 0);
|
||||||
|
if (isDodge) {
|
||||||
// TODO: 触发闪避视图表现
|
// TODO: 触发闪避视图表现
|
||||||
reDate.isDodge=true;
|
reDate.isDodge=true;
|
||||||
return reDate;
|
return reDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 暴击判定
|
// 暴击判定
|
||||||
const isCrit = this.checkCrit(targetModel.Attrs[Attrs.CRITICAL]);
|
const isCrit = this.checkChance(damageEvent.Attrs[Attrs.CRITICAL]);
|
||||||
|
if (isCrit) attackerModel?.clearTalBuffByAttr(Attrs.CRITICAL);
|
||||||
|
// 计算伤害
|
||||||
let damage = this.dmgCount(damageEvent.Attrs,damageEvent.s_uuid);
|
let damage = this.dmgCount(damageEvent.Attrs,damageEvent.s_uuid);
|
||||||
if (isCrit) {
|
if (isCrit) {
|
||||||
damage = Math.floor(damage * (1 + (FightSet.CRIT_DAMAGE + targetModel.Attrs[Attrs.CRITICAL_DMG]) / 100));
|
damage = Math.floor(damage * (1 + (FightSet.CRIT_DAMAGE + targetAttrs.Attrs[Attrs.CRITICAL_DMG]) / 100));
|
||||||
reDate.isCrit=true;
|
reDate.isCrit=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 伤害计算(考虑易伤等debuff)
|
// 伤害计算(考虑易伤等debuff)
|
||||||
damage = this.calculateDamage(targetModel, damage);
|
damage = this.calculateDamage(targetAttrs, damage);
|
||||||
|
|
||||||
// 护盾吸收
|
// 护盾吸收
|
||||||
damage =Math.floor(this.absorbShield(targetModel, damage))
|
damage =Math.floor(this.absorbShield(targetAttrs, damage))
|
||||||
if (damage <= 0) return reDate;
|
if (damage <= 0) return reDate;
|
||||||
|
|
||||||
// 应用伤害到数据层
|
// 应用伤害到数据层
|
||||||
targetModel.hp -= damage;
|
targetAttrs.hp -= damage;
|
||||||
targetModel.atked_count++;
|
targetAttrs.atked_count++;
|
||||||
|
//击退判定
|
||||||
|
const isBack = this.checkChance(damageEvent.Attrs[Attrs.BACK_CHANCE] || 0);
|
||||||
|
if (isBack) attackerModel?.clearTalBuffByAttr(Attrs.BACK_CHANCE);
|
||||||
|
|
||||||
|
|
||||||
// ✅ 触发视图层表现(伤害数字、受击动画、后退)
|
// ✅ 触发视图层表现(伤害数字、受击动画、后退)
|
||||||
if (targetView) {
|
if (targetView) targetView.do_atked(damage, isCrit, damageEvent.s_uuid, isBack);
|
||||||
targetView.do_atked(damage, isCrit, damageEvent.s_uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查死亡
|
// 检查死亡
|
||||||
if (targetModel.hp <= 0) {
|
if (targetAttrs.hp <= 0) {
|
||||||
this.doDead(target);
|
this.doDead(target);
|
||||||
// ✅ 触发死亡视图表现
|
// ✅ 触发死亡视图表现
|
||||||
if (targetView) {
|
if (targetView) {
|
||||||
@@ -156,7 +149,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.debugMode) {
|
if (this.debugMode) {
|
||||||
console.log(`[HeroAtkSystem] ${targetModel.hero_name} 受到 ${damage} 点伤害 (暴击: ${isCrit})`);
|
console.log(`[HeroAtkSystem] ${targetAttrs.hero_name} 受到 ${damage} 点伤害 (暴击: ${isCrit})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
reDate.damage=damage;
|
reDate.damage=damage;
|
||||||
@@ -182,35 +175,19 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
|||||||
this.onDeath(entity);
|
this.onDeath(entity);
|
||||||
|
|
||||||
if (this.debugMode) {
|
if (this.debugMode) {
|
||||||
console.log(`[HeroBattleSystem] ${model.hero_name} 死亡`);
|
console.log(`[HeroAtkSystem] ${model.hero_name} 死亡`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 闪避判定
|
|
||||||
*/
|
|
||||||
private checkDodge(model: HeroAttrsComp): boolean {
|
|
||||||
if (model.Attrs[Attrs.DODGE] > 0) {
|
|
||||||
const random = Math.random() * 100;
|
|
||||||
if (random < model.Attrs[Attrs.DODGE]) {
|
|
||||||
if (this.debugMode) {
|
|
||||||
console.log(`[HeroBattleSystem] ${model.hero_name} 闪避了攻击`);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 暴击判定
|
* 暴击判定
|
||||||
*/
|
*/
|
||||||
private checkCrit(critRate: number): boolean {
|
private checkChance(rate: number): boolean {
|
||||||
if (critRate > 0) {
|
if (rate <= 0) return false;
|
||||||
const random = Math.random() * 100;
|
const r = Math.random() * 100;
|
||||||
return random < critRate;
|
return r < rate;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3,7 +3,7 @@ import { Attrs, AttrsType, BType, NeAttrs } from "../common/config/HeroAttrs";
|
|||||||
import { BuffConf } from "../common/config/SkillSet";
|
import { BuffConf } from "../common/config/SkillSet";
|
||||||
import { HeroInfo, AttrSet } from "../common/config/heroSet";
|
import { HeroInfo, AttrSet } from "../common/config/heroSet";
|
||||||
import { HeroSkillsComp } from "./HeroSkills";
|
import { HeroSkillsComp } from "./HeroSkills";
|
||||||
import { talConf, TalAttrs } from "../common/config/TalSet";
|
|
||||||
|
|
||||||
interface talTrigger{
|
interface talTrigger{
|
||||||
value:number
|
value:number
|
||||||
@@ -35,11 +35,8 @@ export class HeroAttrsComp extends ecs.Comp {
|
|||||||
shield: number = 0; // 当前护盾
|
shield: number = 0; // 当前护盾
|
||||||
Attrs: any = []; // 最终属性数组(经过Buff计算后)
|
Attrs: any = []; // 最终属性数组(经过Buff计算后)
|
||||||
NeAttrs: any = []; // 负面状态数组
|
NeAttrs: any = []; // 负面状态数组
|
||||||
//=====================天赋触发标签=====================
|
Talents: Record<number, talTrigger> = {};
|
||||||
tal_DSill:talTrigger={value:0,count:0}
|
BUFFS_TAL: Record<number, {count:number,BType:BType,attrIndex:number,value: number}> = {};
|
||||||
tal_WFuny:talTrigger={value:0,count:0}
|
|
||||||
/** 天赋buff数组 - 触发过期,数量可叠加 */
|
|
||||||
BUFFS_TAL: Record<number, Array<{tal:number,value: number, BType: BType,count:number}>> = {};
|
|
||||||
|
|
||||||
// ==================== 技能距离缓存 ====================
|
// ==================== 技能距离缓存 ====================
|
||||||
maxSkillDistance: number = 0; // 最远技能攻击距离(缓存,受MP影响)
|
maxSkillDistance: number = 0; // 最远技能攻击距离(缓存,受MP影响)
|
||||||
@@ -81,6 +78,7 @@ export class HeroAttrsComp extends ecs.Comp {
|
|||||||
this.BUFFS = {};
|
this.BUFFS = {};
|
||||||
this.BUFFS_TEMP = {};
|
this.BUFFS_TEMP = {};
|
||||||
this.BUFFS_TAL = {};
|
this.BUFFS_TAL = {};
|
||||||
|
this.Talents = {};
|
||||||
|
|
||||||
// 获取英雄配置
|
// 获取英雄配置
|
||||||
const heroInfo = HeroInfo[this.hero_uuid];
|
const heroInfo = HeroInfo[this.hero_uuid];
|
||||||
@@ -188,12 +186,10 @@ export class HeroAttrsComp extends ecs.Comp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 遍历天赋buff数组(数值型叠加 value*count)
|
for (const key in this.BUFFS_TAL) {
|
||||||
if (this.BUFFS_TAL[attrIndex] && this.BUFFS_TAL[attrIndex].length > 0) {
|
const buff = this.BUFFS_TAL[Number(key)];
|
||||||
for (const buff of this.BUFFS_TAL[attrIndex]) {
|
if (buff.attrIndex === attrIndex && buff.BType === BType.VALUE) {
|
||||||
if (buff.BType === BType.VALUE) {
|
totalValue += buff.value;
|
||||||
totalValue += buff.value * buff.count;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,12 +212,10 @@ export class HeroAttrsComp extends ecs.Comp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 遍历天赋buff数组(百分比型叠加 value*count)
|
for (const key in this.BUFFS_TAL) {
|
||||||
if (this.BUFFS_TAL[attrIndex] && this.BUFFS_TAL[attrIndex].length > 0) {
|
const buff = this.BUFFS_TAL[Number(key)];
|
||||||
for (const buff of this.BUFFS_TAL[attrIndex]) {
|
if (buff.attrIndex === attrIndex && buff.BType === BType.RATIO) {
|
||||||
if (buff.BType === BType.RATIO) {
|
totalRatio += buff.value;
|
||||||
totalRatio += buff.value * buff.count;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,6 +407,48 @@ export class HeroAttrsComp extends ecs.Comp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
addTalBuff(t_uuid: number, attrIndex?: number, bType?: BType, value: number = 0) {
|
||||||
|
if (attrIndex === undefined || bType === undefined) return;
|
||||||
|
const buff = this.BUFFS_TAL[t_uuid];
|
||||||
|
if (!buff) {
|
||||||
|
this.BUFFS_TAL[t_uuid] = { count: 1, BType: bType, attrIndex, value };
|
||||||
|
} else {
|
||||||
|
buff.count += 1;
|
||||||
|
buff.value += value;
|
||||||
|
}
|
||||||
|
this.recalculateSingleAttr(attrIndex);
|
||||||
|
}
|
||||||
|
clearTalBuff(t_uuid: number) {
|
||||||
|
const buff = this.BUFFS_TAL[t_uuid];
|
||||||
|
if (!buff) return;
|
||||||
|
const attrIndex = buff.attrIndex;
|
||||||
|
delete this.BUFFS_TAL[t_uuid];
|
||||||
|
this.recalculateSingleAttr(attrIndex);
|
||||||
|
}
|
||||||
|
clearTalBuffByAttr(attrIndex: number) {
|
||||||
|
let changed = false;
|
||||||
|
for (const key in this.BUFFS_TAL) {
|
||||||
|
const b = this.BUFFS_TAL[Number(key)];
|
||||||
|
if (b && b.attrIndex === attrIndex) {
|
||||||
|
delete this.BUFFS_TAL[Number(key)];
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (changed) this.recalculateSingleAttr(attrIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
addTalent(eff: number, value: number) {
|
||||||
|
const t = this.Talents[eff] || { value: 0, count: 0 };
|
||||||
|
t.value = value;
|
||||||
|
t.count += 1;
|
||||||
|
this.Talents[eff] = t;
|
||||||
|
}
|
||||||
|
consumeTalent(eff: number): boolean {
|
||||||
|
const t = this.Talents[eff];
|
||||||
|
if (!t || t.count <= 0) return false;
|
||||||
|
t.count -= 1;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
// 重置为初始状态
|
// 重置为初始状态
|
||||||
@@ -436,6 +472,7 @@ export class HeroAttrsComp extends ecs.Comp {
|
|||||||
this.BUFFS = {};
|
this.BUFFS = {};
|
||||||
this.BUFFS_TEMP = {};
|
this.BUFFS_TEMP = {};
|
||||||
this.BUFFS_TAL = {};
|
this.BUFFS_TAL = {};
|
||||||
|
this.Talents = {};
|
||||||
// 重置技能距离缓存
|
// 重置技能距离缓存
|
||||||
this.maxSkillDistance = 0;
|
this.maxSkillDistance = 0;
|
||||||
this.minSkillDistance = 0;
|
this.minSkillDistance = 0;
|
||||||
@@ -451,45 +488,10 @@ export class HeroAttrsComp extends ecs.Comp {
|
|||||||
this.atk_count = 0;
|
this.atk_count = 0;
|
||||||
this.atked_count = 0;
|
this.atked_count = 0;
|
||||||
}
|
}
|
||||||
private getTalAttr(tal: number) {
|
|
||||||
const conf = talConf[tal];
|
|
||||||
if (!conf) return null;
|
|
||||||
const attrIndex = conf.attrs ?? TalAttrs.NON;
|
|
||||||
if (attrIndex === TalAttrs.NON) return null;
|
|
||||||
const bType = AttrsType[attrIndex as unknown as number];
|
|
||||||
const value = conf.value;
|
|
||||||
return { attrIndex: attrIndex as unknown as number, bType, value };
|
|
||||||
}
|
|
||||||
addTalBuff(tal: number, count: number = 1) {
|
|
||||||
const info = this.getTalAttr(tal);
|
|
||||||
if (!info) return;
|
|
||||||
const { attrIndex, bType, value } = info;
|
|
||||||
if (!this.BUFFS_TAL[attrIndex]) this.BUFFS_TAL[attrIndex] = [];
|
|
||||||
const list = this.BUFFS_TAL[attrIndex];
|
|
||||||
const exist = list.find(i => i.tal === tal && i.BType === bType);
|
|
||||||
if (exist) {
|
|
||||||
exist.count += count;
|
|
||||||
} else {
|
|
||||||
list.push({ tal, value, BType: bType, count });
|
|
||||||
}
|
|
||||||
this.recalculateSingleAttr(attrIndex);
|
|
||||||
}
|
|
||||||
clearTalBuff(tal: number) {
|
|
||||||
const affected = new Set<number>();
|
|
||||||
for (const key in this.BUFFS_TAL) {
|
|
||||||
const idx = parseInt(key);
|
|
||||||
const list = this.BUFFS_TAL[idx];
|
|
||||||
if (!list || list.length === 0) continue;
|
|
||||||
const newList = list.filter(i => i.tal !== tal);
|
|
||||||
if (newList.length !== list.length) {
|
|
||||||
this.BUFFS_TAL[idx] = newList;
|
|
||||||
affected.add(idx);
|
|
||||||
if (newList.length === 0) delete this.BUFFS_TAL[idx];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
affected.forEach(i => this.recalculateSingleAttr(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -350,7 +350,7 @@ export class HeroViewComp extends CCComp {
|
|||||||
this.ent.destroy();
|
this.ent.destroy();
|
||||||
|
|
||||||
}
|
}
|
||||||
do_atked(damage:number,isCrit:boolean,s_uuid:number){
|
do_atked(damage:number,isCrit:boolean,s_uuid:number,isBack:boolean=false){
|
||||||
// 受到攻击时显示血条,并设置显示时间(即使伤害为0也显示)
|
// 受到攻击时显示血条,并设置显示时间(即使伤害为0也显示)
|
||||||
this.top_node.active = true;
|
this.top_node.active = true;
|
||||||
this.hpBarShowCD = this.hpBarShowTime;
|
this.hpBarShowCD = this.hpBarShowTime;
|
||||||
@@ -359,8 +359,8 @@ export class HeroViewComp extends CCComp {
|
|||||||
|
|
||||||
// 视图层表现
|
// 视图层表现
|
||||||
let SConf=SkillSet[s_uuid]
|
let SConf=SkillSet[s_uuid]
|
||||||
this.back()
|
if (isBack) this.back()
|
||||||
this.showDamage(damage, isCrit, SConf.DAnm); // 暴击状态由战斗系统内部处理, DAnm和EAnm共用设定数组
|
this.showDamage(damage, isCrit, SConf.DAnm);
|
||||||
}
|
}
|
||||||
|
|
||||||
private isBackingUp: boolean = false; // 🔥 添加后退状态标记
|
private isBackingUp: boolean = false; // 🔥 添加后退状态标记
|
||||||
|
|||||||
@@ -134,8 +134,6 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
|
|||||||
*/
|
*/
|
||||||
private executeCast(casterEntity: ecs.Entity, s_uuid: number, heroView: HeroViewComp,hset:HSSet): boolean {
|
private executeCast(casterEntity: ecs.Entity, s_uuid: number, heroView: HeroViewComp,hset:HSSet): boolean {
|
||||||
const heroAttrs=casterEntity.get(HeroAttrsComp)
|
const heroAttrs=casterEntity.get(HeroAttrsComp)
|
||||||
let isDSill=heroAttrs.tal_DSill.count > 0
|
|
||||||
let isWFuny=heroAttrs.tal_WFuny.count > 0
|
|
||||||
const config = SkillSet[s_uuid];
|
const config = SkillSet[s_uuid];
|
||||||
if (!config) {
|
if (!config) {
|
||||||
console.error("[SACastSystem] 技能配置不存在:", s_uuid);
|
console.error("[SACastSystem] 技能配置不存在:", s_uuid);
|
||||||
@@ -165,14 +163,13 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
|
|||||||
}, delay);
|
}, delay);
|
||||||
|
|
||||||
//风怒wfuny 只针对 普通攻击起效
|
//风怒wfuny 只针对 普通攻击起效
|
||||||
if (hset === HSSet.atk&&isWFuny){
|
if (hset === HSSet.atk && heroAttrs.consumeTalent(TalEffet.WFUNY)){
|
||||||
heroView.playSkillEffect(s_uuid);
|
heroView.playSkillEffect(s_uuid);
|
||||||
//需要再添加 风怒动画
|
//需要再添加 风怒动画
|
||||||
this.createSkill(s_uuid, heroView,targets);
|
this.createSkill(s_uuid, heroView,targets);
|
||||||
heroAttrs.tal_WFuny.count --
|
|
||||||
}
|
}
|
||||||
// 双技能 只针对 技能起效
|
// 双技能 只针对 技能起效
|
||||||
if(hset === HSSet.skill&&isDSill){
|
if(hset === HSSet.skill && heroAttrs.consumeTalent(TalEffet.D_SKILL)){
|
||||||
targets = this.sTargets(heroView, s_uuid);
|
targets = this.sTargets(heroView, s_uuid);
|
||||||
if (targets.length === 0) {
|
if (targets.length === 0) {
|
||||||
console.warn("[SACastSystem] 没有找到有效目标");
|
console.warn("[SACastSystem] 没有找到有效目标");
|
||||||
@@ -183,7 +180,6 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
|
|||||||
heroView.scheduleOnce(() => {
|
heroView.scheduleOnce(() => {
|
||||||
this.createSkill(s_uuid, heroView,targets);
|
this.createSkill(s_uuid, heroView,targets);
|
||||||
}, delay);
|
}, delay);
|
||||||
heroAttrs.tal_DSill.count --
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -194,7 +190,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
|
|||||||
/**
|
/**
|
||||||
* 创建技能实体
|
* 创建技能实体
|
||||||
*/
|
*/
|
||||||
private createSkill(s_uuid: number, caster: HeroViewComp,targets:Vec3[]=[],damage:number=0) {
|
private createSkill(s_uuid: number, caster: HeroViewComp,targets:Vec3[]=[],ext_dmg:number=0) {
|
||||||
// 检查节点有效性
|
// 检查节点有效性
|
||||||
if (!caster.node || !caster.node.isValid) {
|
if (!caster.node || !caster.node.isValid) {
|
||||||
console.warn("[SACastSystem] 施法者节点无效");
|
console.warn("[SACastSystem] 施法者节点无效");
|
||||||
@@ -219,8 +215,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,damage);
|
skill.load(startPos, parent, s_uuid, targetPos, caster,ext_dmg);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||||
|
import { BType } from "../common/config/HeroAttrs";
|
||||||
import { TalAttrs, talConf, TalEffet, TalTarget, TriType} from "../common/config/TalSet";
|
import { TalAttrs, talConf, TalEffet, TalTarget, TriType} from "../common/config/TalSet";
|
||||||
import { HeroAttrsComp } from "./HeroAttrsComp";
|
import { HeroAttrsComp } from "./HeroAttrsComp";
|
||||||
import { HeroViewComp } from "./HeroViewComp";
|
import { HeroViewComp } from "./HeroViewComp";
|
||||||
@@ -14,8 +15,11 @@ export interface TalSlot {
|
|||||||
target: TalTarget;
|
target: TalTarget;
|
||||||
effet: TalEffet;
|
effet: TalEffet;
|
||||||
attrs?:TalAttrs //触发的attrs效果的对应attrs value: number; // 触发的效果数值
|
attrs?:TalAttrs //触发的attrs效果的对应attrs value: number; // 触发的效果数值
|
||||||
|
vType:BType; // 数值型还是百分比型
|
||||||
value: number; // 触发的效果数值
|
value: number; // 触发的效果数值
|
||||||
value_add: number; // 触发的效果数值增量
|
value_add: number; // 触发的效果数值增量
|
||||||
|
count: number; // 执行次数,及可以触发的次数
|
||||||
|
count_add: number; // 执行次数增量
|
||||||
Trigger: number; // 天赋触发阈值
|
Trigger: number; // 天赋触发阈值
|
||||||
Trigger_add: number; // 天赋触发阈值减值
|
Trigger_add: number; // 天赋触发阈值减值
|
||||||
desc: string; // 天赋描述(说明触发条件和效果)
|
desc: string; // 天赋描述(说明触发条件和效果)
|
||||||
@@ -86,8 +90,11 @@ export class TalComp extends ecs.Comp {
|
|||||||
target: tConf.target,
|
target: tConf.target,
|
||||||
effet: tConf.effet,
|
effet: tConf.effet,
|
||||||
attrs: tConf.attrs,
|
attrs: tConf.attrs,
|
||||||
|
vType: tConf.vType,
|
||||||
value: tConf.value, // 效果数值初始为配置值
|
value: tConf.value, // 效果数值初始为配置值
|
||||||
value_add: 0, // 效果数值增量初始为0
|
value_add: 0, // 效果数值增量初始为0
|
||||||
|
count: 1, // 执行次数,及可以触发的次数
|
||||||
|
count_add:0, // 执行次数增量初始为0
|
||||||
Trigger: tConf.Trigger, // 触发阈值(后续可从配置中读取)
|
Trigger: tConf.Trigger, // 触发阈值(后续可从配置中读取)
|
||||||
Trigger_add: 0, // 触发阈值增量初始为0
|
Trigger_add: 0, // 触发阈值增量初始为0
|
||||||
desc: tConf.desc,
|
desc: tConf.desc,
|
||||||
@@ -173,12 +180,15 @@ export class TalComp extends ecs.Comp {
|
|||||||
const talent = this.Tals[uuid];
|
const talent = this.Tals[uuid];
|
||||||
if (talent.cur >= (talent.Trigger - talent.Trigger_add)) { // 修复触发条件,累积值达到或超过触发阈值时触发
|
if (talent.cur >= (talent.Trigger - talent.Trigger_add)) { // 修复触发条件,累积值达到或超过触发阈值时触发
|
||||||
console.log(`[TalComp]天赋触发,天赋ID:${uuid}`);
|
console.log(`[TalComp]天赋触发,天赋ID:${uuid}`);
|
||||||
this.doTriggerTal(talent.uuid);
|
for(let i=0;i<(talent.count+talent.count_add);i++){
|
||||||
|
this.doTriggerTal(talent.uuid);
|
||||||
|
}
|
||||||
// 重置累积值
|
// 重置累积值
|
||||||
talent.cur = 0;
|
talent.cur = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//执行天赋触发效果
|
||||||
doTriggerTal(uuid: number) {
|
doTriggerTal(uuid: number) {
|
||||||
// 检查天赋是否存在
|
// 检查天赋是否存在
|
||||||
if (!this.Tals[uuid]) {
|
if (!this.Tals[uuid]) {
|
||||||
@@ -189,23 +199,27 @@ export class TalComp extends ecs.Comp {
|
|||||||
const heroAttrs=this.ent.get(HeroAttrsComp);
|
const heroAttrs=this.ent.get(HeroAttrsComp);
|
||||||
switch(talent.effet){
|
switch(talent.effet){
|
||||||
case TalEffet.WFUNY:
|
case TalEffet.WFUNY:
|
||||||
heroAttrs.tal_WFuny.count += 1;
|
heroAttrs.addTalent(TalEffet.WFUNY, talent.value + talent.value_add);
|
||||||
heroAttrs.tal_WFuny.value = talent.value+talent.value_add;
|
|
||||||
break;
|
break;
|
||||||
case TalEffet.D_SKILL:
|
case TalEffet.D_SKILL:
|
||||||
heroAttrs.tal_DSill.count += 1;
|
heroAttrs.addTalent(TalEffet.D_SKILL, talent.value + talent.value_add);
|
||||||
heroAttrs.tal_DSill.value = talent.value+talent.value_add;
|
break;
|
||||||
|
case TalEffet.C_ATK:
|
||||||
|
heroAttrs.addTalent(TalEffet.C_ATK, talent.value + talent.value_add);
|
||||||
|
break;
|
||||||
|
case TalEffet.C_SKILL:
|
||||||
|
heroAttrs.addTalent(TalEffet.C_SKILL, talent.value + talent.value_add);
|
||||||
|
break;
|
||||||
|
case TalEffet.C_MSKILL:
|
||||||
|
heroAttrs.addTalent(TalEffet.C_MSKILL, talent.value + talent.value_add);
|
||||||
|
break;
|
||||||
|
case TalEffet.BUFF:
|
||||||
|
heroAttrs.addTalBuff(talent.uuid, talent.attrs, talent.vType, talent.value + talent.value_add);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 重置组件状态
|
* 重置组件状态
|
||||||
*
|
|
||||||
* 功能:
|
|
||||||
* - 清空所有天赋数据
|
|
||||||
* - 重置英雄ID
|
|
||||||
* - 清除英雄视图引用
|
|
||||||
* - 为组件的复用做准备
|
|
||||||
*/
|
*/
|
||||||
reset() {
|
reset() {
|
||||||
this.Tals = {};
|
this.Tals = {};
|
||||||
|
|||||||
@@ -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,damage:number=0) {
|
caster:HeroViewComp,ext_dmg:number=0) {
|
||||||
const config = SkillSet[s_uuid];
|
const config = SkillSet[s_uuid];
|
||||||
|
|
||||||
if (!config) {
|
if (!config) {
|
||||||
@@ -90,7 +90,7 @@ export class Skill extends ecs.Entity {
|
|||||||
const sDataCom = this.get(SDataCom);
|
const sDataCom = this.get(SDataCom);
|
||||||
sDataCom.group=caster.box_group
|
sDataCom.group=caster.box_group
|
||||||
sDataCom.caster=caster
|
sDataCom.caster=caster
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user