Пример #1
0
        public static int GetOffsetFromSpellbookType(SpellBookType type)
        {
            switch (type)
            {
            case SpellBookType.Magery:

                return(1);

            case SpellBookType.Necromancy:

                return(101);

            case SpellBookType.Chivalry:

                return(201);

            case SpellBookType.Bushido:

                return(401);

            case SpellBookType.Ninjitsu:

                return(501);

            case SpellBookType.Spellweaving:

                return(601);

            default:

                return(1);
            }
        }
Пример #2
0
        public void Update()
        {
            Item item = World.Items.Get(LocalSerial);

            if (item == null)
            {
                Dispose();
                return;
            }

            switch (item.Graphic)
            {
            default:
            case 0x0EFA:
                _spellBookType = SpellBookType.Magery;

                break;

            case 0x2253:
                _spellBookType = SpellBookType.Necromancy;

                break;

            case 0x2252:
                _spellBookType = SpellBookType.Chivalry;

                break;

            case 0x238C:
                _spellBookType = SpellBookType.Bushido;

                break;

            case 0x23A0:
                _spellBookType = SpellBookType.Ninjitsu;

                break;

            case 0x2D50:
                _spellBookType = SpellBookType.Spellweaving;

                break;

            case 0x2D9D:
                _spellBookType = SpellBookType.Mysticism;

                break;

            case 0x225A:
            case 0x225B:
                _spellBookType = SpellBookType.Bardic;

                break;
            }

            CreateBook();
        }
Пример #3
0
        private void OnEntityUpdate(Entity entity)
        {
            if (entity == null)
            {
                return;
            }

            switch (entity.Graphic)
            {
            default:
            case 0x0EFA:
                _spellBookType = SpellBookType.Magery;

                break;

            case 0x2253:
                _spellBookType = SpellBookType.Necromancy;

                break;

            case 0x2252:
                _spellBookType = SpellBookType.Chivalry;

                break;

            case 0x238C:
                _spellBookType = SpellBookType.Bushido;

                break;

            case 0x23A0:
                _spellBookType = SpellBookType.Ninjitsu;

                break;

            case 0x2D50:
                _spellBookType = SpellBookType.Spellweaving;

                break;

            case 0x2D9D:
                _spellBookType = SpellBookType.Mysticism;

                break;

            case 0x225A:
            case 0x225B:
                _spellBookType = SpellBookType.Bardic;

                break;
            }

            CreateBook();
        }
Пример #4
0
        public static void GetData(Item spellbook, out ulong field, out SpellBookType type)
        {
            type  = GetTypeByGraphic(spellbook.Graphic);
            field = 0;

            if (type == SpellBookType.Unknown)
            {
                return;
            }
            int offset = GetOffsetFromSpellbookType(type);

            foreach (Item item in spellbook.Items)
            {
                int index  = (item.Amount - offset) & 0x0000003F;
                int circle = index >> 3;
                index %= 8;
                index  = (3 - circle % 4 + (circle >> 2) * 4) * 8 + index;
                field |= (ulong)1 << index;
            }
        }
Пример #5
0
        public static SpellBookType GetTypeByGraphic(Graphic graphic)
        {
            SpellBookType bookType = SpellBookType.Unknown;

            switch (graphic)
            {
            case 0x0E3B:     // spellbook
            case 0x0EFA:
                bookType = SpellBookType.Magery;

                break;

            case 0x2252:     // paladin spellbook
                bookType = SpellBookType.Chivalry;

                break;

            case 0x2253:     // necromancer book
                bookType = SpellBookType.Necromancy;

                break;

            case 0x238C:     // book of bushido
                bookType = SpellBookType.Bushido;

                break;

            case 0x23A0:     // book of ninjitsu
                bookType = SpellBookType.Ninjitsu;

                break;

            case 0x2D50:     // spell weaving book
                bookType = SpellBookType.Spellweaving;

                break;
            }

            return(bookType);
        }
