|
@@ -64,14 +64,30 @@ namespace XmdsCommonSkill.Plugin.Buffs
|
|
|
protected override void OnBuffBegin(XmdsCommonServer.Plugin.XmdsVirtual hitter, XmdsCommonServer.Plugin.XmdsVirtual attacker, InstanceUnit.BuffState state)
|
|
|
{
|
|
|
//注册监听.
|
|
|
- mHandleUUID = hitter.RegistOnHitDamage(OnHandleHitDmage, null);
|
|
|
+ if(hitter.mUnit.IsPet)
|
|
|
+ {
|
|
|
+ mHandleUUID = hitter.RegistShareMasterDmgEvent(OnShareMasterDmgEvent, null);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ mHandleUUID = hitter.RegistOnHitDamage(OnHandleHitDmage, null);
|
|
|
+ }
|
|
|
+
|
|
|
XmdsVirtual.FormatLog("BuffBegin : 单位【{0}】增加吸收伤害护盾.", hitter.mProp.ServerData.BaseInfo.name);
|
|
|
}
|
|
|
|
|
|
protected override void OnBuffEnd(XmdsCommonServer.Plugin.XmdsVirtual hitter, InstanceUnit.BuffState state, bool replace)
|
|
|
{
|
|
|
//取消监听.
|
|
|
- hitter.UnRegistOnHitDamage(mHandleUUID);
|
|
|
+ if(hitter.mUnit.IsPet)
|
|
|
+ {
|
|
|
+ hitter.UnRegistShareMasterDmgEvent(mHandleUUID);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ hitter.UnRegistOnHitDamage(mHandleUUID);
|
|
|
+ }
|
|
|
+
|
|
|
XmdsVirtual.FormatLog("BuffBegin : 单位【{0}】失去吸收伤害护盾.", hitter.mProp.ServerData.BaseInfo.name);
|
|
|
|
|
|
//护盾破碎,创建法术
|
|
@@ -87,13 +103,23 @@ namespace XmdsCommonSkill.Plugin.Buffs
|
|
|
//单位被攻击时.伤害吸收计算.
|
|
|
private float OnHandleHitDmage(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source,
|
|
|
ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
|
|
|
+ {
|
|
|
+ return DoAbsortDmg(damage, hitted, attacker, source);
|
|
|
+ }
|
|
|
+
|
|
|
+ private int OnShareMasterDmgEvent(int hp, InstanceUnit sender, InstanceUnit unit, GameSkill skill, ref bool isEndDispatch)
|
|
|
+ {
|
|
|
+ return (int)(DoAbsortDmg(hp, unit.Virtual as XmdsVirtual, sender == null ? null : (sender.Virtual as XmdsVirtual)));
|
|
|
+ }
|
|
|
+
|
|
|
+ private float DoAbsortDmg(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source = null)
|
|
|
{
|
|
|
float ret = damage;
|
|
|
|
|
|
- if(this.mNextHitTime > CommonLang.CUtils.localTimeMS)
|
|
|
- {
|
|
|
- return damage;
|
|
|
- }
|
|
|
+ if (this.mNextHitTime > CommonLang.CUtils.localTimeMS)
|
|
|
+ {
|
|
|
+ return damage;
|
|
|
+ }
|
|
|
|
|
|
//damage > 0是伤害,damage < 0是加血机制.
|
|
|
if (damage > 0 && AbsorbDamageSum > 0)
|
|
@@ -103,13 +129,15 @@ namespace XmdsCommonSkill.Plugin.Buffs
|
|
|
if (ret < 0)
|
|
|
{
|
|
|
ret = 0;
|
|
|
- source.OutClientState = (byte)XmdsCommonServer.Plugin.XmdsVirtual.UnitHitEventState.Absorb;
|
|
|
+ if(source != null)
|
|
|
+ {
|
|
|
+ source.OutClientState = (byte)XmdsCommonServer.Plugin.XmdsVirtual.UnitHitEventState.Absorb;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
int abDamage = CUtils.CastInt(damage - ret);
|
|
|
|
|
|
AbsorbDamageSum -= abDamage;
|
|
|
-
|
|
|
if (AbsorbDamageSum <= 0)
|
|
|
{
|
|
|
//破盾.
|
|
@@ -122,22 +150,33 @@ namespace XmdsCommonSkill.Plugin.Buffs
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //触发频率
|
|
|
- if(this.HitInterval > 0)
|
|
|
- {
|
|
|
- this.mNextHitTime = CommonLang.CUtils.localTimeMS + this.HitInterval;
|
|
|
- }
|
|
|
+ //触发频率
|
|
|
+ if (this.HitInterval > 0)
|
|
|
+ {
|
|
|
+ this.mNextHitTime = CommonLang.CUtils.localTimeMS + this.HitInterval;
|
|
|
+ }
|
|
|
|
|
|
- this.OnAbsortDamage(hitted, attacker, source);
|
|
|
+ this.OnAbsortDamage(hitted, attacker, source);
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
- protected virtual void OnAbsortDamage(XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source)
|
|
|
- {
|
|
|
|
|
|
+
|
|
|
+ protected virtual void OnAbsortDamage(XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source)
|
|
|
+ {
|
|
|
+ if(hitted.mUnit.IsPet)
|
|
|
+ {
|
|
|
+ //手动推送吸收伤害消息
|
|
|
+ UnitHitEvent evt = new UnitHitEvent(hitted.mUnit.ID);
|
|
|
+ evt.senderId = attacker == null ? 0 : attacker.mUnit.ID;
|
|
|
+ evt.senderMasterId = hitted.GetMasterID();
|
|
|
+ evt.hitMasterId = attacker == null ? 0 : attacker.GetMasterID();
|
|
|
+ evt.client_state = (byte)XmdsCommonServer.Plugin.XmdsVirtual.UnitHitEventState.Absorb;
|
|
|
+ hitted.mUnit.queueEvent(evt);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|