public override void Handle(NecClient client, NecPacket packet)
        {
            IBuffer res = BufferProvider.Provide();

            res.WriteInt32(0);
            router.Send(client, (ushort)AreaPacketId.recv_shortcut_request_data_r, res, ServerType.Area);

            // Need to find definitions for different action types as Ids do overlap,  0 ?, 1 ?, 2 ? , 3 for skill_tree item, 4 for system , 5 for emote
            // Should we have a shortcutBarItem class?
            const int MAX_SHORTCUT_BARS = 5;

            for (int i = 0; i < MAX_SHORTCUT_BARS; i++)
            {
                ShortcutBar shortcutBar = database.GetShortcutBar(client.character, i);
                for (int j = 0; j < ShortcutBar.COUNT; j++)
                {
                    if (shortcutBar.item[j] is null)
                    {
                        continue;
                    }
                    IBuffer res0 = BufferProvider.Provide();
                    res0.WriteByte((byte)i);
                    res0.WriteByte((byte)j);
                    res0.WriteInt32((int)shortcutBar.item[j].type);
                    res0.WriteInt64(shortcutBar.item[j].id); // SkillId from skill_tree.csv for class skills
                    res0.WriteFixedString("SkillName", 16);  //size is 0x10
                    router.Send(client, (ushort)AreaPacketId.recv_shortcut_notify_regist, res0, ServerType.Area);
                }
            }
        }
        public static void HandleShortcutBarAdd(ShortcutBarAddRequestMessage message, WorldClient client)
        {
            var bar = client.Character.GetShortcutBar((ShortcutBarEnum)message.barType);

            CharacterShortcut shortcut = ShortcutBar.GetCharacterShortcut(client.Character, message.shortcut);

            if (shortcut != null)
            {
                bar.Add(shortcut);
            }
        }
        public override void Handle(NecClient client, NecPacket packet)
        {
            IBuffer res            = BufferProvider.Provide();
            byte    shortcutBarIdx = packet.Data.ReadByte(),
                    slot    = packet.Data.ReadByte();
            int  actionType = packet.Data.ReadInt32();
            long skillID    = packet.Data.ReadInt64();

            int shortcutBarId = -1;

            switch (shortcutBarIdx)
            {
            case 0:
                shortcutBarId = client.Character.shortcutBar0Id;
                break;

            case 1:
                shortcutBarId = client.Character.shortcutBar1Id;
                break;

            case 2:
                shortcutBarId = client.Character.shortcutBar2Id;
                break;

            case 3:
                shortcutBarId = client.Character.shortcutBar3Id;
                break;

            case 4:
                shortcutBarId = client.Character.shortcutBar4Id;
                break;

            default:
                return;
            }
            ShortcutBar shortcutBar = Database.SelectShortcutBarById(shortcutBarId);

            int [] slots = shortcutBar.getSlotArray();
            slots[slot] = (int)skillID;
            shortcutBar.setSlotArray(slots);
            int[] actions = shortcutBar.getActionArray();
            actions[slot] = actionType;
            shortcutBar.setActionArray(actions);
            Database.UpdateShortcutBar(shortcutBar);

            res.WriteByte(shortcutBarIdx);
            res.WriteByte(slot);
            res.WriteInt32(actionType);
            res.WriteInt64(skillID);
            res.WriteFixedString("SkillName", 16);//size is 0x10

            Router.Send(client, (ushort)AreaPacketId.recv_shortcut_notify_regist, res, ServerType.Area);
        }
