123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- using CommonAI.Data;
- using CommonAI.Zone;
- using CommonAI.Zone.Formula;
- using CommonAI.Zone.Instance;
- using CommonLang;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using XmdsCommon.Plugin;
- using XmdsCommonServer.Plugin;
- using XmdsCommonServer.Plugin.Units;
- using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator;
- using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills;
- namespace XmdsCommonSkill.Plugin.Buffs
- {
- public class XmdsBuff_SpeedChg_DamageRemit : XmdsBuffBase
- {
- //速度变更,免伤
- /// <summary>
- /// 传负值减速度,传正值加速度.
- /// </summary>
- public int speedChange = 0;
- public int damageRemit = 0;
- private int mOpID = 0;
- private int uuid_damgeRemit = 0;
- public override int GetAbilityID()
- {
- return (int)XmdsCommon.Plugin.XmdsBuffProperties.XmdsBuffAbility.SpeedChg_DamageRemit;
- }
- public override void CopyTo(UnitBuff other)
- {
- var ret = other as XmdsBuff_SpeedChg_DamageRemit;
- ret.speedChange = this.speedChange;
- ret.damageRemit = this.damageRemit;
- base.CopyTo(other);
- }
- protected override void OnBuffBegin(XmdsVirtual hitter, XmdsVirtual attacker, InstanceUnit.BuffState state)
- {
- //移动速度变更.
- if(this.speedChange != 0)
- {
- XmdsVirtual.PropChangeOperation pco = hitter.CreatePropChangeOpertation(this);
- pco.Type = XmdsVirtual.UnitAttributeType.MoveSpeed;
- pco.Value = speedChange;
- pco.OpType = XmdsVirtual.PropChangeOperation.OperateType.Percent;
- mOpID = hitter.AddPropChangeOperation(pco);
- }
-
- //注册受击
- if(this.damageRemit != 0)
- {
- uuid_damgeRemit = hitter.RegistOnHitDamage(OnUnitHitEvent, null);
- }
- }
- protected override void OnBuffEnd(XmdsVirtual hitter, InstanceUnit.BuffState state, bool replace)
- {
- if (this.speedChange != 0)
- {
- hitter.RemovePropChangeOperation(mOpID);
- }
- if (this.damageRemit != 0)
- {
- hitter.UnRegistOnHitDamage(uuid_damgeRemit);
- }
- }
- protected virtual float OnUnitHitEvent(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source,
- ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
- {
- //伤害减免
- damage = CUtils.CastInt(damage * XmdsUnitProp.PER * (XmdsDamageCalculator.PERER - damageRemit));
- return damage;
- }
- private bool OnTryAddBuffEvent(ref BuffTemplate buff, XmdsVirtual attacker, XmdsVirtual hitter)
- {
- if (!IsInvaild() && XmdsInstanceUtils.IsControlBuff(buff))
- {
- hitter.SendBattleHintNumberB2C(0, XmdsVirtual.UnitHitEventState.Immunity);
- //每次生效自动检查.
- if (BuffInvaildCheck())
- {
- hitter.mUnit.removeBuff(BindBuffID);
- }
- return false;
- }
- return true;
- }
- }
- }
|