XmdsBuff_Shield_IronMaiden.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using CommonAI.Data;
  2. using CommonAI.Zone.Formula;
  3. using CommonAI.Zone.Instance;
  4. using CommonLang;
  5. using System;
  6. using XmdsCommon.Plugin;
  7. using XmdsCommonServer.Plugin;
  8. using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator;
  9. using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills;
  10. namespace XmdsCommonSkill.Plugin.Buffs
  11. {
  12. public class XmdsBuff_Shield_IronMaiden : XmdsBuffBase
  13. {
  14. /// <summary>
  15. /// 反弹伤害百分比.
  16. /// </summary>
  17. public int IronMaidenPercent = 0;
  18. private int mHandleUUID = 0;
  19. public override int GetAbilityID()
  20. {
  21. return (int)XmdsCommon.Plugin.XmdsBuffProperties.XmdsBuffAbility.SHIELD_IronMaiden;
  22. }
  23. public override void CopyTo(UnitBuff other)
  24. {
  25. var ret = other as XmdsBuff_Shield_IronMaiden;
  26. ret.IronMaidenPercent = this.IronMaidenPercent;
  27. base.CopyTo(other);
  28. }
  29. protected override void OnBuffBegin(XmdsCommonServer.Plugin.XmdsVirtual hitter, XmdsCommonServer.Plugin.XmdsVirtual attacker, InstanceUnit.BuffState state)
  30. {
  31. //注册监听.
  32. mHandleUUID = hitter.RegistOnHitDamage(OnHandleHitDmage, null);
  33. XmdsVirtual.FormatLog("BuffBegin : 单位【{0}】增加反弹伤害.", hitter.mProp.ServerData.BaseInfo.name);
  34. }
  35. protected override void OnBuffEnd(XmdsCommonServer.Plugin.XmdsVirtual hitter, InstanceUnit.BuffState state, bool replace)
  36. {
  37. //取消监听.
  38. hitter.UnRegistOnHitDamage(mHandleUUID);
  39. XmdsVirtual.FormatLog("BuffBegin : 单位【{0}】失去反弹伤害.", hitter.mProp.ServerData.BaseInfo.name);
  40. }
  41. //单位被攻击时.反弹伤害计算.
  42. private float OnHandleHitDmage(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source,
  43. ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
  44. {
  45. int reboundDamage = Math.Max(1, CUtils.CastInt(IronMaidenPercent * XmdsUnitProp.PER * damage));
  46. //反伤.
  47. if (reboundDamage > 0)
  48. {
  49. //根据属性计算反伤伤害.
  50. //d = XmdsDamageCalculator.GetDamage(d, hitted, attacker, source);
  51. //造成伤害并飘字.
  52. attacker.mUnit.AddHP(-reboundDamage, hitted.mUnit);
  53. }
  54. return damage - reboundDamage;
  55. }
  56. }
  57. }