XmdsBuff_SpeedChg_DamageRemit.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using CommonAI.Data;
  2. using CommonAI.Zone;
  3. using CommonAI.Zone.Formula;
  4. using CommonAI.Zone.Instance;
  5. using CommonLang;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using XmdsCommon.Plugin;
  11. using XmdsCommonServer.Plugin;
  12. using XmdsCommonServer.Plugin.Units;
  13. using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator;
  14. using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills;
  15. namespace XmdsCommonSkill.Plugin.Buffs
  16. {
  17. public class XmdsBuff_SpeedChg_DamageRemit : XmdsBuffBase
  18. {
  19. //速度变更,免伤
  20. /// <summary>
  21. /// 传负值减速度,传正值加速度.
  22. /// </summary>
  23. public int speedChange = 0;
  24. public int damageRemit = 0;
  25. private int mOpID = 0;
  26. private int uuid_damgeRemit = 0;
  27. public override int GetAbilityID()
  28. {
  29. return (int)XmdsCommon.Plugin.XmdsBuffProperties.XmdsBuffAbility.SpeedChg_DamageRemit;
  30. }
  31. public override void CopyTo(UnitBuff other)
  32. {
  33. var ret = other as XmdsBuff_SpeedChg_DamageRemit;
  34. ret.speedChange = this.speedChange;
  35. ret.damageRemit = this.damageRemit;
  36. base.CopyTo(other);
  37. }
  38. protected override void OnBuffBegin(XmdsVirtual hitter, XmdsVirtual attacker, InstanceUnit.BuffState state)
  39. {
  40. //移动速度变更.
  41. if(this.speedChange != 0)
  42. {
  43. XmdsVirtual.PropChangeOperation pco = hitter.CreatePropChangeOpertation(this);
  44. pco.Type = XmdsVirtual.UnitAttributeType.MoveSpeed;
  45. pco.Value = speedChange;
  46. pco.OpType = XmdsVirtual.PropChangeOperation.OperateType.Percent;
  47. mOpID = hitter.AddPropChangeOperation(pco);
  48. }
  49. //注册受击
  50. if(this.damageRemit != 0)
  51. {
  52. uuid_damgeRemit = hitter.RegistOnHitDamage(OnUnitHitEvent, null);
  53. }
  54. }
  55. protected override void OnBuffEnd(XmdsVirtual hitter, InstanceUnit.BuffState state, bool replace)
  56. {
  57. if (this.speedChange != 0)
  58. {
  59. hitter.RemovePropChangeOperation(mOpID);
  60. }
  61. if (this.damageRemit != 0)
  62. {
  63. hitter.UnRegistOnHitDamage(uuid_damgeRemit);
  64. }
  65. }
  66. protected virtual float OnUnitHitEvent(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source,
  67. ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
  68. {
  69. //伤害减免
  70. damage = CUtils.CastInt(damage * XmdsUnitProp.PER * (XmdsDamageCalculator.PERER - damageRemit));
  71. return damage;
  72. }
  73. private bool OnTryAddBuffEvent(ref BuffTemplate buff, XmdsVirtual attacker, XmdsVirtual hitter)
  74. {
  75. if (!IsInvaild() && XmdsInstanceUtils.IsControlBuff(buff))
  76. {
  77. hitter.SendBattleHintNumberB2C(0, XmdsVirtual.UnitHitEventState.Immunity);
  78. //每次生效自动检查.
  79. if (BuffInvaildCheck())
  80. {
  81. hitter.mUnit.removeBuff(BindBuffID);
  82. }
  83. return false;
  84. }
  85. return true;
  86. }
  87. }
  88. }