Pet_80002.cs 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 - 攻3(攻击时,有N%的几率对目标造成持续伤害,每秒造成N+N%点伤害,持续N秒。冷却时间N秒。)
  21. /// </summary>
  22. class Pet_80002 : PetPassiveBase
  23. {
  24. public static readonly int ID = 80002;
  25. public static int Buff_ID = (int)XmdsBuffBase.XmdsBuffList.NEWPET_CONTINUE_DAMAGE;
  26. private static XmdsSkillValue triggerRate; // 触发几率
  27. private static XmdsSkillValue triggerRateExt; // 命格增加几率
  28. private static XmdsSkillValue triggerInterval; // 触发间隔
  29. private static XmdsSkillValue damageValue; // 伤害:固定值+百分百
  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. this.mNextTriggerTime = CommonLang.CUtils.localTimeMS + triggerInterval.GetValue();
  38. mUUID_1 = owner.RegistOnHitOther(OnHandleHitOther, skillInfo, true);
  39. XmdsBuffPack pack = XmdsBuffFactory.GetInstance().GetXmdsBuffPack(Buff_ID);
  40. XmdsBuff_Bleed buff = (XmdsBuff_Bleed)pack.GetXmdsBuff(XmdsBuffProperties.XmdsBuffAbility.Bleed);
  41. BuffTemplate bt = pack.mBuffTemplate;
  42. bt.IsHarmful = true;
  43. bt.LifeTimeMS = buffTime.GetValue(skillInfo.SkillLevel);
  44. pack.BindTemplateAndDispose();
  45. owner.RegistSendBuff(bt);
  46. }
  47. protected override void OnSkillDataChange(GameSkill gs, XmdsVirtual unit)
  48. {
  49. var bt = unit.GetRegistBuff(Buff_ID);
  50. bt.LifeTimeMS = buffTime.GetValue(gs.SkillLevel);
  51. }
  52. private float OnHandleHitOther(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source,
  53. ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
  54. {
  55. UnitFateType fateType = attacker.GetUnitFateType();
  56. // 触发时间间隔判断
  57. if (fateType != UnitFateType.None && hitted.mUnit.IsMonster && this.mNextTriggerTime < CommonLang.CUtils.localTimeMS &&
  58. IsTrigger(attacker, triggerRate, triggerRateExt, skill, fateType))
  59. {
  60. var buff = attacker.GetRegisBuffVirtual(Buff_ID) as XmdsBuff_Bleed;
  61. buff.ChangeValue = damageValue.GetValue(skill.SkillLevel) +
  62. CUtils.CastInt((damage * XmdsUnitProp.PER * damageValue.GetValueExt(skill.SkillLevel)));
  63. hitted.mUnit.AddBuff(Buff_ID, attacker.mUnit);
  64. this.mNextTriggerTime = CommonLang.CUtils.localTimeMS + triggerInterval.GetValue();
  65. base.NotifyTriggerAblity(attacker.mUnit, this.SkillID);
  66. }
  67. return damage;
  68. }
  69. protected override void OnInitSkillParam()
  70. {
  71. XmdsSkillData data = XmdsDataMgr.GetInstance().GetXmdsSkillData(ID);
  72. InitData(data, out triggerRate, XmdsSkillData.XmdsSkillDataKey.ValueSet);
  73. InitData(data, out triggerRateExt, XmdsSkillData.XmdsSkillDataKey.ValueSet2);
  74. InitData(data, out triggerInterval, XmdsSkillData.XmdsSkillDataKey.ValueSet3);
  75. InitData(data, out damageValue, XmdsSkillData.XmdsSkillDataKey.ValueSet4);
  76. InitData(data, out buffTime, XmdsSkillData.XmdsSkillDataKey.ValueSet5);
  77. }
  78. protected override void OnDispose(XmdsVirtual owner)
  79. {
  80. owner.UnRegistOnHitOther(mUUID_1);
  81. }
  82. }
  83. }