using CommonAI.Data; using CommonAI.Zone.Formula; using CommonAI.Zone.Helper; using System; using System.Collections.Generic; using System.Linq; using System.Text; using XmdsCommon.Plugin; using XmdsCommonServer.Plugin; using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator; using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills; namespace XmdsCommonSkill.Plugin.Buffs { /// /// Description: 用于改变技能伤害. /// DateTime: 2019/6/17 16:32:21 /// public class XmdsBuff_SkillDamageChange : XmdsBuffBase { /// BUFF作用效果.正:增加伤害,负:减少伤害. public float BuffChangeValue = 0; public int maxOverlayer = 0; //针对的技能类型, public XmdsSkillType validType; /// 大于0,则只影响对应的技能效果. public int TargetSkillID = 0; //默认时间. private const int DefaultTime = int.MaxValue; //当前作用效果. private float CurrentChangeValue = 0; private int mHandUUID = 0; public override int GetAbilityID() { return (int)XmdsBuffProperties.XmdsBuffAbility.SkillDamageChange; } public override void CopyTo(UnitBuff other) { var ret = other as XmdsBuff_SkillDamageChange; ret.BuffChangeValue = this.BuffChangeValue; ret.maxOverlayer = this.maxOverlayer; ret.validType = this.validType; ret.TargetSkillID = this.TargetSkillID; base.CopyTo(other); } protected override void OnBindTemplate(ref CommonAI.Zone.BuffTemplate buffTemplate) { //如果为次数型,那么需设置作用时间. if (BuffUseType == (int)XmdsBuffBase.XmdsBuffUseType.Times) { buffTemplate.LifeTimeMS = DefaultTime; } } protected override void OnBuffBegin(XmdsCommonServer.Plugin.XmdsVirtual hitter, XmdsCommonServer.Plugin.XmdsVirtual attacker, CommonAI.Zone.Instance.InstanceUnit.BuffState state) { CurrentChangeValue = Math.Max(state.OverlayLevel + 1, this.maxOverlayer) * BuffChangeValue; mHandUUID = hitter.RegistOnHitOther(OnHandleHitOther, null); } protected override void OnBuffEnd(XmdsCommonServer.Plugin.XmdsVirtual hitter, CommonAI.Zone.Instance.InstanceUnit.BuffState state, bool replace) { CurrentChangeValue = Math.Min(state.OverlayLevel + 1, this.maxOverlayer) * BuffChangeValue; hitter.UnRegistOnHitOther(mHandUUID); } private float OnHandleHitOther(float damage, XmdsVirtual hitter, XmdsVirtual attacker, AttackSource source, ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch) { if (IsInvaild() == true) { return damage; } //GameSkill skill = attacker.SkillHelper.GetGameSkill(((source.Attack.Properties) as XmdsAttackProperties).SkillTemplateID); if(source.FromSkillType == XmdsSkillType.normalAtk) { return damage; } //大于0代表制定了影响的技能,如果ID与指定ID不匹配,则不影响. XmdsAttackProperties p = (XmdsAttackProperties)source.Attack.Properties; if (TargetSkillID > 0 && TargetSkillID != p.SkillTemplateID) { return damage; } damage = damage * (CurrentChangeValue + XmdsDamageCalculator.PERER) / XmdsDamageCalculator.PERER; if (BuffInvaildCheck()) { attacker.mUnit.removeBuff(BindBuffID); } return damage; } } }