Other_100200_ZhiBao.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills;
  19. namespace XmdsCommonSkill.Plugin.PassiveSkills.Magic
  20. {
  21. /// <summary>
  22. /// 灵宝套装被动: 次攻击时有X%的概率触发,使玩家的当前面板的攻击伤害提高Y%,持续时间Z秒,技能冷却时间S秒
  23. /// </summary>
  24. public class Other_100200_ZhiBao : XmdsPassiveSkillBase
  25. {
  26. /// 技能ID.
  27. public static readonly int ID = 100200;
  28. public static readonly int DAMAGE_INDEX = 10;
  29. private static XmdsSkillValue mValueSet1; // 触发概率
  30. private static XmdsSkillValue mValueSet2; // 伤害百分比
  31. private static XmdsSkillValue mValueSet3; // buff持续时间
  32. private static XmdsSkillValue mValueSet4; // 冷却时间
  33. //本次触发时间
  34. private long mNextTirggerTime = 0;
  35. //buff有效截止时间
  36. private long mBuffValidEndTime = 0;
  37. //当前技能等级
  38. private byte mSkillLevel = 0;
  39. public override int SkillID { get { return ID; } }
  40. private int mUUID_1;
  41. protected override void OnInit(GameSkill skillInfo, XmdsVirtual owner)
  42. {
  43. mUUID_1 = owner.RegistOnHitOther(OnHandleHitOther, skillInfo, true);
  44. this.mSkillLevel = (byte)skillInfo.SkillLevel;
  45. mNextTirggerTime = CommonLang.CUtils.localTimeMS + mValueSet4.GetValue(this.mSkillLevel);
  46. }
  47. private float OnHandleHitOther(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source,
  48. ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
  49. {
  50. if (source == null || source.FromBuff != null)
  51. {
  52. return damage;
  53. }
  54. if (mNextTirggerTime < CommonLang.CUtils.localTimeMS && attacker.mUnit.RandomN.Next(0, 10000) < mValueSet1.GetValue(skill.SkillLevel))
  55. {
  56. mNextTirggerTime = CommonLang.CUtils.localTimeMS + mValueSet4.GetValue(skill.SkillLevel);
  57. mBuffValidEndTime = CommonLang.CUtils.localTimeMS + mValueSet3.GetValue(skill.SkillLevel);
  58. }
  59. return damage;
  60. }
  61. protected override void OnInitOver(XmdsVirtual unit, GameSkill info)
  62. {
  63. //AbstractSkill baseSkill = unit.SkillHelper.GetPlayerSkillById(unit.SkillHelper.GetBaseSkillID());
  64. //if(baseSkill == null)
  65. //{
  66. // log.Error("Other_100200_ZhiBao找不到单位基础技能:" + unit.mUnit.PlayerUUID);
  67. // return;
  68. //}
  69. //// 借用一下这个接口,懒得写新的了
  70. //baseSkill.InitOver(unit, info);
  71. unit.ReInitOverBaseSkill(info);
  72. }
  73. protected override void OnSkillDataChange(GameSkill gs, XmdsVirtual unit)
  74. {
  75. this.mSkillLevel = (byte)gs.SkillLevel;
  76. }
  77. //Value1: 技能伤害,Value2: 技能是否触发, Value3: 释放了特殊技能
  78. public override int GetSkillValue(AbstractSkillType type)
  79. {
  80. if(type == AbstractSkillType.Value1)
  81. {
  82. return mValueSet2.GetValue(this.mSkillLevel);
  83. }
  84. else if(type == AbstractSkillType.Value2)
  85. {
  86. return CommonLang.CUtils.localTimeMS < mBuffValidEndTime ? 1 : 0;
  87. }
  88. else if (type == AbstractSkillType.Value3)
  89. {
  90. this.mBuffValidEndTime = 0;
  91. }else if(type == AbstractSkillType.Value4)
  92. {
  93. return mValueSet2.GetValueExt(this.mSkillLevel);
  94. }
  95. return 0;
  96. }
  97. protected override void OnInitSkillParam()
  98. {
  99. XmdsSkillData data = XmdsDataMgr.GetInstance().GetXmdsSkillData(ID);
  100. InitData(data, out mValueSet1, XmdsSkillData.XmdsSkillDataKey.ValueSet);
  101. InitData(data, out mValueSet2, XmdsSkillData.XmdsSkillDataKey.ValueSet2);
  102. InitData(data, out mValueSet3, XmdsSkillData.XmdsSkillDataKey.ValueSet3);
  103. InitData(data, out mValueSet4, XmdsSkillData.XmdsSkillDataKey.ValueSet4);
  104. }
  105. protected override void OnDispose(XmdsVirtual owner)
  106. {
  107. owner.UnRegistOnHitOther(mUUID_1);
  108. AbstractSkill baseSkill = owner.SkillHelper.GetPlayerSkillById(owner.SkillHelper.GetBaseSkillID());
  109. if (baseSkill == null)
  110. {
  111. //log.Error("Other_100200_ZhiBao找不到单位基础技能:" + owner.mUnit.PlayerUUID);
  112. return;
  113. }
  114. // 借用一下这个接口,懒得写新的了
  115. baseSkill.DoSkillDispose(this.SkillID);
  116. }
  117. }
  118. }