XmdsBuff_Brand_2.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using CommonAI.Zone.Instance;
  2. using CommonAI.Zone.Formula;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using XmdsCommon.Plugin;
  8. using XmdsCommonServer.Plugin;
  9. using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills;
  10. using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator;
  11. using CommonAI.Data;
  12. namespace XmdsCommonSkill.Plugin.Buffs
  13. {
  14. /// <summary>
  15. /// 烙印标记,发送者对其伤害提高
  16. /// </summary>
  17. public class XmdsBuff_Brand_2 : XmdsBuffBase
  18. {
  19. /// <summary>
  20. /// BUFF效果,正值为扣血,负值为抵伤.
  21. /// </summary>
  22. public int BuffValue;
  23. private int mHandleUUID = 0;
  24. //发送者id
  25. private uint mSenderID = 0;
  26. public override int GetAbilityID()
  27. {
  28. return (int)XmdsCommon.Plugin.XmdsBuffProperties.XmdsBuffAbility.Brand_2;
  29. }
  30. public override void CopyTo(UnitBuff other)
  31. {
  32. var ret = other as XmdsBuff_Brand_2;
  33. ret.BuffValue = this.BuffValue;
  34. base.CopyTo(other);
  35. }
  36. protected override void OnBuffBegin(XmdsCommonServer.Plugin.XmdsVirtual hitter, XmdsCommonServer.Plugin.XmdsVirtual attacker, InstanceUnit.BuffState state)
  37. {
  38. //注册监听.
  39. mHandleUUID = hitter.RegistOnHitDamage(OnHandleHitDmage, null);
  40. mSenderID = attacker.mUnit.ID;
  41. }
  42. protected override void OnBuffEnd(XmdsCommonServer.Plugin.XmdsVirtual hitter, InstanceUnit.BuffState state, bool replace)
  43. {
  44. //取消监听.
  45. hitter.UnRegistOnHitDamage(mHandleUUID);
  46. }
  47. //单位被攻击时,判断是否符合条件触发BUFF效果.
  48. private float OnHandleHitDmage(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source,
  49. ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
  50. {
  51. if(mSenderID == attacker.mUnit.ID)
  52. {
  53. damage = damage * XmdsUnitProp.PER * (XmdsDamageCalculator.PERER + this.BuffValue);
  54. }
  55. return damage;
  56. }
  57. protected override void OnDispose()
  58. {
  59. base.OnDispose();
  60. }
  61. }
  62. }