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 - 防4(血量低于N%时,提高当前免伤N%,持续N秒。冷却时间N秒。) /// class Pet_80011 : PetPassiveBase { public static readonly int ID = 80011; public static int Buff_ID = (int)XmdsBuffBase.XmdsBuffList.NEWPET_DAMAGEREDUCE; private static XmdsSkillValue triggerRate; // 触发几率 private static XmdsSkillValue triggerInterval; // 触发间隔 private static XmdsSkillValue hpTriggerData; // 血量阀值 private static XmdsSkillValue reduceDamage; // 免伤比例 private static XmdsSkillValue buffTime; // 免伤提升时间 // 内部数据 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.AllDmgReduce; buff.CurrentValue = reduceDamage.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.RegistOnHitDamage(OnHandleHitDmage, skillInfo, true); mUUID_1 = owner.RegistShareMasterDmgEvent(OnShareMasterDmgEvent, skillInfo); } protected override void OnSkillDataChange(GameSkill gs, XmdsVirtual unit) { var buff = unit.GetRegisBuffVirtual(Buff_ID) as XmdsBuff_PropChange; buff.CurrentValue = reduceDamage.GetValue(gs.SkillLevel); var bt = unit.GetRegistBuff(Buff_ID); bt.LifeTimeMS = buffTime.GetValue(gs.SkillLevel); } private int OnShareMasterDmgEvent(int hp, InstanceUnit sender, InstanceUnit unit, GameSkill skill, ref bool isEndDispatch) { XmdsVirtual hitted = unit.Virtual as XmdsVirtual; UnitFateType fateType = hitted.GetUnitFateType(); if (fateType != UnitFateType.None && hp > 0 && this.mNextTriggerTime < CommonLang.CUtils.localTimeMS) { long triggerHP = (long)(hitted.mUnit.MaxHP * XmdsUnitProp.PER * hpTriggerData.GetValue(skill.SkillLevel)); if(hitted.mUnit.CurrentHP < triggerHP) { hitted.mUnit.AddBuff(Buff_ID, hitted.mUnit); base.NotifyTriggerAblity(hitted.mUnit, this.SkillID); } this.mNextTriggerTime = CommonLang.CUtils.localTimeMS + triggerInterval.GetValue(); } return hp; } //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) // { // long triggerHP = (long)(hitted.mUnit.MaxHP * XmdsUnitProp.PER * hpTriggerData.GetValue(skill.SkillLevel)); // if(hitted.mUnit.CurrentHP < triggerHP) // { // hitted.mUnit.AddBuff(Buff_ID, hitted.mUnit); // base.NotifyTriggerAblity(hitted.mUnit, this.SkillID); // } // this.mNextTriggerTime = CommonLang.CUtils.localTimeMS + triggerInterval.GetValue(); // } // return damage; //} protected override void OnInitSkillParam() { XmdsSkillData data = XmdsDataMgr.GetInstance().GetXmdsSkillData(ID); InitData(data, out triggerRate, XmdsSkillData.XmdsSkillDataKey.ValueSet); //ValueSet2-客户端命格概率假数据 InitData(data, out triggerInterval, XmdsSkillData.XmdsSkillDataKey.ValueSet3); InitData(data, out hpTriggerData, XmdsSkillData.XmdsSkillDataKey.ValueSet4); InitData(data, out reduceDamage, XmdsSkillData.XmdsSkillDataKey.ValueSet5); InitData(data, out buffTime, XmdsSkillData.XmdsSkillDataKey.ValueSet6); } protected override void OnDispose(XmdsVirtual owner) { //owner.UnRegistOnHitDamage(mUUID_1); owner.UnRegistShareMasterDmgEvent(mUUID_1); } } }