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.Data; namespace XmdsCommonSkill.Plugin.Buffs { /// /// 烙印标记,再次攻击触发(法师2-2特殊机制,其他暂时不用吧) /// public class XmdsBuff_Brand_1 : XmdsBuffBase { /// BUFF效果,正值为扣血,负值为抵伤. public int BuffValue; //前N次伤害忽视(buff是伤害造成的,所以一般要去掉首次的判断) public int damgeIngoreTimes = 0; //发送者id private uint mSenderID = 0; private int mHandleUUID = 0; public override int GetAbilityID() { return (int)XmdsCommon.Plugin.XmdsBuffProperties.XmdsBuffAbility.Brand_1; } public override void CopyTo(UnitBuff other) { var ret = other as XmdsBuff_Brand_1; ret.BuffValue = this.BuffValue; ret.damgeIngoreTimes = this.damgeIngoreTimes; base.CopyTo(other); } protected override void OnBuffBegin(XmdsCommonServer.Plugin.XmdsVirtual hitter, XmdsCommonServer.Plugin.XmdsVirtual attacker, InstanceUnit.BuffState state) { //注册监听. mHandleUUID = hitter.RegistOnHitDamage(OnHandleHitDmage, null); mSenderID = attacker.mUnit.ID; } protected override void OnBuffEnd(XmdsCommonServer.Plugin.XmdsVirtual hitter, InstanceUnit.BuffState state, bool replace) { //取消监听. hitter.UnRegistOnHitDamage(mHandleUUID); } //单位被攻击时,判断是否符合条件触发BUFF效果. private float OnHandleHitDmage(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source, ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch) { int flag = source.Attack == null ? 0 : source.Attack.Properties.GetAttackID() / 100; if(flag != 3101 && flag != 3105) { return damage; } --damgeIngoreTimes; if (mSenderID == attacker.mUnit.ID && (damgeIngoreTimes <= 0)) { hitted.mUnit.removeBuff(BindBuffID); hitted.mUnit.AddHP(-this.BuffValue, attacker.mUnit); } return damage ; } protected override void OnDispose() { base.OnDispose(); } } }