|
@@ -304,65 +304,63 @@ namespace XmdsCommonServer.Plugin.Units
|
|
|
|
|
|
public override void guard()
|
|
|
{
|
|
|
- #region 遍历可使用的技能,以技能目标类型作为搜寻条件.
|
|
|
-
|
|
|
- if (IsNoneSkill == false)
|
|
|
+ if (IsNoneSkill)
|
|
|
{
|
|
|
- SkillState ret = GetAvailableSkillExceptDefaultSkill();
|
|
|
+ mTracingTarget = null;
|
|
|
+ base.startIdle();
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- if (ret != null && this.Info.GuardRange > 0)
|
|
|
+ if (this.Info.GuardRange > 0)
|
|
|
+ {
|
|
|
+ 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) =>
|
|
|
{
|
|
|
- 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) =>
|
|
|
+ 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 (len > guardRangSqua)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- if (!Parent.IsAttackable(this, u, ret.Data.ExpectTarget, AttackReason.Look, Info))
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
+ if (!Parent.IsAttackable(this, u, SkillTemplate.CastTarget.Enemy, AttackReason.Look, Info))
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- if (u.Info.Properties is XmdsUnitProperties prop && prop.GameStatusType > XmdsUnitProperties.StatusType.Normal)
|
|
|
+ if (u.Info.Properties is XmdsUnitProperties prop && prop.GameStatusType > XmdsUnitProperties.StatusType.Normal)
|
|
|
+ {
|
|
|
+ if (isSpecial)
|
|
|
{
|
|
|
- if (isSpecial)
|
|
|
- {
|
|
|
- if (len < min_len)
|
|
|
- {
|
|
|
- min = u;
|
|
|
- min_len = len;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
+ if (len < min_len)
|
|
|
{
|
|
|
min = u;
|
|
|
min_len = len;
|
|
|
- isSpecial = true;
|
|
|
}
|
|
|
}
|
|
|
- else if (!isSpecial && min_len > len)
|
|
|
+ else
|
|
|
{
|
|
|
- min_len = len;
|
|
|
min = u;
|
|
|
+ min_len = len;
|
|
|
+ isSpecial = true;
|
|
|
}
|
|
|
- });
|
|
|
-
|
|
|
- if (min != null)
|
|
|
+ }
|
|
|
+ else if (!isSpecial && min_len > len)
|
|
|
{
|
|
|
- changeState(new StateFollowAndAttack(this, min, ret.Data.ExpectTarget));
|
|
|
- return;
|
|
|
+ min_len = len;
|
|
|
+ min = u;
|
|
|
}
|
|
|
+ });
|
|
|
+
|
|
|
+ if (min != null)
|
|
|
+ {
|
|
|
+ changeState(new StateFollowAndAttack(this, min, SkillTemplate.CastTarget.Enemy));
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- #endregion
|
|
|
-
|
|
|
+
|
|
|
base.guard();
|
|
|
}
|
|
|
|
|
@@ -410,22 +408,28 @@ namespace XmdsCommonServer.Plugin.Units
|
|
|
protected override void onAddEnemy(InstanceUnit target, bool group, AttackReason reason)
|
|
|
{
|
|
|
var state = CurrentState;
|
|
|
+ InstanceUnit nowTarget = null;
|
|
|
if (state is StateFollowAndAttack attackstate)
|
|
|
{
|
|
|
- //当前正在追踪一个价值更高的目标时,不理会小啰啰的攻击
|
|
|
- var tar = attackstate.TargetUnit;
|
|
|
- if (tar != null && tar.Info.Properties is XmdsUnitProperties prop && prop.GameStatusType > XmdsUnitProperties.StatusType.Normal)
|
|
|
+ nowTarget = attackstate.TargetUnit;
|
|
|
+ }
|
|
|
+ else if(state is StateSkill skillstate)
|
|
|
+ {
|
|
|
+ nowTarget = skillstate.TargetUnit;
|
|
|
+ }
|
|
|
+
|
|
|
+ //当前正在追踪/攻击一个价值更高的目标时,不理会小啰啰的攻击
|
|
|
+ if (nowTarget != null && nowTarget.Info.Properties is XmdsUnitProperties prop && prop.GameStatusType > XmdsUnitProperties.StatusType.Normal)
|
|
|
+ {
|
|
|
+ if(target.Info.Properties is XmdsUnitProperties propnew && propnew.GameStatusType > prop.GameStatusType)
|
|
|
{
|
|
|
- if(target.Info.Properties is XmdsUnitProperties propnew && propnew.GameStatusType > prop.GameStatusType)
|
|
|
- {
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
base.onAddEnemy(target, group, reason);
|
|
|
}
|
|
|
}
|