refactor: 移除眩晕机制并简化buff系统

- 删除眩晕相关属性、状态检查及动画触发
- 移除BType枚举,简化BuffConf结构,所有buff改为固定值类型
- 清理未使用的导入和配置项,包括debuffs数组和多个英雄属性
- 简化暴击伤害计算,移除施法者暴击伤害加成
- 重构冰冻状态检查逻辑,添加frost_end_time字段
This commit is contained in:
walkpan
2026-03-19 18:43:02 +08:00
parent a58dc818ee
commit 1bb2d6072e
10 changed files with 51 additions and 142 deletions

View File

@@ -122,11 +122,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
mLogger.log(this.debugMode, 'HeroAtkSystem', " dmgCount",damage)
if (isCrit) {
// 暴击伤害计算
// 使用施法者的暴击伤害加成属性damageEvent.Attrs 快照)
// 公式:最终伤害 = 基础伤害 * (1 + 系统暴击倍率 + 施法者暴击伤害加成)
const casterCritDmg = damageEvent.Attrs[Attrs.critical_dmg] || 0;
damage = Math.floor(damage * (1 + (FightSet.CRIT_DAMAGE + casterCritDmg) / 100));
damage = Math.floor(damage * (1 + FightSet.CRIT_DAMAGE / 100));
reDate.isCrit=true;
}

View File

