技能有bug 需要处理

This commit is contained in:
2025-08-12 11:02:16 +08:00
parent 1273ec6e99
commit 61cbd6e7bd
5 changed files with 382 additions and 505 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -172,7 +172,7 @@ export class HeroViewComp extends CCComp {
hp_show(){
// if(this.node.getComponent(HeroViewComp).fac == 0) return
let hp=this.hp;
let hp_max=this.hp_max;
let hp_max=this.Attrs[BuffAttr.HP_MAX];
let hp_progress= hp/hp_max;
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar).progress = hp_progress;
// this.node.getChildByName("top").getChildByName("hp").active = (hp == hp_max) ? false : true;
@@ -211,7 +211,7 @@ export class HeroViewComp extends CCComp {
add_hp(hp: number = 0,is_num:boolean=true) {
this.BUFFCOMP.heathed();
let real_hp=0
let hp_max=this.hp_max
let hp_max=this.Attrs[BuffAttr.HP_MAX]
let lost_hp=hp_max-this.hp
if(is_num){
if(lost_hp > hp){
@@ -306,8 +306,8 @@ export class HeroViewComp extends CCComp {
// this.is_stop=true
break
case DebuffAttr.DEHP:
this.hp_max-=deV/100*this.hp_max
if(this.hp-this.hp_max>0) this.hp=this.hp_max
this.Attrs[BuffAttr.HP_MAX]-=deV/100*this.Attrs[BuffAttr.HP_MAX]
if(this.hp-this.Attrs[BuffAttr.HP_MAX]>0) this.hp=this.Attrs[BuffAttr.HP_MAX]
break
case DebuffAttr.DEATK: //99为具体数字 并且局内永久生效,其他为百分比
if(deC == 99){

View File

@@ -8,7 +8,7 @@ import { HeroInfo } from "../common/config/heroSet";
import { MonModelComp } from "./MonModelComp";
import { BattleMoveComp } from "../common/ecs/position/BattleMoveComp";
import { SkillConComp } from "./SkillConComp";
import { BuffAttr, SkillSet } from "../common/config/SkillSet";
import { BuffAttr, getBuffNum, SkillSet } from "../common/config/SkillSet";
/** 角色实体 */
@ecs.register(`Monster`)
export class Monster extends ecs.Entity {
@@ -75,8 +75,9 @@ export class Monster extends ecs.Entity {
hv.box_group = box_group;
hv.hero_uuid= uuid;
hv.hero_name= hero.name;
hv.speed =hv.speed_base = hero.speed;
hv.dis = hero.dis;
// 初始化Attrs属性系统参考Hero.ts的实现
hv.Attrs = getBuffNum();
// 肉鸽模式使用固定数值,否则使用等级计算
if (rogueHp !== undefined && rogueAttack !== undefined) {
@@ -98,11 +99,34 @@ export class Monster extends ecs.Entity {
hv.hp = hv.hp_max = levelHp;
hv.ap = levelAp;
hv.ap_base=levelAp
hv.ap_base = levelAp;
console.log(`[Monster]: 怪物${hero.name}(等级${lv}) - 基础HP:${baseHp}->等级HP:${levelHp}, 基础AP:${baseAp}->等级AP:${levelAp}`);
}
hv.cd = hero.cd
// 设置基础属性到Attrs系统
hv.Attrs[BuffAttr.SPEED] = hv.speed = hv.speed_base = hero.speed;
hv.Attrs[BuffAttr.DIS] = hv.dis = hero.dis;
hv.Attrs[BuffAttr.ATK_CD] = hv.cd = hero.cd;
hv.Attrs[BuffAttr.HP_MAX] = hv.hp_max;
hv.Attrs[BuffAttr.AP] = hv.ap;
hv.Attrs[BuffAttr.DEF] = hv.def;
// 处理原有Buff使用统一的apply_buff方法
hero.buff.forEach((buff:any)=>{
hv.apply_buff(buff.type, buff.value);
})
// 处理肉鸽模式的词条Buff
if (rogueBuffData && rogueBuffData.length > 0) {
console.log(`[Monster]: 怪物${hero.name}应用肉鸽词条:`, rogueBuffData);
rogueBuffData.forEach((buff:any)=>{
hv.apply_buff(buff.type, buff.value);
})
}
// 重新计算最终HP因为buff可能修改了hp_max
hv.hp = hv.hp_max;
for(let i=0;i<hero.skills.length;i++){
hv.skills.push({
cd:0,
@@ -110,73 +134,7 @@ export class Monster extends ecs.Entity {
cd_max:i==0?hero.cd:SkillSet[hero.skills[i]].cd
})
}
// 处理原有Buff
hero.buff.forEach((buff:any)=>{
this.applyBuffToMonster(hv, buff);
})
// 处理肉鸽模式的词条Buff
if (rogueBuffData && rogueBuffData.length > 0) {
console.log(`[Monster]: 怪物${hero.name}应用肉鸽词条:`, rogueBuffData);
rogueBuffData.forEach((buff:any)=>{
this.applyBuffToMonster(hv, buff);
})
}
// 重新计算最终HP因为buff可能修改了hp_max
hv.hp = hv.hp_max;
this.add(hv);
}
/**
* 应用Buff到怪物的通用方法
*/
private applyBuffToMonster(hv: any, buff: any) {
switch(buff.buff_type){
case BuffAttr.CRITICAL:
hv.crit+=buff.value
break
case BuffAttr.CRITICAL_DMG:
hv.crit_d+=buff.value
break
case BuffAttr.DODGE:
hv.dod+=buff.value
break
case BuffAttr.DODGE_NO:
hv.dod_no+=buff.value
break
case BuffAttr.CRITICAL_NO:
hv.crit_no+=buff.value
break
case BuffAttr.BURN_COUNT:
hv.burn_count+=buff.value
break
case BuffAttr.PUNCTURE:
hv.puncture+=buff.value
break
case BuffAttr.PUNCTURE_DMG:
hv.puncture_damage+=buff.value
break
case BuffAttr.WFUNY:
hv.wfuny+=buff.value
break
case BuffAttr.ATK_CD:
hv.cd=hv.cd*(100+buff.value)/100
break
case BuffAttr.HP:
hv.hp_max=hv.hp_max*(100+buff.value)/100
break
case BuffAttr.DEF:
hv.def+=buff.value
break
case BuffAttr.ATK:
hv.ap=hv.ap*(100+buff.value)/100
break
case BuffAttr.FROST_RATIO:
hv.frost_ratio+=buff.value
break
}
}
}

View File

@@ -68,24 +68,6 @@ export class Skill extends ecs.Entity {
node.angle+=angle
// 添加技能组件
const SComp = node.getComponent(SkillCom); // 初始化技能参数
if (!SComp) {
console.error("[Skill] 技能组件获取失败");
return;
}
// 确保caster有必要的属性
if (typeof caster.ap === 'undefined') {
console.error("[Skill] caster.ap 未定义");
return;
}
if (typeof caster.box_group === 'undefined') {
console.error("[Skill] caster.box_group 未定义");
return;
}
// 只设置必要的运行时属性,配置信息通过 SkillSet[uuid] 访问
Object.assign(SComp, {
@@ -94,7 +76,6 @@ export class Skill extends ecs.Entity {
// 位置和施法者信息
startPos: startPos,
targetPos: targetPos,
caster: caster,
group: caster.box_group,
fac: caster.fac,
// 技能数值

View File

@@ -161,10 +161,23 @@ export class SkillCom extends CCComp {
onAnimationFinished(){
// console.log("[SkillCom]:onAnimationFinished",this.s_uuid)
if (!this.skillConfig) return;
if(this.skillConfig.EType==EType.timeEnd) return
if(this.skillConfig.SType!=SType.damage){
this.to_do_buff()
}
this.is_destroy=true
}
to_do_buff(){
if (!this.skillConfig) return;
switch(this.skillConfig.SType){
case SType.shield:
this.caster.add_shield(this.skillConfig.buV)
break;
}
}
//单体伤害
single_damage(target:HeroViewComp,is_range:boolean=false){
// //console.log("[SkillCom]:onBeginContact hit_count:",this.hit_count,SkillSet[this.s_uuid].hit)