using CommonAI.Data; using CommonAI.Zone.Formula; using CommonAI.Zone.Instance; using CommonLang; using System; using XmdsCommon.Plugin; using XmdsCommonServer.Plugin; using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator; using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills; namespace XmdsCommonSkill.Plugin.Buffs { public class XmdsBuff_Shield_IronMaiden : XmdsBuffBase { /// /// 反弹伤害百分比. /// public int IronMaidenPercent = 0; private int mHandleUUID = 0; public override int GetAbilityID() { return (int)XmdsCommon.Plugin.XmdsBuffProperties.XmdsBuffAbility.SHIELD_IronMaiden; } public override void CopyTo(UnitBuff other) { var ret = other as XmdsBuff_Shield_IronMaiden; ret.IronMaidenPercent = this.IronMaidenPercent; base.CopyTo(other); } protected override void OnBuffBegin(XmdsCommonServer.Plugin.XmdsVirtual hitter, XmdsCommonServer.Plugin.XmdsVirtual attacker, InstanceUnit.BuffState state) { //注册监听. mHandleUUID = hitter.RegistOnHitDamage(OnHandleHitDmage, null); XmdsVirtual.FormatLog("BuffBegin : 单位【{0}】增加反弹伤害.", hitter.mProp.ServerData.BaseInfo.name); } protected override void OnBuffEnd(XmdsCommonServer.Plugin.XmdsVirtual hitter, InstanceUnit.BuffState state, bool replace) { //取消监听. hitter.UnRegistOnHitDamage(mHandleUUID); XmdsVirtual.FormatLog("BuffBegin : 单位【{0}】失去反弹伤害.", hitter.mProp.ServerData.BaseInfo.name); } //单位被攻击时.反弹伤害计算. private float OnHandleHitDmage(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source, ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch) { int reboundDamage = Math.Max(1, CUtils.CastInt(IronMaidenPercent * XmdsUnitProp.PER * damage)); //反伤. if (reboundDamage > 0) { //根据属性计算反伤伤害. //d = XmdsDamageCalculator.GetDamage(d, hitted, attacker, source); //造成伤害并飘字. attacker.mUnit.AddHP(-reboundDamage, hitted.mUnit); } return damage - reboundDamage; } } }