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; namespace XmdsCommonSkill.Plugin.PassiveSkills.Remedy { /// /// 治疗被动 /// 自然平衡:治疗量会随着目标血量少于X增益n% /// class Remedy_510600 : XmdsPassiveSkillBase { /// 技能ID. public static int ID = 510600; private int mUUID_1 = 0; private int mUUID_2 = 0; //被动数值 protected static XmdsSkillValue valueSet; //缓存数值 private float mTriggerPrecent = 0; private float mAddHPPrecent = 0; /// 获取技能ID. public override int SkillID {get{return ID;}} protected override void OnInit(GameSkill skillInfo, XmdsVirtual owner) { //单位攻击监听 mUUID_1 = owner.RegistOnHitOther(OnHandleOnHit, skillInfo, true); //加buff也可能是回血的 mUUID_2 = owner.RegistAddOtherHPEvent(OnAddOtherHPEvnet, skillInfo); this.mTriggerPrecent = XmdsUnitProp.PER * valueSet.GetValue(skillInfo.GetPassiveLevel(), 1); this.mAddHPPrecent = XmdsUnitProp.PER * valueSet.GetValue(skillInfo.GetPassiveLevel(), 2); } protected override void OnSkillDataChange(GameSkill gs, XmdsVirtual unit) { this.mTriggerPrecent = XmdsUnitProp.PER * valueSet.GetValue(gs.GetPassiveLevel(), 1); this.mAddHPPrecent = XmdsUnitProp.PER * valueSet.GetValue(gs.GetPassiveLevel(), 2); } //单位攻击 private float OnHandleOnHit(float damage, XmdsVirtual hitter, XmdsVirtual attacker, AttackSource source, ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch) { //受击为友方,回血效果增加 int extDamage = 0; if (damageType == DamageType.Heal && attacker.IsAllies(hitter, true, true)) { int triggerHP = CUtils.CastInt(hitter.mUnit.MaxHP * XmdsUnitProp.PER * valueSet.GetValue(skill.GetPassiveLevel(), 1)); if(hitter.mUnit.CurrentHP <= triggerHP) { extDamage = -CUtils.CastInt(damage * XmdsUnitProp.PER * valueSet.GetValue(skill.GetPassiveLevel(), 2)); } } return damage + extDamage; } public bool OnAddOtherHPEvnet(int hp, InstanceUnit sender, InstanceUnit hitter, out int finalHP) { finalHP = hp; if(hp > 0 && sender.Virtual.IsAllies(hitter.Virtual, true, true)) { int triggerHP = CUtils.CastInt(hitter.MaxHP * this.mTriggerPrecent); if (hitter.CurrentHP <= triggerHP) { finalHP = CUtils.CastInt(hp * (1 + this.mAddHPPrecent)); } } return true; } //针对每个不同的buff,单独处理了,悲剧@(理应是只考虑受击的,不考虑buff)。坑太大, 填不动 //public void OnSendBuffEvent(BuffTemplate buff, XmdsVirtual attacker, XmdsVirtual hitter) //{ // try // { // int triggerHP = CUtils.CastInt(hitter.mUnit.MaxHP * XmdsUnitProp.PER * valueSet.GetValue(skill.GetPassiveLevel(), 1)); // if (hitter.mUnit.CurrentHP >= triggerHP) // { // return; // } // if (buff.ID == (int)XmdsBuffBase.XmdsBuffList.REMEDY_2_0_ADDHP) // { // } // else if (buff.ID == (int)XmdsBuffBase.XmdsBuffList.REMEDY_4_3_ATTACKADDHP) // { // } // else if (buff.ID == (int)XmdsBuffBase.XmdsBuffList.AttackRoundAddHP) // { // } // } // catch (Exception e) // { // log.Error("Remedy_510600 OnSendBuffEvent catch: " + buff.ID + ", " + e); // } //} protected override void OnDispose(XmdsVirtual owner) { owner.UnRegistOnHitOther(mUUID_1); owner.UnRegistAddOtherHPEvent(mUUID_2); } protected override void OnInitSkillParam() { XmdsSkillData data = XmdsDataMgr.GetInstance().GetXmdsSkillData(ID); InitData(data, out valueSet, XmdsSkillData.XmdsSkillDataKey.ValueSet); } } }