防御还是百分比减免
This commit is contained in:
@@ -24,51 +24,15 @@ const { ccclass, property } = _decorator;
|
||||
@ecs.register('HeroView', false) // 定义为 ECS 组件
|
||||
export class HeroViewComp extends CCComp {
|
||||
BUFFCOMP:BuffComp=null!
|
||||
atk_heart:boolean=false;
|
||||
as: HeroSpine = null!
|
||||
status:String = "idle"
|
||||
hero_uuid:number = 1001;
|
||||
hero_name : string = "hero";
|
||||
fight_pos:number=0;
|
||||
lv:number =1;
|
||||
exp:number = 0;
|
||||
next_exp:number = 100;
|
||||
scale: number = 1; /** 角色阵营 1:hero -1 :mon */
|
||||
type: number = 0; /**角色类型 0近战-需要贴身 1远程-保持距离 2辅助 */
|
||||
fac:number=0; //阵营 0:hero 1:monster
|
||||
skill_cd:number=0;
|
||||
skill_cd_max:number=1.3;
|
||||
|
||||
/**
|
||||
* 获取当前血量 - 根据阵营选择正确的变量
|
||||
*/
|
||||
get currentHp(): number {
|
||||
return this.hp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前血量 - 根据阵营选择正确的变量
|
||||
*/
|
||||
set currentHp(value: number) {
|
||||
this.hp = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最大血量 - 根据阵营选择正确的变量
|
||||
*/
|
||||
get currentHpMax(): number {
|
||||
return this.hp_max;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置最大血量 - 根据阵营选择正确的变量
|
||||
*/
|
||||
set currentHpMax(value: number) {
|
||||
this.hp_max = value;
|
||||
}
|
||||
|
||||
box_group:number = BoxSet.HERO;
|
||||
|
||||
is_dead:boolean = false; //是否摧毁
|
||||
is_count_dead:boolean = false; //是否计数死亡
|
||||
is_stop:boolean = false;
|
||||
@@ -85,7 +49,6 @@ export class HeroViewComp extends CCComp {
|
||||
hp_buff:number=0;
|
||||
hp_base:number=0;
|
||||
|
||||
pwt:Timer = new Timer(1); //计时器
|
||||
ap: number = 10; /**攻击力 */
|
||||
ap_buff:number=0;
|
||||
ap_base:number=0;
|
||||
@@ -97,10 +60,9 @@ export class HeroViewComp extends CCComp {
|
||||
skills:any[]=[]
|
||||
puncture:number=0; //穿刺敌人伤害后方敌人个数
|
||||
puncture_damage:number=0; //后伤害加成
|
||||
def: number = 0; //免伤
|
||||
vun: number = 0; //易伤
|
||||
burn_count:number=0; //易伤次数
|
||||
burn_value:number=0; //易伤值
|
||||
def: number = 0; //防御
|
||||
dmg_red:number=0//免伤
|
||||
burn: number = 0; //易伤 伤害加成
|
||||
stun_time:number=0; //眩晕加成
|
||||
stun_ratto:number=0; //攻击眩晕概率加成
|
||||
stun_no:boolean=false; //眩晕免疫
|
||||
@@ -120,18 +82,14 @@ export class HeroViewComp extends CCComp {
|
||||
ospeed: number = 100; /** 角色初始速度 */
|
||||
reflect:number=0; //反射伤害比率
|
||||
lifesteal:number=0; //吸血比率
|
||||
skill_dmg:number=0
|
||||
|
||||
atk_count: number = 0;
|
||||
atked_count: number = 0;
|
||||
atk_add_count:number=0;
|
||||
atked_count: number = 0;
|
||||
|
||||
stop_cd: number = 0; /*停止倒计时*/
|
||||
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
|
||||
debuff_down_ratto:number=0
|
||||
|
||||
BUFF_DEFS: Array<{value: number, duration: number}> = [] //防御提升
|
||||
BUFF_ATKS: Array<{value: number, duration: number}> = [] //攻击提升
|
||||
@@ -216,8 +174,8 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
hp_show(){
|
||||
// if(this.node.getComponent(HeroViewComp).fac == 0) return
|
||||
let hp=this.currentHp;
|
||||
let hp_max=this.currentHpMax;
|
||||
let hp=this.hp;
|
||||
let hp_max=this.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;
|
||||
@@ -340,9 +298,9 @@ export class HeroViewComp extends CCComp {
|
||||
this.cd=this.check_atrr(BuffAttr.ATK_CD)
|
||||
break
|
||||
case BuffAttr.HP:
|
||||
let diff=this.check_atrr(BuffAttr.HP)-this.currentHpMax
|
||||
this.currentHpMax=this.check_atrr(BuffAttr.HP)
|
||||
this.currentHp+=diff
|
||||
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
|
||||
}
|
||||
@@ -380,8 +338,8 @@ export class HeroViewComp extends CCComp {
|
||||
add_hp(hp: number = 0,is_num:boolean=true) {
|
||||
this.BUFFCOMP.heathed();
|
||||
let real_hp=0
|
||||
let hp_max=Math.floor(this.currentHpMax*(100+this.hp_buff)/100)
|
||||
let lost_hp=hp_max-this.currentHp
|
||||
let hp_max=Math.floor(this.hp_max*(100+this.hp_buff)/100)
|
||||
let lost_hp=hp_max-this.hp
|
||||
if(is_num){
|
||||
if(lost_hp > hp){
|
||||
real_hp=Math.floor(hp);
|
||||
@@ -396,7 +354,7 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
}
|
||||
if(real_hp > 0){
|
||||
this.currentHp+=real_hp;
|
||||
this.hp+=real_hp;
|
||||
this.BUFFCOMP.tooltip(TooltipTypes.health,real_hp.toFixed(0));
|
||||
}
|
||||
this.hp_show()
|
||||
@@ -454,7 +412,7 @@ export class HeroViewComp extends CCComp {
|
||||
DEBUFF_DOWN+=this.BUFF_DEDOWN[i].value
|
||||
// 不再在这里减少duration,改为在update中按时间减少
|
||||
}
|
||||
let n_deR=deR-DEBUFF_DOWN-this.buff_debuff_down // 触发概率
|
||||
let n_deR=deR-DEBUFF_DOWN-this.debuff_down_ratto // 触发概率
|
||||
let r=RandomManager.instance.getRandomInt(0,100) // 随机数
|
||||
//console.log("[HeroViewComp]:类型,值,次数,技能概率,实际概率,随机数",type,deV,deC,deR,n_deR,r)
|
||||
if(r < n_deR) {
|
||||
@@ -484,8 +442,8 @@ export class HeroViewComp extends CCComp {
|
||||
// this.is_stop=true
|
||||
break
|
||||
case DebuffAttr.DEHP:
|
||||
this.currentHpMax-=deV/100*this.currentHpMax
|
||||
if(this.currentHp-this.currentHpMax>0) this.currentHp=this.currentHpMax
|
||||
this.hp_max-=deV/100*this.hp_max
|
||||
if(this.hp-this.hp_max>0) this.hp=this.hp_max
|
||||
break
|
||||
case DebuffAttr.DEATK: //99为具体数字 并且局内永久生效,其他为百分比
|
||||
if(deC == 99){
|
||||
@@ -607,13 +565,10 @@ export class HeroViewComp extends CCComp {
|
||||
let damage = this.count_damage(remainingDamage)
|
||||
if(is_crit) {
|
||||
damage = Math.floor(damage * (1 + (FightSet.CRIT_DAMAGE+crit_d)/100))
|
||||
if(this.fac==FacSet.MON) smc.vmdata.hero.power+=smc.vmdata.hero.POWER_UP+FightSet.CRIT_TO_POWER //暴击涨能量 怪物被暴击,因为只有一个英雄 直接处理
|
||||
}
|
||||
this.currentHp -= damage;
|
||||
if(this.fac==FacSet.HERO) smc.vmdata.hero.power+=smc.vmdata.hero.POWER_UP+FightSet.ATKED_TO_POWER //被攻击涨能量
|
||||
if(this.fac==FacSet.MON) smc.vmdata.hero.power+=smc.vmdata.hero.POWER_UP+FightSet.ATK_TO_POWER //攻击命中涨能量 因为是只有1个英雄 直接处理
|
||||
this.hp -= damage;
|
||||
|
||||
if(this.currentHp <= 0) {
|
||||
if(this.hp <= 0) {
|
||||
if(this == null) return;
|
||||
this.is_dead=true
|
||||
if(this.BUFFCOMP){
|
||||
@@ -651,31 +606,12 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
//伤害计算 debuff 易伤
|
||||
count_damage(remainingDamage:number){
|
||||
let damage = 0;
|
||||
let Burn = 0;
|
||||
let def = 0;
|
||||
for(let i=0;i<this.DEBUFF_BURNS.length;i++){
|
||||
Burn+=this.DEBUFF_BURNS[i].value
|
||||
// 不再在这里减少duration,改为在update中按时间减少
|
||||
}
|
||||
for(let i=0;i<this.BUFF_DEFS.length;i++){
|
||||
def+=this.BUFF_DEFS[i].value
|
||||
// 不再在这里减少duration,改为在update中按时间减少
|
||||
}
|
||||
// buff 防御 即免伤
|
||||
|
||||
damage=remainingDamage*(100-def-this.def+Burn)/100
|
||||
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(damage)
|
||||
}
|
||||
count_debuff(){
|
||||
|
||||
return Math.floor(Math.max(damage,min))
|
||||
}
|
||||
|
||||
count_buff(){
|
||||
|
||||
}
|
||||
|
||||
check_shield(){
|
||||
if(this.shield>0){
|
||||
this.shield -= 1
|
||||
@@ -702,7 +638,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
|
||||
@@ -719,20 +654,12 @@ export class HeroViewComp extends CCComp {
|
||||
// this.to_drop()
|
||||
|
||||
// }
|
||||
do_dead_trigger(){ //双倍死亡设定
|
||||
do_dead_trigger(){ //死亡特殊处理
|
||||
if(this.is_dead||this.fac==FacSet.MON) return
|
||||
let count = 1
|
||||
for(let i=0;i<count;i++){
|
||||
//console.log("[HeroViewComp]:dead"+i+"次")
|
||||
}
|
||||
|
||||
}
|
||||
do_atked_trigger(){ //双倍攻击设定
|
||||
do_atked_trigger(){ //受伤特殊处理
|
||||
if(this.is_dead||this.fac==FacSet.MON) return
|
||||
let count = 1
|
||||
if(this.double_atked) {
|
||||
//console.log("[HeroViewComp]:double_atked")
|
||||
count =2
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user