Пример #6
0
        private void GetBookInfo(SpellBookType type, out Graphic bookGraphic, out Graphic minimizedGraphic, out Graphic iconStartGraphic, out int maxSpellsCount, out int spellsOnPage, out int dictionaryPagesCount)
        {
            switch (type)
            {
            case SpellBookType.Magery:
                maxSpellsCount   = SpellsMagery.MaxSpellCount;
                bookGraphic      = 0x08AC;
                minimizedGraphic = 0x08BA;
                iconStartGraphic = 0x08C0;

                break;

            case SpellBookType.Necromancy:
                maxSpellsCount   = SpellsNecromancy.MaxSpellCount;
                bookGraphic      = 0x2B00;
                minimizedGraphic = 0x2B03;
                iconStartGraphic = 0x5000;

                break;

            case SpellBookType.Chivalry:
                maxSpellsCount   = SpellsChivalry.MaxSpellCount;
                bookGraphic      = 0x2B01;
                minimizedGraphic = 0x2B04;
                iconStartGraphic = 0x5100;

                break;

            case SpellBookType.Bushido:
                maxSpellsCount   = SpellsBushido.MaxSpellCount;
                bookGraphic      = 0x2B07;
                minimizedGraphic = 0x2B09;
                iconStartGraphic = 0x5400;

                break;

            case SpellBookType.Ninjitsu:
                maxSpellsCount   = SpellsNinjitsu.MaxSpellCount;
                bookGraphic      = 0x2B06;
                minimizedGraphic = 0x2B08;
                iconStartGraphic = 0x5300;

                break;

            case SpellBookType.Spellweaving:
                maxSpellsCount   = SpellsSpellweaving.MaxSpellCount;
                bookGraphic      = 0x2B2F;
                minimizedGraphic = 0x2B2D;
                iconStartGraphic = 0x59D8;

                break;

            case SpellBookType.Mysticism:
                maxSpellsCount   = SpellsMysticism.MaxSpellCount;
                bookGraphic      = 0x2B32;
                minimizedGraphic = 0x2B30;
                iconStartGraphic = 0x5DC0;

                break;

            case SpellBookType.Bardic:
                maxSpellsCount   = SpellsBardic.MaxSpellCount;
                bookGraphic      = 0x8AC;
                minimizedGraphic = 0x2B27;
                iconStartGraphic = 0x945;

                break;

            default:

                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }

            spellsOnPage         = Math.Min(maxSpellsCount >> 1, 8);
            dictionaryPagesCount = (int)Math.Ceiling(maxSpellsCount / 8.0f);

            if (dictionaryPagesCount % 2 != 0)
            {
                dictionaryPagesCount++;
            }
        }
Пример #7
0
        private void GetBookInfo(SpellBookType type, out Graphic bookGraphic, out Graphic minimizedGraphic, out Graphic iconStartGraphic, out int maxSpellsCount, out int spellIndexOffset, out int spellsOnPage, out int dictionaryPagesCount)
        {
            switch (type)
            {
            case SpellBookType.Magery:
                maxSpellsCount   = 64;
                bookGraphic      = 0x08AC;
                minimizedGraphic = 0x08BA;
                iconStartGraphic = 0x08C0;
                spellIndexOffset = 0;

                break;

            case SpellBookType.Necromancy:
                maxSpellsCount   = 17;
                bookGraphic      = 0x2B00;
                minimizedGraphic = 0x2B03;
                iconStartGraphic = 0x5000;
                spellIndexOffset = 64;

                break;

            case SpellBookType.Chivalry:
                maxSpellsCount   = 10;
                bookGraphic      = 0x2B01;
                minimizedGraphic = 0x2B04;
                iconStartGraphic = 0x5100;
                spellIndexOffset = 81;

                break;

            case SpellBookType.Bushido:
                maxSpellsCount   = 6;
                bookGraphic      = 0x2B07;
                minimizedGraphic = 0x2B09;
                iconStartGraphic = 0x5400;
                spellIndexOffset = 91;

                break;

            case SpellBookType.Ninjitsu:
                maxSpellsCount   = 8;
                bookGraphic      = 0x2B06;
                minimizedGraphic = 0x2B08;
                iconStartGraphic = 0x5300;
                spellIndexOffset = 97;

                break;

            case SpellBookType.Spellweaving:
                maxSpellsCount   = 16;
                bookGraphic      = 0x2B2F;
                minimizedGraphic = 0x2B2D;
                iconStartGraphic = 0x59D8;
                spellIndexOffset = 105;

                break;

            case SpellBookType.Mysticism:
                maxSpellsCount   = 16;
                bookGraphic      = 0x2B32;
                minimizedGraphic = 0;     // TODO: i dunno
                iconStartGraphic = 0x5DC0;
                spellIndexOffset = 121;

                break;

            default:

                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }

            spellsOnPage         = Math.Min(maxSpellsCount >> 1, 8);
            dictionaryPagesCount = (int)Math.Ceiling(maxSpellsCount / 8.0f);

            if (dictionaryPagesCount % 2 != 0)
            {
                dictionaryPagesCount++;
            }
        }
