using CommonAI.Zone.Instance; using CommonAI.Zone.Formula; using System; using System.Collections.Generic; using System.Linq; using System.Text; using XmdsCommon.Plugin; using XmdsCommonServer.Plugin; using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills; using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator; using CommonAI.Zone; using CommonAI.Data; namespace XmdsCommonSkill.Plugin.Buffs { /// /// buff创建者队友攻击buff拥有者,给队友增加回血buff /// public class XmdsBuff_Brand_5 : XmdsBuffBase { public int addHpTotal = 0; private int mHandleUUID = 0; private XmdsCommonServer.Plugin.XmdsVirtual attacker; //攻击,增加的buff信息 private static BuffTemplate addHpBuf = null; private static int Buff_ID = (int)XmdsBuffBase.XmdsBuffList.JJC_HUICHUN; public XmdsBuff_Brand_5() { var pack = XmdsBuffFactory.GetInstance().GetXmdsBuffPack(Buff_ID); var buff = (XmdsBuff_AddHP)pack.GetXmdsBuff(XmdsBuffProperties.XmdsBuffAbility.AddHP_Unbroken); buff.ChangeValue = addHpTotal/3; addHpBuf = pack.mBuffTemplate; addHpBuf.IsHarmful = true; addHpBuf.LifeTimeMS = 3000; pack.BindTemplateAndDispose(); } public override int GetAbilityID() { return (int)XmdsCommon.Plugin.XmdsBuffProperties.XmdsBuffAbility.Brand_5; } public override void CopyTo(UnitBuff other) { var ret = other as XmdsBuff_Brand_5; ret.addHpTotal = this.addHpTotal; base.CopyTo(other); } protected override void OnBuffBegin(XmdsCommonServer.Plugin.XmdsVirtual hitter, XmdsCommonServer.Plugin.XmdsVirtual attacker, InstanceUnit.BuffState state) { //注册监听. mHandleUUID = hitter.RegistOnHitDamage(OnHandleHitDmage, null); this.attacker = attacker; } protected override void OnBuffEnd(XmdsCommonServer.Plugin.XmdsVirtual hitter, InstanceUnit.BuffState state, bool replace) { //取消监听. hitter.UnRegistOnHitDamage(mHandleUUID); } //单位受到攻击 private float OnHandleHitDmage(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source, ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch) { try { //拥有此buff的人被攻击,攻击者是友军,加一个回血的buff if (attacker != null && attacker.IsAllies(attacker, true, true) && attacker.mUnit.GetBuffByID(Buff_ID) == null) { attacker.mUnit.AddBuff(addHpBuf, attacker.mUnit); } } catch(Exception err) { log.Error("XmdsBuff_Brand_5:" + err); } return damage; } protected override void OnDispose() { base.OnDispose(); } } }