|
@@ -314,17 +314,43 @@ namespace XmdsCommonServer.Plugin.Units
|
|
|
{
|
|
|
InstanceUnit min = null;
|
|
|
float min_len = float.MaxValue;
|
|
|
+ bool isSpecial = false;
|
|
|
+ float guardRangSqua = mGuardRange * mGuardRange;
|
|
|
Parent.ForEachNearObjects(this.X, this.Y, this.Info.GuardRange, (InstanceUnit u, ref bool cancel) =>
|
|
|
{
|
|
|
- if (Parent.IsAttackable(this, u, ret.Data.ExpectTarget, AttackReason.Look, Info))
|
|
|
+ float len = MathVector.getDistanceSquare(u.X, u.Y, this.X, this.Y);
|
|
|
+ if (len > guardRangSqua)
|
|
|
{
|
|
|
- float len = MathVector.getDistanceSquare(u.X, u.Y, this.X, this.Y);
|
|
|
- if (min_len > len && len < this.Info.GuardRange)
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!Parent.IsAttackable(this, u, ret.Data.ExpectTarget, AttackReason.Look, Info))
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (u.Info.Properties is XmdsUnitProperties prop && prop.GameStatusType > XmdsUnitProperties.StatusType.Normal)
|
|
|
+ {
|
|
|
+ if (isSpecial)
|
|
|
+ {
|
|
|
+ if (len < min_len)
|
|
|
+ {
|
|
|
+ min = u;
|
|
|
+ min_len = len;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- min_len = len;
|
|
|
min = u;
|
|
|
+ min_len = len;
|
|
|
+ isSpecial = true;
|
|
|
}
|
|
|
}
|
|
|
+ else if (!isSpecial && min_len > len)
|
|
|
+ {
|
|
|
+ min_len = len;
|
|
|
+ min = u;
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
if (min != null)
|
|
@@ -380,5 +406,27 @@ namespace XmdsCommonServer.Plugin.Units
|
|
|
{
|
|
|
(this.Virtual as XmdsVirtual_Monster).onBack2PositionEnd();
|
|
|
}
|
|
|
+
|
|
|
+ protected override void onAddEnemy(InstanceUnit target, bool group, AttackReason reason)
|
|
|
+ {
|
|
|
+ var state = CurrentState;
|
|
|
+ if (state is StateFollowAndAttack attackstate)
|
|
|
+ {
|
|
|
+ //当前正在追踪一个价值更高的目标时,不理会小啰啰的攻击
|
|
|
+ var tar = attackstate.TargetUnit;
|
|
|
+ if (tar != null && tar.Info.Properties is XmdsUnitProperties prop && prop.GameStatusType > XmdsUnitProperties.StatusType.Normal)
|
|
|
+ {
|
|
|
+ if(target.Info.Properties is XmdsUnitProperties propnew && propnew.GameStatusType > prop.GameStatusType)
|
|
|
+ {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ base.onAddEnemy(target, group, reason);
|
|
|
+ }
|
|
|
}
|
|
|
}
|