Pet_80290.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using CommonAI.Zone.Instance;
  2. using CommonLang;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using XmdsCommon.Plugin;
  9. using XmdsCommonServer.Plugin;
  10. using XmdsCommonServer.XLS.Data;
  11. using XmdsCommonSkill.Plugin.Buffs;
  12. using XmdsCommonSkill.Plugin.Skills;
  13. namespace XmdsCommonSkill.Plugin.PassiveSkills.Pet20200515
  14. {
  15. /// <summary>
  16. /// 宠物装备被动:死亡有几率触发 -》 给主人加血buff
  17. /// </summary>
  18. ///
  19. class Pet_80290 : PetEquipSkillBase
  20. {
  21. /// 技能ID.
  22. private static int ID = 80290;
  23. public override int SkillID { get { return ID; } }
  24. private static readonly int Buff_ID = (int)XmdsBuffBase.XmdsBuffList.PET_EQUIPSKILL_ADDHP; //主人狂暴buff
  25. //加血参数:比例,时间
  26. protected XmdsSkillValue mAddHPValue;
  27. private int mSkillLv;
  28. protected override void OnInit(GameSkill skillInfo, XmdsVirtual owner)
  29. {
  30. var pack = XmdsBuffFactory.GetInstance().GetXmdsBuffPack(Buff_ID);
  31. var buff = pack.GetXmdsBuff(XmdsBuffProperties.XmdsBuffAbility.AddHP) as XmdsBuff_AddHP;
  32. buff.ChangeValue = CUtils.CastInt(owner.MirrorProp.MaxAttack * XmdsUnitProp.PER * mAddHPValue.GetValue(skillInfo.SkillLevel, 1));
  33. var bt = pack.mBuffTemplate;
  34. bt.LifeTimeMS = mAddHPValue.GetValue(skillInfo.SkillLevel, 2);
  35. bt.IsHarmful = true;
  36. pack.BindTemplateAndDispose();
  37. owner.RegistSendBuff(bt);
  38. this.mSkillLv = skillInfo.SkillLevel;
  39. owner.mUnit.OnDead += OnPetDead;
  40. }
  41. protected override void OnSkillDataChange(GameSkill gs, XmdsVirtual unit)
  42. {
  43. var buff = unit.GetRegisBuffVirtual(Buff_ID) as XmdsBuff_AddHP;
  44. buff.ChangeValue = CUtils.CastInt(unit.MirrorProp.MaxAttack * XmdsUnitProp.PER * mAddHPValue.GetValueExt(gs.SkillLevel, 1));
  45. var bt = unit.GetRegistBuff(Buff_ID);
  46. bt.LifeTimeMS = mAddHPValue.GetValue(gs.SkillLevel, 2);
  47. this.mSkillLv = gs.SkillLevel;
  48. }
  49. private void OnPetDead(InstanceUnit unit, InstanceUnit attacker)
  50. {
  51. if (base.IsTrigger((XmdsVirtual)unit.Virtual, this.mSkillLv))
  52. {
  53. //主人添加buff
  54. InstancePet pet = unit as InstancePet;
  55. if (pet != null && pet.Master != null)
  56. {
  57. pet.Master.AddBuff(Buff_ID, unit);
  58. }
  59. }
  60. }
  61. protected override void OnDispose(XmdsVirtual owner)
  62. {
  63. owner.mUnit.OnDead -= OnPetDead;
  64. }
  65. protected override void OnInitConfig(GameSkill skillInfo)
  66. {
  67. XmdsSkillData data = XmdsDataMgr.GetInstance().GetXmdsSkillData(this.SkillID);
  68. XmdsSkillValue triggerInterval, triggerRate;
  69. InitData(data, out triggerInterval, XmdsSkillData.XmdsSkillDataKey.ValueSet);
  70. InitData(data, out triggerRate, XmdsSkillData.XmdsSkillDataKey.ValueSet2);
  71. InitData(data, out mAddHPValue, XmdsSkillData.XmdsSkillDataKey.ValueSet3);
  72. base.initEquipSkillBase(triggerInterval, triggerRate, skillInfo.SkillLevel);
  73. }
  74. }
  75. }