using CommonAI.Zone.Helper; using CommonAI.Zone.Instance; using XmdsCommonServer.Plugin; using XmdsCommonServer.XLS.Data; using XmdsCommonSkill.Plugin.Buffs; using System; using static CommonAI.Zone.Instance.InstanceUnit; using XmdsCommon.Plugin; using CommonAI.Zone; using XmdsCommonServer.Plugin.Units; using CommonAI.Zone.Formula; using XmdsCommonSkill.Plugin.Skills; using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator; using CommonAI.Data; using CommonLang; using XmdsCommonSkill.Plugin.PassiveSkills.Pet20200515; namespace XmdsCommonSkill.Plugin.PassiveSkills.Remedy { /// /// NewPet - 防3(受击时,有N%的几率将N%伤害反弹给目标,持续N秒。冷却时间N秒。) /// class Pet_80010 : PetPassiveBase { public static readonly int ID = 80010; public static int Buff_ID = (int)XmdsBuffBase.XmdsBuffList.NEWPET_REBOUND_DAMAGE; private static XmdsSkillValue triggerRate; // 触发几率 private static XmdsSkillValue triggerRateExt; // 命格增加几率 private static XmdsSkillValue triggerInterval; // 触发间隔 private static XmdsSkillValue reboundDamage; // 反弹比例 private static XmdsSkillValue buffTime; // Buff时间 // 内部数据 private int mUUID_1 = 0; private long mNextTriggerTime = 0; public override int SkillID { get { return ID; } } protected override void OnInit(GameSkill skillInfo, XmdsVirtual owner) { var pack = XmdsBuffFactory.GetInstance().GetXmdsBuffPack(Buff_ID); var buff = (XmdsBuff_Shield_IronMaiden)pack.GetXmdsBuff(XmdsBuffProperties.XmdsBuffAbility.SHIELD_IronMaiden); buff.IronMaidenPercent = reboundDamage.GetValue(skillInfo.SkillLevel); var bt = pack.mBuffTemplate; bt.IsHarmful = true; bt.LifeTimeMS = buffTime.GetValue(skillInfo.SkillLevel); pack.BindTemplateAndDispose(); owner.RegistSendBuff(bt); this.mNextTriggerTime = CommonLang.CUtils.localTimeMS + triggerInterval.GetValue(); mUUID_1 = owner.RegistOnHitDamage(OnHandleHitDmage, skillInfo, true); } protected override void OnSkillDataChange(GameSkill gs, XmdsVirtual unit) { var buff = unit.GetRegisBuffVirtual(Buff_ID) as XmdsBuff_Shield_IronMaiden; buff.IronMaidenPercent = reboundDamage.GetValue(gs.SkillLevel); var bt = unit.GetRegistBuff(Buff_ID); bt.LifeTimeMS = buffTime.GetValue(gs.SkillLevel); } private float OnHandleHitDmage(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source, ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch) { UnitFateType fateType = hitted.GetUnitFateType(); if (fateType != UnitFateType.None && damageType == DamageType.Damage && this.mNextTriggerTime < CommonLang.CUtils.localTimeMS && IsTrigger(hitted, triggerRate, triggerRateExt, skill, fateType)) { hitted.mUnit.AddBuff(Buff_ID, hitted.mUnit); this.mNextTriggerTime = CommonLang.CUtils.localTimeMS + triggerInterval.GetValue(); base.NotifyTriggerAblity(hitted.mUnit, this.SkillID); } return damage; } protected override void OnInitSkillParam() { XmdsSkillData data = XmdsDataMgr.GetInstance().GetXmdsSkillData(ID); InitData(data, out triggerRate, XmdsSkillData.XmdsSkillDataKey.ValueSet); InitData(data, out triggerRateExt, XmdsSkillData.XmdsSkillDataKey.ValueSet2); InitData(data, out triggerInterval, XmdsSkillData.XmdsSkillDataKey.ValueSet3); InitData(data, out reboundDamage, XmdsSkillData.XmdsSkillDataKey.ValueSet4); InitData(data, out buffTime, XmdsSkillData.XmdsSkillDataKey.ValueSet5); } protected override void OnDispose(XmdsVirtual owner) { owner.UnRegistOnHitDamage(mUUID_1); } } }