ReadByte() public method

public ReadByte ( ) : byte
return byte
Ejemplo n.º 1
0
        public static void OnGM(PacketReader reader_, int Index_)
        {
            if (Player.Flags[Index_].GM == 1)
            {
                byte id = reader_.ReadByte();

                switch (id)
                {
                    case 6:
                        MonsterSpawn.OnSpawn(reader_, Index_);
                        break;
                    case 7:
                        Items.CreateItem(reader_, Index_);
                        break;
                    case 13:
                        BanPlayer(reader_, Index_);
                        break;
                    case 14:
                        OnInvisible(Index_);
                        break;

                    case 20:
                        MonsterSpawn.KillMonster(reader_, Index_);
                        break;
                }
            }
        }
Ejemplo n.º 2
0
        public static void OnChat(PacketReader reader_, int Index_)
        {
            reader = reader_;

            byte type = reader.ReadByte();
            byte chatoffset = reader.ReadByte();

            PacketWriter writer = new PacketWriter();
            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_CHAT_ACCEPT);
            writer.AppendByte(1);
            writer.AppendByte(type);
            writer.AppendByte(chatoffset);

            ServerSocket.Send(writer.getWorkspace(), Index_);

            switch (type)
            {
                case 1:
                case 3:
                    OnChatPublic(reader_, Index_);
                    break;
                case 2:
                    OnChatWhisper(reader_, Index_);
                    break;
                case 4:
                    //	OnChatParty();
                    break;
                case 5:
                    //	OnChatGuild();
                    break;
                case 6:
                    //	OnChatGlobal();
                    break;
                case 7:
                    OnChatNotice(reader_);
                    break;
                case 11:
                    //	OnChatUnion();
                    break;
            }
        }
Ejemplo n.º 3
0
        public static void CreateItem(PacketReader reader_, int Index_)
        {
            int[] CharacterItemIndex = DatabaseCore.Item.GetIndexByName(Player.General[Index_].CharacterName);

            byte freeslot = FreeSlot(CharacterItemIndex);

            uint itemid = reader_.ReadDword();
            byte itemplus = reader_.ReadByte();

            Silkroad.Item_ DestinationItem_ = Silkroad.GetItemById(itemid);

            if (DestinationItem_.ITEM_TYPE_NAME.Contains("ITEM_ETC_GOLD_"))
                freeslot = 254;

            PacketWriter writer = new PacketWriter();
            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ITEM_MOVEMENT);
            writer.AppendWord(0x601);
            writer.AppendByte(freeslot);
            if (freeslot != 254)
                writer.AppendDword(itemid);
            if (DestinationItem_.ITEM_TYPE_NAME.Contains("CH") || DestinationItem_.ITEM_TYPE_NAME.Contains("EU"))
            {
                writer.AppendByte(itemplus);
                writer.AppendLword(0);
                writer.AppendDword((uint)DestinationItem_.MIN_DURA);
                writer.AppendByte(0);

                DatabaseCore.WriteQuery("UPDATE items SET itemid='{0}',plusvalue='{1}',type='0',durability='{2}' WHERE itemnumber='item{3}' AND owner ='{4}'", itemid, itemplus, DestinationItem_.MIN_DURA, freeslot, Player.General[Index_].CharacterName);
                AddItemToDatabase(CharacterItemIndex[freeslot], itemid, 0, 0, (byte)DestinationItem_.MIN_DURA, itemplus, 0);

            }
            else if (DestinationItem_.ITEM_TYPE_NAME.Contains("ETC"))
            {
                if (freeslot != 254)
                {
                    writer.AppendWord(itemplus);
                    DatabaseCore.WriteQuery("UPDATE items SET itemid='{0}',plusvalue='0',type='1',durability='{1}',quantity='{2}' WHERE itemnumber='item{3}' AND owner ='{4}'", itemid, DestinationItem_.MIN_DURA, itemplus, freeslot, Player.General[Index_].CharacterName);
                    AddItemToDatabase(CharacterItemIndex[freeslot], itemid, 1, itemplus, (byte)DestinationItem_.MIN_DURA, 0, 0);
                }
            }

            ServerSocket.Send(writer.getWorkspace(), Index_);
        }