Exemple #4
0
        private void CreateShortcutBars(NecClient client, Character character, uint classId)
        {
            if (classId == 0) // Fighter
            {
                //TODO Fix magic numbers all over the place
                database.InsertOrReplaceShortcutItem(character, 0, 0, new ShortcutItem(11101, ShortcutItem.ShortcutType.Skill));
                database.InsertOrReplaceShortcutItem(character, 0, 1, new ShortcutItem(11201, ShortcutItem.ShortcutType.Skill));
            }
            else if (classId == 1) // Thief
            {
                database.InsertOrReplaceShortcutItem(character, 0, 0, new ShortcutItem(14101, ShortcutItem.ShortcutType.Skill));
                database.InsertOrReplaceShortcutItem(character, 0, 1, new ShortcutItem(14302, ShortcutItem.ShortcutType.Skill));
                database.InsertOrReplaceShortcutItem(character, 0, 2, new ShortcutItem(14803, ShortcutItem.ShortcutType.Skill));
            }
            else if (classId == 2) // Mage
            {
                database.InsertOrReplaceShortcutItem(character, 0, 0, new ShortcutItem(13101, ShortcutItem.ShortcutType.Skill));
                database.InsertOrReplaceShortcutItem(character, 0, 1, new ShortcutItem(13404, ShortcutItem.ShortcutType.Skill));
            }
            else if (classId == 3) // Priest
            {
                database.InsertOrReplaceShortcutItem(character, 0, 0, new ShortcutItem(12501, ShortcutItem.ShortcutType.Skill));
                database.InsertOrReplaceShortcutItem(character, 0, 1, new ShortcutItem(12601, ShortcutItem.ShortcutType.Skill));
            }

            database.InsertOrReplaceShortcutItem(character, 0, 4, new ShortcutItem(11, ShortcutItem.ShortcutType.System));
            database.InsertOrReplaceShortcutItem(character, 0, 6, new ShortcutItem(18, ShortcutItem.ShortcutType.System));
            database.InsertOrReplaceShortcutItem(character, 0, 7, new ShortcutItem(22, ShortcutItem.ShortcutType.System));
            database.InsertOrReplaceShortcutItem(character, 0, 9, new ShortcutItem(2, ShortcutItem.ShortcutType.System));


            ShortcutBar shortcutBar1 = new ShortcutBar();

            database.InsertOrReplaceShortcutItem(character, 1, 0, new ShortcutItem(1, ShortcutItem.ShortcutType.Emote));
            database.InsertOrReplaceShortcutItem(character, 1, 1, new ShortcutItem(2, ShortcutItem.ShortcutType.Emote));
            database.InsertOrReplaceShortcutItem(character, 1, 2, new ShortcutItem(4, ShortcutItem.ShortcutType.Emote));
            database.InsertOrReplaceShortcutItem(character, 1, 3, new ShortcutItem(5, ShortcutItem.ShortcutType.Emote));
            database.InsertOrReplaceShortcutItem(character, 1, 4, new ShortcutItem(6, ShortcutItem.ShortcutType.Emote));
            database.InsertOrReplaceShortcutItem(character, 1, 5, new ShortcutItem(7, ShortcutItem.ShortcutType.Emote));
            database.InsertOrReplaceShortcutItem(character, 1, 6, new ShortcutItem(11, ShortcutItem.ShortcutType.Emote));
            database.InsertOrReplaceShortcutItem(character, 1, 7, new ShortcutItem(14, ShortcutItem.ShortcutType.Emote));
            database.InsertOrReplaceShortcutItem(character, 1, 8, new ShortcutItem(15, ShortcutItem.ShortcutType.Emote));
            database.InsertOrReplaceShortcutItem(character, 1, 9, new ShortcutItem(16, ShortcutItem.ShortcutType.Emote));
        }
        public PlayedCharacter(Bot bot, CharacterBaseInformations informations)
        {
            if (informations == null)
            {
                throw new ArgumentNullException("informations");
            }

            Bot = bot;

            Id    = informations.id;
            Level = informations.level;
            Name  = informations.name;
            Breed = DataProvider.Instance.Get <Breed>(informations.breed);
            Look  = informations.entityLook;
            Sex   = informations.sex;

            Inventory  = new Inventory(this);
            Stats      = new Stats.PlayerStats(this);
            SpellsBook = new SpellsBook(this);
            Shortcuts  = new ShortcutBar(this);
            Jobs       = new List <Job>();
            Emotes     = new List <Emoticon>();
        }
        public ShortcutBar GetShortcutBar(Character character, int barNumber)
        {
            ShortcutBar shortcutBar = new ShortcutBar();

            ExecuteReader(SQL_SELECT_SHORTCUT_BAR,
                          command =>
            {
                AddParameter(command, "@character_id", character.id);
                AddParameter(command, "@bar_num", barNumber);
            }, reader =>
            {
                while (reader.Read())
                {
                    int i = GetInt32(reader, "slot_num");
                    if (i < 0 || i > ShortcutBar.COUNT)
                    {
                        continue;
                    }
                    ShortcutItem shortcutItem = new ShortcutItem(GetInt32(reader, "shortcut_id"), (ShortcutItem.ShortcutType)GetInt32(reader, "shortcut_type"));
                    shortcutBar.item[i]       = shortcutItem;
                }
            });
            return(shortcutBar);
        }
