Pet_80009.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using CommonAI.Zone.Helper;
  2. using CommonAI.Zone.Instance;
  3. using XmdsCommonServer.Plugin;
  4. using XmdsCommonServer.XLS.Data;
  5. using XmdsCommonSkill.Plugin.Buffs;
  6. using System;
  7. using static CommonAI.Zone.Instance.InstanceUnit;
  8. using XmdsCommon.Plugin;
  9. using CommonAI.Zone;
  10. using XmdsCommonServer.Plugin.Units;
  11. using CommonAI.Zone.Formula;
  12. using XmdsCommonSkill.Plugin.Skills;
  13. using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator;
  14. using CommonAI.Data;
  15. using CommonLang;
  16. using XmdsCommonSkill.Plugin.PassiveSkills.Pet20200515;
  17. namespace XmdsCommonSkill.Plugin.PassiveSkills.Remedy
  18. {
  19. /// <summary>
  20. /// NewPet - 防2(受击时,有N%的几率提高防御值N+N%(当前防御值),持续N秒。冷却时间N秒。)
  21. /// </summary>
  22. class Pet_80009 : PetPassiveBase
  23. {
  24. public static readonly int ID = 80009;
  25. public static int Buff_ID = (int)XmdsBuffBase.XmdsBuffList.NEWPET_DEFENCEUP;
  26. private static XmdsSkillValue triggerRate; // 触发几率
  27. private static XmdsSkillValue triggerRateExt; // 命格增加几率
  28. private static XmdsSkillValue triggerInterval; // 触发间隔
  29. private static XmdsSkillValue defenceChange; // 防御改变:固定值+百分百
  30. private static XmdsSkillValue buffTime; // Buff时间
  31. // 内部数据
  32. private int mUUID_1 = 0;
  33. private long mNextTriggerTime = 0;
  34. public override int SkillID { get { return ID; } }
  35. protected override void OnInit(GameSkill skillInfo, XmdsVirtual owner)
  36. {
  37. XmdsBuffPack pack = XmdsBuffFactory.GetInstance().GetXmdsBuffPack(Buff_ID);
  38. XmdsBuff_PropChange buff = (XmdsBuff_PropChange)pack.GetXmdsBuff(0);
  39. buff.CurentChangeType = XmdsVirtual.UnitAttributeType.Defence;
  40. buff.CurrentValue = defenceChange.GetValue(skillInfo.SkillLevel); // 基础防御提升
  41. buff.IsPercent = false;
  42. XmdsBuff_PropChange buff1 = (XmdsBuff_PropChange)pack.GetXmdsBuff(1);
  43. buff1.CurentChangeType = XmdsVirtual.UnitAttributeType.Defence;
  44. buff1.CurrentValue = defenceChange.GetValueExt(skillInfo.SkillLevel); // 防御提升比例
  45. buff1.IsPercent = true;
  46. BuffTemplate bt = pack.mBuffTemplate;
  47. bt.IsHarmful = true;
  48. bt.LifeTimeMS = buffTime.GetValue(skillInfo.SkillLevel);
  49. pack.BindTemplateAndDispose();
  50. owner.RegistSendBuff(bt);
  51. this.mNextTriggerTime = CommonLang.CUtils.localTimeMS + triggerInterval.GetValue();
  52. //mUUID_1 = owner.RegistOnHitDamage(OnHandleHitDamage, skillInfo, true);
  53. mUUID_1 = owner.RegistShareMasterDmgEvent(OnShareMasterDmgEvent, skillInfo);
  54. }
  55. protected override void OnSkillDataChange(GameSkill gs, XmdsVirtual unit)
  56. {
  57. var buff1 = unit.GetRegisBuffVirtual(Buff_ID, 0) as XmdsBuff_PropChange;
  58. buff1.CurrentValue = defenceChange.GetValue(gs.SkillLevel);
  59. var buff2 = unit.GetRegisBuffVirtual(Buff_ID, 1) as XmdsBuff_PropChange;
  60. buff2.CurrentValue = defenceChange.GetValueExt(gs.SkillLevel);
  61. var bt = unit.GetRegistBuff(Buff_ID);
  62. bt.LifeTimeMS = buffTime.GetValue(gs.SkillLevel);
  63. }
  64. private int OnShareMasterDmgEvent(int hp, InstanceUnit sender, InstanceUnit unit, GameSkill skill, ref bool isEndDispatch)
  65. {
  66. XmdsVirtual virUnit = unit.Virtual as XmdsVirtual;
  67. UnitFateType fateType = virUnit.GetUnitFateType();
  68. if (fateType != UnitFateType.None && hp > 0 && this.mNextTriggerTime < CommonLang.CUtils.localTimeMS &&
  69. IsTrigger(virUnit, triggerRate, triggerRateExt, skill, fateType))
  70. {
  71. virUnit.mUnit.AddBuff(Buff_ID, virUnit.mUnit);
  72. this.mNextTriggerTime = CommonLang.CUtils.localTimeMS + triggerInterval.GetValue();
  73. base.NotifyTriggerAblity(virUnit.mUnit, this.SkillID);
  74. }
  75. return hp;
  76. }
  77. //private float OnHandleHitDamage(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source,
  78. //ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
  79. //{
  80. // UnitFateType fateType = hitted.GetUnitFateType();
  81. // if (fateType != UnitFateType.None && damageType == DamageType.Damage &&
  82. // this.mNextTriggerTime < CommonLang.CUtils.localTimeMS &&
  83. // IsTrigger(hitted, triggerRate, triggerRateExt, skill, fateType))
  84. // {
  85. // hitted.mUnit.AddBuff(Buff_ID, hitted.mUnit);
  86. // this.mNextTriggerTime = CommonLang.CUtils.localTimeMS + triggerInterval.GetValue();
  87. // base.NotifyTriggerAblity(hitted.mUnit, this.SkillID);
  88. // }
  89. // return damage;
  90. //}
  91. protected override void OnInitSkillParam()
  92. {
  93. XmdsSkillData data = XmdsDataMgr.GetInstance().GetXmdsSkillData(ID);
  94. InitData(data, out triggerRate, XmdsSkillData.XmdsSkillDataKey.ValueSet);
  95. InitData(data, out triggerRateExt, XmdsSkillData.XmdsSkillDataKey.ValueSet2);
  96. InitData(data, out triggerInterval, XmdsSkillData.XmdsSkillDataKey.ValueSet3);
  97. InitData(data, out defenceChange, XmdsSkillData.XmdsSkillDataKey.ValueSet4);
  98. InitData(data, out buffTime, XmdsSkillData.XmdsSkillDataKey.ValueSet5);
  99. }
  100. protected override void OnDispose(XmdsVirtual owner)
  101. {
  102. //owner.UnRegistOnHitDamage(mUUID_1);
  103. owner.UnRegistShareMasterDmgEvent(mUUID_1);
  104. }
  105. }
  106. }