XmdsBuff_RemitDeadlyDamage.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using CommonAI.Data;
  2. using CommonAI.Zone;
  3. using CommonAI.Zone.Formula;
  4. using CommonAI.Zone.Instance;
  5. using XmdsCommon.Plugin;
  6. using XmdsCommonServer.Plugin;
  7. using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator;
  8. using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills;
  9. namespace XmdsCommonSkill.Plugin.Buffs
  10. {
  11. /// <summary>
  12. ///BUFF:抵御一次致命伤害
  13. /// </summary>
  14. public class XmdsBuff_RemitDeadlyDamage : XmdsBuffBase
  15. {
  16. public int maxRemitDamage = 0;
  17. public int minRemitDamage = 0;
  18. private int UUID = 0;
  19. public override int GetAbilityID()
  20. {
  21. return (int)XmdsCommon.Plugin.XmdsBuffProperties.XmdsBuffAbility.Remit_DeadlyDamage;
  22. }
  23. public override void CopyTo(UnitBuff other)
  24. {
  25. var ret = other as XmdsBuff_RemitDeadlyDamage;
  26. ret.maxRemitDamage = this.maxRemitDamage;
  27. ret.minRemitDamage = this.minRemitDamage;
  28. base.CopyTo(other);
  29. }
  30. protected override void OnBindTemplate(ref BuffTemplate buffTemplate)
  31. {
  32. //DOT类技能首帧无效.
  33. buffTemplate.FirstTimeEnable = false;
  34. base.OnBindTemplate(ref buffTemplate);
  35. }
  36. public override void BuffBegin(XmdsVirtual hitter, XmdsVirtual attacker, InstanceUnit.BuffState state)
  37. {
  38. UUID = hitter.RegistOnHitDamage(OnHandleHitDmage, null, true);
  39. }
  40. public override void BuffEnd(XmdsVirtual hitter, InstanceUnit.BuffState state, bool replace)
  41. {
  42. hitter.UnRegistOnHitDamage(UUID);
  43. }
  44. //被打监听.
  45. protected virtual float OnHandleHitDmage(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source,
  46. ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
  47. {
  48. //伤害减免
  49. if (damage >= minRemitDamage)
  50. {
  51. // 有吸收上限
  52. if(damage <= maxRemitDamage)
  53. {
  54. damage = 0;
  55. source.OutClientState = (byte)XmdsCommonServer.Plugin.XmdsVirtual.UnitHitEventState.Absorb;
  56. }
  57. else
  58. {
  59. damage -= maxRemitDamage;
  60. }
  61. hitted.mUnit.removeBuff(this.BindBuffID);
  62. }
  63. return damage;
  64. }
  65. }
  66. }