This commit is contained in:
2025-10-16 23:40:12 +08:00
parent d486d87676
commit 559ddfb653
8 changed files with 267 additions and 562 deletions

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, geDebuffNum, getBuffNum, SkillSet, TGroup, TType } from "../common/config/SkillSet";
import { Attrs, DBuff, geDebuffNum, getAttrs, SkillSet, TGroup, TType, BType, BuffConf, DbuffConf } from "../common/config/SkillSet";
import { BuffComp } from "./BuffComp";
import { oops } from "db://oops-framework/core/Oops";
import { GameEvent } from "../common/config/GameEvent";
@@ -41,72 +41,34 @@ export class HeroViewComp extends CCComp {
is_kalami:boolean =false;
speed: number = 100; /** 角色移动速度 */
speed_base: number = 100; /** 角色初始速度 */
power:number=0;
power_max:number=100;
mp: number = 0;
mp_max: number = 100;
mp_base: number = 100;
mp: number = 100;
hp: number = 100; /** 血量 */
hp_max: number = 100; /** 最大血量 */
hp_base:number=100; /** 基础最大血量 */
shield:number=0; //当前护甲值
shield_max:number=0; //最大护甲值
ap: number = 10; /**攻击力 */
ap_base:number=0;
// atk_speed: number = 1;
cd: number = 1.3; /**攻击速度 攻击间隔 */
def: number = 0; //防御
dmg_red:number=0//免伤
dis: number = 80;
skills:any[]=[]
puncture:number=0; //穿刺敌人伤害后方敌人个数
puncture_damage:number=0; //后伤害加成
burn: number = 0; //易伤 伤害加成
stun_time:number=0; //眩晕加成
stun_ratio:number=0; //攻击眩晕概率加成
stun_no:boolean=false; //眩晕免疫
dod: number = 0; //闪避率
dod_no:boolean=false;
crit:number=0; //暴击率
crit_no:boolean=false; //暴击免疫
crit_d:number=0; //暴击伤害
wfuny:number=0; //风怒概率
frost_ratio:number=0; //冰冻概率
frost_time:number=0; //冰冻时间
frost_no:boolean=false; //冰冻免疫
knockback:number=0; //击退概率
knockback_no:boolean=false; //击退免疫
reflect:number=0; //反射伤害比率
lifesteal:number=0; //吸血比率
skill_dmg:number=0
debuff_down:number=0
Attrs:any=getBuffNum()
debuff_status:any=geDebuffNum()
/** 基础属性 有初始值的基础属性,后续Attrs 属性计算时用到*/
base_ap: number = 0; //基础攻击力
base_map: number = 0;
base_def: number = 5;
base_hp: number = 100;
base_mp: number = 100;
Attrs:any=[]
//数值型debuff
V_DBUFF:any[]=[] //持久
V_DBUFFS:any[]=[] //临时 带时间
//百分比型debuff
R_DBUFF:any[]=[] //持久
R_DBUFFS:any[]=[] //临时 带时间
//数值型buff
V_BUFF:any[]=[] //持久
V_BUFFS:any[]=[] //临时 带时间
//百分比型buff
R_BUFF:any[]=[] //持久
R_BUFFS:any[]=[] //临时 带时间
atk_count: number = 0;
atked_count: number = 0;
stop_cd: number = 0; /*停止倒计时*/
speek_time:number = 0;
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}> = [] //减攻击速度
DEBUFF_SLOW: number = 0; //减速
DEBUFF_FROST: number = 0; //冰冻
DEBUFF_STUN: number = 0; //眩晕
DEBUFF_VALUE:number=0; //debuff 增益值
DEBUFF_COUNT:number=0; //debuff 持续次数
DEBUFF_UP:number=0; //debuff 概率提升
@@ -118,9 +80,6 @@ export class HeroViewComp extends CCComp {
}> = [];
private isProcessingDamage: boolean = false;
private damageInterval: number = 0.01; // 伤害数字显示间隔
private timer:Timer=new Timer(1);
onLoad() {
this.as = this.getComponent(HeroSpine);
//console.log("[HeroViewComp]:hero view comp ",this.FIGHTCON)
@@ -145,7 +104,7 @@ export class HeroViewComp extends CCComp {
}
/* 显示角色血量 */
this.node.getChildByName("top").getChildByName("hp").active = true;
this.BUFFCOMP.show_shield(this.shield,this.shield_max)
this.BUFFCOMP.show_shield(this.shield,this.Attrs[Attrs.SHIELD_MAX])
}
update(dt: number){
@@ -155,14 +114,8 @@ export class HeroViewComp extends CCComp {
// return
// }
this.BaseUp(dt)
if(this.DEBUFF_FROST > 0){
this.DEBUFF_FROST -=dt;
}
if(this.DEBUFF_STUN > 0){
this.DEBUFF_STUN -=dt;
}
// 更新所有按时间减少的buff和debuff
this.updateBuffsAndDebuffs(dt);
this.in_stop(dt);
// 处理伤害队列
this.processDamageQueue();
@@ -171,22 +124,15 @@ export class HeroViewComp extends CCComp {
BaseUp(dt:number){
this.mp += HeroUpSet.MP*dt
this.hp += HeroUpSet.HP*dt
if(this.mp > this.mp_max) this.mp = this.mp_max
if(this.hp > this.hp_max) this.hp = this.hp_max
if(this.mp > this.Attrs[Attrs.MP_MAX]) this.mp = this.Attrs[Attrs.MP_MAX]
if(this.hp > this.Attrs[Attrs.HP_MAX]) this.hp = this.Attrs[Attrs.HP_MAX]
}
do_fight_end(){
this.as.do_buff()
}
get isActive() {
return this.ent.has(HeroViewComp) && this.node?.isValid;
}
hide_info(){
}
//状态切换
status_change(type:string){
this.status=type
@@ -199,17 +145,15 @@ export class HeroViewComp extends CCComp {
// this.as.change_default("move")
}
}
add_shield(shield:number){
this.shield = this.shield_max +=shield
if(this.shield>0) this.BUFFCOMP.show_shield(this.shield,this.shield_max)
this.shield = this.Attrs[Attrs.SHIELD_MAX] +=shield
if(this.shield>0) this.BUFFCOMP.show_shield(this.shield,this.Attrs[Attrs.SHIELD_MAX])
}
add_hp(hp: number = 0,is_num:boolean=true) {
health(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[Attrs.HP_MAX]
let lost_hp=hp_max-this.hp
if(is_num){
if(lost_hp > hp){
@@ -228,30 +172,20 @@ export class HeroViewComp extends CCComp {
this.hp+=real_hp;
this.BUFFCOMP.tooltip(TooltipTypes.health,real_hp.toFixed(0));
}
this.BUFFCOMP.hp_show(this.hp,this.hp_max)
this.BUFFCOMP.hp_show(this.hp,this.Attrs[Attrs.HP_MAX])
// this.update_vm
}
/** 静止时间 */
in_stop (dt: number) {
if(this.stop_cd > 0){
this.stop_cd -= dt;
if(this.stop_cd <= 0){
this.stop_cd = 0;
this.is_atking = false;
}
}
}
count_atk_count(){ //主将攻击
if(this.fac==FacSet.MON) return
this.atk_count+=1
}
do_dead(){
this.do_dead_trigger()
//console.log("[HeroViewComp]:角色死亡",this.hero_uuid)
@@ -278,132 +212,7 @@ export class HeroViewComp extends CCComp {
do_drop(){
}
add_debuff(type:number,deV:number,deC:number,deR:number){
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) {
// this.BUFFCOMP.tooltip(TooltipTypes.uskill,"*抵抗*")
return
}
switch(type){
case DebuffAttr.BURN:
this.DEBUFF_BURNS.push({value:deV,duration:deC+FightSet.BURN_COUNT})
break
case DebuffAttr.DECD:
this.DEBUFF_DECDS.push({value:deV,duration:deC})
break
case DebuffAttr.SLOW:
this.DEBUFF_SLOW+=deV
break
case DebuffAttr.FROST:
this.BUFFCOMP.in_iced(deV)
this.DEBUFF_FROST+=deV
break
case DebuffAttr.STUN:
if(this.DEBUFF_STUN>0) return
this.skills[0].cd=0 // 眩晕 cd归零
this.BUFFCOMP.in_yun(deV+FightSet.STUN_TIME) // 眩晕时间
this.DEBUFF_STUN+=deV+FightSet.STUN_TIME // 眩晕时间
// this.is_stop=true
break
case DebuffAttr.DEHP:
this.Attrs[BuffAttr.HP_MAX]-=deV
this.hp_max=Math.floor(this.hp_base*(100+this.Attrs[BuffAttr.HP_MAX]))
if(this.hp-this.hp_max>0) this.hp=this.hp_max
break
case DebuffAttr.DEATK: //99为具体数字 并且局内永久生效,其他为百分比
if(deC == 99){
this.ap-=deV
}else{
this.DEBUFF_DEATKS.push({value:deV,duration:deC})
}
break
case DebuffAttr.DECOUNT:
this.atk_count-=deV
if(this.atk_count<0) this.atk_count=1
break
case DebuffAttr.BACK:
if(this.fac==FacSet.MON) {
let tx=this.node.position.x+50
if(tx > 320) tx=320
tween(this.node).to(0.3, { position:v3(tx,this.node.position.y,0)}).start()
}
break
}
//console.log("[HeroViewComp]:debuffs",type,deV,deC,deR,this.DEBUFF_BURNS)
}
// 更新所有按时间减少的buff和debuff
updateBuffsAndDebuffs(dt: number) {
// 更新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);
}
}
// 更新DEBUFF_BURNS
for(let i = this.DEBUFF_BURNS.length - 1; i >= 0; i--) {
this.DEBUFF_BURNS[i].duration -= dt;
if(this.DEBUFF_BURNS[i].duration <= 0) {
this.DEBUFF_BURNS.splice(i, 1);
}
}
// 更新DEBUFF_DEATKS
for(let i = this.DEBUFF_DEATKS.length - 1; i >= 0; i--) {
this.DEBUFF_DEATKS[i].duration -= dt;
if(this.DEBUFF_DEATKS[i].duration <= 0) {
this.DEBUFF_DEATKS.splice(i, 1);
}
}
// 更新DEBUFF_DECDS
for(let i = this.DEBUFF_DECDS.length - 1; i >= 0; i--) {
this.DEBUFF_DECDS[i].duration -= dt;
if(this.DEBUFF_DECDS[i].duration <= 0) {
this.DEBUFF_DECDS.splice(i, 1);
}
}
}
add_buff(buff:number,duration:number,type:number){
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){
console.log("[HeroViewComp]:apply_buff",buff_type,buff_value)
switch(buff_type){
case BuffAttr.ATK: //攻击百分比
this.Attrs[BuffAttr.AP]+=Math.floor(buff_value/100*this.ap)
break
case BuffAttr.ATK_CD: //攻击速度百分比
this.Attrs[BuffAttr.ATK_CD]+=buff_value/100*this.cd
break
case BuffAttr.HP_MAX: //血量百分比
this.Attrs[BuffAttr.HP_MAX]+=buff_value
this.hp_max=Math.floor(this.hp_base*(100+this.Attrs[BuffAttr.HP_MAX]))
if(this.hp-this.hp_max>0) this.hp=this.hp_max
break
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,
@@ -412,13 +221,8 @@ export class HeroViewComp extends CCComp {
atked_anm:string="atked"
){
this.do_atked_trigger()
if(burn_count>0){
this.add_debuff(DebuffAttr.BURN,burn_value,burn_count,100)
}
if(stun_time>0){
this.add_debuff(DebuffAttr.STUN,stun_time,1,stun_ratio)
}
if(this.check_dodge()) return
let is_crit = this.check_crit(crit)
@@ -469,10 +273,8 @@ export class HeroViewComp extends CCComp {
}
//伤害计算 debuff 易伤
count_damage(remainingDamage:number){
let min =remainingDamage*0.2
let damage=(remainingDamage-this.dmg_red)*(100-this.def+this.burn)/100
////console.log("[HeroViewComp]:最终伤害,敌人伤害值,免伤,防御,易伤",damage,remainingDamage,buff_def,def,Burn)
return Math.floor(Math.max(damage,min))
return remainingDamage
}
check_shield(damage:number){
@@ -481,23 +283,23 @@ export class HeroViewComp extends CCComp {
this.shield -= damage
this.BUFFCOMP.tooltip(TooltipTypes.uskill,"*吸收*");
if(this.shield <= 0){
this.shield=this.shield_max=0
this.shield=this.Attrs[Attrs.SHIELD_MAX]=0
}
damage = 0
}
if(this.shield < damage){
damage=damage-this.shield
this.shield=0
this.shield_max=0
this.Attrs[Attrs.SHIELD_MAX]=0
}
this.BUFFCOMP.show_shield(this.shield,this.shield_max)
this.BUFFCOMP.show_shield(this.shield,this.Attrs[Attrs.SHIELD_MAX])
return damage
}
check_dodge(){
if(this.dod > 0){
if(this.Attrs[Attrs.DODGE] > 0){
let random = Math.random()*100
if(random < this.dod) {
if(random < this.Attrs[Attrs.DODGE]) {
this.BUFFCOMP.tooltip(TooltipTypes.uskill,"*闪避*");
return true
}
@@ -506,7 +308,6 @@ export class HeroViewComp extends CCComp {
}
check_crit(crit:number=0){
if(this.crit_no) return false
if(crit > 0){
let random = Math.random()*100
if(random < crit) {
@@ -609,7 +410,7 @@ export class HeroViewComp extends CCComp {
/** 立即显示伤害效果 */
private showDamageImmediate(damage: number, isCrit: boolean,anm:string="atked") {
// this.as.atked()
this.BUFFCOMP.hp_show(this.hp,this.Attrs[BuffAttr.HP_MAX])
this.BUFFCOMP.hp_show(this.hp,this.Attrs[Attrs.HP_MAX])
this.BUFFCOMP.in_atked(anm,this.fac==FacSet.HERO?1:-1)
this.atked_count++;
if (isCrit) {