Пример #8
0
        private int Process(MacroObject macro)
        {
            if (macro == null)
            {
                return(0);
            }

            int result = 0;

            switch (macro.Code)
            {
            case MacroType.Say:
            case MacroType.Emote:
            case MacroType.Whisper:
            case MacroType.Yell:

                MacroObjectString mos = (MacroObjectString)macro;

                if (!string.IsNullOrEmpty(mos.Text))
                {
                    MessageType type = MessageType.Regular;
                    ushort      hue  = Engine.Profile.Current.SpeechHue;

                    switch (macro.Code)
                    {
                    case MacroType.Emote:
                        type = MessageType.Emote;
                        hue  = Engine.Profile.Current.EmoteHue;

                        break;

                    case MacroType.Whisper:
                        type = MessageType.Whisper;
                        hue  = Engine.Profile.Current.WhisperHue;

                        break;

                    case MacroType.Yell:
                        type = MessageType.Yell;

                        break;
                    }

                    GameActions.Say(mos.Text, hue, type);
                }

                break;

            case MacroType.Walk:
                byte dt = (byte)Direction.Up;

                if (macro.SubCode != MacroSubType.NW)
                {
                    dt = (byte)(macro.SubCode - 2);

                    if (dt > 7)
                    {
                        dt = 0;
                    }
                }

                if (!Pathfinder.AutoWalking)
                {
                    World.Player.Walk((Direction)dt, false);
                }

                break;

            case MacroType.WarPeace:
                GameActions.ChangeWarMode();

                break;

            case MacroType.Paste:

                if (SDL.SDL_HasClipboardText() != SDL.SDL_bool.SDL_FALSE)
                {
                    string s = SDL.SDL_GetClipboardText();

                    if (!string.IsNullOrEmpty(s))
                    {
                        Engine.UI.SystemChat.textBox.Text += s;
                    }
                }

                break;

            case MacroType.Open:
            case MacroType.Close:
            case MacroType.Minimize:
            case MacroType.Maximize:

                switch (macro.Code)
                {
                case MacroType.Open:

                    switch (macro.SubCode)
                    {
                    case MacroSubType.Configuration:
                        OptionsGump opt = Engine.UI.GetGump <OptionsGump>();

                        if (opt == null)
                        {
                            Engine.UI.Add(opt = new OptionsGump());
                            opt.SetInScreen();
                        }
                        else
                        {
                            opt.SetInScreen();
                            opt.BringOnTop();
                        }

                        break;

                    case MacroSubType.Paperdoll:
                        GameActions.OpenPaperdoll(World.Player);

                        break;

                    case MacroSubType.Status:

                        if (StatusGumpBase.GetStatusGump() == null)
                        {
                            StatusGumpBase.AddStatusGump(100, 100);
                        }

                        break;

                    case MacroSubType.Journal:
                        JournalGump journalGump = Engine.UI.GetGump <JournalGump>();

                        if (journalGump == null)
                        {
                            Engine.UI.Add(new JournalGump
                            {
                                X = 64, Y = 64
                            });
                        }
                        else
                        {
                            journalGump.SetInScreen();
                            journalGump.BringOnTop();
                        }

                        break;

                    case MacroSubType.Skills:
                        World.SkillsRequested = true;
                        NetClient.Socket.Send(new PSkillsRequest(World.Player));

                        break;

                    case MacroSubType.MageSpellbook:
                    case MacroSubType.NecroSpellbook:
                    case MacroSubType.PaladinSpellbook:
                    case MacroSubType.BushidoSpellbook:
                    case MacroSubType.NinjitsuSpellbook:
                    case MacroSubType.SpellWeavingSpellbook:
                    case MacroSubType.MysticismSpellbook:

                        SpellBookType type = SpellBookType.Magery;

                        switch (macro.SubCode)
                        {
                        case MacroSubType.NecroSpellbook:
                            type = SpellBookType.Necromancy;

                            break;

                        case MacroSubType.PaladinSpellbook:
                            type = SpellBookType.Chivalry;

                            break;

                        case MacroSubType.BushidoSpellbook:
                            type = SpellBookType.Bushido;

                            break;

                        case MacroSubType.NinjitsuSpellbook:
                            type = SpellBookType.Ninjitsu;

                            break;

                        case MacroSubType.SpellWeavingSpellbook:
                            type = SpellBookType.Spellweaving;

                            break;

                        case MacroSubType.MysticismSpellbook:
                            type = SpellBookType.Mysticism;

                            break;

                        case MacroSubType.BardSpellbook:
                            type = SpellBookType.Bardic;

                            break;
                        }

                        NetClient.Socket.Send(new POpenSpellBook((byte)type));

                        break;

                    case MacroSubType.Chat:
                        Log.Message(LogTypes.Warning, $"Macro '{macro.SubCode}' not implemented");

                        break;

                    case MacroSubType.Backpack:
                        Item backpack = World.Player.Equipment[(int)Layer.Backpack];

                        if (backpack != null)
                        {
                            GameActions.DoubleClick(backpack);
                        }

                        break;

                    case MacroSubType.Overview:
                        MiniMapGump miniMapGump = Engine.UI.GetGump <MiniMapGump>();

                        if (miniMapGump == null)
                        {
                            Engine.UI.Add(new MiniMapGump());
                        }
                        else
                        {
                            miniMapGump.ToggleSize();
                            miniMapGump.SetInScreen();
                            miniMapGump.BringOnTop();
                        }

                        break;

                    case MacroSubType.WorldMap:
                        Log.Message(LogTypes.Warning, $"Macro '{macro.SubCode}' not implemented");

                        break;

                    case MacroSubType.Mail:
                    case MacroSubType.PartyManifest:
                        var party = Engine.UI.GetGump <PartyGumpAdvanced>();

                        if (party == null)
                        {
                            Engine.UI.Add(new PartyGumpAdvanced());
                        }
                        else
                        {
                            party.BringOnTop();
                        }

                        break;

                    case MacroSubType.Guild:
                        GameActions.OpenGuildGump();

                        break;

                    case MacroSubType.QuestLog:
                        GameActions.RequestQuestMenu();

                        break;

                    case MacroSubType.PartyChat:
                    case MacroSubType.CombatBook:
                    case MacroSubType.RacialAbilitiesBook:
                    case MacroSubType.BardSpellbook:
                        Log.Message(LogTypes.Warning, $"Macro '{macro.SubCode}' not implemented");

                        break;
                    }

                    break;

                case MacroType.Close:
                case MacroType.Minimize:         // TODO: miniminze/maximize
                case MacroType.Maximize:

                    switch (macro.SubCode)
                    {
                    case MacroSubType.Configuration:

                        if (macro.Code == MacroType.Close)
                        {
                            Engine.UI.GetGump <OptionsGump>()?.Dispose();
                        }

                        break;

                    case MacroSubType.Paperdoll:

                        if (macro.Code == MacroType.Close)
                        {
                            Engine.UI.GetGump <PaperDollGump>()?.Dispose();
                        }

                        break;

                    case MacroSubType.Status:

                        if (macro.Code == MacroType.Close)
                        {
                            StatusGumpBase.GetStatusGump()?.Dispose();
                        }

                        break;

                    case MacroSubType.Journal:

                        if (macro.Code == MacroType.Close)
                        {
                            Engine.UI.GetGump <JournalGump>()?.Dispose();
                        }

                        break;

                    case MacroSubType.Skills:

                        if (macro.Code == MacroType.Close)
                        {
                            Engine.UI.GetGump <SkillGumpAdvanced>()?.Dispose();
                        }

                        break;

                    case MacroSubType.MageSpellbook:
                    case MacroSubType.NecroSpellbook:
                    case MacroSubType.PaladinSpellbook:
                    case MacroSubType.BushidoSpellbook:
                    case MacroSubType.NinjitsuSpellbook:
                    case MacroSubType.SpellWeavingSpellbook:
                    case MacroSubType.MysticismSpellbook:

                        if (macro.Code == MacroType.Close)
                        {
                            Engine.UI.GetGump <SpellbookGump>()?.Dispose();
                        }

                        break;

                    case MacroSubType.Chat:
                        Log.Message(LogTypes.Warning, $"Macro '{macro.SubCode}' not implemented");

                        break;

                    case MacroSubType.Overview:

                        if (macro.Code == MacroType.Close)
                        {
                            Engine.UI.GetGump <MiniMapGump>()?.Dispose();
                        }

                        break;

                    case MacroSubType.Mail:
                        Log.Message(LogTypes.Warning, $"Macro '{macro.SubCode}' not implemented");

                        break;

                    case MacroSubType.PartyManifest:

                        if (macro.Code == MacroType.Close)
                        {
                            Engine.UI.GetGump <PartyGumpAdvanced>()?.Dispose();
                        }

                        break;

                    case MacroSubType.PartyChat:
                    case MacroSubType.CombatBook:
                    case MacroSubType.RacialAbilitiesBook:
                    case MacroSubType.BardSpellbook:
                        Log.Message(LogTypes.Warning, $"Macro '{macro.SubCode}' not implemented");

                        break;
                    }

                    break;
                }

                break;

            case MacroType.OpenDoor:
                GameActions.OpenDoor();

                break;

            case MacroType.UseSkill:
                int skill = macro.SubCode - MacroSubType.Anatomy;

                if (skill >= 0 && skill < 24)
                {
                    skill = _skillTable[skill];

                    if (skill != 0xFF)
                    {
                        GameActions.UseSkill(skill);
                    }
                }

                break;

            case MacroType.LastSkill:
                GameActions.UseSkill(GameActions.LastSkillIndex);

                break;

            case MacroType.CastSpell:
                int spell = macro.SubCode - MacroSubType.Clumsy + 1;

                if (spell > 0 && spell <= 151)
                {
                    int totalCount = 0;
                    int spellType  = 0;

                    for (spellType = 0; spellType < 7; spellType++)
                    {
                        totalCount += _spellsCountTable[spellType];

                        if (spell < totalCount)
                        {
                            break;
                        }
                    }

                    if (spellType < 7)
                    {
                        spell += spellType * 100;

                        if (spellType > 2)
                        {
                            spell += 100;
                        }

                        GameActions.CastSpell(spell);
                    }
                }

                break;

            case MacroType.LastSpell:
                GameActions.CastSpell(GameActions.LastSpellIndex);

                break;

            case MacroType.Bow:
            case MacroType.Salute:
                int index = macro.Code - MacroType.Bow;

                const string BOW    = "bow";
                const string SALUTE = "salute";

                GameActions.EmoteAction(index == 0 ? BOW : SALUTE);

                break;

            case MacroType.QuitGame:
                Engine.SceneManager.GetScene <GameScene>()?.RequestQuitGame();

                break;

            case MacroType.AllNames:
                GameActions.AllNames();

                break;

            case MacroType.LastObject:

                if (World.Get(GameActions.LastObject) != null)
                {
                    GameActions.DoubleClick(GameActions.LastObject);
                }

                break;

            case MacroType.UseItemInHand:
                Item itemInLeftHand = World.Player.Equipment[(int)Layer.OneHanded];
                if (itemInLeftHand != null)
                {
                    GameActions.DoubleClick(itemInLeftHand.Serial);
                }
                else
                {
                    Item itemInRightHand = World.Player.Equipment[(int)Layer.TwoHanded];
                    if (itemInRightHand != null)
                    {
                        GameActions.DoubleClick(itemInRightHand.Serial);
                    }
                }

                break;

            case MacroType.LastTarget:

                //if (WaitForTargetTimer == 0)
                //    WaitForTargetTimer = Engine.Ticks + Constants.WAIT_FOR_TARGET_DELAY;

                if (TargetManager.IsTargeting)
                {
                    //if (TargetManager.TargetingState != TargetType.Object)
                    //{
                    //    TargetManager.TargetGameObject(TargetManager.LastGameObject);
                    //}
                    //else
                    TargetManager.TargetGameObject(World.Get(TargetManager.LastTarget));

                    WaitForTargetTimer = 0;
                }
                else if (WaitForTargetTimer < Engine.Ticks)
                {
                    WaitForTargetTimer = 0;
                }
                else
                {
                    result = 1;
                }

                break;

            case MacroType.TargetSelf:

                //if (WaitForTargetTimer == 0)
                //    WaitForTargetTimer = Engine.Ticks + Constants.WAIT_FOR_TARGET_DELAY;

                if (TargetManager.IsTargeting)
                {
                    TargetManager.TargetGameObject(World.Player);
                    WaitForTargetTimer = 0;
                }
                else if (WaitForTargetTimer < Engine.Ticks)
                {
                    WaitForTargetTimer = 0;
                }
                else
                {
                    result = 1;
                }

                break;

            case MacroType.ArmDisarm:
                int       handIndex = 1 - (macro.SubCode - MacroSubType.LeftHand);
                GameScene gs        = Engine.SceneManager.GetScene <GameScene>();

                if (handIndex < 0 || handIndex > 1 || gs.IsHoldingItem)
                {
                    break;
                }

                if (_itemsInHand[handIndex] != 0)
                {
                    Item item = World.Items.Get(_itemsInHand[handIndex]);

                    if (item != null)
                    {
                        GameActions.PickUp(item, 1);
                        gs.WearHeldItem(World.Player);
                    }

                    _itemsInHand[handIndex] = 0;
                }
                else
                {
                    Item backpack = World.Player.Equipment[(int)Layer.Backpack];

                    if (backpack == null)
                    {
                        break;
                    }

                    Item item = World.Player.Equipment[(int)Layer.OneHanded + handIndex];

                    if (item != null)
                    {
                        _itemsInHand[handIndex] = item.Serial;

                        GameActions.PickUp(item, 1);
                        GameActions.DropItem(item, Position.INVALID, backpack);
                    }
                }

                break;

            case MacroType.WaitForTarget:

                if (WaitForTargetTimer == 0)
                {
                    WaitForTargetTimer = Engine.Ticks + Constants.WAIT_FOR_TARGET_DELAY;
                }

                if (TargetManager.IsTargeting || WaitForTargetTimer < Engine.Ticks)
                {
                    WaitForTargetTimer = 0;
                }
                else
                {
                    result = 1;
                }

                break;

            case MacroType.TargetNext:

                if (TargetManager.LastTarget.IsMobile)
                {
                    Mobile mob = World.Mobiles.Get(TargetManager.LastTarget);

                    if (mob == null)
                    {
                        break;
                    }

                    if (mob.HitsMax == 0)
                    {
                        NetClient.Socket.Send(new PStatusRequest(mob));
                    }

                    TargetManager.LastAttack = mob.Serial;
                }

                break;

            case MacroType.AttackLast:
                GameActions.Attack(TargetManager.LastTarget);

                break;

            case MacroType.Delay:
                MacroObjectString mosss = (MacroObjectString)macro;
                string            str   = mosss.Text;

                if (!string.IsNullOrEmpty(str) && int.TryParse(str, out int rr))
                {
                    _nextTimer = Engine.Ticks + rr;
                }

                break;

            case MacroType.CircleTrans:
                Engine.Profile.Current.UseCircleOfTransparency = !Engine.Profile.Current.UseCircleOfTransparency;

                break;

            case MacroType.CloseGump:

                Engine.UI.Gumps
                .Where(s => !(s is TopBarGump) && !(s is BuffGump) && !(s is WorldViewportGump))
                .ToList()
                .ForEach(s => s.Dispose());

                break;

            case MacroType.AlwaysRun:
                Engine.Profile.Current.AlwaysRun = !Engine.Profile.Current.AlwaysRun;
                GameActions.Print($"Always run is now {(Engine.Profile.Current.AlwaysRun ? "on" : "off")}.");

                break;

            case MacroType.SaveDesktop:
                Engine.Profile.Current?.Save(Engine.UI.Gumps.OfType <Gump>().Where(s => s.CanBeSaved).Reverse().ToList());

                break;

            case MacroType.EnableRangeColor:
                Engine.Profile.Current.NoColorObjectsOutOfRange = true;

                break;

            case MacroType.DisableRangeColor:
                Engine.Profile.Current.NoColorObjectsOutOfRange = false;

                break;

            case MacroType.ToggleRangeColor:
                Engine.Profile.Current.NoColorObjectsOutOfRange = !Engine.Profile.Current.NoColorObjectsOutOfRange;

                break;

            case MacroType.AttackSelectedTarget:

                // TODO:
                break;

            case MacroType.UseSelectedTarget:

                // TODO:
                break;

            case MacroType.CurrentTarget:

                // TODO:
                break;

            case MacroType.TargetSystemOnOff:

                // TODO:
                break;

            case MacroType.BandageSelf:
            case MacroType.BandageTarget:

                if (FileManager.ClientVersion < ClientVersions.CV_5020 || Engine.Profile.Current.BandageSelfOld)
                {
                    if (WaitingBandageTarget)
                    {
                        if (WaitForTargetTimer == 0)
                        {
                            WaitForTargetTimer = Engine.Ticks + Constants.WAIT_FOR_TARGET_DELAY;
                        }

                        if (TargetManager.IsTargeting)
                        {
                            TargetManager.TargetGameObject(macro.Code == MacroType.BandageSelf ? World.Player : World.Mobiles.Get(TargetManager.LastTarget));
                        }
                        else
                        {
                            result = 1;
                        }

                        WaitingBandageTarget = false;
                        WaitForTargetTimer   = 0;
                    }
                    else
                    {
                        var bandage = World.Player.FindBandage();

                        if (bandage != null)
                        {
                            WaitingBandageTarget = true;
                            GameActions.DoubleClick(bandage);
                            result = 1;
                        }
                    }
                }
                else
                {
                    var bandage = World.Player.FindBandage();

                    if (bandage != null)
                    {
                        if (macro.Code == MacroType.BandageSelf)
                        {
                            NetClient.Socket.Send(new PTargetSelectedObject(bandage.Serial, World.Player.Serial));
                        }
                        else
                        {
                            // TODO: NewTargetSystem
                            Log.Message(LogTypes.Warning, "BandageTarget (NewTargetSystem) not implemented yet.");
                        }
                    }
                }

                break;

            case MacroType.SetUpdateRange:
            case MacroType.ModifyUpdateRange:

                if (macro is MacroObjectString moss && !string.IsNullOrEmpty(moss.Text) && byte.TryParse(moss.Text, out byte res))
                {
                    if (res < Constants.MIN_VIEW_RANGE)
                    {
                        res = Constants.MIN_VIEW_RANGE;
                    }
                    else if (res > Constants.MAX_VIEW_RANGE)
                    {
                        res = Constants.MAX_VIEW_RANGE;
                    }

                    World.ClientViewRange = res;

                    GameActions.Print($"ClientViewRange is now {res}.");
                }

                break;

            case MacroType.IncreaseUpdateRange:
                World.ClientViewRange++;

                if (World.ClientViewRange > Constants.MAX_VIEW_RANGE)
                {
                    World.ClientViewRange = Constants.MAX_VIEW_RANGE;
                }

                GameActions.Print($"ClientViewRange is now {World.ClientViewRange}.");

                break;

            case MacroType.DecreaseUpdateRange:
                World.ClientViewRange--;

                if (World.ClientViewRange < Constants.MIN_VIEW_RANGE)
                {
                    World.ClientViewRange = Constants.MIN_VIEW_RANGE;
                }
                GameActions.Print($"ClientViewRange is now {World.ClientViewRange}.");

                break;

            case MacroType.MaxUpdateRange:
                World.ClientViewRange = Constants.MAX_VIEW_RANGE;
                GameActions.Print($"ClientViewRange is now {World.ClientViewRange}.");

                break;

            case MacroType.MinUpdateRange:
                World.ClientViewRange = Constants.MIN_VIEW_RANGE;
                GameActions.Print($"ClientViewRange is now {World.ClientViewRange}.");

                break;

            case MacroType.DefaultUpdateRange:
                World.ClientViewRange = Constants.MAX_VIEW_RANGE;
                GameActions.Print($"ClientViewRange is now {World.ClientViewRange}.");

                break;

            case MacroType.SelectNext:
            case MacroType.SelectPrevious:
            case MacroType.SelectNearest:
                // TODO:
                int scantype  = macro.SubCode - MacroSubType.Hostile;
                int scanRange = macro.Code - MacroType.SelectNext;


                switch (scanRange)
                {
                case 0:

                    break;

                case 1:

                    break;

                case 2:

                    break;
                }


                break;

            case MacroType.ToggleBuffIconGump:
                BuffGump buff = Engine.UI.GetGump <BuffGump>();

                if (buff != null)
                {
                    buff.Dispose();
                }
                else
                {
                    Engine.UI.Add(new BuffGump(100, 100));
                }

                break;

            case MacroType.InvokeVirtue:
                byte id = (byte)(macro.SubCode - MacroSubType.Honor + 31);
                NetClient.Socket.Send(new PInvokeVirtueRequest(id));

                break;

            case MacroType.PrimaryAbility:
                GameActions.UsePrimaryAbility();

                break;

            case MacroType.SecondaryAbility:
                GameActions.UseSecondaryAbility();

                break;

            case MacroType.ToggleGargoyleFly:

                if (World.Player.Race == RaceType.GARGOYLE)
                {
                    NetClient.Socket.Send(new PToggleGargoyleFlying());
                }

                break;

            case MacroType.EquipLastWeapon:
                NetClient.Socket.Send(new PEquipLastWeapon());

                break;

            case MacroType.KillGumpOpen:
                // TODO:

                break;

            case MacroType.DefaultScale:
                Engine.SceneManager.GetScene <GameScene>().Scale = 1;

                break;

            case MacroType.ToggleChatVisibility:
                Engine.UI.SystemChat?.ToggleChatVisibility();

                break;

            case MacroType.MovePlayer:
                switch (macro.SubCode)
                {
                case MacroSubType.Top:
                    break;

                case MacroSubType.Right:
                    break;

                case MacroSubType.Down:
                    break;

                case MacroSubType.Left:
                    break;
                }

                break;

            case MacroType.Aura:
                // hold to draw
                break;

            case MacroType.AuraOnOff:
                Engine.AuraManager.ToggleVisibility();

                break;

            case MacroType.Grab:
                GameActions.Print("Target an Item to grab it.");
                TargetManager.SetTargeting(CursorTarget.Grab, Serial.INVALID, TargetType.Neutral);

                break;

            case MacroType.SetGrabBag:
                GameActions.Print("Target the container to Grab items into.");
                TargetManager.SetTargeting(CursorTarget.SetGrabBag, Serial.INVALID, TargetType.Neutral);

                break;

            case MacroType.NamesOnOff:
                NameOverHeadManager.ToggleOverheads();

                break;

            case MacroType.UsePotion:
                scantype = macro.SubCode - MacroSubType.ConfusionBlastPotion;

                ushort start = (ushort)(0x0F06 + scantype);

                Item potion = World.Player.FindItemByGraphic(start);
                if (potion != null)
                {
                    GameActions.DoubleClick(potion);
                }

                break;
            }


            return(result);
        }