XmdsBuff_SkillDamageChange.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using CommonAI.Data;
  2. using CommonAI.Zone.Formula;
  3. using CommonAI.Zone.Helper;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using XmdsCommon.Plugin;
  9. using XmdsCommonServer.Plugin;
  10. using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator;
  11. using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills;
  12. namespace XmdsCommonSkill.Plugin.Buffs
  13. {
  14. /// <summary>
  15. /// Description: 用于改变技能伤害.
  16. /// DateTime: 2019/6/17 16:32:21
  17. /// </summary>
  18. public class XmdsBuff_SkillDamageChange : XmdsBuffBase
  19. {
  20. /// BUFF作用效果.正:增加伤害,负:减少伤害.
  21. public float BuffChangeValue = 0;
  22. public int maxOverlayer = 0;
  23. //针对的技能类型,
  24. public XmdsSkillType validType;
  25. /// 大于0,则只影响对应的技能效果.
  26. public int TargetSkillID = 0;
  27. //默认时间.
  28. private const int DefaultTime = int.MaxValue;
  29. //当前作用效果.
  30. private float CurrentChangeValue = 0;
  31. private int mHandUUID = 0;
  32. public override int GetAbilityID()
  33. {
  34. return (int)XmdsBuffProperties.XmdsBuffAbility.SkillDamageChange;
  35. }
  36. public override void CopyTo(UnitBuff other)
  37. {
  38. var ret = other as XmdsBuff_SkillDamageChange;
  39. ret.BuffChangeValue = this.BuffChangeValue;
  40. ret.maxOverlayer = this.maxOverlayer;
  41. ret.validType = this.validType;
  42. ret.TargetSkillID = this.TargetSkillID;
  43. base.CopyTo(other);
  44. }
  45. protected override void OnBindTemplate(ref CommonAI.Zone.BuffTemplate buffTemplate)
  46. {
  47. //如果为次数型,那么需设置作用时间.
  48. if (BuffUseType == (int)XmdsBuffBase.XmdsBuffUseType.Times)
  49. {
  50. buffTemplate.LifeTimeMS = DefaultTime;
  51. }
  52. }
  53. protected override void OnBuffBegin(XmdsCommonServer.Plugin.XmdsVirtual hitter, XmdsCommonServer.Plugin.XmdsVirtual attacker, CommonAI.Zone.Instance.InstanceUnit.BuffState state)
  54. {
  55. CurrentChangeValue = Math.Max(state.OverlayLevel + 1, this.maxOverlayer) * BuffChangeValue;
  56. mHandUUID = hitter.RegistOnHitOther(OnHandleHitOther, null);
  57. }
  58. protected override void OnBuffEnd(XmdsCommonServer.Plugin.XmdsVirtual hitter, CommonAI.Zone.Instance.InstanceUnit.BuffState state, bool replace)
  59. {
  60. CurrentChangeValue = Math.Min(state.OverlayLevel + 1, this.maxOverlayer) * BuffChangeValue;
  61. hitter.UnRegistOnHitOther(mHandUUID);
  62. }
  63. private float OnHandleHitOther(float damage, XmdsVirtual hitter, XmdsVirtual attacker, AttackSource source,
  64. ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
  65. {
  66. if (IsInvaild() == true) { return damage; }
  67. //GameSkill skill = attacker.SkillHelper.GetGameSkill(((source.Attack.Properties) as XmdsAttackProperties).SkillTemplateID);
  68. if(source.FromSkillType == XmdsSkillType.normalAtk)
  69. {
  70. return damage;
  71. }
  72. //大于0代表制定了影响的技能,如果ID与指定ID不匹配,则不影响.
  73. XmdsAttackProperties p = (XmdsAttackProperties)source.Attack.Properties;
  74. if (TargetSkillID > 0 && TargetSkillID != p.SkillTemplateID)
  75. {
  76. return damage;
  77. }
  78. damage = damage * (CurrentChangeValue + XmdsDamageCalculator.PERER) / XmdsDamageCalculator.PERER;
  79. if (BuffInvaildCheck())
  80. {
  81. attacker.mUnit.removeBuff(BindBuffID);
  82. }
  83. return damage;
  84. }
  85. }
  86. }