@@ -41,7 +41,7 @@ interface FinalData {
@ecs . register ( 'HeroAtkSystem' )
export class HeroAtkSystem extends ecs . ComblockSystem implements ecs . ISystemUpdate {
private debugMode : boolean = fals e; // 是否启用调试模式
private debugMode : boolean = tru e; // 是否启用调试模式
/**
* 过滤器:处理拥有伤害队列的实体
@@ -77,7 +77,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
damageQueue . processedCount ++ ;
// 如果目标已死亡,停止处理后续伤害
if ( TAttrsComp . is_dead ) {
mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` [HeroAtkSystem] ${ TAttrsComp . hero_name } 已死亡,停止处理剩余伤害 ` ) ;
mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` ${ TAttrsComp . hero_name } 已死亡,停止处理剩余伤害 ` ) ;
damageQueue . clear ( ) ; // 清空剩余伤害
break ;
}
@@ -88,7 +88,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
e . remove ( DamageQueueComp ) ;
if ( processedCount > 0 ) {
mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` [HeroAtkSystem] ${ TAttrsComp . hero_name } 伤害队列处理完成,共处理 ${ processedCount } 个伤害事件 ` ) ;
mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` ${ TAttrsComp . hero_name } 伤害队列处理完成,共处理 ${ processedCount } 个伤害事件 ` ) ;
}
}
}
@@ -156,7 +156,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
const isCrit = this . checkChance ( damageEvent . Attrs [ Attrs . CRITICAL ] - TAttrsComp . Attrs [ Attrs . CRITICAL_RES ] ) ;
// 计算基础伤害
let damage = this . dmgCount ( damageEvent , TAttrsComp ) ;
mLogger . log ( this . debugMode , 'HeroAtkSystem' , "[HeroAtkSystem] dmgCount" , damage )
mLogger . log ( this . debugMode , 'HeroAtkSystem' , " dmgCount" , damage )
if ( isCrit ) {
// 暴击伤害计算
// 使用施法者的暴击伤害加成属性( damageEvent.Attrs 快照)
@@ -167,11 +167,11 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
CAttrsComp ? . useValueTalByAttr ( Attrs . CRITICAL ) ; // 清除施法者的暴击buff
}
mLogger . log ( this . debugMode , 'HeroAtkSystem' , "[HeroAtkSystem] after crit" , damage )
mLogger . log ( this . debugMode , 'HeroAtkSystem' , " after crit" , damage )
// 护盾吸收
const shieldResult = this . absorbShield ( TAttrsComp , damage ) ;
damage = shieldResult . remainingDamage ;
mLogger . log ( this . debugMode , 'HeroAtkSystem' , "[HeroAtkSystem] after shield" , damage )
mLogger . log ( this . debugMode , 'HeroAtkSystem' , " after shield" , damage )
// 显示护盾吸收飘字
if ( shieldResult . absorbedDamage > 0 && targetView ) {
targetView . shield_tip ( shieldResult . absorbedDamage ) ;
@@ -189,7 +189,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
smc . updateHeroInfo ( TAttrsComp ) ; // 更新英雄数据到 VM
const casterName = CAttrsComp ? . hero_name || "未知" ;
mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` [HeroAtkSystem] 英雄${ TAttrsComp . hero_name } (uuid: ${ TAttrsComp . hero_uuid } ) 受到 ${ casterName } (eid: ${ casterEid } )的 伤害 ${ damage } , ${ isCrit ? "暴击" : "普通" } 攻击,技能ID ${ damageEvent . s_uuid } ` ) ;
mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` 英雄 ${ TAttrsComp . hero_name } (uuid: ${ TAttrsComp . hero_uuid } ) 受到 ${ casterName } (eid: ${ casterEid } )的 伤害 ${ damage } , ${ isCrit ? "暴击" : "普通" } 攻击,技能ID ${ damageEvent . s_uuid } ` ) ;
//反伤判定 并应用到施法者
this . check_thorns ( TAttrsComp , caster , damage ) ;
@@ -221,7 +221,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
targetView . scheduleRevive ( 1.0 ) ;
}
mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` [HeroAtkSystem] Hero waiting to revive! Lives left: ${ TAttrsComp . Attrs [ Attrs . REVIVE_COUNT ] } ` ) ;
mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` Hero waiting to revive! Lives left: ${ TAttrsComp . Attrs [ Attrs . REVIVE_COUNT ] } ` ) ;
return reDate ;
}
@@ -232,7 +232,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
if ( TAttrsComp . is_master && TAttrsComp . Attrs [ Attrs . REVIVE_COUNT ] <= 0 ) {
smc . mission . stop_mon_action = true ;
oops . message . dispatchEvent ( GameEvent . HeroDead , { hero_uuid : TAttrsComp.hero_uuid } ) ;
mLogger . log ( this . debugMode , 'HeroAtkSystem' , "[HeroAtkSystem] Hero died, stopping monster action (spawn/move)" + TAttrsComp . Attrs [ Attrs . REVIVE_COUNT ] ) ;
mLogger . log ( this . debugMode , 'HeroAtkSystem' , " Hero died, stopping monster action (spawn/move)" + TAttrsComp . Attrs [ Attrs . REVIVE_COUNT ] ) ;
}
this . doDead ( target ) ;
@@ -242,7 +242,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
}
}
mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` [HeroAtkSystem] ${ TAttrsComp . hero_name } 受到 ${ damage } 点伤害 (暴击: ${ isCrit } ) ` ) ;
mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` ${ TAttrsComp . hero_name } 受到 ${ damage } 点伤害 (暴击: ${ isCrit } ) ` ) ;
reDate . damage = damage ;
@@ -278,7 +278,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
CView . scheduleRevive ( 1.0 ) ;
}
mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` [HeroAtkSystem] Hero waiting to revive from Thorns! Lives left: ${ CAttrs . Attrs [ Attrs . REVIVE_COUNT ] } ` ) ;
mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` Hero waiting to revive from Thorns! Lives left: ${ CAttrs . Attrs [ Attrs . REVIVE_COUNT ] } ` ) ;
return ;
}
@@ -286,7 +286,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
if ( CAttrs . is_master && CAttrs . Attrs [ Attrs . REVIVE_COUNT ] <= 0 ) {
smc . mission . stop_mon_action = true ;
oops . message . dispatchEvent ( GameEvent . HeroDead , { hero_uuid : CAttrs.hero_uuid } ) ;
mLogger . log ( this . debugMode , 'HeroAtkSystem' , "[HeroAtkSystem] Hero died from thorns, stopping monster action (spawn/move)" ) ;
mLogger . log ( this . debugMode , 'HeroAtkSystem' , " Hero died from thorns, stopping monster action (spawn/move)" ) ;
}
this . doDead ( caster ) ;
@@ -322,11 +322,11 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
const TAttrs = TAttrsComp . Attrs ;
let sConf = SkillSet [ damageEvent . s_uuid ] ;
if ( ! sConf ) return 0 ;
mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` [HeroAtkSystem] 伤害处理对象` , CAttrs , TAttrs ) ;
mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` 伤害处理对象 ` , CAttrs , TAttrs ) ;
// 2. 计算原始物理伤害和魔法伤害
// 物理伤害基础值 = 技能物理倍率 * (施法者物理攻击力 + 额外伤害) / 100 * 额外伤害比例
let apBase = ( sConf . ap || 0 ) * ( CAttrs [ Attrs . AP ] + damageEvent . ext_dmg ) / 100 * damageEvent . dmg_ratio ;
mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` [HeroAtkSystem] 物理伤害基础值: ${ apBase } , 技能ap= ${ sConf . ap } ,施法者物理攻击力: ${ CAttrs [ Attrs . AP ] } ,}
mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` 物理伤害基础值: ${ apBase } , 技能ap= ${ sConf . ap } ,施法者物理攻击力: ${ CAttrs [ Attrs . AP ] } ,}
额外伤害: ${ damageEvent . ext_dmg } , 额外伤害比例: ${ damageEvent . dmg_ratio } ` ) ;
// 易伤
let DMG_INVUL = TAttrs [ Attrs . DMG_INVUL ] || 0
@@ -343,7 +343,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
total = Math . floor ( total * damageRatio ) ;
if ( this . debugMode ) mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` [HeroAtkSystem] 最终伤害: ${ total } (Base: ${ apBase } , Def: ${ DMG_RED } %, Invul: ${ DMG_INVUL } %, Ratio: ${ damageRatio } ) ` ) ;
if ( this . debugMode ) mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` 最终伤害: ${ total } (Base: ${ apBase } , Def: ${ DMG_RED } %, Invul: ${ DMG_INVUL } %, Ratio: ${ damageRatio } ) ` ) ;
return total ;
}
@@ -409,7 +409,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
this . onDeath ( entity ) ;
if ( this . debugMode ) {
mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` [HeroAtkSystem] ${ TAttrsComp . hero_name } 死亡 ` ) ;
mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` ${ TAttrsComp . hero_name } 死亡 ` ) ;
}
}
@@ -459,7 +459,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
private absorbShield ( TAttrsComp : HeroAttrsComp , damage : number ) : { remainingDamage : number , absorbedDamage : number } {
if ( TAttrsComp . shield <= 0 ) {
mLogger . log ( this . debugMode , 'HeroAtkSystem' , "[HeroAtkSystem] 护盾值小于等于0, 无法吸收伤害" ) ;
mLogger . log ( this . debugMode , 'HeroAtkSystem' , " 护盾值小于等于0, 无法吸收伤害" ) ;
return { remainingDamage : damage , absorbedDamage : 0 } ;
} ;
@@ -470,7 +470,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
TAttrsComp . Attrs [ Attrs . SHIELD_MAX ] = 0 ;
}
TAttrsComp . dirty_shield = true ;
mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` [HeroAtkSystem] 护盾值完全吸收伤害 ${ damage } ` ) ;
mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` 护盾值完全吸收伤害 ${ damage } ` ) ;
return { remainingDamage : 0 , absorbedDamage : damage } ;
} else {
const absorbedDamage = TAttrsComp . shield ;
@@ -478,7 +478,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
TAttrsComp . shield = 0 ;
TAttrsComp . Attrs [ Attrs . SHIELD_MAX ] = 0 ;
TAttrsComp . dirty_shield = true ;
mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` [HeroAtkSystem] 护盾值部分吸收伤害 ${ absorbedDamage } ` ) ;
mLogger . log ( this . debugMode , 'HeroAtkSystem' , ` 护盾值部分吸收伤害 ${ absorbedDamage } ` ) ;
return { remainingDamage , absorbedDamage } ;
}
}