Esempio n. 1
0
        public void Update(double totalTime, double frameTime)
        {
            if (_timer < Time.Ticks)
            {
                _timer = Time.Ticks + 1000;

                if (_actions.Count == 0)
                {
                    return;
                }

                uint serial = _actions.RemoveFromFront();

                if (World.Get(serial) != null)
                {
                    if (SerialHelper.IsMobile(serial))
                    {
                        GameActions.OpenPaperdoll(serial);
                    }
                    else
                    {
                        GameActions.DoubleClick(serial);
                    }
                }
            }
        }
Esempio n. 2
0
        public static bool IsAllowed(Entity serial)
        {
            if (serial == null)
            {
                return(false);
            }

            if (TypeAllowed == NameOverheadTypeAllowed.All)
            {
                return(true);
            }

            if (SerialHelper.IsItem(serial.Serial) && TypeAllowed == NameOverheadTypeAllowed.Items)
            {
                return(true);
            }

            if (SerialHelper.IsMobile(serial.Serial) && TypeAllowed.HasFlag(NameOverheadTypeAllowed.Mobiles))
            {
                return(true);
            }

            if (TypeAllowed.HasFlag(NameOverheadTypeAllowed.Corpses) && SerialHelper.IsItem(serial.Serial) && World.Items.Get(serial)?.IsCorpse == true)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 3
0
            public override void Update(double totalMS, double frameMS)
            {
                base.Update(totalMS, frameMS);

                if (SerialHelper.IsMobile(LocalSerial))
                {
                    ushort hue = Hue;
                    GetMobileAnimationDirection(Graphic, ref hue, 1).LastAccessTime = Time.Ticks;
                }
            }
Esempio n. 4
0
 public void MergeHeldItem(Entity container)
 {
     if (ItemHold.Enabled && ItemHold.Serial != container)
     {
         if (SerialHelper.IsMobile(container.Serial))
         {
             GameActions.DropItem(ItemHold.Serial, 0xFFFF, 0xFFFF, 0, container.Serial);
         }
         else if (SerialHelper.IsItem(container.Serial))
         {
             GameActions.DropItem(ItemHold.Serial, container.X, container.Y, container.Z, container.Serial);
         }
     }
 }
Esempio n. 5
0
            public override void Update(double totalTime, double frameTime)
            {
                base.Update(totalTime, frameTime);

                if (SerialHelper.IsMobile(LocalSerial))
                {
                    ushort             hue = Hue;
                    AnimationDirection dir = GetMobileAnimationDirection(Graphic, ref hue, 1);

                    if (dir != null)
                    {
                        dir.LastAccessTime = Time.Ticks;
                    }
                }
            }
        private static void SetPositionNearGameObject(ushort g, uint serial, int width, int height)
        {
            Item item = World.Items.Get(serial);

            if (item == null)
            {
                return;
            }

            Item bank = World.Player.FindItemByLayer(Layer.Bank);

            if (bank != null && serial == bank)
            {
                // open bank near player
                X = World.Player.RealScreenPosition.X + ProfileManager.CurrentProfile.GameWindowPosition.X + 40;
                Y = World.Player.RealScreenPosition.Y + ProfileManager.CurrentProfile.GameWindowPosition.Y - (height >> 1);
            }
            else if (item.OnGround)
            {
                // item is in world
                X = item.RealScreenPosition.X + ProfileManager.CurrentProfile.GameWindowPosition.X + 40;
                Y = item.RealScreenPosition.Y + ProfileManager.CurrentProfile.GameWindowPosition.Y - (height >> 1);
            }
            else if (SerialHelper.IsMobile(item.Container))
            {
                // pack animal, snooped player, npc vendor
                Mobile mobile = World.Mobiles.Get(item.Container);

                if (mobile != null)
                {
                    X = mobile.RealScreenPosition.X + ProfileManager.CurrentProfile.GameWindowPosition.X + 40;
                    Y = mobile.RealScreenPosition.Y + ProfileManager.CurrentProfile.GameWindowPosition.Y - (height >> 1);
                }
            }
            else
            {
                // in a container, open near the container
                ContainerGump parentContainer = UIManager.GetGump <ContainerGump>(item.Container);

                if (parentContainer != null)
                {
                    X = parentContainer.X + (width >> 1);
                    Y = parentContainer.Y;
                }
            }
        }
Esempio n. 7
0
        public static void Target(uint serial)
        {
            if (!IsTargeting)
            {
                return;
            }

            Entity entity = World.InGame ? World.Get(serial) : null;

            if (entity != null)
            {
                switch (TargetingState)
                {
                case CursorTarget.Invalid:
                    return;

                case CursorTarget.MultiPlacement:
                case CursorTarget.Position:
                case CursorTarget.Object:
                case CursorTarget.HueCommandTarget:
                case CursorTarget.SetTargetClientSide:

                    if (entity != World.Player)
                    {
                        LastTargetInfo.SetEntity(serial);
                    }

                    if (SerialHelper.IsMobile(serial) && serial != World.Player &&
                        (World.Player.NotorietyFlag == NotorietyFlag.Innocent || World.Player.NotorietyFlag == NotorietyFlag.Ally))
                    {
                        Mobile mobile = entity as Mobile;

                        if (mobile != null)
                        {
                            bool showCriminalQuery = false;

                            if (TargetingType == TargetType.Harmful && ProfileManager.Current.EnabledCriminalActionQuery && mobile.NotorietyFlag == NotorietyFlag.Innocent)
                            {
                                showCriminalQuery = true;
                            }
                            else if (TargetingType == TargetType.Beneficial && ProfileManager.Current.EnabledBeneficialCriminalActionQuery &&
                                     (mobile.NotorietyFlag == NotorietyFlag.Criminal || mobile.NotorietyFlag == NotorietyFlag.Murderer || mobile.NotorietyFlag == NotorietyFlag.Gray))
                            {
                                showCriminalQuery = true;
                            }

                            if (showCriminalQuery)
                            {
                                QuestionGump messageBox = new QuestionGump("This may flag\nyou criminal!",
                                                                           s =>
                                {
                                    if (s)
                                    {
                                        NetClient.Socket.Send(new PTargetObject(entity, entity.Graphic, entity.X, entity.Y, entity.Z, _targetCursorId, (byte)TargetingType));
                                        ClearTargetingWithoutTargetCancelPacket();
                                    }
                                });

                                UIManager.Add(messageBox);

                                return;
                            }
                        }
                    }

                    if (TargetingState != CursorTarget.SetTargetClientSide)
                    {
                        var packet = new PTargetObject(entity, entity.Graphic, entity.X, entity.Y, entity.Z, _targetCursorId, (byte)TargetingType);

                        for (int i = 0; i < _lastDataBuffer.Length; i++)
                        {
                            _lastDataBuffer[i] = packet[i];
                        }

                        NetClient.Socket.Send(packet);
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    Mouse.CancelDoubleClick = true;
                    break;

                case CursorTarget.Grab:

                    if (SerialHelper.IsItem(serial))
                    {
                        GameActions.GrabItem(serial, ((Item)entity).Amount);
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                case CursorTarget.SetGrabBag:

                    if (SerialHelper.IsItem(serial))
                    {
                        ProfileManager.Current.GrabBagSerial = serial;
                        GameActions.Print($"Grab Bag set: {serial}");
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;
                }
            }
        }
Esempio n. 8
0
        public void Draw(UltimaBatcher2D batcher, float scale)
        {
            int screenX = ProfileManager.Current.GameWindowPosition.X;
            int screenY = ProfileManager.Current.GameWindowPosition.Y;
            int screenW = ProfileManager.Current.GameWindowSize.X;
            int screenH = ProfileManager.Current.GameWindowSize.Y;

            if (SerialHelper.IsMobile(TargetManager.LastTargetInfo.Serial))
            {
                DrawHealthLineWithMath(batcher, TargetManager.LastTargetInfo.Serial, screenX, screenY, screenW, screenH, scale);
            }
            if (SerialHelper.IsMobile(TargetManager.SelectedTarget))
            {
                DrawHealthLineWithMath(batcher, TargetManager.SelectedTarget, screenX, screenY, screenW, screenH, scale);
            }
            if (SerialHelper.IsMobile(TargetManager.LastAttack))
            {
                DrawHealthLineWithMath(batcher, TargetManager.LastAttack, screenX, screenY, screenW, screenH, scale);
            }

            if (!IsEnabled)
            {
                return;
            }


            int mode = ProfileManager.Current.MobileHPType;

            if (mode < 0)
            {
                return;
            }

            int showWhen = ProfileManager.Current.MobileHPShowWhen;

            foreach (Mobile mobile in World.Mobiles)
            {
                //if (World.Party.Contains(mobile) && mobile.Tile == null)
                //    continue;

                if (mobile.IsDestroyed)
                {
                    continue;
                }

                int current = mobile.Hits;
                int max     = mobile.HitsMax;

                if (showWhen == 1 && current == max)
                {
                    continue;
                }

                int x = screenX + mobile.RealScreenPosition.X;
                int y = screenY + mobile.RealScreenPosition.Y;

                x += (int)mobile.Offset.X + 22;
                y += (int)(mobile.Offset.Y - mobile.Offset.Z) + 22;

                x  = (int)(x / scale);
                y  = (int)(y / scale);
                x -= (int)(screenX / scale);
                y -= (int)(screenY / scale);
                x += screenX;
                y += screenY;

                x += 5;
                y += 5;

                x -= BAR_WIDTH_HALF;
                y -= BAR_HEIGHT_HALF;

                if (mode != 1 && !mobile.IsDead)
                {
                    if ((showWhen == 2 && current != max) || showWhen <= 1)
                    {
                        int xx = x;
                        int yy = y;

                        if (mobile.IsGargoyle && mobile.IsFlying)
                        {
                            yy -= (int)(22 / scale);
                        }
                        else if (!mobile.IsMounted)
                        {
                            yy += (int)(22 / scale);
                        }


                        AnimationsLoader.Instance.GetAnimationDimensions(mobile.AnimIndex,
                                                                         mobile.GetGraphicForAnimation(),
                                                                         /*(byte) m.GetDirectionForAnimation()*/ 0,
                                                                         /*Mobile.GetGroupForAnimation(m, isParent:true)*/ 0,
                                                                         mobile.IsMounted,
                                                                         /*(byte) m.AnimIndex*/ 0,
                                                                         out int centerX,
                                                                         out int centerY,
                                                                         out int width,
                                                                         out int height);


                        yy -= (int)((height + centerY + 28) / scale);



                        if (mobile.HitsPercentage != 0)
                        {
                            xx -= (mobile.HitsTexture.Width >> 1) + 3;
                            xx += 22;
                            yy -= mobile.HitsTexture.Height / 1;
                            if (mobile.ObjectHandlesOpened)
                            {
                                yy -= 22;
                            }

                            if (!(xx < screenX || xx > screenX + screenW - mobile.HitsTexture.Width || yy < screenY || yy > screenY + screenH))
                            {
                                mobile.HitsTexture.Draw(batcher, xx, yy);
                            }
                        }
                    }
                }

                if (x < screenX || x > screenX + screenW - BAR_WIDTH)
                {
                    continue;
                }

                if (y < screenY || y > screenY + screenH - BAR_HEIGHT)
                {
                    continue;
                }

                if (mode >= 1 && TargetManager.LastTargetInfo.Serial != mobile)
                {
                    // already done
                    if (mobile == TargetManager.LastTargetInfo.Serial ||
                        mobile == TargetManager.SelectedTarget ||
                        mobile == TargetManager.LastAttack)
                    {
                        continue;
                    }


                    DrawHealthLine(batcher, mobile, x, y, mobile != World.Player);
                }
            }
        }
Esempio n. 9
0
        public void Draw(UltimaBatcher2D batcher)
        {
            int screenW = ProfileManager.CurrentProfile.GameWindowSize.X;
            int screenH = ProfileManager.CurrentProfile.GameWindowSize.Y;

            if (SerialHelper.IsMobile(TargetManager.LastTargetInfo.Serial))
            {
                DrawHealthLineWithMath(batcher, TargetManager.LastTargetInfo.Serial, screenW, screenH);
            }

            if (SerialHelper.IsMobile(TargetManager.SelectedTarget))
            {
                DrawHealthLineWithMath(batcher, TargetManager.SelectedTarget, screenW, screenH);
            }

            if (SerialHelper.IsMobile(TargetManager.LastAttack))
            {
                DrawHealthLineWithMath(batcher, TargetManager.LastAttack, screenW, screenH);
            }

            if (!IsEnabled)
            {
                return;
            }

            int mode = ProfileManager.CurrentProfile.MobileHPType;

            if (mode < 0)
            {
                return;
            }

            int showWhen = ProfileManager.CurrentProfile.MobileHPShowWhen;

            foreach (Mobile mobile in World.Mobiles.Values)
            {
                if (mobile.IsDestroyed)
                {
                    continue;
                }

                int current = mobile.Hits;
                int max     = mobile.HitsMax;

                if (max == 0)
                {
                    continue;
                }

                if (showWhen == 1 && current == max)
                {
                    continue;
                }

                Point p = mobile.RealScreenPosition;
                p.X += (int)mobile.Offset.X + 22 + 5;
                p.Y += (int)(mobile.Offset.Y - mobile.Offset.Z) + 22 + 5;


                if (mode != 1 && !mobile.IsDead)
                {
                    if (showWhen == 2 && current != max || showWhen <= 1)
                    {
                        if (mobile.HitsPercentage != 0)
                        {
                            AnimationsLoader.Instance.GetAnimationDimensions
                            (
                                mobile.AnimIndex,
                                mobile.GetGraphicForAnimation(),
                                /*(byte) m.GetDirectionForAnimation()*/
                                0,
                                /*Mobile.GetGroupForAnimation(m, isParent:true)*/
                                0,
                                mobile.IsMounted,
                                /*(byte) m.AnimIndex*/
                                0,
                                out int centerX,
                                out int centerY,
                                out int width,
                                out int height
                            );

                            Point p1 = p;
                            p1.Y -= height + centerY + 8 + 22;

                            if (mobile.IsGargoyle && mobile.IsFlying)
                            {
                                p1.Y -= 22;
                            }
                            else if (!mobile.IsMounted)
                            {
                                p1.Y += 22;
                            }

                            p1    = Client.Game.Scene.Camera.WorldToScreen(p1);
                            p1.X -= (mobile.HitsTexture.Width >> 1) + 5;
                            p1.Y -= mobile.HitsTexture.Height;

                            if (mobile.ObjectHandlesStatus == ObjectHandlesStatus.DISPLAYING)
                            {
                                p1.Y -= Constants.OBJECT_HANDLES_GUMP_HEIGHT + 5;
                            }

                            if (!(p1.X < 0 || p1.X > screenW - mobile.HitsTexture.Width || p1.Y < 0 || p1.Y > screenH))
                            {
                                mobile.HitsTexture.Draw(batcher, p1.X, p1.Y);
                            }
                        }
                    }
                }

                if (mobile.Serial == TargetManager.LastTargetInfo.Serial || mobile.Serial == TargetManager.SelectedTarget || mobile.Serial == TargetManager.LastAttack)
                {
                    continue;
                }

                p.X -= 5;
                p    = Client.Game.Scene.Camera.WorldToScreen(p);
                p.X -= BAR_WIDTH_HALF;
                p.Y -= BAR_HEIGHT_HALF;

                if (p.X < 0 || p.X > screenW - BAR_WIDTH)
                {
                    continue;
                }

                if (p.Y < 0 || p.Y > screenH - BAR_HEIGHT)
                {
                    continue;
                }

                if (mode >= 1)
                {
                    DrawHealthLine
                    (
                        batcher,
                        mobile,
                        p.X,
                        p.Y,
                        mobile.Serial != World.Player.Serial
                    );
                }
            }
        }
Esempio n. 10
0
            public ShopItem
            (
                uint serial,
                ushort graphic,
                ushort hue,
                int count,
                uint price,
                string name
            )
            {
                LocalSerial = serial;
                Graphic     = graphic;
                Hue         = hue;
                Price       = price;
                Name        = name;

                Add
                (
                    new ResizePicLine(0x39)
                {
                    X     = 10,
                    Width = 190
                }
                );

                int offY = 15;

                string itemName = StringHelper.CapitalizeAllWords(Name);

                TextureControl control;

                if (SerialHelper.IsMobile(LocalSerial))
                {
                    ushort             hue2      = Hue;
                    AnimationDirection direction = GetMobileAnimationDirection(Graphic, ref hue2, 1);

                    Add
                    (
                        control = new TextureControl
                    {
                        Texture          = direction != null ? direction.FrameCount != 0 ? direction.Frames[0] : null : null,
                        X                = 5,
                        Y                = 5 + offY,
                        AcceptMouseInput = false,
                        Hue              = Hue == 0 ? hue2 : Hue,
                        IsPartial        = TileDataLoader.Instance.StaticData[Graphic].IsPartialHue
                    }
                    );

                    if (control.Texture != null)
                    {
                        control.Width  = control.Texture.Width;
                        control.Height = control.Texture.Height;
                    }
                    else
                    {
                        control.Width  = 35;
                        control.Height = 35;
                    }

                    if (control.Width > 35)
                    {
                        control.Width = 35;
                    }

                    if (control.Height > 35)
                    {
                        control.Height = 35;
                    }
                }
                else if (SerialHelper.IsItem(LocalSerial))
                {
                    ArtTexture texture = ArtLoader.Instance.GetTexture(Graphic);

                    Add
                    (
                        control = new TextureControl
                    {
                        Texture          = texture,
                        X                = 10 - texture?.ImageRectangle.X ?? 0,
                        Y                = 5 + offY + texture?.ImageRectangle.Y ?? 0,
                        Width            = texture?.ImageRectangle.Width ?? 0,
                        Height           = texture?.ImageRectangle.Height ?? 0,
                        AcceptMouseInput = false,
                        ScaleTexture     = false,
                        Hue              = Hue,
                        IsPartial        = TileDataLoader.Instance.StaticData[Graphic].IsPartialHue
                    }
                    );
                }
                else
                {
                    return;
                }

                string subname = string.Format(ResGumps.Item0Price1, itemName, Price);

                Add
                (
                    _name = new Label(subname, true, 0x219, 110, 1, FontStyle.None, TEXT_ALIGN_TYPE.TS_LEFT, true)
                {
                    X = 55,
                    Y = offY
                }
                );

                int height = Math.Max(_name.Height, control.Height) + 10;

                Add
                (
                    _amountLabel = new Label
                                       (count.ToString(), true, 0x0219, 35, 1, FontStyle.None, TEXT_ALIGN_TYPE.TS_RIGHT)
                {
                    X = 168,
                    Y = offY + (height >> 2)
                }
                );

                Width  = 220;
                Height = Math.Max(50, height);

                WantUpdateSize = false;

                if (World.ClientFeatures.TooltipsEnabled)
                {
                    SetTooltip(LocalSerial);
                }

                Amount = count;
            }
Esempio n. 11
0
        public static void Target(uint serial)
        {
            if (!IsTargeting)
            {
                return;
            }

            Entity entity = World.InGame ? World.Get(serial) : null;

            if (entity != null)
            {
                switch (TargetingState)
                {
                case CursorTarget.Invalid: return;

                case CursorTarget.MultiPlacement:
                case CursorTarget.Position:
                case CursorTarget.Object:
                case CursorTarget.HueCommandTarget:
                case CursorTarget.SetTargetClientSide:

                    if (entity != World.Player)
                    {
                        LastTargetInfo.SetEntity(serial);
                    }

                    if (SerialHelper.IsMobile(serial) && serial != World.Player && (World.Player.NotorietyFlag == NotorietyFlag.Innocent || World.Player.NotorietyFlag == NotorietyFlag.Ally))
                    {
                        Mobile mobile = entity as Mobile;

                        if (mobile != null)
                        {
                            bool showCriminalQuery = false;

                            if (TargetingType == TargetType.Harmful && ProfileManager.CurrentProfile.EnabledCriminalActionQuery && mobile.NotorietyFlag == NotorietyFlag.Innocent)
                            {
                                showCriminalQuery = true;
                            }
                            else if (TargetingType == TargetType.Beneficial && ProfileManager.CurrentProfile.EnabledBeneficialCriminalActionQuery && (mobile.NotorietyFlag == NotorietyFlag.Criminal || mobile.NotorietyFlag == NotorietyFlag.Murderer || mobile.NotorietyFlag == NotorietyFlag.Gray))
                            {
                                showCriminalQuery = true;
                            }

                            if (showCriminalQuery && UIManager.GetGump <QuestionGump>() == null)
                            {
                                QuestionGump messageBox = new QuestionGump
                                                          (
                                    "This may flag\nyou criminal!",
                                    s =>
                                {
                                    if (s)
                                    {
                                        NetClient.Socket.Send_TargetObject(entity,
                                                                           entity.Graphic,
                                                                           entity.X,
                                                                           entity.Y,
                                                                           entity.Z,
                                                                           _targetCursorId,
                                                                           (byte)TargetingType);

                                        ClearTargetingWithoutTargetCancelPacket();

                                        if (LastTargetInfo.Serial != serial)
                                        {
                                            GameActions.RequestMobileStatus(serial);
                                        }
                                    }
                                }
                                                          );

                                UIManager.Add(messageBox);

                                return;
                            }
                        }
                    }

                    if (TargetingState != CursorTarget.SetTargetClientSide)
                    {
                        _lastDataBuffer[0] = 0x6C;

                        _lastDataBuffer[1] = 0x00;

                        _lastDataBuffer[2] = (byte)(_targetCursorId >> 24);
                        _lastDataBuffer[3] = (byte)(_targetCursorId >> 16);
                        _lastDataBuffer[4] = (byte)(_targetCursorId >> 8);
                        _lastDataBuffer[5] = (byte)_targetCursorId;

                        _lastDataBuffer[6] = (byte)TargetingType;

                        _lastDataBuffer[7]  = (byte)(entity.Serial >> 24);
                        _lastDataBuffer[8]  = (byte)(entity.Serial >> 16);
                        _lastDataBuffer[9]  = (byte)(entity.Serial >> 8);
                        _lastDataBuffer[10] = (byte)entity.Serial;

                        _lastDataBuffer[11] = (byte)(entity.X >> 8);
                        _lastDataBuffer[12] = (byte)entity.X;

                        _lastDataBuffer[13] = (byte)(entity.Y >> 8);
                        _lastDataBuffer[14] = (byte)entity.Y;

                        _lastDataBuffer[15] = (byte)(entity.Z >> 8);
                        _lastDataBuffer[16] = (byte)entity.Z;

                        _lastDataBuffer[17] = (byte)(entity.Graphic >> 8);
                        _lastDataBuffer[18] = (byte)entity.Graphic;


                        NetClient.Socket.Send_TargetObject(entity,
                                                           entity.Graphic,
                                                           entity.X,
                                                           entity.Y,
                                                           entity.Z,
                                                           _targetCursorId,
                                                           (byte)TargetingType);

                        if (SerialHelper.IsMobile(serial) && LastTargetInfo.Serial != serial)
                        {
                            GameActions.RequestMobileStatus(serial);
                        }
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    Mouse.CancelDoubleClick = true;

                    break;

                case CursorTarget.Grab:

                    if (SerialHelper.IsItem(serial))
                    {
                        GameActions.GrabItem(serial, ((Item)entity).Amount);
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                case CursorTarget.SetGrabBag:

                    if (SerialHelper.IsItem(serial))
                    {
                        ProfileManager.CurrentProfile.GrabBagSerial = serial;
                        GameActions.Print(string.Format(ResGeneral.GrabBagSet0, serial));
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                case CursorTarget.IgnorePlayerTarget:
                    if (SelectedObject.Object is Entity pmEntity)
                    {
                        IgnoreManager.AddIgnoredTarget(pmEntity);
                    }
                    CancelTarget();
                    return;
                }
            }
        }
Esempio n. 12
0
        public void Draw(UltimaBatcher2D batcher, float scale)
        {
            int screenX = ProfileManager.Current.GameWindowPosition.X;
            int screenY = ProfileManager.Current.GameWindowPosition.Y;
            int screenW = ProfileManager.Current.GameWindowSize.X;
            int screenH = ProfileManager.Current.GameWindowSize.Y;

            if (SerialHelper.IsMobile(TargetManager.LastTarget))
            {
                DrawHealthLineWithMath(batcher, TargetManager.LastTarget, screenX, screenY, screenW, screenH, scale);
            }
            if (SerialHelper.IsMobile(TargetManager.SelectedTarget))
            {
                DrawHealthLineWithMath(batcher, TargetManager.SelectedTarget, screenX, screenY, screenW, screenH, scale);
            }
            if (SerialHelper.IsMobile(TargetManager.LastAttack))
            {
                DrawHealthLineWithMath(batcher, TargetManager.LastAttack, screenX, screenY, screenW, screenH, scale);
            }

            if (!IsEnabled)
            {
                return;
            }


            //Color color;

            int mode = ProfileManager.Current.MobileHPType;

            if (mode < 0)
            {
                return;
            }

            int showWhen = ProfileManager.Current.MobileHPShowWhen;

            foreach (Mobile mobile in World.Mobiles)
            {
                //if (World.Party.Contains(mobile) && mobile.Tile == null)
                //    continue;

                int current = mobile.Hits;
                int max     = mobile.HitsMax;

                if (showWhen == 1 && current == max)
                {
                    continue;
                }

                int x = screenX + mobile.RealScreenPosition.X;
                int y = screenY + mobile.RealScreenPosition.Y;

                x += (int)mobile.Offset.X + 22;
                y += (int)(mobile.Offset.Y - mobile.Offset.Z) + 22;

                x  = (int)(x / scale);
                y  = (int)(y / scale);
                x -= (int)(screenX / scale);
                y -= (int)(screenY / scale);
                x += screenX;
                y += screenY;

                x += 5;
                y += 5;

                x -= BAR_WIDTH_HALF;
                y -= BAR_HEIGHT_HALF;

                if (mode != 1 && !mobile.IsDead)
                {
                    if ((showWhen == 2 && current != max) || showWhen <= 1)
                    {
                        int xx = x;
                        int yy = y;

                        if (mobile.IsGargoyle && mobile.IsFlying)
                        {
                            yy -= (int)(22 / scale);
                        }
                        else if (!mobile.IsMounted)
                        {
                            yy += (int)(22 / scale);
                        }


                        AnimationsLoader.Instance.GetAnimationDimensions(mobile.AnimIndex,
                                                                         mobile.GetGraphicForAnimation(),
                                                                         /*(byte) m.GetDirectionForAnimation()*/ 0,
                                                                         /*Mobile.GetGroupForAnimation(m, isParent:true)*/ 0,
                                                                         mobile.IsMounted,
                                                                         /*(byte) m.AnimIndex*/ 0,
                                                                         out int centerX,
                                                                         out int centerY,
                                                                         out int width,
                                                                         out int height);


                        yy -= (int)((height + centerY + 28) / scale);


                        int ww = mobile.HitsMax;

                        if (ww > 0)
                        {
                            ww = mobile.Hits * 100 / ww;

                            if (ww > 100)
                            {
                                ww = 100;
                            }
                            else if (ww < 1)
                            {
                                ww = 0;
                            }

                            mobile.UpdateHits((byte)ww);
                        }

                        if (mobile.HitsPercentage != 0)
                        {
                            xx -= (mobile.HitsTexture.Width >> 1) + 3;
                            xx += 22;
                            yy -= mobile.HitsTexture.Height / 1;
                            if (mobile.ObjectHandlesOpened)
                            {
                                yy -= 22;
                            }

                            if (!(xx < screenX || xx > screenX + screenW - mobile.HitsTexture.Width || yy < screenY || yy > screenY + screenH))
                            {
                                mobile.HitsTexture.Draw(batcher, xx, yy);
                            }
                        }
                    }
                }

                if (x < screenX || x > screenX + screenW - BAR_WIDTH)
                {
                    continue;
                }

                if (y < screenY || y > screenY + screenH - BAR_HEIGHT)
                {
                    continue;
                }

                if (mode >= 1 && TargetManager.LastTarget != mobile)
                {
                    // already done
                    if (mobile == TargetManager.LastTarget ||
                        mobile == TargetManager.SelectedTarget ||
                        mobile == TargetManager.LastAttack)
                    {
                        continue;
                    }

                    DrawHealthLine(batcher, mobile, x, y, mobile != World.Player);

                    //if (max > 0)
                    //{
                    //    max = current * 100 / max;

                    //    if (max > 100)
                    //        max = 100;

                    //    if (max > 1)
                    //        max = BAR_WIDTH * max / 100;
                    //}



                    //batcher.Draw2D(_edge, x - 1, y - 1, BAR_WIDTH + 2, BAR_HEIGHT + 2, ref _vectorHue);
                    //batcher.Draw2D(_back, x, y, BAR_WIDTH, BAR_HEIGHT, ref _vectorHue);

                    //if (mobile.IsParalyzed)
                    //    color = Color.AliceBlue;
                    //else if (mobile.IsYellowHits)
                    //    color = Color.Orange;
                    //else if (mobile.IsPoisoned)
                    //    color = Color.LimeGreen;
                    //else
                    //    color = Color.CornflowerBlue;

                    //batcher.Draw2D(Texture2DCache.GetTexture(color), x, y, max, BAR_HEIGHT, ref _vectorHue);
                }
            }
        }
Esempio n. 13
0
            public override bool Draw(UltimaBatcher2D batcher, int x, int y)
            {
                Vector3 hueVector;

                if (SerialHelper.IsMobile(LocalSerial))
                {
                    ushort             hue2      = Hue;
                    AnimationDirection direction = GetMobileAnimationDirection(Graphic, ref hue2, 1);

                    if (direction != null && direction.SpriteInfos != null && direction.FrameCount != 0)
                    {
                        hueVector = ShaderHueTranslator.GetHueVector(hue2, TileDataLoader.Instance.StaticData[Graphic].IsPartialHue, 1f);

                        batcher.Draw
                        (
                            direction.SpriteInfos[0].Texture,
                            new Rectangle
                            (
                                x - 3,
                                y + 5 + 15,
                                Math.Min(direction.SpriteInfos[0].UV.Width, 45),
                                Math.Min(direction.SpriteInfos[0].UV.Height, 45)
                            ),
                            direction.SpriteInfos[0].UV,
                            hueVector
                        );
                    }
                }
                else if (SerialHelper.IsItem(LocalSerial))
                {
                    var texture = ArtLoader.Instance.GetStaticTexture(Graphic, out var bounds);

                    hueVector = ShaderHueTranslator.GetHueVector(Hue, TileDataLoader.Instance.StaticData[Graphic].IsPartialHue, 1f);

                    var rect = ArtLoader.Instance.GetRealArtBounds(Graphic);

                    const int RECT_SIZE = 50;

                    Point originalSize = new Point(RECT_SIZE, Height);
                    Point point        = new Point();

                    if (rect.Width < RECT_SIZE)
                    {
                        originalSize.X = rect.Width;
                        point.X        = (RECT_SIZE >> 1) - (originalSize.X >> 1);
                    }

                    if (rect.Height < Height)
                    {
                        originalSize.Y = rect.Height;
                        point.Y        = (Height >> 1) - (originalSize.Y >> 1);
                    }

                    batcher.Draw
                    (
                        texture,
                        new Rectangle
                        (
                            x + point.X - 5,
                            y + point.Y + 10,
                            originalSize.X,
                            originalSize.Y
                        ),
                        new Rectangle
                        (
                            bounds.X + rect.X,
                            bounds.Y + rect.Y,
                            rect.Width,
                            rect.Height
                        ),
                        hueVector
                    );
                }

                return(base.Draw(batcher, x, y));
            }
Esempio n. 14
0
        public static void Target(uint serial)
        {
            if (!IsTargeting)
            {
                return;
            }

            Entity entity = World.InGame ? World.Get(serial) : null;

            if (entity != null)
            {
                switch (TargetingState)
                {
                case CursorTarget.Invalid: return;

                case CursorTarget.MultiPlacement:
                case CursorTarget.Position:
                case CursorTarget.Object:
                case CursorTarget.HueCommandTarget:
                case CursorTarget.SetTargetClientSide:

                    if (entity != World.Player)
                    {
                        LastTargetInfo.SetEntity(serial);
                    }

                    if (SerialHelper.IsMobile
                            (serial) && serial != World.Player &&
                        (World.Player.NotorietyFlag == NotorietyFlag.Innocent ||
                         World.Player.NotorietyFlag == NotorietyFlag.Ally))
                    {
                        Mobile mobile = entity as Mobile;

                        if (mobile != null)
                        {
                            bool showCriminalQuery = false;

                            if (TargetingType == TargetType.Harmful &&
                                ProfileManager.CurrentProfile.EnabledCriminalActionQuery &&
                                mobile.NotorietyFlag == NotorietyFlag.Innocent)
                            {
                                showCriminalQuery = true;
                            }
                            else if (TargetingType == TargetType.Beneficial &&
                                     ProfileManager.CurrentProfile.EnabledBeneficialCriminalActionQuery &&
                                     (mobile.NotorietyFlag == NotorietyFlag.Criminal ||
                                      mobile.NotorietyFlag == NotorietyFlag.Murderer ||
                                      mobile.NotorietyFlag == NotorietyFlag.Gray))
                            {
                                showCriminalQuery = true;
                            }

                            if (showCriminalQuery && UIManager.GetGump <QuestionGump>() == null)
                            {
                                QuestionGump messageBox = new QuestionGump
                                                          (
                                    "This may flag\nyou criminal!", s =>
                                {
                                    if (s)
                                    {
                                        NetClient.Socket.Send
                                        (
                                            new PTargetObject
                                            (
                                                entity, entity.Graphic, entity.X, entity.Y, entity.Z,
                                                _targetCursorId, (byte)TargetingType
                                            )
                                        );

                                        ClearTargetingWithoutTargetCancelPacket();

                                        if (LastTargetInfo.Serial != serial)
                                        {
                                            GameActions.RequestMobileStatus(serial);
                                        }
                                    }
                                }
                                                          );

                                UIManager.Add(messageBox);

                                return;
                            }
                        }
                    }

                    if (TargetingState != CursorTarget.SetTargetClientSide)
                    {
                        PTargetObject packet = new PTargetObject
                                               (
                            entity, entity.Graphic, entity.X, entity.Y, entity.Z, _targetCursorId,
                            (byte)TargetingType
                                               );

                        for (int i = 0; i < _lastDataBuffer.Length; i++)
                        {
                            _lastDataBuffer[i] = packet[i];
                        }

                        NetClient.Socket.Send(packet);

                        if (SerialHelper.IsMobile(serial) && LastTargetInfo.Serial != serial)
                        {
                            GameActions.RequestMobileStatus(serial);
                        }
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    Mouse.CancelDoubleClick = true;

                    break;

                case CursorTarget.Grab:

                    if (SerialHelper.IsItem(serial))
                    {
                        GameActions.GrabItem(serial, ((Item)entity).Amount);
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                case CursorTarget.SetGrabBag:

                    if (SerialHelper.IsItem(serial))
                    {
                        ProfileManager.CurrentProfile.GrabBagSerial = serial;
                        GameActions.Print(string.Format(ResGeneral.GrabBagSet0, serial));
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                // ## BEGIN - END ## //
                case CursorTarget.SetCustomSerial:

                    if (SerialHelper.IsItem(serial))
                    {
                        ProfileManager.CurrentProfile.CustomSerial = serial;
                        GameActions.Print($"Custom UOClassicEquipment Item set: {serial}", 88);
                    }
                    else if ((TargetingType == TargetType.Neutral && SerialHelper.IsMobile(serial)))
                    {
                        Mobile mobile = entity as Mobile;

                        if ((!World.Player.IsDead && !mobile.IsDead) && serial != World.Player)
                        {
                            ProfileManager.CurrentProfile.Mimic_PlayerSerial = entity;                          //entity.serial
                            GameActions.Print($"Mimic Player Serial Set: {entity.Name} : {entity.Serial}", 88); //entity.serial
                        }
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;
                    // ## BEGIN - END ## //
                }
            }
        }
Esempio n. 15
0
        public static void Target(uint serial)
        {
            if (!IsTargeting)
            {
                return;
            }

            Entity entity = World.InGame ? World.Get(serial) : null;

            if (entity != null)
            {
                switch (TargetingState)
                {
                case CursorTarget.Invalid:
                    return;

                case CursorTarget.MultiPlacement:
                case CursorTarget.Position:
                case CursorTarget.Object:
                case CursorTarget.HueCommandTarget:
                case CursorTarget.SetTargetClientSide:
                    Mobile m = World.Mobiles.Get(entity);
                    if (entity != World.Player)
                    {
                        UIManager.RemoveTargetLineGump(LastAttack);
                        UIManager.RemoveTargetLineGump(LastTarget);
                        LastTarget      = entity.Serial;
                        LastTarget_name = entity.Name;
                        TargetMenuGump tm = UIManager.GetGump <TargetMenuGump>();
                        if (tm != null)
                        {
                            tm.SetName();
                        }
                    }
                    if (m != null && m != World.Player)
                    {
                        switch (m.NotorietyFlag)
                        {
                        case NotorietyFlag.Ally:
                        case NotorietyFlag.Innocent:
                            LastBeneficialTarget      = entity.Serial;
                            LastBeneficialTarget_name = entity.Name;
                            TargetMenuGump tm = UIManager.GetGump <TargetMenuGump>();
                            if (tm != null)
                            {
                                tm.SetName();
                            }
                            break;

                        case NotorietyFlag.Enemy:
                        case NotorietyFlag.Gray:
                        case NotorietyFlag.Murderer:
                        case NotorietyFlag.Unknown:
                        case NotorietyFlag.Criminal:

                            LastHarmfulTarget      = entity.Serial;
                            LastHarmfulTarget_name = entity.Name;
                            tm = UIManager.GetGump <TargetMenuGump>();
                            if (tm != null)
                            {
                                tm.SetName();
                            }
                            break;
                        }
                    }
                    if (TargeringType == TargetType.Harmful && SerialHelper.IsMobile(serial) &&
                        ProfileManager.Current.EnabledCriminalActionQuery)
                    {
                        Mobile mobile = entity as Mobile;

                        if (((World.Player.NotorietyFlag == NotorietyFlag.Innocent ||
                              World.Player.NotorietyFlag == NotorietyFlag.Ally) && mobile.NotorietyFlag == NotorietyFlag.Innocent && serial != World.Player))
                        {
                            QuestionGump messageBox = new QuestionGump(LanguageManager.Current.UI_Public_Criminal,
                                                                       s =>
                            {
                                if (s)
                                {
                                    NetClient.Socket.Send(new PTargetObject(entity, entity.Graphic, entity.X, entity.Y, entity.Z, _targetCursorId, (byte)TargeringType));
                                    ClearTargetingWithoutTargetCancelPacket();
                                }
                            });

                            UIManager.Add(messageBox);

                            return;
                        }
                    }

                    var packet = new PTargetObject(entity, entity.Graphic, entity.X, entity.Y, entity.Z, _targetCursorId, (byte)TargeringType);

                    for (int i = 0; i < _lastDataBuffer.Length; i++)
                    {
                        _lastDataBuffer[i] = packet[i];
                    }

                    NetClient.Socket.Send(packet);
                    ClearTargetingWithoutTargetCancelPacket();

                    Mouse.CancelDoubleClick = true;
                    break;

                case CursorTarget.Grab:

                    if (SerialHelper.IsItem(serial))
                    {
                        GameActions.GrabItem(serial, ((Item)entity).Amount);
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                case CursorTarget.SetGrabBag:

                    if (SerialHelper.IsItem(serial))
                    {
                        ProfileManager.Current.GrabBagSerial = serial;
                        GameActions.Print(LanguageManager.Current.UI_GrabBagSet + $"{ serial}");
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                case CursorTarget.AddToLootlist:
                    Item item = World.Items.Get(serial);
                    if (SerialHelper.IsItem(serial))
                    {
                        ushort[] obj = new ushort[2];
                        obj[0] = item.Graphic;
                        obj[1] = item.Hue;

                        if (ProfileManager.Current.LootList == null)
                        {
                            ProfileManager.Current.LootList = new List <ushort[]>();
                        }
                        bool contain = false;
                        foreach (ushort[] i in ProfileManager.Current.LootList)
                        {
                            if (obj[0] == i[0] && obj[1] == i[1])
                            {
                                contain = true;
                                break;
                            }
                        }
                        if (!contain)
                        {
                            ProfileManager.Current.LootList.Add(obj);
                            UIManager.GetGump <LootListGump>()?.Dispose();
                            UIManager.Add(new LootListGump());
                        }
                    }
                    ClearTargetingWithoutTargetCancelPacket();
                    return;

                case CursorTarget.AddToSelllist:

                    if (SerialHelper.IsItem(serial))
                    {
                        item = World.GetOrCreateItem(serial);
                        ushort[] obj = new ushort[3];
                        obj[0] = item.Graphic;
                        obj[1] = item.Hue;
                        obj[2] = (ushort)ProfileManager.Current.AutoBuyAmount;

                        if (ProfileManager.Current.SellList == null)
                        {
                            ProfileManager.Current.SellList = new List <ushort[]>();
                        }
                        bool contain = false;
                        foreach (ushort[] i in ProfileManager.Current.SellList)
                        {
                            if (obj[0] == i[0] && obj[1] == i[1])
                            {
                                contain = true;
                                break;
                            }
                        }
                        if (!contain)
                        {
                            ProfileManager.Current.SellList.Add(obj);
                            UIManager.GetGump <SellListGump>()?.Dispose();
                            UIManager.Add(new SellListGump(false));
                        }
                    }
                    ClearTargetingWithoutTargetCancelPacket();
                    return;

                case CursorTarget.AddToBuylist:

                    if (SerialHelper.IsItem(serial))
                    {
                        item = World.GetOrCreateItem(serial);
                        ushort[] obj = new ushort[3];
                        obj[0] = item.Graphic;
                        obj[1] = item.Hue;
                        obj[2] = (ushort)ProfileManager.Current.AutoBuyAmount;

                        if (ProfileManager.Current.BuyList == null)
                        {
                            ProfileManager.Current.BuyList = new List <ushort[]>();
                        }
                        bool contain = false;
                        foreach (ushort[] i in ProfileManager.Current.BuyList)
                        {
                            if (obj[0] == i[0] && obj[1] == i[1])
                            {
                                contain = true;
                                break;
                            }
                        }
                        if (!contain)
                        {
                            ProfileManager.Current.BuyList.Add(obj);
                            UIManager.GetGump <SellListGump>()?.Dispose();
                            UIManager.Add(new SellListGump(true));
                        }
                    }
                    ClearTargetingWithoutTargetCancelPacket();
                    return;

                case CursorTarget.Target_1:
                    if (SerialHelper.IsMobile(serial))
                    {
                        m             = World.GetOrCreateMobile(serial);
                        Target_1      = m;
                        Target_1_name = entity.Name;
                        TargetMenuGump tm = UIManager.GetGump <TargetMenuGump>();
                        if (tm != null)
                        {
                            tm.SetName();
                        }
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                case CursorTarget.Target_2:
                    if (SerialHelper.IsMobile(serial))
                    {
                        m             = World.GetOrCreateMobile(serial);
                        Target_2      = m;
                        Target_2_name = entity.Name;
                        TargetMenuGump tm = UIManager.GetGump <TargetMenuGump>();
                        if (tm != null)
                        {
                            tm.SetName();
                        }
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                case CursorTarget.Target_3:
                    if (SerialHelper.IsMobile(serial))
                    {
                        m             = World.GetOrCreateMobile(serial);
                        Target_3      = m;
                        Target_3_name = entity.Name;
                        TargetMenuGump tm = UIManager.GetGump <TargetMenuGump>();
                        if (tm != null)
                        {
                            tm.SetName();
                        }
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                case CursorTarget.Target_4:
                    if (SerialHelper.IsMobile(serial))
                    {
                        m             = World.GetOrCreateMobile(serial);
                        Target_4      = m;
                        Target_4_name = m.Name;
                        TargetMenuGump tm = UIManager.GetGump <TargetMenuGump>();
                        if (tm != null)
                        {
                            tm.SetName();
                        }
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                case CursorTarget.Target_5:

                    if (SerialHelper.IsMobile(serial))
                    {
                        m             = World.GetOrCreateMobile(serial);
                        Target_5      = m;
                        Target_5_name = m.Name;
                        TargetMenuGump tm = UIManager.GetGump <TargetMenuGump>();
                        if (tm != null)
                        {
                            tm.SetName();
                        }
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                case CursorTarget.Clear:
                    if (SerialHelper.IsItem(serial))
                    {
                        PlayerMobile.MoveObject = true;
                        PlayerMobile.MoveType   = 0;
                        PlayerMobile.MoveBag    = World.GetOrCreateItem(serial);
                    }
                    ClearTargetingWithoutTargetCancelPacket();
                    return;

                case CursorTarget.Supply:
                    if (SerialHelper.IsItem(serial))
                    {
                        PlayerMobile.MoveObject = true;
                        PlayerMobile.MoveType   = 1;
                        PlayerMobile.MoveBag    = World.GetOrCreateItem(serial);
                    }
                    ClearTargetingWithoutTargetCancelPacket();
                    return;
//                    case CursorTarget.Object_1:
//                        if (SerialHelper.IsItem(serial))
//                        {
//                            item = World.GetOrCreateItem(serial);
//                            Object_1 = item.Graphic;
////                            Object_1_name = item.Name;
//                            TargetMenuGump tm = UIManager.GetGump<TargetMenuGump>();
//                            if (tm != null)
//                            {
//                                tm.SetName();
//                            }
//                        }
//                        ClearTargetingWithoutTargetCancelPacket();
//                        return;

//                    case CursorTarget.Object_2:
//                        if (SerialHelper.IsItem(serial))
//                        {
//                            item = World.GetOrCreateItem(serial);
//                            Object_2 = item.Graphic;
//                            //Object_2_name = item.Name;
//                            TargetMenuGump tm = UIManager.GetGump<TargetMenuGump>();
//                            if (tm != null)
//                            {
//                                tm.SetName();
//                            }
//                        }
//                        ClearTargetingWithoutTargetCancelPacket();
//                        return;
//                    case CursorTarget.Object_3:
//                        if (SerialHelper.IsItem(serial))
//                        {
//                            item = World.GetOrCreateItem(serial);
//                            Object_3 = item.Graphic;
//                            //Object_3_name = item.Name;
//                            TargetMenuGump tm = UIManager.GetGump<TargetMenuGump>();
//                            if (tm != null)
//                            {
//                                tm.SetName();
//                            }
//                        }
//                        ClearTargetingWithoutTargetCancelPacket();
//                        return;
//                    case CursorTarget.Object_4:
//                        if (SerialHelper.IsItem(serial))
//                        {
//                            item = World.GetOrCreateItem(serial);
//                            Object_4 = item.Graphic;
//                            //Object_4_name = item.Name;
//                            TargetMenuGump tm = UIManager.GetGump<TargetMenuGump>();
//                            if (tm != null)
//                            {
//                                tm.SetName();
//                            }
//                        }
//                        ClearTargetingWithoutTargetCancelPacket();
//                        return;
//                    case CursorTarget.Object_5:
//                        if (SerialHelper.IsItem(serial))
//                        {
//                            item = World.GetOrCreateItem(serial);
//                            Object_5 = item.Graphic;
//                            //Object_5_name = item.Name;
//                            TargetMenuGump tm = UIManager.GetGump<TargetMenuGump>();
//                            if (tm != null)
//                            {
//                                tm.SetName();
//                            }
//                        }
//                        ClearTargetingWithoutTargetCancelPacket();
//                        return;
                }
            }
        }
Esempio n. 16
0
        public static void DefendParty()
        {
            //
            var healpotion = World.Player.FindItemByGraphic(0x0F0C);

            //
            if (!World.Player.IsDead && World.Player.Exists && World.Player != null && ProfileManager.CurrentProfile != null)
            {
                foreach (Mobile mobile in World.Mobiles)
                {
                    if (World.Mobiles.Get(mobile.Serial).Distance < 12 && mobile.IsHuman && ProfileManager.CurrentProfile != null)
                    {
                        if (mobile.Name.Length == 0 || mobile.Name == null && ProfileManager.CurrentProfile != null)
                        {
                            TimeSpan.FromMilliseconds(125);
                            return;
                        }
                        else
                        {
                            foreach (Mobile mobile1 in World.Mobiles)
                            {
                                if (mobile.NotorietyFlag == NotorietyFlag.Ally || World.Party.Contains(mobile.Serial) && mobile != World.Player && ProfileManager.CurrentProfile != null)
                                {
                                    if (!mobile.IsDead && mobile != null && SerialHelper.IsMobile(mobile.Serial) && ProfileManager.CurrentProfile != null)
                                    {
                                        if (SerialHelper.IsValid(mobile.Serial) && ProfileManager.CurrentProfile != null)
                                        {
                                            if (mobile.Hits < 64 && mobile.Distance < 12 && ProfileManager.CurrentProfile != null)
                                            {
                                                if (TargetManager.IsTargeting)
                                                {
                                                    if (SerialHelper.IsValid(mobile.Serial) && mobile.Distance < 12 && ProfileManager.CurrentProfile != null)
                                                    {
                                                        TargetManager.Target(mobile.Serial);

                                                        TimeSpan.FromMilliseconds(125);
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        break;
                                                    }
                                                }
                                                else if (!TargetManager.IsTargeting)
                                                {
                                                    GameActions.CastSpell(29);

                                                    TimeSpan.FromMilliseconds(375);

                                                    if (!TargetManager.IsTargeting)
                                                    {
                                                        TimeSpan.FromMilliseconds(125);
                                                    }
                                                    else
                                                    {
                                                        continue;
                                                    }

                                                    if (TargetManager.IsTargeting && SerialHelper.IsValid(mobile.Serial) && mobile.Distance < 12 && ProfileManager.CurrentProfile != null)
                                                    {
                                                        TargetManager.Target(mobile.Serial);

                                                        TimeSpan.FromMilliseconds(125);
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        break;
                                                    }
                                                }
                                            }
                                            else if (World.Player.Hits < 64 && ProfileManager.CurrentProfile != null)
                                            {
                                                if (TargetManager.IsTargeting)
                                                {
                                                    if (!World.Player.IsDead && World.Player.Hits < 64 && ProfileManager.CurrentProfile != null)
                                                    {
                                                        TargetManager.Target(World.Player);

                                                        TimeSpan.FromMilliseconds(125);
                                                        if (healpotion != null && ProfileManager.CurrentProfile != null)
                                                        {
                                                            GameActions.DoubleClick(healpotion);
                                                            GameActions.Print("AD: Heal Potion used");
                                                        }
                                                        else
                                                        {
                                                            GameActions.Print("AD: No Heal Potions.");
                                                        }

                                                        TimeSpan.FromMilliseconds(125);
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        break;
                                                    }
                                                }
                                                else if (!TargetManager.IsTargeting)
                                                {
                                                    GameActions.CastSpell(29);

                                                    TimeSpan.FromMilliseconds(375);

                                                    if (!TargetManager.IsTargeting)
                                                    {
                                                        TimeSpan.FromMilliseconds(125);
                                                    }
                                                    else
                                                    {
                                                        continue;
                                                    }

                                                    if (TargetManager.IsTargeting && !World.Player.IsDead && World.Player.Hits < 64 && ProfileManager.CurrentProfile != null)
                                                    {
                                                        TargetManager.Target(World.Player);

                                                        TimeSpan.FromMilliseconds(125);
                                                        if (healpotion != null && ProfileManager.CurrentProfile != null)
                                                        {
                                                            GameActions.DoubleClickQueued(healpotion);
                                                            GameActions.Print("AD: Heal Potion used");
                                                        }
                                                        else
                                                        {
                                                            GameActions.Print("AD: No Heal Potions.");
                                                        }

                                                        TimeSpan.FromMilliseconds(125);
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        break;
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                GameActions.Print("AD: Nothing to do.");
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        continue;
                    }
                    else
                    {
                        GameActions.Print("AD: Nobody near.");
                    }
                }
            }
        }