@@ -1,5 +1,5 @@
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { Attrs, BType } from "../common/config/HeroAttrs";
import { Attrs } from "../common/config/HeroAttrs";
import { BuffConf } from "../common/config/SkillSet";
import { HeroDisVal, HType } from "../common/config/heroSet";
import { mLogger } from "../common/Logger";
@@ -30,17 +30,13 @@ export class HeroAttrsComp extends ecs.Comp {
s_cd_max: number = 0; // 技能CD
// ==================== 暴击与命中属性 ====================
critical: number = 0; // 暴击率
critical_dmg: number = 0; // 暴击伤害
// ==================== 特殊效果属性 ====================
freeze_chance: number = 0; // 冰冻概率
stun_chance: number = 0; // 眩晕概率
back_chance: number = 0; // 击退概率
slow_chance: number = 0; // 减速概率
// ==================== 武器进化相关 ====================
puncture: number = 0; // 穿刺次数
puncture_dmg: number = 0; // 穿刺伤害
wfuny: number = 0; // 风怒
// ==================== 增益效果属性 ====================
@@ -49,8 +45,8 @@ export class HeroAttrsComp extends ecs.Comp {
invincible_time: number = 0;// 无敌时间
in_stun=false
in_frost=false
frost_end_time: number = 0;
boom: boolean = false; // 自爆怪
@@ -92,8 +88,8 @@ export class HeroAttrsComp extends ecs.Comp {
* 从 HeroInfo 读取初始配置,建立属性系统
*/
initAttrs() {
this.in_stun = false;
this.in_frost = false;
this.frost_end_time = 0;
}
/*******************基础属性管理********************/
@@ -139,10 +135,9 @@ export class HeroAttrsComp extends ecs.Comp {
* @param buffConf buff 配置
*/
addBuff(buffConf: BuffConf) {
const normalized = this.normalizeBuffValue(buffConf);
this.applyAttrChange(buffConf.buff, normalized.value, normalized.BType);
this.applyAttrChange(buffConf.buff, buffConf.value);
if (this.debugMode) {
mLogger.log(this.debugMode, 'HeroAttrs', `添加属性: ${buffConf.name}, 属性:${buffConf.buff}, 值:${normalized.value}`);
mLogger.log(this.debugMode, 'HeroAttrs', `添加属性: ${buffConf.name}, 属性:${buffConf.buff}, 值:${buffConf.value}`);
}
}
@@ -151,39 +146,28 @@ export class HeroAttrsComp extends ecs.Comp {
* - RATIO 会在写入前转换为 VALUE
* - BOOLEAN 保持原类型
*/
private normalizeBuffValue(buffConf: BuffConf): { value: number; BType: BType } {
return {
value: buffConf.value,
BType: BType.VALUE
};
}
/**
* 通用属性修改应用
* @param attr 属性名
* @param value 变化值
* @param type 数值类型 (0:固定值, 1:百分比)
* @param reverse 是否反向应用 (用于移除 buff)
*/
private applyAttrChange(attr: Attrs, value: number, type: BType, reverse: boolean = false) {
private applyAttrChange(attr: Attrs, value: number,) {
const mappedAttr = attr === Attrs.hp ? Attrs.hp_max : (attr === Attrs.shield ? Attrs.shield_max : attr);
if (mappedAttr !== Attrs.ap && mappedAttr !== Attrs.hp_max && mappedAttr !== Attrs.shield_max) return;
void type;
let finalValue = value;
if (reverse) finalValue = -finalValue;
if (mappedAttr === Attrs.ap) {
this.ap = Math.max(0, this.ap + finalValue);
this.ap = Math.max(0, this.ap + value);
return;
}
if (mappedAttr === Attrs.hp_max) {
this.hp_max = Math.max(1, this.hp_max + finalValue);
this.hp_max = Math.max(1, this.hp_max + value);
if (this.hp > this.hp_max) this.hp = this.hp_max;
this.dirty_hp = true;
return;
}
this.shield_max = Math.max(0, this.shield_max + finalValue);
this.shield = Math.max(0, Math.min(this.shield + finalValue, this.shield_max));
this.shield_max = Math.max(0, this.shield_max + value);
this.shield = Math.max(0, Math.min(this.shield + value, this.shield_max));
this.dirty_shield = true;
}
//======更新cd========//
@@ -197,11 +181,18 @@ export class HeroAttrsComp extends ecs.Comp {
if(this.s_cd >= this.s_cd_max) this.can_skill = true
}
}
isStun(): boolean {
return false;
}
isFrost(): boolean {
return false;
if (!this.in_frost) return false;
if (this.frost_end_time <= 0) {
this.in_frost = false;
return false;
}
if (Date.now() / 1000 >= this.frost_end_time) {
this.in_frost = false;
this.frost_end_time = 0;
return false;
}
return true;
}
triggerAtkCD() {
this.a_cd = 0;
@@ -272,21 +263,17 @@ export class HeroAttrsComp extends ecs.Comp {
this.a_cd_max = 0;
this.s_cd_max = 0;
this.critical = 0;
this.critical_dmg = 0;
this.freeze_chance = 0;
this.stun_chance = 0;
this.back_chance = 0;
this.slow_chance = 0;
this.revive_count = 0;
this.revive_time = 0;
this.invincible_time = 0;
this.puncture = 0;
this.puncture_dmg = 0;
this.wfuny = 0;
this.boom = false;
this.in_frost = false;
this.in_stun = false;
this.frost_end_time = 0;
// 重置技能距离缓存
this.maxSkillDistance = 0;

View File

@@ -417,9 +417,6 @@ export class HeroViewComp extends CCComp {
this.in_iced(0.3);
return;
}
if (attr === Attrs.IN_STUN && value > 0) {
this.in_yun(0.3);
}
}
alive(){

View File

@@ -5,7 +5,6 @@ import { smc } from "../common/SingletonModuleComp";
import { BoxSet, FacSet, FightSet, IndexSet } from "../common/config/GameSet";
import { HeroInfo } from "../common/config/heroSet";
import { HeroAttrsComp } from "./HeroAttrsComp";
import { BuffConf, SkillSet } from "../common/config/SkillSet";
import { HeroViewComp } from "./HeroViewComp";
import { MoveComp } from "./MoveComp";
import { mLogger } from "../common/Logger";

View File

@@ -98,7 +98,7 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
view.status_change("idle");
return;
}
if (model.is_stop || model.is_dead || model.is_reviving || model.in_stun || model.in_frost) {
if (model.is_stop || model.is_dead || model.is_reviving || model.isFrost()) {
this.clearCombatTarget(model);
if (!model.is_reviving) view.status_change("idle");
return;

View File

@@ -43,7 +43,7 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
const heroAttrs = e.get(HeroAttrsComp);
const heroView = e.get(HeroViewComp);
if (!heroAttrs || !heroView || !heroView.node) return;
if (heroAttrs.is_dead || heroAttrs.is_reviving || heroAttrs.isStun() || heroAttrs.isFrost()) return;
if (heroAttrs.is_dead || heroAttrs.is_reviving || heroAttrs.isFrost()) return;
heroAttrs.updateCD(this.dt);
heroView.cd_show();
@@ -149,15 +149,6 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
}
}
}
if (config.debuffs) {
for (const buffId of config.debuffs) {
const buffConf = BuffsList[buffId];
if (buffConf) {
model.addBuff(buffConf);
}
}
}
}
}