Ejemplo n.º 4
0
        public static void OnUseItem(PacketReader reader, int Index_)
        {
            int[] CharacterItemIndex = DatabaseCore.Item.GetIndexByName(Player.General[Index_].CharacterName);
            byte slot = reader.ReadByte();
            Silkroad.Item_ item = Silkroad.GetItemById(DatabaseCore.Item.ItemId[CharacterItemIndex[slot]]);

            if (DatabaseCore.Item.ItemId[CharacterItemIndex[slot]] >= 4 && DatabaseCore.Item.ItemId[CharacterItemIndex[slot]] <= 23)
            {
                if ((DatabaseCore.Item.Quantity[CharacterItemIndex[slot]] - 1) > 0)
                    DatabaseCore.Item.Quantity[CharacterItemIndex[slot]]--;
                else
                {
                    DeleteFromDatabase(CharacterItemIndex[slot]);
                    DatabaseCore.WriteQuery("DELETE FROM items WHERE itemnumber='item{0}' AND owner='{1}'", slot, Player.General[Index_].CharacterName);
                }

                PacketWriter writer = new PacketWriter();
                writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ITEM_USE);
                writer.AppendByte(1);
                writer.AppendByte(slot);
                writer.AppendWord(DatabaseCore.Item.Quantity[CharacterItemIndex[slot]]);
                writer.AppendWord(reader.ReadWord());
                ServerSocket.Send(writer.getWorkspace(), Index_);

                writer = new PacketWriter();
                writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ANIMATION_POTION);
                writer.AppendDword(Player.General[Index_].UniqueID);
                if (item.ITEM_TYPE_NAME.Contains("HP") && !item.ITEM_TYPE_NAME.Contains("SPOTION"))
                {
                    writer.AppendDword(0x04);
                    ServerSocket.SendPacketIfPlayerIsSpawned(writer.getWorkspace(), Index_);

                    Player.Stats[Index_].CHP += item.USE_TIME;
                    Stats.HPUpdate(Index_, false);
                }
                else if (item.ITEM_TYPE_NAME.Contains("HP") && item.ITEM_TYPE_NAME.Contains("SPOTION"))
                {
                    writer.AppendDword(0x04);
                    ServerSocket.SendPacketIfPlayerIsSpawned(writer.getWorkspace(), Index_);

                    Player.Stats[Index_].CHP += ((int)Player.Stats[Index_].HP * item.USE_TIME2 / 100);
                    Stats.HPUpdate(Index_, false);
                }
                else if (item.ITEM_TYPE_NAME.Contains("MP") && !item.ITEM_TYPE_NAME.Contains("SPOTION"))
                {
                    writer.AppendDword(0x0E);
                    ServerSocket.SendPacketIfPlayerIsSpawned(writer.getWorkspace(), Index_);

                    Player.Stats[Index_].CMP += item.USE_TIME3;
                    Stats.MPUpdate(Index_, false);
                }
                else if (item.ITEM_TYPE_NAME.Contains("MP") && item.ITEM_TYPE_NAME.Contains("SPOTION"))
                {
                    writer.AppendDword(0x0E);
                    ServerSocket.SendPacketIfPlayerIsSpawned(writer.getWorkspace(), Index_);

                    Player.Stats[Index_].CMP += ((int)Player.Stats[Index_].MP * item.USE_TIME4 / 100);
                    Stats.MPUpdate(Index_, false);
                }
                else if (item.ITEM_TYPE_NAME.Contains("ALL") && !item.ITEM_TYPE_NAME.Contains("SPOTION"))
                {
                    writer.AppendDword(0x17);
                    ServerSocket.SendPacketIfPlayerIsSpawned(writer.getWorkspace(), Index_);

                    Player.Stats[Index_].CHP += item.USE_TIME;
                    Player.Stats[Index_].CMP += item.USE_TIME3;
                    Stats.HPMPUpdate(Index_);
                }
                else if (item.ITEM_TYPE_NAME.Contains("ALL") && item.ITEM_TYPE_NAME.Contains("SPOTION"))
                {
                    writer.AppendDword(0x17);
                    ServerSocket.SendPacketIfPlayerIsSpawned(writer.getWorkspace(), Index_);

                    Player.Stats[Index_].CHP += ((int)Player.Stats[Index_].HP * item.USE_TIME2 / 100);
                    Player.Stats[Index_].CMP += ((int)Player.Stats[Index_].MP * item.USE_TIME4 / 100);
                    Stats.HPMPUpdate(Index_);
                }
            }
        }
