public virtual void UpdateFollow() { if (FollowTarget == null) { return; } if (CurrentSpeed != 0) { return; } float Pct = FollowTarget.CbtInterface.GetFollowPct(Obj.Oid); int Id = FollowTarget.CbtInterface.GetFollowId(Obj.Oid); int Dist = Obj.GetDistanceTo(FollowTarget); Point3D NewPos = new Point3D(0, 0, 0); UInt16 NewHead = 0; switch (Formation) { case eFormationType.Line: { int MinDist = Id * FollowMinDist; int MaxDist = MinDist + (FollowMaxDist - FollowMinDist); if (!Obj.IsObjectInFront(FollowTarget, 10)) { TurnTo(FollowTarget, true); } if (Dist >= MaxDist) { Point2D Tp = FollowTarget.GetBackPoint(FollowTarget.Heading, MinDist); NewPos.X = Tp.X; NewPos.Y = Tp.Y; NewPos.Z = FollowTarget.Z; } break; } case eFormationType.Protect: { if (!Obj.IsObjectInFront(FollowTarget, 10)) { TurnTo(FollowTarget, true); } if (Dist > FollowMaxDist) { Point2D Tp = FollowTarget.GetPointFromHeading((ushort)((float)4096 - ((float)4096 / (float)100 * Pct)), FollowMinDist); NewPos.X = Tp.X; NewPos.Y = Tp.Y; NewPos.Z = FollowTarget.Z; } } break; } if (NewPos.X != 0 || NewPos.Y != 0 || NewPos.Z != 0) { WalkTo(NewPos, FollowSpeed); } else if (NewHead != 0) { TurnTo(NewHead, true); } }