XmdsBuff_Brand.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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.Zone.Helper;
  12. using CommonAI.Data;
  13. using CommonLang;
  14. namespace XmdsCommonSkill.Plugin.Buffs
  15. {
  16. /// <summary>
  17. /// 烙印,符合触发条件时,造成额外伤害,可选择使用类型,时间OR次数.
  18. /// </summary>
  19. public class XmdsBuff_Brand : XmdsBuffBase
  20. {
  21. /// BUFF效果,正值为扣血,负值为抵伤.
  22. public int BuffValue;
  23. //buff消失时,造成一次性伤害加成
  24. public int breakHitDamage = 0;
  25. //结束一刀,每层伤害加成
  26. public int damageDeeps = 0;
  27. //普攻加成最高层数
  28. public int maxLayers = 0;
  29. private int baseDamage = 0; //10000基准伤害值
  30. private uint senderId = 0;
  31. private int normalAtkHit = 0;
  32. private int mHandleUUID = 0;
  33. public override int GetAbilityID()
  34. {
  35. return (int)XmdsCommon.Plugin.XmdsBuffProperties.XmdsBuffAbility.Brand;
  36. }
  37. public override void CopyTo(UnitBuff other)
  38. {
  39. var ret = other as XmdsBuff_Brand;
  40. ret.BuffValue = this.BuffValue;
  41. ret.breakHitDamage = this.breakHitDamage;
  42. ret.damageDeeps = this.damageDeeps;
  43. ret.maxLayers = this.maxLayers;
  44. base.CopyTo(other);
  45. }
  46. protected override void OnBuffBegin(XmdsCommonServer.Plugin.XmdsVirtual hitter, XmdsCommonServer.Plugin.XmdsVirtual attacker, InstanceUnit.BuffState state)
  47. {
  48. senderId = attacker.mUnit.ID;
  49. //注册监听.
  50. mHandleUUID = hitter.RegistOnHitDamage(OnHandleHitDmage, null);
  51. this.baseDamage = Math.Max(1, XmdsDamageCalculator.GetDamage(attacker.MirrorProp.GetFinalAttack(hitter.mUnit.IsMonster), attacker, hitter, null));
  52. }
  53. protected override void OnBuffEnd(XmdsCommonServer.Plugin.XmdsVirtual hitter, InstanceUnit.BuffState state, bool replace)
  54. {
  55. //取消监听.
  56. hitter.UnRegistOnHitDamage(mHandleUUID);
  57. if(this.breakHitDamage > 0)
  58. {
  59. int finalAttack = this.breakHitDamage + this.damageDeeps * Math.Min(this.maxLayers, this.normalAtkHit);
  60. int finalDamage = Math.Max(1, CUtils.CastInt(finalAttack * XmdsUnitProp.PER * baseDamage));
  61. //buff结束了,再补一刀
  62. state.Owner.AddHP(-finalDamage, state.Sender);
  63. }
  64. }
  65. protected override int OnBuffHit(XmdsVirtual hitter,XmdsVirtual attacker,
  66. CommonAI.Zone.Formula.AttackSource source, ref XmdsVirtual.AtkResult result)
  67. {
  68. if (BuffValue != 0)
  69. {
  70. return BuffValue;
  71. }
  72. return base.OnBuffHit(hitter, attacker, source, ref result);
  73. }
  74. //单位被攻击时,判断是否符合条件触发BUFF效果.
  75. private float OnHandleHitDmage(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source,
  76. ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
  77. {
  78. if (BuffInvaildCheck())
  79. {
  80. hitted.mUnit.removeBuff(BindBuffID);
  81. }
  82. if(senderId == attacker.mUnit.ID && source.FromSkillType == XmdsSkillType.normalAtk)
  83. {
  84. this.normalAtkHit++;
  85. }
  86. return damage;
  87. }
  88. protected override void OnDispose()
  89. {
  90. base.OnDispose();
  91. }
  92. }
  93. }