Ejemplo n.º 5
0
        private static void OnCharCreation(PacketReader Reader_, int Index_)
        {
            PacketWriter writer = new PacketWriter();

            ushort charlen = Reader_.ReadWord();
            string name = Reader_.ReadString(false, charlen);

            uint model = Reader_.ReadDword();
            byte volume = Reader_.ReadByte();

            uint[] _item = new uint[5];

            _item[1] = Reader_.ReadDword();
            _item[2] = Reader_.ReadDword();
            _item[3] = Reader_.ReadDword();
            _item[4] = Reader_.ReadDword();

            int UserIndex = DatabaseCore.User.GetIndexByName(Player.General[Index_].User);

            if (DatabaseCore.Character.GetIndexByName(name) != -1)
            {
                writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_CHARACTER);
                writer.AppendWord(0x204);
                writer.AppendByte(0x10);
                ServerSocket.Send(writer.getWorkspace(), Index_);
            }
            else
            {
                double magdefmin = 3.0;
                double phydefmin = 6.0;
                ushort parrymin = 11;
                ushort phyatkmin = 6;
                ushort phyatkmax = 9;
                ushort magatkmin = 6;
                ushort magatkmax = 10;

                Silkroad.Item_ _item_1 = Silkroad.GetItemById(_item[1]);
                Silkroad.Item_ _item_2 = Silkroad.GetItemById(_item[2]);
                Silkroad.Item_ _item_3 = Silkroad.GetItemById(_item[3]);
                Silkroad.Item_ _item_4 = Silkroad.GetItemById(_item[4]);

                DatabaseCore.User.CharacterCount[UserIndex]++;
                Array.Resize<string>(ref DatabaseCore.User.Characters[UserIndex].CharacterName, DatabaseCore.User.CharacterCount[UserIndex]);
                DatabaseCore.User.Characters[UserIndex].CharacterName[DatabaseCore.User.CharacterCount[UserIndex] - 1] = name;

                DatabaseCore.Character.NumberOfCharacters++;
                Array.Resize<string>(ref DatabaseCore.Character.CharacterName, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<string>(ref DatabaseCore.Character.CharacterName, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<uint>(ref DatabaseCore.Character.CharacterId, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<uint>(ref DatabaseCore.Character.UniqueId, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<uint>(ref DatabaseCore.Character.HP, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<uint>(ref DatabaseCore.Character.MP, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<int>(ref DatabaseCore.Character.CHP, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<int>(ref DatabaseCore.Character.CMP, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<uint>(ref DatabaseCore.Character.Model, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<byte>(ref DatabaseCore.Character.Volume, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<byte>(ref DatabaseCore.Character.Level, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<ulong>(ref DatabaseCore.Character.Experience, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<ulong>(ref DatabaseCore.Character.Gold, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<uint>(ref DatabaseCore.Character.SkillPoints, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<ushort>(ref DatabaseCore.Character.Attributes, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<byte>(ref DatabaseCore.Character.BerserkBar, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<byte>(ref DatabaseCore.Character.Berserk, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<float>(ref DatabaseCore.Character.WalkSpeed, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<float>(ref DatabaseCore.Character.RunSpeed, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<float>(ref DatabaseCore.Character.BerserkSpeed, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<ushort>(ref DatabaseCore.Character.MinPhy, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<ushort>(ref DatabaseCore.Character.MaxPhy, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<ushort>(ref DatabaseCore.Character.MinMag, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<ushort>(ref DatabaseCore.Character.MaxMag, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<ushort>(ref DatabaseCore.Character.PhyDef, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<ushort>(ref DatabaseCore.Character.MagDef, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<ushort>(ref DatabaseCore.Character.Hit, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<ushort>(ref DatabaseCore.Character.Parry, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<ushort>(ref DatabaseCore.Character.Strength, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<ushort>(ref DatabaseCore.Character.Intelligence, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<ushort>(ref DatabaseCore.Character.SkillPointBar, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<byte>(ref DatabaseCore.Character.GM, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<sbyte>(ref DatabaseCore.Character.PVP, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<byte>(ref DatabaseCore.Character.XSector, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<byte>(ref DatabaseCore.Character.YSector, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<float>(ref DatabaseCore.Character.X, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<float>(ref DatabaseCore.Character.Z, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<float>(ref DatabaseCore.Character.Y, DatabaseCore.Character.NumberOfCharacters);
                Array.Resize<byte>(ref DatabaseCore.Character.MaxSlots, DatabaseCore.Character.NumberOfCharacters);

                int NewCharacterIndex = DatabaseCore.Character.NumberOfCharacters - 1;
                DatabaseCore.Character.CharacterName[NewCharacterIndex] = name;
                DatabaseCore.Character.CharacterId[NewCharacterIndex] = DatabaseCore.Character.CharacterId[NewCharacterIndex] + 1;
                DatabaseCore.Character.UniqueId[NewCharacterIndex] = DatabaseCore.Character.UniqueId[NewCharacterIndex] + 300000;
                DatabaseCore.Character.HP[NewCharacterIndex] = 200;
                DatabaseCore.Character.MP[NewCharacterIndex] = 200;
                DatabaseCore.Character.CHP[NewCharacterIndex] = 200;
                DatabaseCore.Character.CMP[NewCharacterIndex] = 200;
                DatabaseCore.Character.Model[NewCharacterIndex] = model;
                DatabaseCore.Character.Volume[NewCharacterIndex] = volume;
                DatabaseCore.Character.Level[NewCharacterIndex] = 1;

                DatabaseCore.Character.WalkSpeed[NewCharacterIndex] = 16;
                DatabaseCore.Character.RunSpeed[NewCharacterIndex] = 50;
                DatabaseCore.Character.BerserkSpeed[NewCharacterIndex] = 100;
                DatabaseCore.Character.Strength[NewCharacterIndex] = 20;
                DatabaseCore.Character.Intelligence[NewCharacterIndex] = 20;
                DatabaseCore.Character.PVP[NewCharacterIndex] = -1;
                DatabaseCore.Character.XSector[NewCharacterIndex] = 168;
                DatabaseCore.Character.YSector[NewCharacterIndex] = 98;
                DatabaseCore.Character.X[NewCharacterIndex] = 978;
                DatabaseCore.Character.Z[NewCharacterIndex] = 1097;
                DatabaseCore.Character.Y[NewCharacterIndex] = 40;
                DatabaseCore.Character.MaxSlots[NewCharacterIndex] = 45;

                DatabaseCore.Item.NumberOfItems += 46;
                Array.Resize<string>(ref DatabaseCore.Item.CharacterName, DatabaseCore.Item.NumberOfItems);
                Array.Resize<uint>(ref DatabaseCore.Item.ItemId, DatabaseCore.Item.NumberOfItems);
                Array.Resize<byte>(ref DatabaseCore.Item.PlusValue, DatabaseCore.Item.NumberOfItems);
                Array.Resize<byte>(ref DatabaseCore.Item.Quantity, DatabaseCore.Item.NumberOfItems);
                Array.Resize<byte>(ref DatabaseCore.Item.Type, DatabaseCore.Item.NumberOfItems);
                Array.Resize<byte>(ref DatabaseCore.Item.Slot, DatabaseCore.Item.NumberOfItems);
                Array.Resize<byte>(ref DatabaseCore.Item.Durability, DatabaseCore.Item.NumberOfItems);
                Array.Resize<byte>(ref DatabaseCore.Item.BlueAmount, DatabaseCore.Item.NumberOfItems);
                Array.Resize<DatabaseCore.Item_.Blue_>(ref DatabaseCore.Item.Blue, DatabaseCore.Item.NumberOfItems);

                for (byte i = 0; i < 46; i++)
                {
                    int tmpItemIndex = DatabaseCore.Item.NumberOfItems - 46 + i;
                    DatabaseCore.Item.Slot[tmpItemIndex] = i;
                    DatabaseCore.Item.Durability[tmpItemIndex] = 30;
                    DatabaseCore.Item.CharacterName[tmpItemIndex] = name;
                    DatabaseCore.Item.Blue[tmpItemIndex] = new DatabaseCore.Item_.Blue_();
                    DatabaseCore.Item.Blue[tmpItemIndex].Blue = new uint[9];
                    DatabaseCore.Item.Blue[tmpItemIndex].BlueAmount = new byte[9];
                }

                DatabaseCore.WriteQuery("UPDATE user SET char_{0}='{1}' WHERE name='{2}'", DatabaseCore.User.CharacterCount[UserIndex], name, Player.General[Index_].User);
                DatabaseCore.WriteQuery("UPDATE user SET char_count='{0}' WHERE name='{1}'", DatabaseCore.User.CharacterCount[UserIndex], Player.General[Index_].User);
                DatabaseCore.WriteQuery("INSERT INTO characters (account, name, chartype, volume) VALUE ('{0}','{1}', '{2}', '{3}')", Player.General[Index_].User, name, model, volume);

                for (int i = 0; i <= 45; i++)
                    DatabaseCore.WriteQuery("INSERT INTO items (itemnumber, owner, slot) VALUE ('item{0}','{1}', '{0}')", i, name);

                DatabaseCore.WriteQuery("UPDATE items SET itemid='{0}',plusvalue='0' ,durability='{1}' WHERE itemnumber='item1' AND owner ='{2}'", _item[1], _item_1.MIN_DURA, name);
                DatabaseCore.WriteQuery("UPDATE items SET itemid='{0}',plusvalue='0' ,durability='{1}' WHERE itemnumber='item4' AND owner ='{2}'", _item[2], _item_2.MIN_DURA, name);
                DatabaseCore.WriteQuery("UPDATE items SET itemid='{0}',plusvalue='0' ,durability='{1}' WHERE itemnumber='item5' AND owner ='{2}'", _item[3], _item_3.MIN_DURA, name);
                DatabaseCore.WriteQuery("UPDATE items SET itemid='{0}',plusvalue='0' ,durability='{1}' WHERE itemnumber='item6' AND owner ='{2}'", _item[4], _item_4.MIN_DURA, name);

                DatabaseCore.Item.ItemId[DatabaseCore.Item.NumberOfItems - 45] = _item[1];
                DatabaseCore.Item.Durability[DatabaseCore.Item.NumberOfItems - 45] = (byte)_item_1.MIN_DURA;
                DatabaseCore.Item.ItemId[DatabaseCore.Item.NumberOfItems - 42] = _item[2];
                DatabaseCore.Item.Durability[DatabaseCore.Item.NumberOfItems - 42] = (byte)_item_2.MIN_DURA;
                DatabaseCore.Item.ItemId[DatabaseCore.Item.NumberOfItems - 41] = _item[3];
                DatabaseCore.Item.Durability[DatabaseCore.Item.NumberOfItems - 41] = (byte)_item_3.MIN_DURA;
                DatabaseCore.Item.ItemId[DatabaseCore.Item.NumberOfItems - 40] = _item[4];
                DatabaseCore.Item.Durability[DatabaseCore.Item.NumberOfItems - 40] = (byte)_item_4.MIN_DURA;

                phydefmin += _item_1.MIN_PHYSDEF + _item_2.MIN_PHYSDEF + _item_3.MIN_PHYSDEF;
                magdefmin += _item_1.MAGDEF_MIN + _item_2.MAGDEF_MIN + _item_3.MAGDEF_MIN;
                parrymin += (ushort)(_item_1.MIN_PARRY + _item_2.MIN_PARRY + _item_3.MIN_PARRY);
                phyatkmin += (ushort)_item_4.MIN_LPHYATK;
                phyatkmax += (ushort)_item_4.MIN_HPHYATK;
                magatkmin += (ushort)_item_4.MIN_LMAGATK;
                magatkmax += (ushort)_item_4.MIN_HMAGATK;

                if (model >= 1907 && model <= 1932)
                {
                    DatabaseCore.Mastery.NumberOfMasteries += 7;
                    Array.Resize<string>(ref DatabaseCore.Mastery.CharacterName, DatabaseCore.Mastery.NumberOfMasteries);
                    Array.Resize<ushort>(ref DatabaseCore.Mastery.MasteryId, DatabaseCore.Mastery.NumberOfMasteries);
                    Array.Resize<byte>(ref DatabaseCore.Mastery.MasteryLevel, DatabaseCore.Mastery.NumberOfMasteries);
                    Array.Resize<uint>(ref DatabaseCore.Character.CharacterId, DatabaseCore.Character.NumberOfCharacters);
                    for (byte i = 0; i < 7; i++)
                        DatabaseCore.Mastery.CharacterName[DatabaseCore.Mastery.NumberOfMasteries - 1 - i] = name;

                    DatabaseCore.Mastery.MasteryId[DatabaseCore.Mastery.NumberOfMasteries - 7] = 257;
                    DatabaseCore.Mastery.MasteryId[DatabaseCore.Mastery.NumberOfMasteries - 6] = 258;
                    DatabaseCore.Mastery.MasteryId[DatabaseCore.Mastery.NumberOfMasteries - 5] = 259;
                    DatabaseCore.Mastery.MasteryId[DatabaseCore.Mastery.NumberOfMasteries - 4] = 273;
                    DatabaseCore.Mastery.MasteryId[DatabaseCore.Mastery.NumberOfMasteries - 3] = 274;
                    DatabaseCore.Mastery.MasteryId[DatabaseCore.Mastery.NumberOfMasteries - 2] = 275;
                    DatabaseCore.Mastery.MasteryId[DatabaseCore.Mastery.NumberOfMasteries - 1] = 276;

                    DatabaseCore.WriteQuery("INSERT INTO mastery (owner, mastery, level, mastery_row) VALUE ('{0}','{1}', '0', 'mastery_1')", name, 257);
                    DatabaseCore.WriteQuery("INSERT INTO mastery (owner, mastery, level, mastery_row) VALUE ('{0}','{1}', '0', 'mastery_2')", name, 258);
                    DatabaseCore.WriteQuery("INSERT INTO mastery (owner, mastery, level, mastery_row) VALUE ('{0}','{1}', '0', 'mastery_3')", name, 259);
                    DatabaseCore.WriteQuery("INSERT INTO mastery (owner, mastery, level, mastery_row) VALUE ('{0}','{1}', '0', 'mastery_4')", name, 273);
                    DatabaseCore.WriteQuery("INSERT INTO mastery (owner, mastery, level, mastery_row) VALUE ('{0}','{1}', '0', 'mastery_5')", name, 274);
                    DatabaseCore.WriteQuery("INSERT INTO mastery (owner, mastery, level, mastery_row) VALUE ('{0}','{1}', '0', 'mastery_6')", name, 275);
                    DatabaseCore.WriteQuery("INSERT INTO mastery (owner, mastery, level, mastery_row) VALUE ('{0}','{1}', '0', 'mastery_7')", name, 276);

                }

                else if (model >= 14717 && model <= 14742)
                {
                    DatabaseCore.Mastery.NumberOfMasteries += 6;
                    Array.Resize<string>(ref DatabaseCore.Mastery.CharacterName, DatabaseCore.Mastery.NumberOfMasteries);
                    Array.Resize<ushort>(ref DatabaseCore.Mastery.MasteryId, DatabaseCore.Mastery.NumberOfMasteries);
                    Array.Resize<byte>(ref DatabaseCore.Mastery.MasteryLevel, DatabaseCore.Mastery.NumberOfMasteries);
                    Array.Resize<uint>(ref DatabaseCore.Character.CharacterId, DatabaseCore.Character.NumberOfCharacters);
                    for (byte i = 0; i < 6; i++)
                        DatabaseCore.Mastery.CharacterName[DatabaseCore.Mastery.NumberOfMasteries - 1 - i] = name;

                    DatabaseCore.Mastery.MasteryId[DatabaseCore.Mastery.NumberOfMasteries - 6] = 513;
                    DatabaseCore.Mastery.MasteryId[DatabaseCore.Mastery.NumberOfMasteries - 5] = 514;
                    DatabaseCore.Mastery.MasteryId[DatabaseCore.Mastery.NumberOfMasteries - 4] = 515;
                    DatabaseCore.Mastery.MasteryId[DatabaseCore.Mastery.NumberOfMasteries - 3] = 516;
                    DatabaseCore.Mastery.MasteryId[DatabaseCore.Mastery.NumberOfMasteries - 2] = 517;
                    DatabaseCore.Mastery.MasteryId[DatabaseCore.Mastery.NumberOfMasteries - 1] = 518;

                    DatabaseCore.WriteQuery("INSERT INTO mastery (owner, mastery, level, mastery_row) VALUE ('{0}','{1}', '0', 'mastery_1')", name, 513);
                    DatabaseCore.WriteQuery("INSERT INTO mastery (owner, mastery, level, mastery_row) VALUE ('{0}','{1}', '0', 'mastery_2')", name, 514);
                    DatabaseCore.WriteQuery("INSERT INTO mastery (owner, mastery, level, mastery_row) VALUE ('{0}','{1}', '0', 'mastery_3')", name, 515);
                    DatabaseCore.WriteQuery("INSERT INTO mastery (owner, mastery, level, mastery_row) VALUE ('{0}','{1}', '0', 'mastery_4')", name, 516);
                    DatabaseCore.WriteQuery("INSERT INTO mastery (owner, mastery, level, mastery_row) VALUE ('{0}','{1}', '0', 'mastery_5')", name, 517);
                    DatabaseCore.WriteQuery("INSERT INTO mastery (owner, mastery, level, mastery_row) VALUE ('{0}','{1}', '0', 'mastery_6')", name, 518);
                }

                DatabaseCore.WriteQuery("INSERT INTO skills (owner, AmountSkill) VALUE ('{0}','0')", name);
                DatabaseCore.Skill.NumberOfSkills++;
                Array.Resize<string>(ref DatabaseCore.Skill.CharacterName, DatabaseCore.Skill.NumberOfSkills);
                Array.Resize<int>(ref DatabaseCore.Skill.SkillAmount, DatabaseCore.Skill.NumberOfSkills);
                Array.Resize<DatabaseCore.Skill_.Skills_>(ref DatabaseCore.Skill.Skills, DatabaseCore.Skill.NumberOfSkills);
                DatabaseCore.Skill.CharacterName[DatabaseCore.Skill.NumberOfSkills - 1] = name;

                if (_item[4] == 3632 || _item[4] == 3633)
                {
                    Silkroad.Item_ tmpItem = Silkroad.GetItemById(251);
                    phydefmin += tmpItem.MIN_PHYSDEF;
                    magdefmin += tmpItem.MAGDEF_MIN;
                    parrymin += (ushort)tmpItem.MIN_PARRY;

                    DatabaseCore.Item.ItemId[DatabaseCore.Item.NumberOfItems - 39] = 251;
                    DatabaseCore.Item.Durability[DatabaseCore.Item.NumberOfItems - 39] = (byte)tmpItem.MIN_DURA;

                    DatabaseCore.WriteQuery("UPDATE items SET itemid='251',plusvalue='0' ,durability='{0}' WHERE itemnumber='item7' AND owner ='{1}'", tmpItem.MIN_DURA, name);
                    DatabaseCore.WriteQuery("update characters set min_phyatk='{0}', max_phyatk='{1}', min_magatk='{2}', max_magatk='{3}', phydef='{4}', magdef='{5}', parry='{6}' where name='{7}'", phyatkmin, phyatkmax, magatkmin, magatkmax, (int)phydefmin, (int)magatkmin, parrymin, name);

                }
                else if (_item[4] == 10730 || _item[4] == 10734 || _item[4] == 10737)
                {
                    Silkroad.Item_ tmpItem = Silkroad.GetItemById(11387);
                    phydefmin += tmpItem.MIN_PHYSDEF;
                    magdefmin += tmpItem.MAGDEF_MIN;
                    parrymin += (ushort)tmpItem.MIN_PARRY;

                    DatabaseCore.Item.ItemId[DatabaseCore.Item.NumberOfItems - 39] = 11387;
                    DatabaseCore.Item.Durability[DatabaseCore.Item.NumberOfItems - 39] = (byte)tmpItem.MIN_DURA;

                    DatabaseCore.WriteQuery("UPDATE items SET itemid='11387',plusvalue='0' ,durability='{0}' WHERE itemnumber='item7' AND owner ='{1}'", tmpItem.MIN_DURA, name);
                    DatabaseCore.WriteQuery("update characters set min_phyatk='{0}', max_phyatk='{1}', min_magatk='{2}', max_magatk='{3}', phydef='{4}', magdef='{5}', parry='{6}' where name='{7}'", phyatkmin, phyatkmax, magatkmin, magatkmax, (int)phydefmin, (int)magatkmin, parrymin, name);
                }
                else if (_item[4] == 3636)
                {
                    DatabaseCore.Item.ItemId[DatabaseCore.Item.NumberOfItems - 39] = 62;
                    DatabaseCore.Item.Quantity[DatabaseCore.Item.NumberOfItems - 39] = 250;
                    DatabaseCore.Item.Type[DatabaseCore.Item.NumberOfItems - 39] = 1;

                    DatabaseCore.WriteQuery("UPDATE items SET itemid='62',quantity='250',type='1'  WHERE itemnumber='item7' AND owner ='{0}'", name);
                }

                else if (_item[4] == 10733)
                {
                    DatabaseCore.Item.ItemId[DatabaseCore.Item.NumberOfItems - 39] = 10727;
                    DatabaseCore.Item.Quantity[DatabaseCore.Item.NumberOfItems - 39] = 250;
                    DatabaseCore.Item.Type[DatabaseCore.Item.NumberOfItems - 39] = 1;
                    DatabaseCore.WriteQuery("UPDATE items SET itemid='10727',quantity='250',type='1'  WHERE itemnumber='item7' AND owner ='{0}'", name);
                }

                DatabaseCore.Character.MinPhy[NewCharacterIndex] = phyatkmin;
                DatabaseCore.Character.MaxPhy[NewCharacterIndex] = phyatkmax;
                DatabaseCore.Character.MinMag[NewCharacterIndex] = magatkmin;
                DatabaseCore.Character.MaxMag[NewCharacterIndex] = magatkmax;
                DatabaseCore.Character.PhyDef[NewCharacterIndex] = (ushort)phydefmin;
                DatabaseCore.Character.MagDef[NewCharacterIndex] = (ushort)magdefmin;
                DatabaseCore.Character.Hit[NewCharacterIndex] = 11;
                DatabaseCore.Character.Parry[NewCharacterIndex] = parrymin;

                writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_CHARACTER);
                writer.AppendWord(0x101);
                ServerSocket.Send(writer.getWorkspace(), Index_);
            }
        }
Ejemplo n.º 6
0
        public static void OnState(PacketReader reader_, int Index_)
        {
            PacketWriter writer = new PacketWriter();
            byte state = reader_.ReadByte();
            if (Player.General[Index_].State != 4 && Player.General[Index_].State != 10 && Player.General[Index_].State != 1)
                Player.General[Index_].State = state;
            else
            {
                state = 0;
                Player.General[Index_].State = state;
            }
            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_CHARACTER_STATE);
            writer.AppendDword(Player.General[Index_].UniqueID);
            writer.AppendByte(1);
            writer.AppendByte(state);

            ServerSocket.SendPacketIfPlayerIsSpawned(writer.getWorkspace(), Index_);
        }
Ejemplo n.º 7
0
        public static void OnCharacter(PacketReader Reader_, int Index_)
        {
            reader = Reader_;

            byte pType = reader.ReadByte();
            Console.WriteLine("pType: {0}",pType);
            switch (pType)
            {
                case 1:
                    Console.WriteLine("Char Creation");
                    OnCharCreation(Reader_, Index_);
                    break;
                case 2:
                    Console.WriteLine("Char List");
                    SendCharacterList(Index_);
                    break;
                case 3:
                    //  OnCharDeletion(Reader_, Index_);
                    break;
                case 4:
                    Console.WriteLine("Char Name Check");
                    OnCharnameCheck(Reader_, Index_);
                    break;
                case 5:
                    //  OnCharRestore();
                    break;
            }
        }
Ejemplo n.º 8
0
        public static void OnSpawn(PacketReader reader_, int Index_)
        {
            int MonsterIndex = Monsters.MonsterAmount;
            uint monsterid = reader_.ReadDword();
            byte monstertype = reader_.ReadByte();

            uint uniqueid = (uint)Monsters.MonsterAmount + 1000;
            if (monstertype == 1)
                monstertype = 0;

            Silkroad.Object_ tmpMonster = Silkroad.GetObjectById(monsterid);

            PacketWriter writer = new PacketWriter();
            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_SPAWN);

            writer.AppendDword(monsterid);
            writer.AppendDword(uniqueid);

            writer.AppendByte(Player.Position[Index_].XSector);
            writer.AppendByte(Player.Position[Index_].YSector);
            writer.AppendFloat(Player.Position[Index_].X);
            writer.AppendFloat(Player.Position[Index_].Z);
            writer.AppendFloat(Player.Position[Index_].Y);

            writer.AppendWord(0);
            writer.AppendByte(0);
            writer.AppendByte(1);
            writer.AppendByte(0);
            writer.AppendWord(0);
            writer.AppendWord(1);
            writer.AppendByte(0);

            writer.AppendFloat(tmpMonster.Speed);
            writer.AppendFloat(tmpMonster.Speed);
            writer.AppendFloat(tmpMonster.Speed);

            writer.AppendByte(0);
            writer.AppendByte(0);

            writer.AppendByte(monstertype);
            writer.AppendByte(1);
            byte[] tmpBuffer = writer.getWorkspace();
            //   ServerSocket.SendPacketInRange(writer.getWorkspace(),Index_);

            int monsterhp = (int)tmpMonster.Hp;
            ulong exp = tmpMonster.Exp;
            switch (monstertype)
            {
                case 2:
                    monsterhp *= 2;
                    exp *= 2;
                    break;

                case 3:
                    exp *= 7;
                    break;

                case 4:
                    monsterhp *= 20;
                    exp *= 3;
                    break;

                case 6:
                    monsterhp *= 4;
                    exp *= 4;
                    break;

                case 16:
                    monsterhp *= 10;
                    exp *= 5;
                    break;

                case 17:
                    monsterhp *= 20;
                    exp *= 6;

                    break;

                case 20:
                    monsterhp *= 200;
                    exp *= 8;
                    break;
            }

            Monsters.General[MonsterIndex].ID = monsterid;
            Monsters.General[MonsterIndex].UniqueID = uniqueid;
            Monsters.General[MonsterIndex].Type = monstertype;
            Monsters.General[MonsterIndex].HP = monsterhp;
            Monsters.Position[MonsterIndex].XSector = Player.Position[Index_].XSector;
            Monsters.Position[MonsterIndex].YSector = Player.Position[Index_].YSector;
            Monsters.Position[MonsterIndex].X = Player.Position[Index_].X;
            Monsters.Position[MonsterIndex].Z = Player.Position[Index_].Z;
            Monsters.Position[MonsterIndex].Y = Player.Position[Index_].Y;
            Monsters.General[MonsterIndex].Exp = exp;
            Monsters.General[MonsterIndex].Level = tmpMonster.Level;
            Monsters.General[MonsterIndex].Skills = new ArrayList();
            Monsters.General[MonsterIndex].Dead = false;

            for (int i = 0; i < Player.PlayersOnline; i++)
            {
                if (Player.General[i].CharacterID != 0)
                {
                    if (Formula.CalculateDistance(Monsters.Position[MonsterIndex], Player.Position[i]) <= 800)
                    {
                        ServerSocket.Send(tmpBuffer, i);
                        Player.Objects[i].SpawnedMonsterIndex.Add(MonsterIndex);
                    }
                }
            }

            uint[] skill = new uint[9];
            skill[0] = tmpMonster.Skill1;
            skill[1] = tmpMonster.Skill2;
            skill[2] = tmpMonster.Skill3;
            skill[3] = tmpMonster.Skill4;
            skill[4] = tmpMonster.Skill5;
            skill[5] = tmpMonster.Skill6;
            skill[6] = tmpMonster.Skill7;
            skill[7] = tmpMonster.Skill8;
            skill[8] = tmpMonster.Skill9;

            for (int i = 0; i <= 8; i++)
            {
                if (skill[i] != 0 && skill[i] <= 3000)
                    Monsters.General[MonsterIndex].Skills.Add(skill[i]);
            }

            Monsters.MonsterAmount++;

            if (monstertype == 3)
                Unique.OnUnique(monsterid, false, null);

            Timers.MonsterMovement[MonsterIndex].Interval = 5000;
            Timers.MonsterMovement[MonsterIndex].Start();
        }
Ejemplo n.º 9
0
        private static void OnGameQuit(PacketReader reader_,int Index_)
        {
            byte type = reader_.ReadByte();
            byte countdown = 5;

            PacketWriter writer = new PacketWriter();
            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_COUNTDOWN);
            writer.AppendByte(1);
            writer.AppendByte(countdown);
            writer.AppendByte(type);
            ServerSocket.Send(writer.getWorkspace(), Index_);

            System.Threading.Thread.Sleep(countdown * 1000);

            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_QUIT_GAME);
            ServerSocket.Send(writer.getWorkspace(), Index_);
        }
Ejemplo n.º 10
0
        public static void Action(PacketReader reader_, int Index_)
        {
            PacketWriter writer = new PacketWriter();

            reader_.ModifyIndex(1);
            byte type = reader_.ReadByte();

            if (Player.General[Index_].State != 1)
            {
                switch (type)
                {
                    case 1:

                        reader_.ModifyIndex(1);
                        uint ObjectId = reader_.ReadDword();
                        Player.Objects[Index_].AttackingObjectId = ObjectId;
                        int ObjectIndex = Players.GetObjectIndexAndType(Index_, Player.Objects[Index_].AttackingObjectId);

                        bool attack = false;

                        if (Player.Objects[Index_].SelectedObjectType == 2)
                            attack = Movement.MoveToObject(Index_, ref Player.Position[Index_], Monsters.Position[ObjectIndex], Player.General[Index_], false);

                        else
                            attack = Movement.MoveToObject(Index_, ref Player.Position[Index_], Player.Position[ObjectIndex], Player.General[Index_], false);

                        if (attack)
                        {
                            if (!Player.Objects[Index_].NormalAttack)
                                Attack.NormalAttack(Index_);
                        }
                        break;
                    case 2:
                        reader_.ModifyIndex(1);
                        ObjectId = reader_.ReadDword();

                        ObjectIndex = 0;
                        for (int i = 0; i <= Item.ItemAmount; i++)
                        {

                            if (Item.General[i].UniqueID == ObjectId && Index_ != i)
                            {
                                ObjectIndex = i;
                                break;
                            }
                        }

                        bool pickup = false;

                        pickup = Movement.MoveToObject(Index_, ref Player.Position[Index_], Item.Position[ObjectIndex], Player.General[Index_], false);

                        if (pickup)
                            PickUpItem(Index_, ObjectIndex);

                        break;

                    case 4:

                        uint skillid = reader_.ReadDword();

                        bool skillexist = false;
                        int CharacterSkillIndex = DatabaseCore.Skill.GetIndexByName(Player.General[Index_].CharacterName);

                        for (int i = 0; i <= DatabaseCore.Skill.SkillAmount[CharacterSkillIndex]; i++)
                        {
                            if (skillid == DatabaseCore.Skill.Skills[CharacterSkillIndex].SkillId[i])
                            {
                                skillexist = true;
                                break;
                            }
                            skillexist = false;
                        }

                        if (skillexist)
                        {
                            byte type_ = reader_.ReadByte();
                            switch (type_)
                            {
                                case 0:
                                    bool alreadyactive = false;
                                    for (byte i = 0; i < Player.Objects[Index_].ActiveBuffs.Length; i++)
                                    {
                                        if (Player.Objects[Index_].ActiveBuffs[i].Id == skillid)
                                            alreadyactive = true;
                                    }
                                    if (!alreadyactive)
                                    {
                                        Player.Objects[Index_].UsingSkillID = skillid;
                                        if (!Player.Objects[Index_].UsingSkill)
                                            PrepareBuff(Index_);
                                    }
                                    return;

                                case 1:
                                    uint attackingObjectId = reader_.ReadDword();

                                    Player.Objects[Index_].AttackingSkillID = skillid;
                                    Player.Objects[Index_].AttackingObjectId = attackingObjectId;
                                    Player.Objects[Index_].NormalAttack = false;
                                    if (!Player.Objects[Index_].UsingSkill)
                                        SkillAttackType(Index_);

                                    return;
                            }
                        }
                        break;

                    default:
                        Timers.PlayerAttack[Index_].Stop();
                        break;
                }
            }
        }
Ejemplo n.º 11
0
        public static void OnEmotion(PacketReader reader_, int Index_)
        {
            PacketWriter writer = new PacketWriter();
            byte type = reader_.ReadByte();

            writer.SetOpcode(CLIENT_OPCODES.GAME_CLIENT_EMOTION);
            writer.AppendDword(Player.General[Index_].UniqueID);
            writer.AppendByte(type);
            ServerSocket.Send(writer.getWorkspace(), Index_);
        }