Other_100100.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 XmdsCommonSkill.Plugin.Skills.Magic;
  15. using CommonLang;
  16. using CommonAI.Data;
  17. using System.Collections.Generic;
  18. namespace XmdsCommonSkill.Plugin.PassiveSkills.Magic
  19. {
  20. /// <summary>
  21. /// 灵宝套装被动: 次攻击时有X%的概率触发,使玩家的当前面板的攻击伤害提高Y%,持续时间Z秒,技能冷却时间S秒
  22. /// </summary>
  23. public class Other_100100 : XmdsPassiveSkillBase
  24. {
  25. /// 技能ID.
  26. public static readonly int ID = 100100;
  27. private static XmdsSkillValue mValueSet1; // 触发概率
  28. private static XmdsSkillValue mValueSet2; // 攻击百分比提高
  29. private static XmdsSkillValue mValueSet3; // buff持续时间
  30. private static XmdsSkillValue mValueSet4; // 冷却时间
  31. private static readonly int Buff_ID = (int)XmdsBuffBase.XmdsBuffList.LINGBAO_BUFF;
  32. private int mUUID_1 = 0;
  33. //本次触发时间
  34. private long mNextTirggerTime = 0;
  35. //buff有效截止时间
  36. private long mBuffValidEndTime = 0;
  37. public override int SkillID { get { return ID; } }
  38. protected override void OnInit(GameSkill skillInfo, XmdsVirtual owner)
  39. {
  40. var pack1 = XmdsBuffFactory.GetInstance().GetXmdsBuffPack(Buff_ID);
  41. var bt1 = pack1.mBuffTemplate;
  42. bt1.LifeTimeMS = mValueSet3.GetValue(skillInfo.SkillLevel);
  43. pack1.BindTemplateAndDispose();
  44. owner.RegistSendBuff(bt1);
  45. mNextTirggerTime = CommonLang.CUtils.localTimeMS + mValueSet4.GetValue(skillInfo.SkillLevel);
  46. mUUID_1 = owner.RegistOnHitOther(OnHandleHitOther, skillInfo, true);
  47. }
  48. protected override void OnSkillDataChange(GameSkill gs, XmdsVirtual unit)
  49. {
  50. var buf1 = unit.GetRegistBuff(Buff_ID);
  51. buf1.LifeTimeMS = mValueSet3.GetValue(gs.SkillLevel);
  52. }
  53. private float OnHandleHitOther(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source,
  54. ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
  55. {
  56. if (source == null || source.FromBuff != null)
  57. {
  58. return damage;
  59. }
  60. // 对战玩家触发
  61. if (hitted != null && !hitted.IsPlayerUnit())
  62. {
  63. //如果buff生效了
  64. if (mBuffValidEndTime > 0 && mBuffValidEndTime > CommonLang.CUtils.localTimeMS)
  65. {
  66. damage += damage * mValueSet2.GetValue(skill.SkillLevel) * XmdsUnitProp.PER;
  67. return damage;
  68. }
  69. else if (mNextTirggerTime < CommonLang.CUtils.localTimeMS && attacker.mUnit.RandomN.Next(0, 10000) < mValueSet1.GetValue(skill.SkillLevel))
  70. {
  71. mNextTirggerTime = CommonLang.CUtils.localTimeMS + mValueSet4.GetValue(skill.SkillLevel);
  72. mBuffValidEndTime = CommonLang.CUtils.localTimeMS + mValueSet3.GetValue(skill.SkillLevel);
  73. attacker.mUnit.AddBuff(Buff_ID);
  74. }
  75. }
  76. return damage;
  77. }
  78. protected override void OnInitSkillParam()
  79. {
  80. XmdsSkillData data = XmdsDataMgr.GetInstance().GetXmdsSkillData(ID);
  81. InitData(data, out mValueSet1, XmdsSkillData.XmdsSkillDataKey.ValueSet);
  82. InitData(data, out mValueSet2, XmdsSkillData.XmdsSkillDataKey.ValueSet2);
  83. InitData(data, out mValueSet3, XmdsSkillData.XmdsSkillDataKey.ValueSet3);
  84. InitData(data, out mValueSet4, XmdsSkillData.XmdsSkillDataKey.ValueSet4);
  85. }
  86. protected override void OnDispose(XmdsVirtual owner)
  87. {
  88. owner.UnRegistOnHitOther(mUUID_1);
  89. }
  90. }
  91. }