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 - 攻2(最大血量每减少N%,提高当前攻击力N(固定值)+N%(当前攻击力),检测逻辑间隔N秒。)不能实时变化攻击力,暂时转化成实时加成最终伤害 /// class Pet_80001 : PetPassiveBase { public static readonly int ID = 80001; private static XmdsSkillValue triggerInterval; // 触发间隔 private static XmdsSkillValue hpReducePer; // HP减少XX触发 private static XmdsSkillValue attackAddition; // 攻击力增加:固定值+百分比 //内部数据 private int mUUID_1 = 0; private float mDamageAddition = 0.0f; //伤害加成,攻击力转换过来的 private long mNextTriggerTime = 0; public override int SkillID { get { return ID; } } protected override void OnInit(GameSkill skillInfo, XmdsVirtual owner) { mUUID_1 = owner.RegistOnHitOther(OnHandleHitOther, skillInfo, true); } // 检测被动 private void CheckPassive(XmdsVirtual owner, GameSkill skill) { //直接算生命加成最终伤害值 if (this.mNextTriggerTime < CommonLang.CUtils.localTimeMS) { float hpLevel = (int)((owner.mUnit.MaxHP - owner.mUnit.CurrentHP) / (owner.mUnit.MaxHP * XmdsUnitProp.PER * hpReducePer.GetValue(skill.SkillLevel))); float attackLayerAdd = attackAddition.GetValue(skill.SkillLevel) + owner.MirrorProp.BaseAttack * XmdsUnitProp.PER * attackAddition.GetValueExt(skill.SkillLevel); this.mDamageAddition = hpLevel * attackLayerAdd / owner.MirrorProp.MaxAttack; this.mNextTriggerTime = CommonLang.CUtils.localTimeMS + triggerInterval.GetValue(); } } // 攻击其他人 private float OnHandleHitOther(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source, ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch) { CheckPassive(attacker, skill); if (mDamageAddition > 0) { damage = damage * (1 + mDamageAddition); } return damage; } protected override void OnInitSkillParam() { XmdsSkillData data = XmdsDataMgr.GetInstance().GetXmdsSkillData(ID); //ValueSet, ValueSet2-客户端命格概率假数据 InitData(data, out triggerInterval, XmdsSkillData.XmdsSkillDataKey.ValueSet3); InitData(data, out hpReducePer, XmdsSkillData.XmdsSkillDataKey.ValueSet4); InitData(data, out attackAddition, XmdsSkillData.XmdsSkillDataKey.ValueSet5); } protected override void OnDispose(XmdsVirtual owner) { owner.UnRegistOnHitOther(mUUID_1); } } }