Exemple #7
0
        private void CreateShortcutBars(NecClient client, Character character, uint class_id)
        {
            ShortcutBar shortcutBar0 = new ShortcutBar();

            if (class_id == 0) // Fighter
            {
                shortcutBar0.Slot0   = 11101;
                shortcutBar0.Action0 = 3;
                shortcutBar0.Slot1   = 11201;
                shortcutBar0.Action1 = 3;
            }
            else if (class_id == 1) // Thief
            {
                shortcutBar0.Slot0   = 14101;
                shortcutBar0.Action0 = 3;
                shortcutBar0.Slot1   = 14302;
                shortcutBar0.Action1 = 3;
                shortcutBar0.Slot2   = 14803;
                shortcutBar0.Action2 = 3;
            }
            else if (class_id == 2) // Mage
            {
                shortcutBar0.Slot0   = 13101;
                shortcutBar0.Action0 = 3;
                shortcutBar0.Slot1   = 13404;
                shortcutBar0.Action1 = 3;
            }
            else if (class_id == 3) // Priest
            {
                shortcutBar0.Slot0   = 12501;
                shortcutBar0.Action0 = 3;
                shortcutBar0.Slot1   = 12601;
                shortcutBar0.Action1 = 3;
            }

            shortcutBar0.Slot4   = 11;
            shortcutBar0.Action4 = 4;
            shortcutBar0.Slot6   = 18;
            shortcutBar0.Action6 = 4;
            shortcutBar0.Slot7   = 22;
            shortcutBar0.Action7 = 4;
            shortcutBar0.Slot9   = 2;
            shortcutBar0.Action9 = 4;
            if (!Database.InsertShortcutBar(shortcutBar0))
            {
                Logger.Error(client, $"Failed to create ShortcutBar0");
                client.Close();
                character.shortcutBar0Id = -1;
                return;
            }

            character.shortcutBar0Id = shortcutBar0.Id;

            ShortcutBar shortcutBar1 = new ShortcutBar();

            shortcutBar1.Slot0   = 1;
            shortcutBar1.Action0 = 5;
            shortcutBar1.Slot1   = 2;
            shortcutBar1.Action1 = 5;
            shortcutBar1.Slot2   = 4;
            shortcutBar1.Action2 = 5;
            shortcutBar1.Slot3   = 5;
            shortcutBar1.Action3 = 5;
            shortcutBar1.Slot4   = 6;
            shortcutBar1.Action4 = 5;
            shortcutBar1.Slot5   = 7;
            shortcutBar1.Action5 = 5;
            shortcutBar1.Slot6   = 11;
            shortcutBar1.Action6 = 5;
            shortcutBar1.Slot7   = 14;
            shortcutBar1.Action7 = 5;
            shortcutBar1.Slot8   = 15;
            shortcutBar1.Action8 = 5;
            shortcutBar1.Slot9   = 16;
            shortcutBar1.Action9 = 5;
            if (!Database.InsertShortcutBar(shortcutBar1))
            {
                Logger.Error(client, $"Failed to create ShortcutBar1");
                client.Close();
                character.shortcutBar1Id = -1;
                return;
            }

            character.shortcutBar1Id = shortcutBar1.Id;

            ShortcutBar shortcutBar2 = new ShortcutBar();

            if (!Database.InsertShortcutBar(shortcutBar2))
            {
                Logger.Error(client, $"Failed to create ShortcutBar2");
                client.Close();
                character.shortcutBar2Id = -1;
                return;
            }

            character.shortcutBar2Id = shortcutBar2.Id;

            ShortcutBar shortcutBar3 = new ShortcutBar();

            if (!Database.InsertShortcutBar(shortcutBar3))
            {
                Logger.Error(client, $"Failed to create ShortcutBar3");
                client.Close();
                character.shortcutBar3Id = -1;
                return;
            }

            character.shortcutBar3Id = shortcutBar3.Id;

            ShortcutBar shortcutBar4 = new ShortcutBar();

            if (!Database.InsertShortcutBar(shortcutBar4))
            {
                Logger.Error(client, $"Failed to create ShortcutBar4");
                client.Close();
                character.shortcutBar4Id = -1;
                return;
            }

            character.shortcutBar4Id = shortcutBar4.Id;
        }
