Pet_80260.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using CommonAI.Data;
  2. using CommonAI.Zone;
  3. using CommonAI.Zone.Formula;
  4. using CommonAI.Zone.Helper;
  5. using CommonLang;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using XmdsCommon.Plugin;
  12. using XmdsCommonServer.Plugin;
  13. using XmdsCommonServer.XLS.Data;
  14. using XmdsCommonSkill.Plugin.Buffs;
  15. using XmdsCommonSkill.Plugin.Interface;
  16. using XmdsCommonSkill.Plugin.Skills;
  17. namespace XmdsCommonSkill.Plugin.PassiveSkills.Pet20200515
  18. {
  19. /// <summary>
  20. /// 宠物装备被动:受击概率触发-》宠物获得护盾
  21. /// </summary>
  22. ///
  23. class Pet_80260 : PetEquipSkillBase
  24. {
  25. /// 技能ID.
  26. private static int ID = 80260;
  27. public override int SkillID { get { return ID; } }
  28. private static readonly int Buff_ID = (int)XmdsBuffBase.XmdsBuffList.PET_EQUIPSKILL_HUDUN; //主人狂暴buff
  29. //最大生命,持续时间
  30. protected XmdsSkillValue mHuDun;
  31. //绑定法术
  32. LaunchSpell mBindSpell;
  33. //内部变量
  34. private int mUUID_1 = 0;
  35. protected override void OnInit(GameSkill skillInfo, XmdsVirtual owner)
  36. {
  37. XmdsBuffPack pack = XmdsBuffFactory.GetInstance().GetXmdsBuffPack(Buff_ID);
  38. XmdsBuff_Shield_AbsorbDamage buff = (XmdsBuff_Shield_AbsorbDamage)pack.GetXmdsBuff(XmdsBuffProperties.XmdsBuffAbility.SHIELD_AbsorbDamage);
  39. buff.AbsorbDamageSum = CUtils.CastInt(owner.MirrorProp.MaxHP * XmdsUnitProp.PER * mHuDun.GetValue(skillInfo.SkillLevel, 1));
  40. BuffTemplate bt = pack.mBuffTemplate;
  41. bt.IsHarmful = false;
  42. bt.LifeTimeMS = mHuDun.GetValue(skillInfo.SkillLevel, 2);
  43. pack.BindTemplateAndDispose();
  44. owner.RegistSendBuff(bt);
  45. mUUID_1 = owner.RegistOnHitDamage(OnHandleHitDamage, skillInfo, true);
  46. }
  47. protected override void OnSkillDataChange(GameSkill gs, XmdsVirtual unit)
  48. {
  49. var buff = unit.GetRegisBuffVirtual(Buff_ID) as XmdsBuff_Shield_AbsorbDamage;
  50. buff.AbsorbDamageSum = CUtils.CastInt(unit.MirrorProp.MaxAttack * XmdsUnitProp.PER * mHuDun.GetValue(gs.SkillLevel, 1));
  51. var bt = unit.GetRegistBuff(Buff_ID);
  52. bt.LifeTimeMS = mHuDun.GetValue(gs.SkillLevel, 2);
  53. }
  54. protected override void OnDispose(XmdsVirtual owner)
  55. {
  56. owner.UnRegistOnHitDamage(mUUID_1);
  57. }
  58. private float OnHandleHitDamage(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source,
  59. ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
  60. {
  61. if (damage > 0 && base.IsTrigger(hitted, skill.SkillLevel))
  62. {
  63. hitted.mUnit.Parent.unitLaunchSpell(XmdsSkillType.none, hitted.mUnit, mBindSpell,
  64. hitted.mUnit.X, hitted.mUnit.Y, hitted.mUnit.ID);
  65. hitted.mUnit.AddBuff(Buff_ID);
  66. }
  67. return damage;
  68. }
  69. protected override void OnInitConfig(GameSkill skillInfo)
  70. {
  71. XmdsSkillData data = XmdsDataMgr.GetInstance().GetXmdsSkillData(this.SkillID);
  72. XmdsSkillValue triggerInterval, triggerRate, bindEffectSpell;
  73. InitData(data, out triggerInterval, XmdsSkillData.XmdsSkillDataKey.ValueSet);
  74. InitData(data, out triggerRate, XmdsSkillData.XmdsSkillDataKey.ValueSet2);
  75. InitData(data, out mHuDun, XmdsSkillData.XmdsSkillDataKey.ValueSet3);
  76. InitData(data, out bindEffectSpell, XmdsSkillData.XmdsSkillDataKey.ValueSet4);
  77. base.initEquipSkillBase(triggerInterval, triggerRate, skillInfo.SkillLevel);
  78. mBindSpell = ComSpellTemplate.Instance().GetSpellBySpellID(bindEffectSpell.GetValue());
  79. if (mBindSpell == null)
  80. {
  81. log.Error("Pet_80260找不到绑定特效法术ID:" + bindEffectSpell.GetValue());
  82. }
  83. }
  84. }
  85. }