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.Helper; using CommonAI.Data; using CommonLang; namespace XmdsCommonSkill.Plugin.Buffs { /// /// 烙印,符合触发条件时,造成额外伤害,可选择使用类型,时间OR次数. /// public class XmdsBuff_Brand : XmdsBuffBase { /// BUFF效果,正值为扣血,负值为抵伤. public int BuffValue; //buff消失时,造成一次性伤害加成 public int breakHitDamage = 0; //结束一刀,每层伤害加成 public int damageDeeps = 0; //普攻加成最高层数 public int maxLayers = 0; private int baseDamage = 0; //10000基准伤害值 private uint senderId = 0; private int normalAtkHit = 0; private int mHandleUUID = 0; public override int GetAbilityID() { return (int)XmdsCommon.Plugin.XmdsBuffProperties.XmdsBuffAbility.Brand; } public override void CopyTo(UnitBuff other) { var ret = other as XmdsBuff_Brand; ret.BuffValue = this.BuffValue; ret.breakHitDamage = this.breakHitDamage; ret.damageDeeps = this.damageDeeps; ret.maxLayers = this.maxLayers; base.CopyTo(other); } protected override void OnBuffBegin(XmdsCommonServer.Plugin.XmdsVirtual hitter, XmdsCommonServer.Plugin.XmdsVirtual attacker, InstanceUnit.BuffState state) { senderId = attacker.mUnit.ID; //注册监听. mHandleUUID = hitter.RegistOnHitDamage(OnHandleHitDmage, null); this.baseDamage = Math.Max(1, XmdsDamageCalculator.GetDamage(attacker.MirrorProp.GetFinalAttack(hitter.mUnit.IsMonster), attacker, hitter, null)); } protected override void OnBuffEnd(XmdsCommonServer.Plugin.XmdsVirtual hitter, InstanceUnit.BuffState state, bool replace) { //取消监听. hitter.UnRegistOnHitDamage(mHandleUUID); if(this.breakHitDamage > 0) { int finalAttack = this.breakHitDamage + this.damageDeeps * Math.Min(this.maxLayers, this.normalAtkHit); int finalDamage = Math.Max(1, CUtils.CastInt(finalAttack * XmdsUnitProp.PER * baseDamage)); //buff结束了,再补一刀 state.Owner.AddHP(-finalDamage, state.Sender); } } protected override int OnBuffHit(XmdsVirtual hitter,XmdsVirtual attacker, CommonAI.Zone.Formula.AttackSource source, ref XmdsVirtual.AtkResult result) { if (BuffValue != 0) { return BuffValue; } return base.OnBuffHit(hitter, attacker, source, ref result); } //单位被攻击时,判断是否符合条件触发BUFF效果. private float OnHandleHitDmage(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source, ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch) { if (BuffInvaildCheck()) { hitted.mUnit.removeBuff(BindBuffID); } if(senderId == attacker.mUnit.ID && source.FromSkillType == XmdsSkillType.normalAtk) { this.normalAtkHit++; } return damage; } protected override void OnDispose() { base.OnDispose(); } } }