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秒。当前血量低于N%时不触发,冷却时间N秒。) /// class Pet_80003 : PetPassiveBase { public static readonly int ID = 80003; public static int Buff_ID = (int)XmdsBuffBase.XmdsBuffList.NEWPET_ATTACK_UP; private static XmdsSkillValue triggerRate; // 触发几率 private static XmdsSkillValue triggerRateExt; // 命格增加几率 private static XmdsSkillValue triggerInterval; // 触发间隔 private static XmdsSkillValue hpTriggerData; // 消耗生命,触发阀值 private static XmdsSkillValue attackChange; // 提升攻击力 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.Attack; buff.CurrentValue = attackChange.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 = attackChange.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 && this.mNextTriggerTime < CommonLang.CUtils.localTimeMS && IsTrigger(attacker, triggerRate, triggerRateExt, skill, fateType)) { long triggerHP = (long)(attacker.mUnit.MaxHP * XmdsUnitProp.PER * hpTriggerData.GetValueExt(skill.SkillLevel)); if (attacker.mUnit.CurrentHP > triggerHP) { int reduceHP = CUtils.CastInt(attacker.mUnit.MaxHP * XmdsUnitProp.PER * hpTriggerData.GetValue(skill.SkillLevel)); attacker.mUnit.ReduceHP(reduceHP, attacker.mUnit, null); attacker.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 hpTriggerData, XmdsSkillData.XmdsSkillDataKey.ValueSet4); InitData(data, out attackChange, XmdsSkillData.XmdsSkillDataKey.ValueSet5); InitData(data, out buffTime, XmdsSkillData.XmdsSkillDataKey.ValueSet6); } protected override void OnDispose(XmdsVirtual owner) { owner.UnRegistOnHitOther(mUUID_1); } } }