FightConComp 的效用已经取消,下一步 进一步 精简,去掉临时 buff debuff 因为本身就是 当局游戏 没必要加零时debuff 直接当局永久debuff

This commit is contained in:
2025-07-22 16:42:42 +08:00
parent e45ebd524b
commit b17de4a2ac
5 changed files with 55 additions and 114 deletions

View File

@@ -4,12 +4,8 @@ import { ecs } from 'db://oops-framework/libs/ecs/ECS';
import { Tooltip } from '../skills/Tooltip';
import { timedCom } from '../skills/timedCom';
import { smc } from '../common/SingletonModuleComp';
import { BuffGet } from '../skills/BuffGet';
import { HeroViewComp } from './HeroViewComp';
import { FightConComp } from '../map/FightConComp';
import { BuffAttr, DebuffAttr } from '../common/config/SkillSet';
import { GameEvent } from '../common/config/GameEvent';
import { FacSet } from '../common/config/BoxSet';
const { ccclass, property } = _decorator;
@ccclass('BuffComp')
@@ -36,7 +32,6 @@ export class BuffComp extends Component {
wind_cd:number=0;
speek_time:number=0;
HeroView:HeroViewComp=null!
FIGHTCON:FightConComp=null!
hp_bar:any=null
protected onLoad(): void {
oops.message.on(GameEvent.UpdateVMData,this.to_update_vmdata,this)
@@ -47,7 +42,6 @@ export class BuffComp extends Component {
info_init(){
this.HeroView=this.node.getComponent(HeroViewComp)
this.FIGHTCON=this.node.parent.getComponent(FightConComp)
this.top_node = this.node.getChildByName("top");
let hp_y=this.node.getComponent(UITransform).height+20
this.top_node.setPosition(0,hp_y,0)
@@ -91,26 +85,20 @@ export class BuffComp extends Component {
vmdata_update(is_hp:boolean=false){
// console.log("[BuffComp]:to_update_vmdata:"+this.HeroView.hero_name)
let buff=null
let info= null
if(!this.HeroView) return
if(!this.HeroView.is_master) return
if(this.HeroView.fac==FacSet.HERO) {info=smc.vmdata.hero;buff=this.FIGHTCON.hero_buff}
if(this.HeroView.is_boss) {info=smc.vmdata.boss;buff=this.FIGHTCON.enemy_buff}
//if(this.HeroView.is_kalami) {target_key="enemy";buff_key="enemy"} 不显示小怪
info=smc.vmdata.hero
if(info==null) return
let view_atk = 0 //临时buff
let view_deatk = 0 //临时debuff
if(is_hp){
info.hp=this.HeroView.hp
info.hp_buff=buff.HP
info.hp_max=this.HeroView.hp_max*(100+buff.HP)/100
// info.exp=this.HeroView.exp
// info.next_exp=this.HeroView.next_exp
info.hp_max=this.HeroView.hp_max
}else{
info.hp=this.HeroView.hp
info.hp_buff=buff.HP
info.hp_max=this.HeroView.hp_max*(100+buff.HP)/100
info.hp_max=this.HeroView.hp_max
for(let i=0;i<this.HeroView.BUFF_ATKS.length;i++){
view_atk += this.HeroView.BUFF_ATKS[i].value
}
@@ -118,20 +106,20 @@ export class BuffComp extends Component {
for(let i=0;i<this.HeroView.DEBUFF_DEATKS.length;i++){
view_deatk += this.HeroView.DEBUFF_DEATKS[i].value
}
info.ap=this.HeroView.ap
// info.lv=this.HeroView.lv
info.cd=Number((this.HeroView.cd*(100-buff.ATK_CD)/100).toFixed(2))
console.log("info.buff.ATK_CD",buff.ATK_CD)
info.equip_ap=buff.ATK
info.cd=Number(this.HeroView.cd.toFixed(2))
info.equip_ap=this.HeroView.ap_base*this.HeroView.buff_ap
info.buff_ap=view_atk
info.debuff_ap=view_deatk
info.damage=this.HeroView.ap*(100+buff.ATK)/100*(100+view_atk-view_deatk)/100
info.crit=this.HeroView.crit+buff.CRITICAL
info.crit_d=this.HeroView.crit_d+buff.CRITICAL_DMG
info.dod=this.HeroView.dod+buff.DODGE
info.def=this.HeroView.def+buff.DEF
info.wind=buff.WFUNY
info.skill_cd_buff=buff.SKILL_CD
info.damage=this.HeroView.ap*(100+view_atk-view_deatk)/100
info.crit=this.HeroView.crit
info.crit_d=this.HeroView.crit_d
info.dod=this.HeroView.dod
info.def=this.HeroView.def
info.wind=this.HeroView.wfuny
}
}

View File

@@ -9,7 +9,6 @@ import { BuffAttr, DebuffAttr, SkillSet, TGroup, TType } from "../common/config/
import { BuffComp } from "./BuffComp";
import { oops } from "db://oops-framework/core/Oops";
import { GameEvent } from "../common/config/GameEvent";
import { FightConComp } from "../map/FightConComp";
import { EquipSpecialAttr } from "../common/config/Equips";
import { FightSet, getExpDrops, getStoneDrops, TooltipTypes } from "../common/config/Mission";
import { getApIncrease, getHpIncrease, getUpExp, HeroInfo, HeroPos } from "../common/config/heroSet";
@@ -24,7 +23,6 @@ const { ccclass, property } = _decorator;
@ccclass('HeroViewComp') // 定义为 Cocos Creator 组件
@ecs.register('HeroView', false) // 定义为 ECS 组件
export class HeroViewComp extends CCComp {
FIGHTCON:FightConComp=null!
BUFFCOMP:BuffComp=null!
as: HeroSpine = null!
status:String = "idle"
@@ -92,6 +90,10 @@ export class HeroViewComp extends CCComp {
speek_time:number = 0;
is_stop_temp:boolean = false
double_atked:boolean=false
atk_add_master_atk:number=0
atk_add_master_hp:number=0
buff_debuff_down:number=0
skill_dmg:number=0
BUFF_DEFS: Array<{value: number, count: number}> = [] //防御提升
BUFF_ATKS: Array<{value: number, count: number}> = [] //攻击提升
@@ -105,6 +107,10 @@ export class HeroViewComp extends CCComp {
DEBUFF_FROST: number = 0; //冰冻
DEBUFF_STUN: number = 0; //眩晕
DEBUFF_VALUE:number=0; //debuff 增益值
DEBUFF_COUNT:number=0; //debuff 持续次数
DEBUFF_UP:number=0; //debuff 概率提升
private damageQueue: Array<{
damage: number,
isCrit: boolean,
@@ -117,7 +123,6 @@ export class HeroViewComp extends CCComp {
onLoad() {
this.as = this.getComponent(HeroSpine);
this.FIGHTCON=this.node.parent.getComponent(FightConComp);
//console.log("[HeroViewComp]:hero view comp ",this.FIGHTCON)
this.on(GameEvent.ChangeATK_EQUIP_SPECIAL_ATTR,this.change_atk,this)
this.on(GameEvent.EXPUP,this.exp_up,this)
@@ -311,17 +316,16 @@ export class HeroViewComp extends CCComp {
if(!this.is_master) return
this.atk_count+=1
if(this.atk_count< FightSet.ATK_ADD_COUNT) return
if(this.FIGHTCON.atk_add_glod >0) smc.vmdata.mission_data.gold+=this.FIGHTCON.atk_add_glod
let master=ecs.query(ecs.allOf(MasterModelComp))
master.forEach(master=>{
let master_view=master.get(HeroViewComp)
if(this.FIGHTCON.atk_add_master_atk>0) {
master_view.add_ap(this.FIGHTCON.atk_add_master_atk)
if(this.atk_add_master_atk>0) {
master_view.add_ap(this.atk_add_master_atk,true)
}
if(this.FIGHTCON.atk_add_master_hp>0) {
master_view.add_hp_max(this.FIGHTCON.atk_add_master_hp)
if(this.atk_add_master_hp>0) {
master_view.add_hp_max(this.atk_add_master_hp,true)
}
})
@@ -349,22 +353,13 @@ export class HeroViewComp extends CCComp {
}
get_buff(){
let buff=null
if(this.fac==FacSet.HERO) buff=this.FIGHTCON.hero_buff
if(this.is_boss) buff=this.FIGHTCON.enemy_buff
if(this.is_kalami) buff=this.FIGHTCON.enemy_buff
if(buff==null) return
return buff
}
get_debuff(){
}
add_debuff(type:number,deV:number,deC:number,deR:number){
let DEBUFF_DOWN=0
let buff_debuff_down=0
let buff=this.get_buff()
if(buff!==null) buff_debuff_down=buff.DEBUFF_DOWN
for(let i=0;i<this.BUFF_DEDOWN.length;i++){
DEBUFF_DOWN+=this.BUFF_DEDOWN[i].value
this.BUFF_DEDOWN[i].count-=1
@@ -372,7 +367,7 @@ export class HeroViewComp extends CCComp {
this.BUFF_DEDOWN.splice(i,1)
}
}
let n_deR=deR-DEBUFF_DOWN-buff_debuff_down // 触发概率
let n_deR=deR-DEBUFF_DOWN-this.buff_debuff_down // 触发概率
let r=RandomManager.instance.getRandomInt(0,100) // 随机数
//console.log("[HeroViewComp]:类型,值,次数,技能概率,实际概率,随机数",type,deV,deC,deR,n_deR,r)
if(r < n_deR) {
@@ -504,11 +499,8 @@ export class HeroViewComp extends CCComp {
}
}
// buff 防御 即免伤
let buff_def=0
let buff=this.get_buff()
if(buff!==null) buff_def=buff.DEF
damage=remainingDamage*(100-(buff_def+def)+Burn)/100
damage=remainingDamage*(100-def-this.def+Burn)/100
////console.log("[HeroViewComp]:最终伤害,敌人伤害值,免伤,防御,易伤",damage,remainingDamage,buff_def,def,Burn)
return Math.floor(damage)
}
@@ -650,7 +642,7 @@ export class HeroViewComp extends CCComp {
this.add_speed(data.value)
break
case EnhancementType.HEALTH:
this.add_hp_max(data.value)
this.add_hp_max(data.value,true)
break
case EnhancementType.DEF:
this.add_def(data.value)

View File

@@ -8,7 +8,6 @@ import { GameEvent } from '../common/config/GameEvent';
import { BoxSet, FacSet } from '../common/config/BoxSet';
import { smc } from '../common/SingletonModuleComp';
import { CCComp } from 'db://oops-framework/module/common/CCComp';
import { FightConComp } from '../map/FightConComp';
import { MonModelComp } from './MonModelComp';
import { HeroModelComp } from './HeroModelComp';
import { FightSet } from '../common/config/Mission';
@@ -18,7 +17,6 @@ const { ccclass, property } = _decorator;
@ccclass('SkillCon')
@ecs.register('SkillCon')
export class SkillConComp extends CCComp {
FIGHTCON:FightConComp=null!
HeroView:any=null;
HeroEntity:any=null;
private _timers: { [key: string]: number } = {};
@@ -36,7 +34,6 @@ export class SkillConComp extends CCComp {
}
onLoad(){
this.HeroView=this.node.getComponent(HeroViewComp)
this.FIGHTCON=this.node.parent.getComponent(FightConComp)
// //console.log(this.HeroView.uuid+"=>"+this.HeroView.hero_name+"=> SkillConComp onLoad")
this.on(GameEvent.CastHeroSkill,this.cast_master_skill,this)
oops.message.on(GameEvent.MaxSkill,this.use_max_skill,this)
@@ -51,7 +48,7 @@ export class SkillConComp extends CCComp {
if(!smc.mission.play||smc.mission.pause) return
if(this.HeroView.DEBUFF_STUN <= 0&&this.HeroView.DEBUFF_FROST <= 0) this.HeroView.at += dt;
let cd = this.get_cd(this.HeroView.cd,this.HeroView)
let cd = this.count_cd(this.HeroView.cd,this.HeroView)
if (this.HeroView.is_atking &&(this.HeroView.at > cd)) {
if(this.HeroView.is_dead) return
const config = SkillSet[this.HeroView.atk_skill];
@@ -95,7 +92,7 @@ export class SkillConComp extends CCComp {
if(!this.HeroView.is_master) return
//console.log("hart cast_skill",uuid ,e)
const config = SkillSet[uuid];
this.castSkill(config,false,this.FIGHTCON.hero_buff.SKILL_DMG)
this.castSkill(config,false,this.HeroView.skill_dmg)
}
/** 施放技能 */
castSkill(config: typeof SkillSet[keyof typeof SkillSet],is_wfuny:boolean=false,dmg:number=0) {
@@ -176,10 +173,8 @@ export class SkillConComp extends CCComp {
}
check_wfuny(){
let buff=this.get_buff(this.HeroView)
if(buff==null) return false
let random = Math.random()*100
if(random < buff.WFUNY){
if(random < this.HeroView.wfuny){
return true
}
return false
@@ -287,11 +282,7 @@ export class SkillConComp extends CCComp {
// //console.log("clear_timer");
Object.values(this._timers).forEach(clearTimeout);
}
get_cd(cd:number,view:HeroViewComp){
let buff=this.get_buff(view)
let buff_cd=0
if(buff!=null) buff_cd=buff.ATK_CD
count_cd(cd:number,view:HeroViewComp){
// 汇总DEBUFF_DECD并处理count值
let decd = 0;
@@ -311,21 +302,15 @@ export class SkillConComp extends CCComp {
view.BUFF_CDS.splice(i, 1);
}
}
return cd*(100-bcd-buff_cd+decd)/100
return cd*(100-bcd+decd)/100
}
get_count(count:number,view:HeroViewComp){
let buff=this.get_buff(view)
if(buff==null) return count
let re=count+(buff.WFUNY)
let re=count+view.wfuny
if(re<1) re=1
return re
}
get_buff(view:HeroViewComp){
if(view.is_master) return this.FIGHTCON.hero_buff
if(view.is_boss||view.is_kalami) return this.FIGHTCON.enemy_buff
return null
}
reset() {
this.clear_timer();
this.aoe_queues = [] // 清空技能队列

View File

@@ -4,14 +4,12 @@ import { BoxSet, FacSet } from "../common/config/BoxSet";
import { SkillSet } from "../common/config/SkillSet";
import { smc } from "../common/SingletonModuleComp";
import { HeroViewComp } from "../hero/HeroViewComp";
import { FightConComp } from "../map/FightConComp";
import { SkillCom } from "./SkillCom";
import { instantiate, Node, Prefab, Vec3 ,tween, v3,animation,Label,resources,SpriteFrame,Sprite} from "cc";
/** Skill 模块 */
@ecs.register(`Skill`)
export class Skill extends ecs.Entity {
FIGHTCON:FightConComp=null!
SkillView!: SkillCom;
/** 实始添加的数据层组件 */
protected init() {
@@ -33,7 +31,6 @@ export class Skill extends ecs.Entity {
dmg:number=0
) {
let FIGHTCON=parent.getComponent(FightConComp);
const config = SkillSet[uuid];
if (!config) {
console.error("[Skill] 技能配置不存在:", uuid);
@@ -82,7 +79,7 @@ export class Skill extends ecs.Entity {
return;
}
let ap_data = this.get_ap(caster,dmg,uuid,FIGHTCON)
let ap_data = this.get_ap(caster,dmg,uuid)
SComp.ap = ap_data.ap
SComp.caster_crit = ap_data.crit
SComp.caster_crit_d = ap_data.crit_d
@@ -115,12 +112,11 @@ export class Skill extends ecs.Entity {
this.add(SComp);
}
get_ap(view:HeroViewComp,dmg:number=0,uuid:number=0,FIGHTCON:FightConComp=null!){
get_ap(view:HeroViewComp,dmg:number=0,uuid:number=0){
let ap=0
let crit=0
let crit_d=0
let buffap=1
let buff=null
let puncture=0
let puncture_damage=0
let burn_count=0
@@ -129,12 +125,6 @@ export class Skill extends ecs.Entity {
let stun_ratto=0
let frost_time=0
let frost_ratto=0
if(view.is_master) buff=FIGHTCON.hero_buff
if(view.is_boss) buff=FIGHTCON.enemy_buff
if(view.is_kalami) buff=FIGHTCON.enemy_buff
if(buff!==null) {
buffap=(100+buff.ATK)/100 //装备区 总加成
}
// 汇总DEBUFF_DECD并处理count值
let BUFF_ATK = 0
let DEBUFF_DEATK = 0
@@ -158,17 +148,17 @@ export class Skill extends ecs.Entity {
}
let BUFF_AP=(100-DEBUFF_DEATK+BUFF_ATK+dmg)/100 //buff区 总加成
puncture =buff.PUNCTURE+view.puncture
puncture_damage=buff.PUNCTURE_DMG+view.puncture_damage
puncture =view.puncture
puncture_damage=view.puncture_damage
ap=view.ap*buffap*BUFF_AP*SkillSet[uuid].ap/100
crit=view.crit+buff.CRITICAL
crit_d=view.crit_d+buff.CRITICAL_DMG
burn_count=buff.BURN_COUNT+view.burn_count
burn_value=buff.BURN_VALUE+view.burn_value
stun_time=buff.STUN_TIME+view.stun_time
stun_ratto=buff.STUN_RATTO+view.stun_ratto
frost_time=buff.FROST_TIME+view.frost_time
frost_ratto=buff.FROST_RATTO+view.frost_ratto
crit=view.crit
crit_d=view.crit_d
burn_count=view.burn_count
burn_value=view.burn_value
stun_time=view.stun_time
stun_ratto=view.stun_ratto
frost_time=view.frost_time
frost_ratto=view.frost_ratto
return {ap,crit,crit_d,puncture,puncture_damage,burn_count,burn_value,stun_time,stun_ratto,frost_time,frost_ratto}
}
}

View File

@@ -8,7 +8,6 @@ import { AType, DTType, EType, RType, SkillSet, SType, TGroup } from "../common/
import { BoxSet, FacSet } from "../common/config/BoxSet";
import { HeroViewComp } from "../hero/HeroViewComp";
import { BezierMove } from "../BezierMove/BezierMove";
import { FightConComp } from "../map/FightConComp";
import { MonModelComp } from "../hero/MonModelComp";
import { FightSet } from "../common/config/Mission";
import { HeroModelComp } from "../hero/HeroModelComp";
@@ -49,7 +48,6 @@ export class SkillCom extends CCComp {
stun_ratto:number=0;
frost_ratto:number=0;
frost_time:number=0;
FIGHTCON:FightConComp=null;
run_time:number=0;
hited_time:number=0;
hit_count:number=0;
@@ -65,7 +63,6 @@ export class SkillCom extends CCComp {
private moveDirection: Vec3 | null = null; // 添加一个属性来存储移动方向
protected onLoad(): void {
this.FIGHTCON=this.node.parent.getComponent(FightConComp)
}
@@ -183,12 +180,11 @@ export class SkillCom extends CCComp {
this.frost_time,this.frost_ratto) // ap 及暴击 属性已经在skill.ts 处理
// console.log("[SkillCom]:single_damage t:tp:rtp",this.node.position,this.targetPos,target.node.position)
if(SkillSet[this.s_uuid].debuff>0){
let deUP =this.get_debuff() // 因为不是每个技能都需要,debuff的增益在这里处理, ap 及暴击 属性已经在skill.ts 处理
let debuff=SkillSet[this.s_uuid]
let dev=debuff.deV*(100+deUP.deV)/100
let deR=debuff.deR+deUP.deR
let dev=debuff.deV*(100+this.caster.DEBUFF_VALUE)/100
let deR=debuff.deR+this.caster.DEBUFF_UP
dev=Math.round(dev*100)/100
let deC=debuff.deC+deUP.deC //dec只作为次数叠加
let deC=debuff.deC+this.caster.DEBUFF_COUNT //dec只作为次数叠加
// //console.log("[SkillCom]:debuff",SkillSet[this.s_uuid].name,debuff.debuff,deUP.deV,deUP.deC)
target.add_debuff(debuff.debuff,dev,deC,deR)
}
@@ -208,18 +204,8 @@ export class SkillCom extends CCComp {
// this.ent.destroy()
}
}
get_debuff(){ //debuff 加成
let debuff = {deV:0,deC:0,deR:0}
let buff=null
if(this.caster.is_master) buff = this.FIGHTCON.hero_buff
if(this.caster.is_boss||this.caster.is_kalami) buff = this.FIGHTCON.enemy_buff
if(buff==null) return debuff
debuff.deV=buff.DEBUFF_VALUE
debuff.deC=buff.DEBUFF_COUNT
debuff.deR=buff.DEBUFF_UP
return debuff
}
/**
* 执行2段位移先升高然后移到目的地
*/