Exemple #8
0
        public winGame()
        {
            //this.Windowed = false;
            //this.Size = SdlDotNet.Graphics.Video.Screen.Size;
            //this.Location = new System.Drawing.Point(0, 0);
            //this.BackColor = Color.SteelBlue;

            pnlTeam          = new ActiveTeamPanel("pnlTeam");
            pnlTeam.Size     = new Size(SdlDotNet.Graphics.Video.Screen.Width /* - 50*/, 100);
            pnlTeam.Location = new Point(SdlDotNet.Widgets.DrawingSupport.GetCenter(SdlDotNet.Graphics.Video.Screen.Size, pnlTeam.Size).X, 0);

            lblStats          = new StatLabel("lblStats");
            lblStats.Size     = new System.Drawing.Size(400, 30);
            lblStats.Location = new Point(pnlTeam.X + 10, 70);

            mapViewer                   = new Widgets.MapViewer("mapViewer");
            mapViewer.Size              = new Size(640, 480);
            mapViewer.Location          = new Point(SdlDotNet.Graphics.Video.Screen.Width - mapViewer.Width, pnlTeam.Y + pnlTeam.Height + 1);
            mapViewer.ActiveMap         = null;
            mapViewer.BackColor         = Color.Gray;
            mapViewer.KeyRepeatInterval = 1;
            //mapViewer.BeforeKeyDown += new EventHandler<SdlDotNet.Widgets.BeforeKeyDownEventArgs>(mapViewer_BeforeKeyDown);
            mapViewer.KeyDown     += new EventHandler <SdlDotNet.Input.KeyboardEventArgs>(mapViewer_KeyDown);
            mapViewer.KeyUp       += new EventHandler <SdlDotNet.Input.KeyboardEventArgs>(mapViewer_KeyUp);
            mapViewer.Click       += new EventHandler <SdlDotNet.Widgets.MouseButtonEventArgs>(mapViewer_Click);
            mapViewer.MouseMotion += new EventHandler <SdlDotNet.Input.MouseMotionEventArgs>(mapViewer_MouseMotion);

            menuManager                   = new Menus.Core.MenuManager("menuManager", mapViewer);
            menuManager.Location          = mapViewer.Location;
            menuManager.Size              = mapViewer.Size;
            menuManager.Visible           = false;
            menuManager.KeyDown          += new EventHandler <SdlDotNet.Input.KeyboardEventArgs>(menuManager_KeyDown);
            menuManager.KeyUp            += new EventHandler <SdlDotNet.Input.KeyboardEventArgs>(menuManager_KeyUp);
            menuManager.KeyRepeatInterval = 0;
            menuManager.Click            += new EventHandler <SdlDotNet.Widgets.MouseButtonEventArgs>(menuManager_Click);

            battleLog          = new BattleLog("battleLog");
            battleLog.Size     = new System.Drawing.Size(mapViewer.Width - 10, 100);
            battleLog.Location = new Point(mapViewer.X + 5, mapViewer.Y + mapViewer.Height - battleLog.Height);
            battleLog.Visible  = false;

            shortcutBar          = new ShortcutBar("shortcutBar");
            shortcutBar.Location = new Point(SdlDotNet.Graphics.Video.Screen.Width - shortcutBar.Width, mapViewer.Y + mapViewer.Height);
            ShortcutBarBuilder.AssembleShortcutBarButtons(shortcutBar);

            pnlTeam.Hide();
            lblStats.Hide();
            mapViewer.Hide();
            menuManager.Hide();
            shortcutBar.Hide();

            SdlDotNet.Widgets.Screen.AddWidget(pnlTeam);
            SdlDotNet.Widgets.Screen.AddWidget(mapViewer);
            SdlDotNet.Widgets.Screen.AddWidget(lblStats);
            SdlDotNet.Widgets.Screen.AddWidget(battleLog);
            SdlDotNet.Widgets.Screen.AddWidget(menuManager);
            SdlDotNet.Widgets.Screen.AddWidget(shortcutBar);

            InitMapEditorWidgets();

            // Add the events
            pnlTeam.ActiveRecruitChanged += new EventHandler <Events.ActiveRecruitChangedEventArgs>(pnlTeam_ActiveRecruitChanged);

            //this.LoadComplete();

            SdlDotNet.Core.Events.Tick += new EventHandler <SdlDotNet.Core.TickEventArgs>(winGame_Tick);
            //base.Tick += new EventHandler<SdlDotNet.Core.TickEventArgs>(winGame_Tick);
        }
