using CommonAI.Data; using CommonAI.Zone; using CommonAI.Zone.Formula; using CommonAI.Zone.Instance; using System; using XmdsCommon.Plugin; using XmdsCommonServer.Plugin; using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator; using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills; namespace XmdsCommonSkill.Plugin.Buffs { /// ///BUFF:锁血 /// public class XmdsBuff_LockHP : XmdsBuffBase { /// ///填正值为扣血. /// public int lockHP = 0; private int UUID = 0; public override int GetAbilityID() { return (int)XmdsCommon.Plugin.XmdsBuffProperties.XmdsBuffAbility.Lock_HP; } public override void CopyTo(UnitBuff other) { var ret = other as XmdsBuff_LockHP; ret.lockHP = this.lockHP; base.CopyTo(other); } protected override void OnBindTemplate(ref BuffTemplate buffTemplate) { //DOT类技能首帧无效. buffTemplate.FirstTimeEnable = false; base.OnBindTemplate(ref buffTemplate); } public override void BuffBegin(XmdsVirtual hitter, XmdsVirtual attacker, InstanceUnit.BuffState state) { UUID = hitter.RegistOnHitDamage(OnUnitHitEvent, null, true); } public override void BuffEnd(XmdsVirtual hitter, InstanceUnit.BuffState state, bool replace) { hitter.UnRegistOnHitDamage(UUID); } //被打监听. protected virtual float OnUnitHitEvent(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source, ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch) { //伤害减免 if(hitted.mUnit.CurrentHP - damage < lockHP) { if (BuffInvaildCheck()) { hitted.mUnit.removeBuff(BindBuffID); } source.OutClientState = (byte)XmdsCommonServer.Plugin.XmdsVirtual.UnitHitEventState.Absorb; damage = Math.Max(0, hitted.mUnit.CurrentHP - lockHP); } return damage; } } }