去掉skillcom处理 buff skill只负责动画运行和碰撞伤害

This commit is contained in:
panw
2025-08-12 10:31:01 +08:00
parent ca8bbd397b
commit 1273ec6e99
13 changed files with 166 additions and 443 deletions

View File

@@ -10,7 +10,7 @@ import { BattleMoveComp } from "../common/ecs/position/BattleMoveComp";
import { FriendModelComp } from "./FriendModel";
import { MasterModelComp } from "./MasterModel";
import { GameEvent } from "../common/config/GameEvent";
import { BuffAttr, SkillSet } from "../common/config/SkillSet";
import { BuffAttr, getBuffNum, SkillSet } from "../common/config/SkillSet";
import { FightSet } from "../common/config/Mission";
import { Skill } from "../skills/Skill";
/** 角色实体 */
@@ -80,62 +80,15 @@ export class Hero extends ecs.Entity {
hv.box_group = BoxSet.HERO;
hv.hero_uuid= uuid;
hv.hero_name= hero.name;
hv.speed =hv.ospeed = hero.speed;
hv.dis = hero.dis;
hv.cd = hv.cd_base = hero.cd
hv.hp = hv.hp_max = hv.hp_base=hero.hp+info.hp
hv.ap = hv.ap_base=hero.ap+info.ap;
hv.Attrs=getBuffNum()
hv.Attrs[BuffAttr.SPEED]=hv.speed = 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=hv.hp_max=hero.hp+info.hp
hv.Attrs[BuffAttr.AP]=hv.ap=hero.ap+info.ap;
hv.Attrs[BuffAttr.DEF]=hv.def=hero.def+info.def;
hero.buff.forEach((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.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.STUN_RATTO:
hv.stun_ratto=buff.value
break
case BuffAttr.FROST_RATIO:
hv.frost_ratto=buff.value
break
case BuffAttr.KNOCKBACK:
hv.knockback=buff.value
break
case BuffAttr.POWER_UP:
smc.vmdata.hero.POWER_UP+=buff.value
break
}
hv.apply_buff(buff.type,buff.value)
})
for(let i=0;i<hero.skills.length;i++){
hv.skills.push({

View File

@@ -32,7 +32,7 @@ export class HeroConComp extends CCComp {
[BuffAttr.PUNCTURE_DMG, 'handlePunctureDmgBuff'],
[BuffAttr.FROST_RATIO, 'handleFrostBuff'],
[BuffAttr.KNOCKBACK, 'handleKnockbackBuff'],
[BuffAttr.STUN_RATTO, 'handleStunBuff'],
[BuffAttr.STUN_RATIO, 'handleStunBuff'],
[BuffAttr.REFLECT, 'handleReflectBuff'],
[BuffAttr.LIFESTEAL, 'handleLifestealBuff']
]);
@@ -116,22 +116,22 @@ export class HeroConComp extends CCComp {
}
// Buff处理方法
private handleAPBuff(value: number): void { this.heroView.change_ap(value, true); }
private handleATKBuff(value: number): void { this.heroView.change_ap(value, false); }
private handleSpeedBuff(value: number): void { this.heroView.add_speed(value); }
private handleDefBuff(value: number): void { this.heroView.change_def(value); }
private handleHPBuff(value: number): void { this.heroView.change_hp_max(value, false); }
private handleHPMaxBuff(value: number): void { this.heroView.change_hp_max(value, true); }
private handleCritBuff(value: number): void { this.heroView.change_crit(value); }
private handleCritDmgBuff(value: number): void { this.heroView.change_crit_d(value); }
private handleDodgeBuff(value: number): void { this.heroView.change_dodge(value); }
private handlePunctureBuff(value: number): void { this.heroView.change_puncture(value); }
private handlePunctureDmgBuff(value: number): void { this.heroView.change_puncture_damage(value); }
private handleFrostBuff(value: number): void { this.heroView.change_frost_ratto(value); }
private handleKnockbackBuff(value: number): void { this.heroView.change_knockback(value); }
private handleStunBuff(value: number): void { this.heroView.change_stun_ratto(value); }
private handleReflectBuff(value: number): void { this.heroView.change_reflect(value); }
private handleLifestealBuff(value: number): void { this.heroView.change_lifesteal(value); }
private handleAPBuff(value: number): void { this.heroView.apply_buff(BuffAttr.AP, value); }
private handleATKBuff(value: number): void { this.heroView.apply_buff(BuffAttr.ATK, value); }
private handleSpeedBuff(value: number): void { this.heroView.apply_buff(BuffAttr.ATK_CD, value); }
private handleDefBuff(value: number): void { this.heroView.apply_buff(BuffAttr.DEF, value); }
private handleHPBuff(value: number): void { this.heroView.apply_buff(BuffAttr.HP, value); }
private handleHPMaxBuff(value: number): void { this.heroView.apply_buff(BuffAttr.HP_MAX, value); }
private handleCritBuff(value: number): void { this.heroView.apply_buff(BuffAttr.CRITICAL, value); }
private handleCritDmgBuff(value: number): void { this.heroView.apply_buff(BuffAttr.CRITICAL_DMG, value); }
private handleDodgeBuff(value: number): void { this.heroView.apply_buff(BuffAttr.DODGE, value); }
private handlePunctureBuff(value: number): void { this.heroView.apply_buff(BuffAttr.PUNCTURE, value); }
private handlePunctureDmgBuff(value: number): void { this.heroView.apply_buff(BuffAttr.PUNCTURE_DMG, value); }
private handleFrostBuff(value: number): void { this.heroView.apply_buff(BuffAttr.FROST_RATIO, value); }
private handleKnockbackBuff(value: number): void { this.heroView.apply_buff(BuffAttr.KNOCKBACK, value); }
private handleStunBuff(value: number): void { this.heroView.apply_buff(BuffAttr.STUN_RATIO, value); }
private handleReflectBuff(value: number): void { this.heroView.apply_buff(BuffAttr.REFLECT, value); }
private handleLifestealBuff(value: number): void { this.heroView.apply_buff(BuffAttr.LIFESTEAL, value); }
/** 组件重置 */
reset(): void {
this.node.destroy();

View File

@@ -5,7 +5,7 @@ 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 { BuffAttr, DebuffAttr, SkillSet, TGroup, TType } from "../common/config/SkillSet";
import { BuffAttr, DebuffAttr, geDebuffNum, getBuffNum, SkillSet, TGroup, TType } from "../common/config/SkillSet";
import { BuffComp } from "./BuffComp";
import { oops } from "db://oops-framework/core/Oops";
import { GameEvent } from "../common/config/GameEvent";
@@ -44,27 +44,25 @@ export class HeroViewComp extends CCComp {
is_friend:boolean =false;
is_kalami:boolean =false;
speed: number = 100; /** 角色移动速度 */
speed_base: number = 100; /** 角色初始速度 */
hp: number = 100; /** 血量 */
hp_max: number = 100; /** 最大血量 */
hp_buff:number=0;
hp_base:number=0;
ap: number = 10; /**攻击力 */
ap_buff:number=0;
ap_base:number=0;
// atk_speed: number = 1;
cd_base:number=1.3;
cd: number = 1.3; /**攻击速度 攻击间隔 */
cd_buff:number=0;
def: number = 0; //防御
dmg_red:number=0//免伤
dis: number = 80;
skills:any[]=[]
puncture:number=0; //穿刺敌人伤害后方敌人个数
puncture_damage:number=0; //后伤害加成
def: number = 0; //防御
dmg_red:number=0//免伤
burn: number = 0; //易伤 伤害加成
stun_time:number=0; //眩晕加成
stun_ratto:number=0; //攻击眩晕概率加成
stun_ratio:number=0; //攻击眩晕概率加成
stun_no:boolean=false; //眩晕免疫
dod: number = 0; //闪避率
dod_no:boolean=false;
@@ -72,30 +70,30 @@ export class HeroViewComp extends CCComp {
crit_no:boolean=false; //暴击免疫
crit_d:number=0; //暴击伤害
wfuny:number=0; //风怒概率
frost_ratto:number=0; //冰冻概率
frost_ratio:number=0; //冰冻概率
frost_time:number=0; //冰冻时间
frost_no:boolean=false; //冰冻免疫
knockback:number=0; //击退概率
knockback_no:boolean=false; //击退免疫
shield:number = 0; //护盾,免伤1次减1
speed: number = 100; /** 角色移动速度 */
ospeed: number = 100; /** 角色初始速度 */
reflect:number=0; //反射伤害比率
lifesteal:number=0; //吸血比率
skill_dmg:number=0
debuff_down:number=0
Attrs:any=getBuffNum()
debuff_status:any=geDebuffNum()
atk_count: number = 0;
atked_count: number = 0;
stop_cd: number = 0; /*停止倒计时*/
speek_time:number = 0;
debuff_down_ratto:number=0
BUFF_DEFS: Array<{value: number, duration: number}> = [] //防御提升
BUFF_ATKS: Array<{value: number, duration: number}> = [] //攻击提升
BUFF_CDS: Array<{value: number, duration: number}> = [] //攻击加速
BUFF_DEDOWN:Array<{value: number, duration: number}> = [] //debuff 概率降低
BUFFS:Array<{value: number, duration: number,type:number}> = [] //buff
DEBUFF_BURNS: Array<{value: number, duration: number}> = [] //易伤
DEBUFF_DEATKS: Array<{value: number, duration: number}> = [] //减攻击
DEBUFF_DECDS: Array<{value: number, duration: number}> = [] //减攻击速度
@@ -138,7 +136,6 @@ export class HeroViewComp extends CCComp {
start () {
this.as.idle()
this.BUFFCOMP=this.node.getComponent(BuffComp);
/** 方向 */
this.node.setScale(this.scale,1);
this.node.getChildByName("top").setScale(this.scale,1);
@@ -209,136 +206,12 @@ export class HeroViewComp extends CCComp {
if(this.shield>6) this.shield=6
if(this.shield>0) this.BUFFCOMP.show_shield(true)
}
change_wfuny(wfuny: number){
this.wfuny+=wfuny
if(this.wfuny<0) this.wfuny=0
}
change_puncture(puncture: number){
this.puncture+=puncture
if(this.puncture<1) this.puncture=1
}
change_puncture_damage(puncture_damage: number){
this.puncture_damage+=puncture_damage
if(this.puncture_damage<0) this.puncture_damage=0
if(this.puncture_damage>80) this.puncture_damage=80
}
change_dodge(dodge: number){
this.dod+=dodge
if(this.dod<0) this.dod=0
if(this.dod>90) this.dod=90
}
change_frost_ratto(frost_ratto: number){
this.frost_ratto+=frost_ratto
if(this.frost_ratto<0) this.frost_ratto=0
if(this.frost_ratto>90) this.frost_ratto=90
}
change_knockback(knockback: number){
this.knockback+=knockback
if(this.knockback<0) this.knockback=0
}
change_stun_ratto(stun_ratto: number){
this.stun_ratto+=stun_ratto
if(this.stun_ratto<0) this.stun_ratto=0
}
change_def(def: number){
this.def+=def
if(this.def>90) this.def=90
if(this.def<0) this.def=0
// this.BUFFCOMP.tooltip(TooltipTypes.defup,def.toFixed(0));
}
change_crit(crit: number){
this.crit+=crit
if(this.crit<0) this.crit=0
}
change_crit_d(crit_d: number){
this.crit_d+=crit_d
if(this.crit_d<0) this.crit_d=0
}
change_reflect(reflect: number){
this.reflect+=reflect
if(this.reflect<0) this.reflect=0
}
change_lifesteal(lifesteal: number){
this.lifesteal+=lifesteal
if(this.lifesteal<0) this.lifesteal=0
}
check_atrr(buff:BuffAttr){
switch(buff){
case BuffAttr.ATK:
return Math.floor(this.ap_base*(100+this.ap_buff)/100)
case BuffAttr.ATK_CD:
return this.cd_base/((this.cd_buff)/100+1)
case BuffAttr.HP:
return Math.floor(this.hp_base*(100+this.hp_buff)/100)
}
}
count_atrr(buff:BuffAttr){
switch(buff){
case BuffAttr.ATK:
this.ap=this.check_atrr(BuffAttr.ATK)
break
case BuffAttr.ATK_CD:
this.cd=this.check_atrr(BuffAttr.ATK_CD)
break
case BuffAttr.HP:
let diff=this.check_atrr(BuffAttr.HP)-this.hp_max
this.hp_max=this.check_atrr(BuffAttr.HP)
this.hp+=diff
this.hp_show()
break
}
}
add_speed(cd: number){
this.cd_buff+=cd
this.count_atrr(BuffAttr.ATK_CD)
// this.BUFFCOMP.tooltip(TooltipTypes.speedup,speed.toFixed(0));
}
change_ap(ap: number,is_num:boolean=true){
// console.log("[HeroViewComp]:add_ap add:",ap,this.ap)
if(is_num){
this.ap_base += Math.floor(ap);
}else{
this.ap_buff += Math.floor(ap/100*this.ap_base);
}
this.count_atrr(BuffAttr.ATK)
}
change_hp_max(hp: number=0,is_num:boolean=false){
// console.log("[HeroViewComp]:add_hp_max add:",hp,this.currentHpMax)
if(is_num){
this.hp_base += Math.floor(hp) ;
}else{
this.hp_buff+=hp
}
this.count_atrr(BuffAttr.HP)
// this.update_vm
}
add_hp(hp: number = 0,is_num:boolean=true) {
this.BUFFCOMP.heathed();
let real_hp=0
let hp_max=Math.floor(this.hp_max*(100+this.hp_buff)/100)
let hp_max=this.hp_max
let lost_hp=hp_max-this.hp
if(is_num){
if(lost_hp > hp){
@@ -402,17 +275,8 @@ export class HeroViewComp extends CCComp {
}
get_debuff(){
}
add_debuff(type:number,deV:number,deC:number,deR:number){
let DEBUFF_DOWN=0
for(let i=0;i<this.BUFF_DEDOWN.length;i++){
DEBUFF_DOWN+=this.BUFF_DEDOWN[i].value
// 不再在这里减少duration改为在update中按时间减少
}
let n_deR=deR-DEBUFF_DOWN-this.debuff_down_ratto // 触发概率
let n_deR=deR-this.Attrs[BuffAttr.DEBUFF_DOWN]
let r=RandomManager.instance.getRandomInt(0,100) // 随机数
//console.log("[HeroViewComp]:类型,值,次数,技能概率,实际概率,随机数",type,deV,deC,deR,n_deR,r)
if(r < n_deR) {
@@ -469,35 +333,12 @@ export class HeroViewComp extends CCComp {
// 更新所有按时间减少的buff和debuff
updateBuffsAndDebuffs(dt: number) {
// 更新BUFF_DEFS
for(let i = this.BUFF_DEFS.length - 1; i >= 0; i--) {
this.BUFF_DEFS[i].duration -= dt;
if(this.BUFF_DEFS[i].duration <= 0) {
this.BUFF_DEFS.splice(i, 1);
}
}
// 更新BUFF_ATKS
for(let i = this.BUFF_ATKS.length - 1; i >= 0; i--) {
this.BUFF_ATKS[i].duration -= dt;
if(this.BUFF_ATKS[i].duration <= 0) {
this.BUFF_ATKS.splice(i, 1);
}
}
// 更新BUFF_CDS
for(let i = this.BUFF_CDS.length - 1; i >= 0; i--) {
this.BUFF_CDS[i].duration -= dt;
if(this.BUFF_CDS[i].duration <= 0) {
this.BUFF_CDS.splice(i, 1);
}
}
// 更新BUFF_DEDOWN
for(let i = this.BUFF_DEDOWN.length - 1; i >= 0; i--) {
this.BUFF_DEDOWN[i].duration -= dt;
if(this.BUFF_DEDOWN[i].duration <= 0) {
this.BUFF_DEDOWN.splice(i, 1);
// 更新BUFFS
for(let i = this.BUFFS.length - 1; i >= 0; i--) {
this.BUFFS[i].duration -= dt;
if(this.BUFFS[i].duration <= 0) {
this.apply_buff(this.BUFFS[i].type,-this.BUFFS[i].value)
this.BUFFS.splice(i, 1);
}
}
@@ -527,27 +368,40 @@ export class HeroViewComp extends CCComp {
}
add_buff(buff:number,duration:number,type:number){
switch(type){
case BuffAttr.DEF:
this.BUFF_DEFS.push({value:buff,duration:duration})
if(this.BUFFS.find(b=>b.type==type)) {
if(this.BUFFS.find(b=>b.type==type).value<buff) {
let dis_buff_value=buff-this.BUFFS.find(b=>b.type==type).value
this.BUFFS.find(b=>b.type==type).value=buff
this.BUFFS.find(b=>b.type==type).duration=duration
this.apply_buff(type,dis_buff_value)
}
}else{
this.BUFFS.push({value:buff,duration:duration,type:type})
this.apply_buff(type,buff)
}
}
// 应用buff,有基础值的需要特殊处理,其他的直接加减
apply_buff(buff_type:number,buff_value:number){
switch(buff_type){
case BuffAttr.ATK: //攻击百分比
this.Attrs[BuffAttr.AP]+=Math.floor(buff_value/100*this.ap)
break
case BuffAttr.ATK:
this.BUFF_ATKS.push({value:buff,duration:duration})
case BuffAttr.ATK_CD: //攻击速度百分比
this.Attrs[BuffAttr.ATK_CD]+=buff_value/100*this.cd
break
case BuffAttr.ATK_CD:
this.BUFF_CDS.push({value:buff,duration:duration})
case BuffAttr.HP: //血量百分比
this.Attrs[BuffAttr.HP_MAX]+=Math.floor(buff_value/100*this.hp_max)
break
case BuffAttr.DEBUFF_DOWN:
this.BUFF_DEDOWN.push({value:buff,duration:duration})
default:
this.Attrs[buff_type]+=buff_value
break
}
}
do_atked(remainingDamage:number,
crit:number=0,crit_d:number=0,
burn_count:number=0,burn_value:number=0,
stun_time:number=0,stun_ratto:number=0,
frost_time:number=0,frost_ratto:number=0,
stun_time:number=0,stun_ratio:number=0,
frost_time:number=0,frost_ratio:number=0,
atked_anm:string="atked"
){
this.do_atked_trigger()
@@ -555,7 +409,7 @@ export class HeroViewComp extends CCComp {
this.add_debuff(DebuffAttr.BURN,burn_value,burn_count,100)
}
if(stun_time>0){
this.add_debuff(DebuffAttr.STUN,stun_time,1,stun_ratto)
this.add_debuff(DebuffAttr.STUN,stun_time,1,stun_ratio)
}
if(this.check_shield()) return
if(this.check_dodge()) return
@@ -730,8 +584,8 @@ export class HeroViewComp extends CCComp {
if(this.fac==FacSet.MON) return
console.log("[HeroViewComp]:升级",this.BUFFCOMP)
if(this.hero_uuid!=data.uuid) return
this.change_ap(HeroInfo[data.uuid].ap,true)
this.change_hp_max(HeroInfo[data.uuid].hp,true)
this.apply_buff(BuffAttr.HP_MAX,data.hp)
this.apply_buff(BuffAttr.AP,data.ap)
this.BUFFCOMP.lv_up()
// this.BUFFCOMP.tooltip(TooltipTypes.lvup)
}

View File

@@ -75,7 +75,7 @@ export class Monster extends ecs.Entity {
hv.box_group = box_group;
hv.hero_uuid= uuid;
hv.hero_name= hero.name;
hv.speed =hv.ospeed = hero.speed;
hv.speed =hv.speed_base = hero.speed;
hv.dis = hero.dis;
// 肉鸽模式使用固定数值,否则使用等级计算
@@ -174,7 +174,7 @@ export class Monster extends ecs.Entity {
hv.ap=hv.ap*(100+buff.value)/100
break
case BuffAttr.FROST_RATIO:
hv.frost_ratto+=buff.value
hv.frost_ratio+=buff.value
break
}
}

View File

@@ -1,6 +1,6 @@
import { _decorator, Component, Node, v3, Vec3 } from 'cc';
import { HeroViewComp } from './HeroViewComp';
import { DTType, SkillSet, SType, TGroup, TType } from '../common/config/SkillSet';
import { BuffAttr, DTType, SkillSet, SType, TGroup, TType } from '../common/config/SkillSet';
import { Skill } from '../skills/Skill';
import { ecs } from 'db://oops-framework/libs/ecs/ECS';
import { oops } from 'db://oops-framework/core/Oops';
@@ -50,7 +50,7 @@ export class SkillConComp extends CCComp {
if(this.HeroView.DEBUFF_STUN <= 0&&this.HeroView.DEBUFF_FROST <= 0) {
for(let i=0;i<this.HeroView.skills.length;i++){
this.HeroView.skills[i].cd += dt;
if(this.HeroView.skills[i].cd > (i==0?this.count_cd(this.HeroView.skills[i].cd_max,this.HeroView):this.HeroView.skills[i].cd_max)){
if(this.HeroView.skills[i].cd > (i==0?this.HeroView.Attrs[BuffAttr.ATK_CD]:this.HeroView.skills[i].cd_max)){
let sc=SkillSet[this.HeroView.skills[i].uuid]
if(!sc) return
if(sc.SType==SType.damage&&!this.HeroView.is_atking) return
@@ -90,21 +90,7 @@ export class SkillConComp extends CCComp {
}
}
count_cd(cd:number,view:HeroViewComp){
// 汇总DEBUFF_DECD不再按次数减少改为按时间减少
let decd = 0;
for (let i = view.DEBUFF_DECDS.length - 1; i >= 0; i--) {
decd += view.DEBUFF_DECDS[i].value;
// 不再在这里减少duration改为在update中按时间减少
}
let bcd=0
for (let i = view.BUFF_CDS.length - 1; i >= 0; i--) {
bcd += view.BUFF_CDS[i].value;
// 不再在这里减少duration改为在update中按时间减少
}
return cd/((bcd+decd)/100+1)
}
/** 施放技能 */
castSkill(config: typeof SkillSet[keyof typeof SkillSet]) {
// //console.log(view.uuid+"=>"+view.hero_name+"施放技能:"+config.uuid);
@@ -171,7 +157,7 @@ export class SkillConComp extends CCComp {
check_wfuny(){
let random = Math.random()*100
if(random < this.HeroView.wfuny){
if(random < this.HeroView.Attrs[BuffAttr.WFUNY]){
return true
}
return false