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 - 辅1(攻击时,有N%的几率使目标当前防御降低N%,持续N秒。冷却时间N秒。) /// class Pet_80016 : PetPassiveBase { public static readonly int ID = 80016; public static int Buff_ID = (int)XmdsBuffBase.XmdsBuffList.NEWPET_DEFENCE_DOWN; private static XmdsSkillValue triggerRate; // 触发几率 private static XmdsSkillValue triggerRateExt; // 命格增加几率 private static XmdsSkillValue triggerInterval; // 触发间隔 private static XmdsSkillValue defenceChange; // 降低防御 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) { XmdsBuffPack pack = XmdsBuffFactory.GetInstance().GetXmdsBuffPack(Buff_ID); XmdsBuff_PropChange buff = (XmdsBuff_PropChange)pack.GetXmdsBuff(0); buff.CurentChangeType = XmdsVirtual.UnitAttributeType.Defence; buff.CurrentValue = -defenceChange.GetValue(skillInfo.SkillLevel); buff.IsPercent = true; BuffTemplate 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.RegistOnHitOther(OnHandleHitOther, skillInfo, true); } protected override void OnSkillDataChange(GameSkill gs, XmdsVirtual unit) { var buff = unit.GetRegisBuffVirtual(Buff_ID) as XmdsBuff_PropChange; buff.CurrentValue = -defenceChange.GetValue(gs.SkillLevel); var bt = unit.GetRegistBuff(Buff_ID); bt.LifeTimeMS = buffTime.GetValue(gs.SkillLevel); } private float OnHandleHitOther(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source, ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch) { UnitFateType fateType = attacker.GetUnitFateType(); if (fateType != UnitFateType.None && hitted.mUnit.IsMonster && this.mNextTriggerTime < CommonLang.CUtils.localTimeMS && IsTrigger(attacker, triggerRate, triggerRateExt, skill, fateType)) { hitted.mUnit.AddBuff(Buff_ID, attacker.mUnit); this.mNextTriggerTime = CommonLang.CUtils.localTimeMS + triggerInterval.GetValue(); base.NotifyTriggerAblity(attacker.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 defenceChange, XmdsSkillData.XmdsSkillDataKey.ValueSet4); InitData(data, out buffTime, XmdsSkillData.XmdsSkillDataKey.ValueSet5); } protected override void OnDispose(XmdsVirtual owner) { owner.UnRegistOnHitOther(mUUID_1); } } }