XmdsBuff_IgnorCtrlToSpeedDown.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using CommonAI.Zone;
  2. using CommonAI.Zone.Formula;
  3. using CommonAI.Zone.Instance;
  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.Units;
  11. using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator;
  12. using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills;
  13. namespace XmdsCommonSkill.Plugin.Buffs
  14. {
  15. public class XmdsBuff_IgnorCtrlToSpeedDown : XmdsBuffBase
  16. {
  17. //免疫硬控,并转换成减速50%
  18. public int speedChange = -5000;
  19. private static int Buff_ID = (int)XmdsBuffBase.XmdsBuffList.SPEED_DOWN;
  20. private int uuid_ignoreCtrl = 0;
  21. public override int GetAbilityID()
  22. {
  23. return (int)XmdsCommon.Plugin.XmdsBuffProperties.XmdsBuffAbility.IgnorCtrl_To_SpeedDown;
  24. }
  25. public override void CopyTo(UnitBuff other)
  26. {
  27. var ret = other as XmdsBuff_IgnorCtrlToSpeedDown;
  28. ret.speedChange = this.speedChange;
  29. base.CopyTo(other);
  30. }
  31. protected override void OnBuffBegin(XmdsVirtual hitter, XmdsVirtual attacker, InstanceUnit.BuffState state)
  32. {
  33. //注册免控
  34. uuid_ignoreCtrl = hitter.RegistTryAddBuffEvent(OnTryAddBuffEvent, null);
  35. }
  36. protected override void OnBuffEnd(XmdsVirtual hitter, InstanceUnit.BuffState state, bool replace)
  37. {
  38. hitter.UnRegistTryAddBuffEvent(uuid_ignoreCtrl);
  39. }
  40. private bool OnTryAddBuffEvent(ref BuffTemplate buff, XmdsVirtual attacker, XmdsVirtual hitter, GameSkill skill)
  41. {
  42. // Buff没有生效
  43. if(XmdsInstanceUtils.IsControlBuff(buff))
  44. {
  45. hitter.SendBattleHintNumberB2C(0, XmdsVirtual.UnitHitEventState.Immunity);
  46. //每次生效自动检查.
  47. XmdsBuffPack pack = XmdsBuffFactory.GetInstance().GetXmdsBuffPack(Buff_ID);
  48. XmdsBuff_MoveSpeedDown buffAdd = (XmdsBuff_MoveSpeedDown)pack.GetXmdsBuff(XmdsBuffProperties.XmdsBuffAbility.MoveSpeedDown);
  49. buffAdd.ChangePercent = this.speedChange;
  50. BuffTemplate bt = pack.mBuffTemplate;
  51. bt.IsHarmful = true;
  52. bt.LifeTimeMS = buff.LifeTimeMS;
  53. pack.BindTemplateAndDispose();
  54. hitter.RegistSendBuff(bt);
  55. hitter.mUnit.AddBuff(Buff_ID, hitter.mUnit);
  56. return false;
  57. }
  58. return true;
  59. }
  60. }
  61. }