All pastes #404690 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-03-21 04:50 UTC
rendered paste body
        public void PlotBox()
        {
            string RegionName;
            int Degrees = 0;
            double Distance = (MaximumBoxSize / 2) + 1;
            double X1, X2, Y1, Y2, Z1, Z2;
            LavishScriptAPI.Point3f Location = Bytebot.Global.WoW.Me.Location;
            LavishScriptAPI.Point3f CollisionPoint;
            double X, Y;


            Z1 = Location.Z;
            Z2 = Location.Z + KneeHeight;
            do
            {
                do
                {
                    X = Location.X + (MaximumBoxSize / 2) * Math.Cos(Degrees);
                    Y = Location.Y - (MaximumBoxSize / 2) * Math.Sin(Degrees);

                    CollisionPoint = Bytebot.Global.WoW.IsPathObstructed(Location.X,Location.Y,Z2,X,Y,Z2);
                    if (CollisionPoint != null)
                    {
                        if (Bytebot.Global.Distance(Location.X, Location.Y, Z2, CollisionPoint.X, CollisionPoint.Y, Z2) < Distance)
                        {
                            Distance = Bytebot.Global.Distance(Location.X, Location.Y, Z2, CollisionPoint.X, CollisionPoint.Y, Z2);
                        }
                    }

                    Degrees = Degrees + 30;
                }
                while (Degrees <= 360);
                Z2 = Z2 + 1;
            }
            while (Bytebot.Global.Distance(Location.X,Location.Y,Location.Z,Location.X,Location.Y,Z2) <= 2);

            X1 = Location.X - Distance;
            Y1 = Location.Y - Distance;
            X2 = Location.X + Distance;
            Y2 = Location.Y + Distance;
            Z1 = Location.Z - KneeHeight;

            // Z handling is terrible but it's there. Improve when time.

            RegionName = string.Format("R{0}",SubZone.ChildCount);
            Bytebot.Global.Debug(string.Format("Added {0} Size: {1}",RegionName,(Distance * 2)));
            SubZone.AddBox(RegionName, X1, X2, Y1, Y2, Z1, Z2, 0);
            Save();
        }