Exemple #9
0
        public override void Handle(NecClient client, NecPacket packet)
        {
            IBuffer res = BufferProvider.Provide();

            res.WriteInt32(0);
            Router.Send(client, (ushort)AreaPacketId.recv_shortcut_request_data_r, res, ServerType.Area);

            // Need to find definitions for different action types as Ids do overlap,  0 ?, 1 ?, 2 ? , 3 for skill_tree item, 4 for system , 5 for emote
            // Should we have a shortcutBarItem class?
            ShortcutBar shortcutBar0 = Database.SelectShortcutBarById(client.Character.shortcutBar0Id);
            ShortcutBar shortcutBar1 = Database.SelectShortcutBarById(client.Character.shortcutBar1Id);
            ShortcutBar shortcutBar2 = Database.SelectShortcutBarById(client.Character.shortcutBar2Id);
            ShortcutBar shortcutBar3 = Database.SelectShortcutBarById(client.Character.shortcutBar3Id);
            ShortcutBar shortcutBar4 = Database.SelectShortcutBarById(client.Character.shortcutBar4Id);

            int[] slots0  = shortcutBar0.getSlotArray();
            int[] slots1  = shortcutBar1.getSlotArray();
            int[] slots2  = shortcutBar2.getSlotArray();
            int[] slots3  = shortcutBar3.getSlotArray();
            int[] slots4  = shortcutBar4.getSlotArray();
            int[] action0 = shortcutBar0.getActionArray();
            int[] action1 = shortcutBar1.getActionArray();
            int[] action2 = shortcutBar2.getActionArray();
            int[] action3 = shortcutBar3.getActionArray();
            int[] action4 = shortcutBar4.getActionArray();
            for (int i = 0; i < slots0.Length; i++)
            {
                if (slots0[i] > 0)
                {
                    IBuffer res0 = BufferProvider.Provide();
                    res0.WriteByte(0);
                    res0.WriteByte((byte)i);
                    res0.WriteInt32(action0[i]);
                    res0.WriteInt64(slots0[i]);             // SkillId from skill_tree.csv for class skills
                    res0.WriteFixedString("SkillName", 16); //size is 0x10
                    Router.Send(client, (ushort)AreaPacketId.recv_shortcut_notify_regist, res0, ServerType.Area);
                }
            }
            for (int i = 0; i < slots1.Length; i++)
            {
                if (slots1[i] > 0)
                {
                    IBuffer res1 = BufferProvider.Provide();
                    res1.WriteByte(1);
                    res1.WriteByte((byte)i);
                    res1.WriteInt32(action1[i]);
                    res1.WriteInt64(slots1[i]);
                    res1.WriteFixedString("SkillName", 16);//size is 0x10
                    Router.Send(client, (ushort)AreaPacketId.recv_shortcut_notify_regist, res1, ServerType.Area);
                }
            }

            for (int i = 0; i < slots2.Length; i++)
            {
                if (slots2[i] > 0)
                {
                    IBuffer res1 = BufferProvider.Provide();
                    res1.WriteByte(2);
                    res1.WriteByte((byte)i);
                    res1.WriteInt32(action2[i]);
                    res1.WriteInt64(slots2[i]);
                    res1.WriteFixedString("SkillName", 16);//size is 0x10
                    Router.Send(client, (ushort)AreaPacketId.recv_shortcut_notify_regist, res1, ServerType.Area);
                }
            }
            for (int i = 0; i < slots3.Length; i++)
            {
                if (slots3[i] > 0)
                {
                    IBuffer res1 = BufferProvider.Provide();
                    res1.WriteByte(3);
                    res1.WriteByte((byte)i);
                    res1.WriteInt32(action3[i]);
                    res1.WriteInt64(slots3[i]);
                    res1.WriteFixedString("SkillName", 16);//size is 0x10
                    Router.Send(client, (ushort)AreaPacketId.recv_shortcut_notify_regist, res1, ServerType.Area);
                }
            }
            for (int i = 0; i < slots4.Length; i++)
            {
                if (slots4[i] > 0)
                {
                    IBuffer res1 = BufferProvider.Provide();
                    res1.WriteByte(4);
                    res1.WriteByte((byte)i);
                    res1.WriteInt32(action4[i]);
                    res1.WriteInt64(slots4[i]);
                    res1.WriteFixedString("SkillName", 16);//size is 0x10
                    Router.Send(client, (ushort)AreaPacketId.recv_shortcut_notify_regist, res1, ServerType.Area);
                }
            }
        }