예제 #1
0
        public static byte[] CreateSpawnPacket(uint monsterid, uint uniqueid, _Position pos, byte monstertype)
        {
            PacketWriter writer = new PacketWriter();
            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_SPAWN);
            writer.AppendDword(monsterid);
            writer.AppendDword(uniqueid);

            writer.AppendByte(pos.XSector);
            writer.AppendByte(pos.YSector);
            writer.AppendFloat(pos.X);
            writer.AppendFloat(pos.Z);
            writer.AppendFloat(pos.Y);

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

            writer.AppendFloat(16f);
            writer.AppendFloat(16f);
            writer.AppendFloat(16f);

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

            writer.AppendByte(monstertype);
            writer.AppendByte(1);
            return writer.getWorkspace();
        }
예제 #2
0
파일: Players.cs 프로젝트: CarlosX/DarkEmu
 public static byte[] CreateDeSpawnPacket(uint UniqueId)
 {
     PacketWriter writer = new PacketWriter();
     writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_DESPAWN);
     writer.AppendDword(UniqueId);
     return writer.getWorkspace();
 }
예제 #3
0
        public static void MonsterMovement(int Index_)
        {
            int X = random.Next(-20, 20);
            int Z = random.Next(-5, 10);
            int Y = random.Next(-20, 20);

            PacketWriter writer = new PacketWriter();
            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_MOVEMENT);
            writer.AppendDword(Monsters.General[Index_].UniqueID);
            writer.AppendByte(1);
            writer.AppendByte(Monsters.Position[Index_].XSector);
            writer.AppendByte(Monsters.Position[Index_].YSector);
            writer.AppendWord((ushort)(Monsters.Position[Index_].X + X));
            writer.AppendWord((ushort)(Monsters.Position[Index_].Z + Z));
            writer.AppendWord((ushort)(Monsters.Position[Index_].Y + Y));
            writer.AppendByte(0);

            byte[] tmpBuffer = writer.getWorkspace();

            for (int i = 0; i < Player.PlayersOnline; i++)
            {
                if (Player.General[i].CharacterID != 0 && Player.Objects[i].SpawnedMonsterIndex.Contains(Index_))
                {
                    if (Formula.CalculateDistance(Monsters.Position[Index_], Player.Position[i]) <= 800)
                        ServerSocket.Send(tmpBuffer, i);
                }
            }
        }
예제 #4
0
        public static void CreateSpawnPacket(ref PacketWriter writer, uint monsterid, uint uniqueid, _Position pos, byte monstertype)
        {
            writer.AppendDword(monsterid);
            writer.AppendDword(uniqueid);

            writer.AppendByte(pos.XSector);
            writer.AppendByte(pos.YSector);
            writer.AppendFloat(pos.X);
            writer.AppendFloat(pos.Z);
            writer.AppendFloat(pos.Y);

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

            writer.AppendFloat(16f);
            writer.AppendFloat(16f);
            writer.AppendFloat(16f);

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

            writer.AppendByte(monstertype);
            writer.AppendByte(1);
        }
예제 #5
0
파일: Chat.cs 프로젝트: CarlosX/DarkEmu
        public static void SendExternNotice(string msg)
        {
            byte[] bmsg = Encoding.Unicode.GetBytes(msg);

            PacketWriter writer = new PacketWriter();
            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_CHAT);
            writer.AppendByte(7);
            writer.AppendWord((ushort)(bmsg.Length / 2));
            writer.AppendByteArray(bmsg, bmsg.Length);
            ServerSocket.SendToAllIngame(writer.getWorkspace());
        }
예제 #6
0
파일: Items.cs 프로젝트: CarlosX/DarkEmu
        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_);
        }
예제 #7
0
파일: Unique.cs 프로젝트: CarlosX/DarkEmu
        public static void OnUnique(uint monsterid, bool kill, string name)
        {
            PacketWriter writer = new PacketWriter();
            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_UNIQUE);
            if (kill)
            {
                writer.AppendByte(6);
                writer.AppendDword(monsterid);
                writer.AppendWord((ushort)name.Length);
                writer.AppendString(false, name);
            }
            else
            {
                writer.AppendByte(5);
                writer.AppendDword(monsterid);
            }

            int ObjectIndex = Players.GetObjectIndex(monsterid);
            ServerSocket.SendPacketIfMonsterIsSpawned(writer.getWorkspace(), ObjectIndex);
        }
예제 #8
0
파일: Chat.cs 프로젝트: CarlosX/DarkEmu
        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;
            }
        }
예제 #9
0
파일: Attack.cs 프로젝트: CarlosX/DarkEmu
        public static void BeginSkill(int Index_)
        {
            Player.Objects[Index_].UsingSkill = true;

            Silkroad.Skill_ tmpSkill = Silkroad.GetSkillById(Player.Objects[Index_].AttackingSkillID);

            Player.Stats[Index_].CMP -= tmpSkill.RequiredMp;
            Stats.MPUpdate(Index_, true);

            Player.Objects[Index_].AttackingCastingID = (uint)random.Next(500, 50000);

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

            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ATTACK);
            writer.AppendWord(0x201);
            writer.AppendDword(Player.Objects[Index_].AttackingSkillID);
            writer.AppendDword(Player.General[Index_].UniqueID);
            writer.AppendDword(Player.Objects[Index_].AttackingCastingID);
            writer.AppendDword(Player.Objects[Index_].AttackingObjectId);
            writer.AppendByte(0);

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

            if (tmpSkill.CastTime <= 0)
                EndSkill(Index_);

            else
            {
                Timers.CastAttackTimer[Index_].Interval = tmpSkill.CastTime * 1000;
                Timers.CastAttackTimer[Index_].Start();
            }
        }
예제 #10
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Character listening packet
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public static byte[] CharacterListing(string name)
        {
            
            Systems.MsSQL ms    = new Systems.MsSQL("SELECT TOP 4 * FROM character WHERE account='" + name + "'");
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_CHARACTERSCREEN);      // Select opcode
            Writer.Byte(2);                                     // Static byte 2
            Writer.Byte(1);                                     // Static byte 1
            Writer.Byte(ms.Count());                            // Byte Character Count

            using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
            {
                while (reader.Read())
                {
                    Writer.DWord(reader.GetInt32(3));           // DWord Skin Model
                    Writer.Text(reader.GetString(2));           // String Name
 
                    Writer.Byte(reader.GetByte(4));             // Byte Skin Volume
                    Writer.Byte(reader.GetByte(5));             // Byte Level

                    Writer.LWord(reader.GetInt64(12));          // Long Experience

                    Writer.Word(reader.GetInt16(6));            // Word STR
                    Writer.Word(reader.GetInt16(7));            // Word INT
                    Writer.Word(reader.GetInt16(8));            // Attribute points
                    
                    Writer.DWord(reader.GetInt32(9));           // HP
                    Writer.DWord(reader.GetInt32(10));          // MP

                    TimeSpan ts = Convert.ToDateTime(reader.GetDateTime(43)) - DateTime.Now;
                    double time = ts.TotalMinutes;

                    if (Math.Round(time) > 0)
                    {
                        Writer.Byte(1);
                        Writer.DWord(Math.Round(time));
                    }
                    else
                    {
                        Writer.Byte(0);
                    }

                    if (Math.Round(time) < 0 && DateTime.Now != reader.GetDateTime(43))
                    {
                        Systems.MsSQL.UpdateData("UPDATE character SET deleted='1' Where id='" + reader.GetInt32(0) + "'");
                    }

                    Writer.Word(0);
                    Writer.Byte(0);

                    Function.Items.PrivateItemPacket(Writer, reader.GetInt32(0), 8, 0,false);
                    Function.Items.PrivateItemPacket(Writer, reader.GetInt32(0), 5, 1,false);
                }
                //Jobtype information
                int jobinfo = Systems.MsSQL.GetDataInt("SELECT * FROM users WHERE id='"+ name +"'", "jobtype");
                Writer.Byte(Convert.ToByte(jobinfo));
            }
            ms.Close();

            return Writer.GetBytes();
        }
예제 #11
0
        public static void ReSpawnMe(int Index_)
        {
            PacketWriter writer = new PacketWriter();
            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_DEAD2);
            writer.AppendDword(0);
            ServerSocket.Send(writer.getWorkspace(), Index_);

            OnState(Index_,0, 1);

            Player.Stats[Index_].CHP = (int)Player.Stats[Index_].HP / 2;
            Stats.HPUpdate(Index_, false);
            Player.General[Index_].State = 0;
            Player.General[Index_].Busy = false;

            Player.Objects[Index_].AttackingSkillID = 0;
            Player.Objects[Index_].AttackingObjectId = 0;
            Player.Objects[Index_].NormalAttack = false;
            Player.Objects[Index_].UsingSkill = false;
            Player.Flags[Index_].Dead = false;
        }
예제 #12
0
        public static void OnState(int Index_, byte type, byte state)
        {
            PacketWriter writer = new PacketWriter();
            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_CHARACTER_STATE);
            writer.AppendDword(Player.General[Index_].UniqueID);
            writer.AppendByte(type);
            writer.AppendByte(state);

            ServerSocket.SendPacketIfPlayerIsSpawned(writer.getWorkspace(), Index_);
        }
예제 #13
0
        public static byte[] CreateSpawnPacket(Player._General general, Player._Flags flags, _Position position, Player._Stats stats, Player._Speeds speeds)
        {
            PacketWriter writer = new PacketWriter();
            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_SPAWN);
            writer.AppendDword(stats.Model);
            writer.AppendByte(stats.Volume);
            if (flags.GM == 1)
                writer.AppendByte(1);

            else
                writer.AppendByte((byte)(stats.Level < 20 ? 1 : 0));

            writer.AppendByte(1);
            writer.AppendByte(general.MaxSlots);

            int tmpCharacterIndex = DatabaseCore.Character.GetIndexByName(general.CharacterName);
            int[] CharacterItemIndex = DatabaseCore.Item.GetIndexByName(general.CharacterName);

            byte PlayerItemCount = 0;
            for (byte j = 0; j < 10; j++)
            {
                if (DatabaseCore.Item.ItemId[CharacterItemIndex[j]] != 0)
                    PlayerItemCount++;
            }
            writer.AppendByte(PlayerItemCount);

            for (int j = 0; j < 10; j++)
            {
                if (DatabaseCore.Item.ItemId[CharacterItemIndex[j]] != 0)
                {
                    writer.AppendDword(DatabaseCore.Item.ItemId[CharacterItemIndex[j]]);
                    writer.AppendByte(DatabaseCore.Item.PlusValue[CharacterItemIndex[j]]);
                }
            }

            writer.AppendByte(4);
            writer.AppendByte(0);
            writer.AppendByte(0);
            writer.AppendDword((uint)general.UniqueID);

            writer.AppendByte(position.XSector);
            writer.AppendByte(position.YSector);
            writer.AppendFloat(position.X);
            writer.AppendFloat(position.Z);
            writer.AppendFloat(position.Y);

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

            writer.AppendWord(1);

            writer.AppendByte(flags.Berserk);
            writer.AppendFloat(speeds.WalkSpeed);
            writer.AppendFloat(speeds.RunSpeed);
            writer.AppendFloat(speeds.BerserkSpeed);

            writer.AppendByte(0);

            if (flags.GM == 1)
            {
                string gmname = string.Format("[GM]{0}", general.CharacterName);
                writer.AppendWord((ushort)gmname.Length);
                writer.AppendString(false, gmname);
            }
            else
            {
                writer.AppendWord((ushort)general.CharacterName.Length);
                writer.AppendString(false, general.CharacterName);
            }

            writer.AppendByte(0);
            writer.AppendByte(1);
            writer.AppendDword(0);
            writer.AppendDword(0);
            writer.AppendDword(0);
            writer.AppendDword(0);
            writer.AppendDword(0);
            writer.AppendDword(0);
            writer.AppendDword(0);
            writer.AppendByte(1);
            writer.AppendByte((byte)flags.PvP);
            return writer.getWorkspace();
        }
예제 #14
0
 public static void Die2(int Index_)
 {
     PacketWriter writer = new PacketWriter();
     writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_DEAD2);
     writer.AppendDword(0);
     ServerSocket.Send(writer.getWorkspace(), Index_);
 }
예제 #15
0
 public static byte[] EndPlayerLoad()
 {
     PacketWriter Writer = new PacketWriter();
     Writer.Create(Systems.SERVER_ENDPLAYERDATA);
     return Writer.GetBytes();
 }
예제 #16
0
        //Listening main uses a single packet only so we write our packet here
        public static byte[] CharacterListing(player p)
        {
            //Create new sql query to get all characters except fully deleted
            Systems.MsSQL ms = new Systems.MsSQL("SELECT TOP 4 * FROM character WHERE account='" + p.AccountName + "' AND deleted='0' OR account='" + p.AccountName + "' AND deleted ='1'");
            //Create new packet writer
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_CHARACTERSCREEN);      // Select opcode
            Writer.Byte(2);                                     // Static byte 2
            Writer.Byte(1);                                     // Static byte 1
            Writer.Byte(ms.Count());                            // Byte Character Count
            //Create new sql data reader
            using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
            {
                //While the reader is reading data from the database
                while (reader.Read())
                {
                    Writer.DWord(reader.GetInt32(3));           // DWord Skin Model
                    Writer.Text(reader.GetString(2));           // String Name
                    Writer.Byte(reader.GetByte(4));             // Byte Skin Volume
                    Writer.Byte(reader.GetByte(5));             // Byte Level
                    Writer.LWord(reader.GetInt64(12));          // Long Experience
                    Writer.Word(reader.GetInt16(6));            // Word STR
                    Writer.Word(reader.GetInt16(7));            // Word INT
                    Writer.Word(reader.GetInt16(8));            // Attribute points
                    Writer.DWord(reader.GetInt32(9));           // HP
                    Writer.DWord(reader.GetInt32(10));          // MP
                    //Set defnition for current time
                    DateTime CurrentTime = DateTime.Now;
                    //Subtract the current time with deletion time information
                    TimeSpan TIMESPAN = reader.GetDateTime(43) - DateTime.Now;
                    //If the character has been deleted but still sitting
                    if (reader.GetByte(42) == 1)
                    {
                        //Write state byte 1 for sitting
                        Writer.Byte(1);
                        //Display deletion time reamining
                        Writer.DWord((double)TIMESPAN.TotalMinutes);
                        //If time has expired delete the character
                        if (TIMESPAN.TotalMinutes <= 0)
                        {
                            //Note: There are more ways like full delete but if someone got deleted by someone else's action
                            //It will be easy to recover the character by changing the deletion byte in the database
                            //0 = Not deleted , 1 = Deletion in progress, 2 = Deleted

                            //Set deletion state so it wont be listed again.
                            Systems.MsSQL.UpdateData("UPDATE character SET deleted='2' Where id='" + reader.GetInt32(0) + "'");
                        }
                    }
                    //If not deleted
                    else
                    {
                        //State byte = 0 Standing
                        Writer.Byte(0);
                    }
                    //Static
                    Writer.Word(0);
                    Writer.Byte(0);
                    //Get normal equipped items upto slot 8 not in avatar slots
                    Function.Items.PrivateItemPacket(Writer, reader.GetInt32(0), 8, 0, false);
                    //Get avatar type items
                    Function.Items.PrivateItemPacket(Writer, reader.GetInt32(0), 5, 1, false);
                }
                //Jobtype information
                int jobinfo = Systems.MsSQL.GetDataInt("SELECT * FROM users WHERE id='" + p.AccountName + "'", "jobtype");
                Writer.Byte(Convert.ToByte(jobinfo));
            }
            ms.Close();
            //Return all bytes to the client
            return(Writer.GetBytes());
        }
예제 #17
0
 void KickFromGuild()
 {
     //Wrap our function inside a catcher
     try
     {
         //Open a new packet reader
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         //Read short value lenght of name below
         short CharacterNameLen = Reader.Int16();
         //Read string charactername
         string CharacterName = Reader.String(CharacterNameLen);
         //Close packet reader
         Reader.Close();
         //Get player information
         Systems TargetCharacter = GetPlayerName(CharacterName);
         //Send required packets to network
         foreach (int member in Character.Network.Guild.Members)
         {
             //Make sure member s not null
             if (member != 0)
             {
                 //Get information for the guildmember
                 Systems guildmember = GetPlayerMainid(member);
                 //Make sure the guildmember isnt null
                 if (guildmember != null)
                 {
                     //Make sure the kicked member does not receive the packet
                     if (guildmember.Character.Information.CharacterID != TargetCharacter.Character.Information.CharacterID)
                     {
                         guildmember.client.Send(Packet.GuildUpdate(TargetCharacter.Character, 7, 0, 0, 0));
                     }
                 }
             }
         }
         //Send update packet to the kicked player
         TargetCharacter.client.Send(Packet.GuildUpdate(TargetCharacter.Character, 7, 0, 0, 0));
         //Send guild kick message packet to the kicked player
         PacketWriter Writer = new PacketWriter();
         //Add opcode
         Writer.Create(Systems.SERVER_GUILD_KICK);
         //Add static byte 1
         Writer.Byte(1);
         //Send packet to kicked member
         TargetCharacter.client.Send(Writer.GetBytes());
         //Send guildkick visual packet update to kicked player
         TargetCharacter.Send(Packet.GuildKick(TargetCharacter.Character.Information.UniqueID));
         //Remove the player from database
         MsSQL.UpdateData("DELETE from guild_members where guild_member_id='" + TargetCharacter.Character.Information.CharacterID + "'");
         //Update database
         Character.Network.Guild.TotalMembers -= 1;
         MsSQL.InsertData("UPDATE guild SET guild_members_t='" + Character.Network.Guild.TotalMembers + "' WHERE guild_name='" + Character.Network.Guild.Name + "'");
         TargetCharacter.CleanUp(TargetCharacter);
     }
     //Catch bad exception errors
     catch (Exception ex)
     {
         //Write information to the console
         Console.WriteLine("Guild Kick Error: {0}", ex);
         //Write information to the debug log
         Systems.Debugger.Write(ex);
     }
 }
예제 #18
0
파일: GuildPoints.cs 프로젝트: uvbs/DarkEmu
 void DonateGP()
 {
     //First we write our function inside a catcher
     try
     {
         //Max level of guild wont allow new gp donations.
         if (Character.Network.Guild.Level == 5)
         {
             //Send error message to client
             client.Send(Packet.IngameMessages(SERVER_GUILD_PROMOTE_MSG, IngameMessages.UIIT_MSG_GUILD_LACK_GP));
             return;
         }
         //Open our packet reader
         PacketReader reader = new PacketReader(PacketInformation.buffer);
         //Read donated gp amount (int).
         int donatedgp = reader.Int32();
         //Close packet reader
         reader.Close();
         //Anti hack checking (If donated gp higher is then the player skillpoints.
         if (donatedgp > Character.Information.SkillPoint)
         {
             return;
         }
         //Calculate total
         int totalgp = Character.Network.Guild.PointsTotal + donatedgp;
         //Set guild points total
         Character.Network.Guild.PointsTotal += donatedgp;
         //Set skill points minus donated amount
         Character.Information.SkillPoint -= donatedgp;
         //Set donated gp + donated skill points
         Character.Network.Guild.DonateGP += donatedgp;
         //Save our information (Skill points).
         SavePlayerInfo();
         //Update database total guild points
         MsSQL.UpdateData("UPDATE guild SET guild_points='" + totalgp + "' WHERE guild_name='" + Character.Network.Guild.Name + "'");
         //Update database donated player guild points amount
         MsSQL.UpdateData("UPDATE guild_members SET guild_points='" + Character.Network.Guild.DonateGP + "' WHERE guild_member_id='" + Character.Information.CharacterID + "'");
         //Send packets to donator.
         client.Send(Packet.InfoUpdate(1, totalgp, 0));
         //Send donated gp info
         PacketWriter writer = new PacketWriter();
         //Add opcode
         writer.Create(Systems.SERVER_GUILD_DONATE_GP);
         //Write static byte 1
         writer.Byte(1);
         //Write dword int value donated gp amount.
         writer.DWord(donatedgp);
         //Send bytes to client
         client.Send(writer.GetBytes());
         //Repeat for each member in our guild
         foreach (int member in Character.Network.Guild.Members)
         {
             //Make sure that the member isnt null
             if (member != 0)
             {
                 //Now we get the detailed information for each member
                 Systems guildmember = GetPlayerMainid(member);
                 //Make sure the guildmember is still there
                 if (guildmember != null)
                 {
                     //Send guild update packets to each member (Donated gp information and % bar update).
                     guildmember.client.Send(Packet.GuildUpdate(Character, 13, 0, 0, totalgp));
                     guildmember.client.Send(Packet.GuildUpdate(Character, 9, 0, 0, totalgp));
                 }
             }
         }
     }
     //Catch any bad exception error
     catch (Exception ex)
     {
         //Write information to the console
         Console.WriteLine("Donate GP Error {0}", ex);
         //Write information to the debug log.
         Systems.Debugger.Write(ex);
     }
 }
예제 #19
0
파일: Items.cs 프로젝트: CarlosX/DarkEmu
        private static byte UnEnquipShield(int Index_, int[] CharacterItemIndex, int CharacterShieldIndex)
        {
            Silkroad.Item_ SourceItem = Silkroad.GetItemById(DatabaseCore.Item.ItemId[CharacterShieldIndex]);

            if (SourceItem.CLASS_C != 2 && SourceItem.CLASS_C != 3)
            {
                if (Player.Stats[Index_].PhyDef < SourceItem.MAX_PHYSDEF)
                    Player.Stats[Index_].PhyDef = 1;
                else if (Player.Stats[Index_].MagDef < SourceItem.MAGDEF_MAX)
                    Player.Stats[Index_].MagDef = 1;
                else
                {
                    Player.Stats[Index_].PhyDef -= (ushort)SourceItem.MAX_PHYSDEF;
                    Player.Stats[Index_].MagDef -= (ushort)SourceItem.MAGDEF_MAX;
                }

                byte freeslot = FreeSlot(CharacterItemIndex);

                PacketWriter writer = new PacketWriter();
                writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ITEM_UNEQUIP);
                writer.AppendDword(Player.General[Index_].UniqueID);
                writer.AppendByte(7);
                writer.AppendDword(DatabaseCore.Item.ItemId[CharacterShieldIndex]);

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

                writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ITEM_MOVEMENT);
                writer.AppendByte(1);
                writer.AppendByte(0);
                writer.AppendByte(7);
                writer.AppendByte(freeslot);
                writer.AppendWord(1);
                writer.AppendByte(0);
                ServerSocket.Send(writer.getWorkspace(), Index_);

                return freeslot;
            }
            return 255;
        }
예제 #20
0
파일: Items.cs 프로젝트: CarlosX/DarkEmu
        private static void UnEquipItem(int Index_, int CharacterItemSourceIndex, int CharacterItemDestinationIndex)
        {
            PacketWriter writer = new PacketWriter();
            Silkroad.Item_ SourceItem = Silkroad.GetItemById(DatabaseCore.Item.ItemId[CharacterItemSourceIndex]);

            if (DatabaseCore.Item.Slot[CharacterItemSourceIndex] <= 5)
            {
                Player.Stats[Index_].PhyDef -= (ushort)SourceItem.MAX_PHYSDEF;
                Player.Stats[Index_].MagDef -= (ushort)SourceItem.MAGDEF_MAX;
                Player.Stats[Index_].Parry -= (ushort)SourceItem.MIN_PARRY;

            }
            else if (DatabaseCore.Item.Slot[CharacterItemSourceIndex] == 6)
            {
                Player.Stats[Index_].MinPhy -= (ushort)SourceItem.MIN_LPHYATK;
                Player.Stats[Index_].MaxPhy -= (ushort)SourceItem.MIN_HPHYATK;
                Player.Stats[Index_].MinMag -= (ushort)SourceItem.MIN_LMAGATK;
                Player.Stats[Index_].MaxMag -= (ushort)SourceItem.MIN_HMAGATK;
                Player.General[Index_].WeaponType = 0;
            }
            else if (DatabaseCore.Item.Slot[CharacterItemSourceIndex] == 7)
            {
                Player.Stats[Index_].PhyDef -= (ushort)SourceItem.MAX_PHYSDEF;
                Player.Stats[Index_].MagDef -= (ushort)SourceItem.MAGDEF_MAX;
            }

            else if (DatabaseCore.Item.Slot[CharacterItemSourceIndex] >= 9 && DatabaseCore.Item.Slot[CharacterItemSourceIndex] <= 12)
            {
                Player.Stats[Index_].TotalAccessoriesAbsorption -= SourceItem.ABSORB_INC;
            }

            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ITEM_UNEQUIP);
            writer.AppendDword(Player.General[Index_].UniqueID);
            writer.AppendByte(DatabaseCore.Item.Slot[CharacterItemSourceIndex]);
            writer.AppendDword(DatabaseCore.Item.ItemId[CharacterItemSourceIndex]);

            ServerSocket.SendPacketIfPlayerIsSpawned(writer.getWorkspace(), Index_);
        }
예제 #21
0
        public static byte[] GuildUpdate(character c, byte type, int memberid, int permissions, int donatedgp)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_GUILD_UPDATE);
            switch (type)
            {
            case 1:
                //Invited user to guild
                Writer.Byte(2);
                Writer.DWord(c.Information.CharacterID);
                Writer.Text(c.Information.Name);
                Writer.Byte(0x0A);     //Check
                Writer.Byte(c.Information.Level);
                Writer.DWord(0);       //Permissions below
                Writer.DWord(0);
                Writer.DWord(0);
                Writer.DWord(0);
                Writer.DWord(0);
                Writer.Word(0);
                Writer.DWord(c.Information.Model);     //Character Model For Icon In Guild
                Writer.Byte(0);
                Writer.Byte(c.Position.xSec);
                Writer.Byte(c.Position.ySec);
                Writer.DWord(0);
                Writer.DWord(0);
                Writer.Byte(1);
                break;

            case 2:
                //Disband guild
                Writer.Byte(1);
                break;

            case 3:
                //Transfer Leadership
                Writer.Byte(0x16);
                Writer.Byte(2);
                Writer.Byte(0x54);
                Writer.DWord(memberid);
                Writer.Byte(0);
                Writer.DWord(0xFFFFFFFF);
                Writer.Byte(1);
                Writer.DWord(c.Information.CharacterID);
                Writer.Byte(0x0A);
                Writer.DWord(0);
                Writer.Byte(0);
                break;

            case 4:
                //Change permissions
                Writer.Byte(0x16);
                Writer.Byte(1);
                Writer.Byte(0x10);
                Writer.DWord(c.Information.CharacterID);
                Writer.DWord(permissions);
                break;

            case 5:
                //Guild upgrade
                Writer.Byte(5);
                Writer.Byte(0x0C);    //Members allowed? 12
                Writer.Byte(c.Network.Guild.Level);
                Writer.DWord(c.Network.Guild.PointsTotal);
                break;

            //Invite user online
            case 6:
                //Static byte 6
                Writer.Byte(6);
                //Write member id
                Writer.DWord(c.Information.CharacterID);
                //Static byte 2
                Writer.Byte(2);
                //Online byte (If online byte = 0, If offline byte = 1).
                Writer.Byte(Convert.ToBoolean(c.Information.Online) ? 0 : 1);
                break;

            case 7:
                //User online / offline
                Writer.Byte(3);
                Writer.DWord(c.Information.CharacterID);
                Writer.Byte(2);
                break;

            case 8:
                //Update player level
                Writer.Byte(6);
                Writer.DWord(c.Information.CharacterID);
                Writer.Byte(1);
                Writer.Byte(c.Information.Level);
                break;

            case 9:
                //Update gp information guild
                Writer.Byte(6);
                Writer.DWord(c.Information.CharacterID);
                Writer.Byte(8);
                Writer.DWord(c.Network.Guild.DonateGP);
                break;

            case 10:
                //Update user location
                Writer.Byte(6);
                Writer.DWord(c.Information.CharacterID);
                Writer.Byte(0x80);    //need to check
                Writer.Byte(c.Position.xSec);
                Writer.Byte(c.Position.ySec);
                break;

            case 11:
                //Guild message update
                Writer.Byte(0x05);
                Writer.Byte(0x10);
                Writer.Text(c.Network.Guild.NewsTitle);
                Writer.Text(c.Network.Guild.NewsMessage);
                break;

            case 12:
                //Leave guild
                Writer.Byte(3);
                Writer.DWord(c.Information.CharacterID);
                Writer.Byte(1);
                break;

            case 13:
                //Donated gp #1
                Writer.Byte(5);
                Writer.Byte(8);
                Writer.DWord(donatedgp);
                break;

            case 14:
                //Union invite send
                Writer.Byte(c.Network.Guild.TotalMembers);
                Writer.DWord(c.Network.Guild.Guildid);
                Writer.Text(c.Network.Guild.Name);
                Writer.Byte(c.Network.Guild.Level);
                Writer.Text(c.Information.Name);
                Writer.DWord(c.Information.Model);
                Writer.Byte(0x11);    //??
                break;
            }
            return(Writer.GetBytes());
        }
예제 #22
0
        public static void DeSpawnMe(int Index_)
        {
            if (Player.Flags[Index_].Ingame == 1)
            {
                PacketWriter writer = new PacketWriter();
                writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_DESPAWN);
                writer.AppendDword(Player.General[Index_].UniqueID);

                byte[] tmpBuffer = writer.getWorkspace();

                for (int i = 0; i < Player.PlayersOnline; i++)
                {
                    if (Player.General[i].CharacterID != 0 && i != Index_)
                    {
                        if (Formula.CalculateDistance(Player.Position[Index_], Player.Position[i]) <= 800 && Player.Objects[i].SpawnedIndex.Contains(Index_))
                        {
                            Console.WriteLine(i);
                            ServerSocket.Send(tmpBuffer, i);
                            Player.Objects[i].SpawnedIndex.Remove(Index_);
                        }
                    }
                }
             //   ServerSocket.SendToAllExceptMe(writer.getWorkspace(), Index_);
            }
        }
예제 #23
0
        public static void Guild_ListPlayersInfo(List <Global.guild_player> guildMembers, PacketWriter Writer)
        {
            Writer.Byte(guildMembers.Count);
            foreach (Global.guild_player m in guildMembers)
            {
                Writer.DWord(m.MemberID);
                Writer.Text(m.Name);
                Writer.Byte(m.Rank);
                Writer.Byte(m.Level);
                Writer.DWord(m.DonateGP);

                System.Collections.BitArray bits = new System.Collections.BitArray(new bool[]
                {
                    m.noticeeditRight,
                    m.guildstorageRight,
                    m.unionRight,
                    m.withdrawRight,
                    m.joinRight,
                    false, false, false
                });
                byte[] bytes = new byte[1];
                bits.CopyTo(bytes, 0);

                Writer.DWord((int)bytes[0]);
                Writer.DWord(0);
                Writer.DWord(0);
                Writer.DWord(0);
                if (m.GrantName != null)
                {
                    if (m.GrantName != "")
                    {
                        Writer.Text(m.GrantName);
                    }
                    else
                    {
                        Writer.Word(0);
                    }
                }
                else
                {
                    Writer.Word(0);
                }

                Writer.DWord(m.Model);
                Writer.Byte(m.FWrank);

                Writer.Byte(m.Xsector);
                Writer.Byte(m.Ysector);
                Writer.DWord(0xFFFFFFFF); // when he entered last time 25794314
                Writer.DWord(0x0189EECA); // when he leveled up last time 25816778 later :P
                Writer.Bool(!m.Online);
            }
        }
예제 #24
0
        public static void OnIngameRequest(PacketReader Reader_, int Index_)
        {
            PacketWriter writer = new PacketWriter();
            reader = Reader_;

            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_INGAME_ACCEPT);
            writer.AppendByte(0x01);
            ServerSocket.Send(writer.getWorkspace(), Index_);

            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_LOADING_START);
            ServerSocket.Send(writer.getWorkspace(), Index_);

            ushort characternamelen = reader.ReadWord();
            string charactername = reader.ReadString(false, characternamelen);

            int CharacterIndex = DatabaseCore.Character.GetIndexByName(charactername);
            int[] CharacterItemIndex = DatabaseCore.Item.GetIndexByName(charactername);
            int[] CharacterMasteryIndex = DatabaseCore.Mastery.GetIndexByName(charactername, DatabaseCore.Character.Model[CharacterIndex] >= 14717);
            int CharacterSkillIndex = DatabaseCore.Skill.GetIndexByName(charactername);

            Player.General[Index_].CharacterName = DatabaseCore.Character.CharacterName[CharacterIndex];
            Player.General[Index_].CharacterID = DatabaseCore.Character.CharacterId[CharacterIndex];
            Player.General[Index_].UniqueID = DatabaseCore.Character.UniqueId[CharacterIndex];
            Player.Stats[Index_].HP = DatabaseCore.Character.HP[CharacterIndex];
            Player.Stats[Index_].MP = DatabaseCore.Character.MP[CharacterIndex];
            Player.Stats[Index_].CHP = DatabaseCore.Character.CHP[CharacterIndex];
            Player.Stats[Index_].CMP = DatabaseCore.Character.CMP[CharacterIndex];
            Player.Stats[Index_].Model = DatabaseCore.Character.Model[CharacterIndex];
            Player.Stats[Index_].Volume = DatabaseCore.Character.Volume[CharacterIndex];
            Player.Stats[Index_].Level = DatabaseCore.Character.Level[CharacterIndex];
            Player.Stats[Index_].Experience = DatabaseCore.Character.Experience[CharacterIndex];
            Player.Stats[Index_].Gold = DatabaseCore.Character.Gold[CharacterIndex];
            Player.Stats[Index_].Skillpoints = DatabaseCore.Character.SkillPoints[CharacterIndex];
            Player.Stats[Index_].Attributes = DatabaseCore.Character.Attributes[CharacterIndex];
            Player.Stats[Index_].BerserkBar = DatabaseCore.Character.BerserkBar[CharacterIndex];
            Player.Flags[Index_].Berserk = DatabaseCore.Character.Berserk[CharacterIndex];
            Player.Speeds[Index_].WalkSpeed = DatabaseCore.Character.WalkSpeed[CharacterIndex];
            Player.Speeds[Index_].RunSpeed = DatabaseCore.Character.RunSpeed[CharacterIndex];
            Player.Speeds[Index_].BerserkSpeed = DatabaseCore.Character.BerserkSpeed[CharacterIndex];
            Player.Stats[Index_].MinPhy = DatabaseCore.Character.MinPhy[CharacterIndex];
            Player.Stats[Index_].MaxPhy = DatabaseCore.Character.MaxPhy[CharacterIndex];
            Player.Stats[Index_].MinMag = DatabaseCore.Character.MinMag[CharacterIndex];
            Player.Stats[Index_].MaxMag = DatabaseCore.Character.MaxMag[CharacterIndex];
            Player.Stats[Index_].PhyDef = DatabaseCore.Character.PhyDef[CharacterIndex];
            Player.Stats[Index_].MagDef = DatabaseCore.Character.MagDef[CharacterIndex];
            Player.Stats[Index_].Hit = DatabaseCore.Character.Hit[CharacterIndex];
            Player.Stats[Index_].Parry = DatabaseCore.Character.Parry[CharacterIndex];
            Player.Stats[Index_].Strength = DatabaseCore.Character.Strength[CharacterIndex];
            Player.Stats[Index_].Intelligence = DatabaseCore.Character.Intelligence[CharacterIndex];
            Player.Stats[Index_].SkillpointBar = DatabaseCore.Character.SkillPointBar[CharacterIndex];
            Player.Flags[Index_].GM = DatabaseCore.Character.GM[CharacterIndex];
            Player.Flags[Index_].PvP = DatabaseCore.Character.PVP[CharacterIndex];
            Player.Position[Index_].XSector = DatabaseCore.Character.XSector[CharacterIndex];
            Player.Position[Index_].YSector = DatabaseCore.Character.YSector[CharacterIndex];
            Player.Position[Index_].X = DatabaseCore.Character.X[CharacterIndex];
            Player.Position[Index_].Y = DatabaseCore.Character.Z[CharacterIndex];
            Player.Position[Index_].Z = DatabaseCore.Character.Y[CharacterIndex];
            Player.General[Index_].MaxSlots = DatabaseCore.Character.MaxSlots[CharacterIndex];

            Player.Objects[Index_].ActiveBuffs = new Player._Objects._Buffs[20];
            Player.General[Index_].Busy = false;
            Player.General[Index_].State = 0;
            Player.Objects[Index_].UsingSkill = false;
            Player.Objects[Index_].NormalAttack = false;
            Player.Objects[Index_].SpawnedIndex = new List<int>();
            Player.Objects[Index_].SpawnedMonsterIndex = new List<int>();
            Player.Objects[Index_].SpawnedItemsIndex = new List<int>();

            Player.General[Index_].WeaponType = Silkroad.GetItemById(DatabaseCore.Item.ItemId[CharacterItemIndex[6]]).CLASS_C;

            if (DatabaseCore.Item.ItemId[CharacterItemIndex[8]] != 0)
                Player.Flags[Index_].WearingCape = true;

            for (byte i = 9; i < 13; i++)
            {
                if (DatabaseCore.Item.ItemId[CharacterItemIndex[i]] != 0)
                    Player.Stats[0].TotalAccessoriesAbsorption += Silkroad.GetItemById(DatabaseCore.Item.ItemId[CharacterItemIndex[i]]).ABSORB_INC;
            }

            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_CHARDATA);

            //writer.AppendDword(Player.Stats[Index_].Model);
            //8B 16 C7 C0
            //74 07 00 00
            //44
            writer.AppendByte(0x8B);
            writer.AppendByte(0x16);
            writer.AppendByte(0xC7);
            writer.AppendByte(0xC0);

            writer.AppendByte(0x74);
            //writer.AppendByte(Player.Stats[Index_].Volume);

            writer.AppendByte(0x07);
            writer.AppendByte(0x00);
            writer.AppendByte(0x00);

            writer.AppendByte(0x44);

            writer.AppendByte(Player.Stats[Index_].Level);
            writer.AppendByte(Player.Stats[Index_].Level);
            writer.AppendLword(Player.Stats[Index_].Experience);
            writer.AppendDword(Player.Stats[Index_].SkillpointBar);
            //writer.AppendWord(0);
            writer.AppendLword(Player.Stats[Index_].Gold);
            writer.AppendDword(Player.Stats[Index_].Skillpoints);
            writer.AppendWord(Player.Stats[Index_].Attributes);
            writer.AppendByte(Player.Stats[Index_].BerserkBar);
            writer.AppendDword(0);
            writer.AppendDword(Player.Stats[Index_].HP);
            writer.AppendDword(Player.Stats[Index_].MP);
            if (Player.Flags[Index_].GM == 1)
                writer.AppendByte(1);
            else
                writer.AppendByte((byte)(Player.Stats[Index_].Level < 20 ? 1 : 0));

            //Pk
            writer.AppendByte(0);
            writer.AppendWord(0);
            writer.AppendDword(0);

            //Title
            writer.AppendByte(0);

            //Pvp
            writer.AppendByte(0);

            //Items
            writer.AppendByte(Player.General[Index_].MaxSlots);

            byte PlayerItemCount = 0;
            for (byte i = 0; i <= Player.General[Index_].MaxSlots; i++)
            {
                if (DatabaseCore.Item.ItemId[CharacterItemIndex[i]] != 0)
                    PlayerItemCount++;
            }
            writer.AppendByte(PlayerItemCount);

            for (byte i = 1; i <= Player.General[Index_].MaxSlots; i++)
            {
                if (DatabaseCore.Item.ItemId[CharacterItemIndex[i]] != 0)
                {
                    writer.AppendByte(i);
                    writer.AppendDword(DatabaseCore.Item.ItemId[CharacterItemIndex[i]]);
                    switch (DatabaseCore.Item.Type[CharacterItemIndex[i]])
                    {
                        case 0:
                            writer.AppendByte(DatabaseCore.Item.PlusValue[CharacterItemIndex[i]]);
                            writer.AppendLword(0);
                            writer.AppendDword(DatabaseCore.Item.Durability[CharacterItemIndex[i]]);
                            writer.AppendByte(DatabaseCore.Item.BlueAmount[CharacterItemIndex[i]]);
                            for (byte j = 0; j <= 8; j++)
                            {
                                if (DatabaseCore.Item.Blue[CharacterItemIndex[i]].Blue[j] != 0)
                                {
                                    writer.AppendDword(DatabaseCore.Item.Blue[CharacterItemIndex[i]].Blue[j]);
                                    writer.AppendDword(DatabaseCore.Item.Blue[CharacterItemIndex[i]].BlueAmount[j]);
                                }
                            }
                            break;
                        case 1:
                            writer.AppendWord(DatabaseCore.Item.Quantity[CharacterItemIndex[i]]);
                            break;
                        case 2:
                            writer.AppendByte(0);
                            writer.AppendWord(1);
                            break;
                    }
                }
            }

            //Avatar
            writer.AppendByte(5);

            //Load Items
            writer.AppendByte(0);

            //unk
            writer.AppendByte(0);

            //Job Mastery
            writer.AppendByte(0x0B);
            writer.AppendByte(0x00);
            writer.AppendByte(0x00);

            // Mastery
            for (byte i = 0; i < CharacterMasteryIndex.Length; i++)
            {
                if (DatabaseCore.Mastery.MasteryId[CharacterMasteryIndex[i]] != 0)
                {
                    writer.AppendByte(1);
                    writer.AppendDword(DatabaseCore.Mastery.MasteryId[CharacterMasteryIndex[i]]);
                    writer.AppendByte(DatabaseCore.Mastery.MasteryLevel[CharacterMasteryIndex[i]]);
                }
            }

            //Skills
            //writer.AppendWord(2); //unk

            for (int i = 1; i < DatabaseCore.Skill.SkillAmount[CharacterSkillIndex]; i++)
            {
                writer.AppendByte(1);
                writer.AppendDword(DatabaseCore.Skill.Skills[CharacterSkillIndex].SkillId[i]);
                writer.AppendByte(0);
            }

            writer.AppendByte(2); //unk

            // Quest
            /*
            writer.AppendWord(0);  // how many Quest ids completed/aborted
            writer.AppendDword(2); // Quest id
            writer.AppendByte(0);  // number of Quests that are live*/

            //writer.AppendByte(2);  // unk

            // Talisman
            //writer.AppendWord(0x01); //unk
            //writer.AppendWord(0x01); //unk
            //writer.AppendDword(0x00); //unk
            //writer.AppendDword(0x00); //unk

            // unk
            writer.AppendByte(0x00);
            writer.AppendByte(0x02);
            writer.AppendWord(0x01);
            writer.AppendDword(0x01);
            writer.AppendByte(0x00);
            writer.AppendByte(0x00);
            writer.AppendDword(0x00);

            //Position
            writer.AppendDword(Player.General[Index_].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);  //Angle
            writer.AppendByte(0);
            writer.AppendByte(1);
            writer.AppendByte(0);
            writer.AppendWord(0);  //Angle
            writer.AppendWord(0);
            writer.AppendByte(0);

            writer.AppendByte(Player.Flags[Index_].Berserk);
            //writer.AppendByte(0);  //unk
            writer.AppendFloat(Player.Speeds[Index_].WalkSpeed);
            writer.AppendFloat(Player.Speeds[Index_].RunSpeed);
            writer.AppendFloat(Player.Speeds[Index_].BerserkSpeed);

            writer.AppendByte(0); //ITEM_MALL_GOLD_TIME_SERVICE_TICKET_4W

            //Gm Name
            if (Player.Flags[Index_].GM == 1)
            {
                string gmname = string.Format("[GM]{0}", charactername);
                writer.AppendWord((ushort)gmname.Length);
                writer.AppendString(false, gmname);
            }
            else
            {
                writer.AppendWord((ushort)charactername.Length);
                writer.AppendString(false, charactername);
            }

            //Job System
            //Need Implement
            //if (c.Job.state == 1)
            //{
            //    Writer.Text(c.Job.Jobname);
            //    Writer.Byte(1);
            //    Writer.Byte(c.Job.level);//Level job
            //    Writer.Byte(c.Information.Level);//Level char
            //    Writer.Byte(1); // job level? myb
            //    Writer.LWord(0);// job exp probably y
            //    Writer.Byte(0);
            //    Writer.Byte(0);
            //    Writer.Byte(0);
            //    Writer.Byte(0);
            //}
            //else
            //{

            //    Writer.Word(0);
            //    Writer.Byte(0);
            //    Writer.Byte(0);
            //    Writer.Byte(2); // job type
            //    Writer.Byte(1); // job level? myb
            //    Writer.LWord(0);// job exp probably y
            //    Writer.Byte(0);
            //    Writer.Byte(0);
            //    Writer.Byte(0);
            //    Writer.Byte(0);
            //}

            writer.AppendWord(0);
            writer.AppendByte(0);
            writer.AppendByte(0);
            writer.AppendByte(0); //job type
            writer.AppendByte(1); //job level?
            writer.AppendLword(0); //job exp
            writer.AppendByte(0);
            writer.AppendByte(0);
            writer.AppendByte(0);
            writer.AppendByte(0);

            // Pvp pk state
            writer.AppendByte((byte)Player.Flags[Index_].PvP);

            // Guild Data
            //D3 02 A0 00 00 00 00 00
            writer.AppendByte(0x00);
            writer.AppendByte(0x00);
            writer.AppendByte(0x00);
            writer.AppendByte(0x00);
            writer.AppendByte(0x00);
            writer.AppendByte(0x00);
            writer.AppendByte(0x00);
            writer.AppendByte(0x00);

            // AccountId + Gm Info
            writer.AppendDword(Player.General[Index_].AccountID);
            writer.AppendByte(Player.Flags[Index_].GM);

            // Bar Information
            writer.AppendByte(0x00);
            writer.AppendByte(0x00);

            //unk
            writer.AppendLword(0x00);

            // Academy
            writer.AppendByte(0);
            writer.AppendByte(0);
            writer.AppendWord(1);
            writer.AppendWord(1);
            writer.AppendByte(0);
            writer.AppendByte(2);

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

            //Stats.OnStatPacket(Index_);

            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_LOADING_END);
            ServerSocket.Send(writer.getWorkspace(), Index_);

            //PlayerUnk1(Index_);
        }
예제 #25
0
        public static byte[] UnionInfo(Systems c)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_GUILD_UNIONS);
            Writer.DWord(c.Character.Information.CharacterID);                // Union owner id
            Writer.DWord(7);                                                  // ??Need to check
            Writer.DWord(c.Character.Network.Guild.Guildid);                  // Union leader guild id
            Writer.Byte(c.Character.Network.Guild.Unions.Count);              // Count guilds in union
            //Get all guilds details
            foreach (int guild in c.Character.Network.Guild.Unions)
            {
                //Load other guild data
                Systems.MsSQL guild_data = new Systems.MsSQL("SELECT * FROM guild WHERE id='" + guild + "'");

                using (System.Data.SqlClient.SqlDataReader reader = guild_data.Read())
                {
                    while (reader.Read())
                    {
                        string Guildname        = reader.GetString(1);
                        byte   Guildlevel       = reader.GetByte(2);
                        byte   Guildmembercount = reader.GetByte(6);
                        int    Ownerid          = reader.GetInt32(9);

                        string Charname  = Systems.MsSQL.GetData("SELECT name FROM character WHERE id='" + Ownerid + "'", "name").ToString();
                        int    Charmodel = Convert.ToInt32(Systems.MsSQL.GetData("SELECT chartype FROM character WHERE id='" + Ownerid + "'", "chartype"));

                        Writer.DWord(guild);                        //Guild ID
                        Writer.Text(reader.GetString(1));           //Guildname
                        Writer.Byte(reader.GetByte(2));             //Guildlevel
                        Writer.Text(Charname);                      //Ownername
                        Writer.DWord(Charmodel);                    //Owner model
                        Writer.Byte(reader.GetByte(6));             //Guild member count

                        //Get guild details
                        Systems Guildmembers = Systems.GetGuildPlayer(guild);
                        //Add clients that are online to union list
                        //Null check
                        if (Guildmembers != null)
                        {
                            foreach (int member in Guildmembers.Character.Network.Guild.Members)
                            {
                                //make sure member isnt 0
                                if (member != 0)
                                {
                                    //Get player details
                                    Systems getmember = Systems.GetPlayerMainid(member);
                                    //Make sure that the player is there
                                    if (getmember != null)
                                    {
                                        //Add client to union list
                                        c.Character.Network.Guild.UnionMembers.Add(getmember.Character.Information.CharacterID);
                                        //Add to member
                                        if (c.Character.Information.CharacterID != getmember.Character.Information.CharacterID)
                                        {
                                            getmember.Character.Network.Guild.UnionMembers.Add(c.Character.Information.CharacterID);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(Writer.GetBytes());
        }
예제 #26
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_);
        }
예제 #27
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_);
            }
        }
예제 #28
0
 public static void PlayerUnk1(int Index_)
 {
     TimeSpan ts = GameSocket.ServerStartedTime - DateTime.Now;
     PacketWriter writer = new PacketWriter();
     writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_CHARACTER_CELESTIAL_POSITION);
     writer.AppendDword((uint)Index_);
     writer.AppendDword((uint)Math.Abs(ts.TotalSeconds));
     ServerSocket.Send(writer.getWorkspace(), Index_);
 }
예제 #29
0
파일: Items.cs 프로젝트: CarlosX/DarkEmu
        public static void EquipCape(int Index_)
        {
            PacketWriter writer = new PacketWriter();
            if (!Player.Flags[Index_].WearingCape)
            {
                writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ITEM_EQUIP);
                writer.AppendDword(Player.General[Index_].UniqueID);
                writer.AppendByte(DatabaseCore.Item.Slot[Player.Objects[Index_].SourceItemIndex]);
                writer.AppendDword(DatabaseCore.Item.ItemId[Player.Objects[Index_].SourceItemIndex]);
                writer.AppendByte(0);

                ServerSocket.SendPacketIfPlayerIsSpawned(writer.getWorkspace(), Index_);
                Player.Flags[Index_].WearingCape = true;
            }
            else
            {
                writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ITEM_UNEQUIP);
                writer.AppendDword(Player.General[Index_].UniqueID);
                writer.AppendByte(DatabaseCore.Item.Slot[Player.Objects[Index_].SourceItemIndex]);
                writer.AppendDword(DatabaseCore.Item.ItemId[Player.Objects[Index_].SourceItemIndex]);

                ServerSocket.SendPacketIfPlayerIsSpawned(writer.getWorkspace(), Index_);
                Player.Flags[Index_].WearingCape = false;
            }

            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ITEM_MOVEMENT);
            writer.AppendWord(1);
            writer.AppendByte(DatabaseCore.Item.Slot[Player.Objects[Index_].SourceItemIndex]);
            writer.AppendByte(DatabaseCore.Item.Slot[Player.Objects[Index_].DestinationItemIndex]);
            writer.AppendWord(0);
            writer.AppendByte(0);
            ServerSocket.Send(writer.getWorkspace(), Index_);

            MoveItemToDatabase(Player.Objects[Index_].SourceItemIndex, Player.Objects[Index_].DestinationItemIndex, Player.General[Index_].CharacterName);
        }
예제 #30
0
        public static void SendCharacterList(int Index_)
        {
            PacketWriter writer = new PacketWriter();
            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_CHARACTER);
            writer.AppendWord(0x0102);

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

            writer.AppendByte(DatabaseCore.User.CharacterCount[UserIndex]);

            for (int i = 0; i < DatabaseCore.User.CharacterCount[UserIndex]; i++)
            {
                int tmpCharacterIndex = DatabaseCore.Character.GetIndexByName(DatabaseCore.User.Characters[UserIndex].CharacterName[i]);
                int[] CharacterItemIndex = DatabaseCore.Item.GetIndexByName(DatabaseCore.User.Characters[UserIndex].CharacterName[i]);

                writer.AppendDword(DatabaseCore.Character.Model[tmpCharacterIndex]);
                writer.AppendWord((ushort)DatabaseCore.Character.CharacterName[tmpCharacterIndex].Length);
                writer.AppendString(false, DatabaseCore.Character.CharacterName[tmpCharacterIndex]);
                writer.AppendByte(DatabaseCore.Character.Volume[tmpCharacterIndex]);
                writer.AppendByte(DatabaseCore.Character.Level[tmpCharacterIndex]);
                writer.AppendLword(DatabaseCore.Character.Experience[tmpCharacterIndex]);
                writer.AppendWord(DatabaseCore.Character.Strength[tmpCharacterIndex]);
                writer.AppendWord(DatabaseCore.Character.Intelligence[tmpCharacterIndex]);
                writer.AppendWord(DatabaseCore.Character.Attributes[tmpCharacterIndex]);
                writer.AppendInt(DatabaseCore.Character.CHP[tmpCharacterIndex]);
                writer.AppendInt(DatabaseCore.Character.CMP[tmpCharacterIndex]);
                //writer.AppendDword(0x00);
                writer.AppendByte(0x00);
                writer.AppendByte(0x00);
                writer.AppendByte(0x00);
                writer.AppendByte(0x01);

                byte PlayerItemCount = 0;
                for (byte j = 0; j < 10; j++)
                {
                    if (DatabaseCore.Item.ItemId[CharacterItemIndex[j]] != 0)
                        PlayerItemCount++;
                }
                writer.AppendByte(PlayerItemCount);

                for (int j = 0; j < 10; j++)
                {
                    if (DatabaseCore.Item.ItemId[CharacterItemIndex[j]] != 0)
                    {
                        writer.AppendDword(DatabaseCore.Item.ItemId[CharacterItemIndex[j]]);
                        writer.AppendByte(DatabaseCore.Item.PlusValue[CharacterItemIndex[j]]);
                    }
                }

                writer.AppendByte(0x00);
                writer.AppendByte(0x00);
            }

            ServerSocket.Send(writer.getWorkspace(), Index_);
        }
예제 #31
0
        public static byte[] Load(character c)
        {

            PacketWriter Writer = new PacketWriter();
            Writer.Create(Systems.SERVER_PLAYERDATA);
            /////////////////////////////////////////////////////// Character basic info
            #region Basic info   
            Writer.DWord(c.Ids.GetLoginID);
            Writer.DWord(c.Information.Model);
            Writer.Byte(c.Information.Volume);
            Writer.Byte(c.Information.Level);
            Writer.Byte(c.Information.Level);
            Writer.LWord(c.Information.XP);
            Writer.DWord(c.Information.SpBar);
            Writer.LWord(c.Information.Gold);
            Writer.DWord(c.Information.SkillPoint);
            Writer.Word(c.Information.Attributes);
            Writer.Byte(c.Information.BerserkBar);
            Writer.DWord(0);
            Writer.DWord(c.Stat.SecondHp);
            Writer.DWord(c.Stat.SecondMP);
            Writer.Bool(c.Information.Level < 20 ? true : false);
            #endregion
            /////////////////////////////////////////////////////// Character Player Kill Info
            #region Pk information
            //Mssql perfection reading with multiple data adapters... while this one is open i can still read anything else from the database
            //With no speed reduction...
            Systems.MsSQL checkpk = new Systems.MsSQL("SELECT * FROM character WHERE name ='" + c.Information.Name + "'");
            using (System.Data.SqlClient.SqlDataReader getinfo = checkpk.Read())
            {
                while (getinfo.Read())
                {
                    byte dailypk = getinfo.GetByte(48);
                    byte pklevel = getinfo.GetByte(49);
                    byte murderlevel = getinfo.GetByte(50);

                    Writer.Byte(dailypk);
                    Writer.Word(pklevel);
                    Writer.DWord(murderlevel);
                    if (murderlevel != 0) c.Information.Murderer = true;
                }
            }
            #endregion
            /////////////////////////////////////////////////////// Character Title
            #region Title
            Writer.Byte(c.Information.Title);
            #endregion
            /////////////////////////////////////////////////////// Character Pvpstate
            #region Pvp
            Writer.Byte(c.Information.Pvpstate);
            if (c.Information.Pvpstate > 0) 
                c.Information.PvP = true;
            #endregion
            /////////////////////////////////////////////////////// Character Items
            #region Item
            
            Writer.Byte(c.Information.Slots);

            Systems.MsSQL ms = new Systems.MsSQL("SELECT * FROM char_items WHERE owner='" + c.Information.CharacterID + "' AND slot >= '0' AND slot <= '" + c.Information.Slots + "' AND inavatar='0' AND storagetype='0'");
            Writer.Byte(ms.Count());
            using (System.Data.SqlClient.SqlDataReader msreader = ms.Read())
            {

                while (msreader.Read())
                {

                    short amount = msreader.GetInt16(6);

                    if (amount < 1) amount = 1;
                    Systems.MsSQL.InsertData("UPDATE char_items SET quantity='" + amount + "' WHERE owner='" + c.Information.CharacterID + "' AND itemid='" + msreader.GetInt32(2) + "' AND id='" + msreader.GetInt32(0) + "' AND storagetype='0'");

                    if (msreader.GetByte(5) == 6)
                        c.Information.Item.wID = Convert.ToInt32(msreader.GetInt32(2));
                    if (msreader.GetByte(5) == 7)
                    {
                        c.Information.Item.sID = msreader.GetInt32(2);
                        c.Information.Item.sAmount = msreader.GetInt16(6);
                    }
                    
                    Item.AddItemPacket(Writer, msreader.GetByte(5), msreader.GetInt32(2), msreader.GetByte(4), amount, msreader.GetInt32(7),msreader.GetInt32(0), msreader.GetInt32(9), msreader.GetInt32(30));
                }
            }
            ms.Close();

            //Avatar
            Writer.Byte(5);

            ms = new Systems.MsSQL("SELECT * FROM char_items WHERE owner='" + c.Information.CharacterID + "' AND slot >= '0' AND slot <= '" + c.Information.Slots + "' AND inavatar='1' AND storagetype='0'");

            Writer.Byte(ms.Count());
            using (System.Data.SqlClient.SqlDataReader msreader = ms.Read())
            {
                while (msreader.Read())
                {
                    Item.AddItemPacket(Writer, msreader.GetByte(5), msreader.GetInt32(2), msreader.GetByte(4), msreader.GetInt16(6), msreader.GetInt32(7), msreader.GetInt32(0), msreader.GetInt32(9),msreader.GetInt32(30));
                }
            }
            ms.Close();

            Writer.Byte(0);

            // job mastery 
            Writer.Byte(0x0B);
            Writer.Byte(0);
            Writer.Byte(0);

            #endregion
            ///////////////////////////////////////////////////////  Mastery
            #region Mastery
            if (c.Information.Model <= 12000)
            {
                for (byte i = 1; i <= 8; i++)
                {
                    Writer.Byte(1);
                    Writer.DWord(c.Stat.Skill.Mastery[i]);
                    Writer.Byte(c.Stat.Skill.Mastery_Level[i]);
                }
            }
            else
            {
                if (c.Information.Model >= 14000)
                {
                    for (byte i = 1; i < 8; i++)
                    {
                        Writer.Byte(1);
                        Writer.DWord(c.Stat.Skill.Mastery[i]);
                        Writer.Byte(c.Stat.Skill.Mastery_Level[i]);
                    }
                }
            }
            #endregion
            /////////////////////////////////////////////////////// Skills
            #region Skill
            Writer.Byte(2);
            Writer.Byte(0);
                for (int i = 1; i <= c.Stat.Skill.AmountSkill; i++)
                {
                    Writer.Byte(1);
                    Writer.DWord(c.Stat.Skill.Skill[i]);
                    Writer.Byte(1);
                }
            Writer.Byte(2);
            #endregion
            /////////////////////////////////////////////////////// Quests
            #region Quest
            Writer.Word(1); // how many Quest ids completed/aborted
            Writer.DWord(1);// Quest id
            Writer.Byte(0);//number of Quests that are live
            #endregion
            Writer.Byte(0);//? for now
            /////////////////////////////////////////////////////// Talisman
            #region Talisman
            Writer.DWord(1);//new
            Writer.DWord(1);//new
            Writer.DWord(0);//? for now
            Writer.DWord(0x0C);//new
            #endregion
            /////////////////////////////////////////////////////// Position + id + speed
            #region Character id / Position / Speed
            Writer.DWord(c.Information.UniqueID);
            Writer.Byte(c.Position.xSec);
            Writer.Byte(c.Position.ySec);
            if (!File.FileLoad.CheckCave(c.Position.xSec, c.Position.ySec))
            {
                Writer.Float(Formule.packetx(c.Position.x, c.Position.xSec));
                Writer.Float(c.Position.z);
                Writer.Float(Formule.packety(c.Position.y, c.Position.ySec));
            }
            else
            {
                Writer.Float(Formule.cavepacketx(c.Position.x));// Added for cave Coords
                Writer.Float(c.Position.z);
                Writer.Float(Formule.cavepackety(c.Position.y));// Added for cave Coords

            }
            Writer.Word(0);							// Angle
            Writer.Byte(0);
            Writer.Byte(1);
            Writer.Byte(0);
            Writer.Word(0);							// Angle
            Writer.Word(0);
            Writer.Byte(0);
            Writer.Bool(false); //berserk

            Writer.Byte(0);//new ?

            Writer.Float(c.Speed.WalkSpeed);
            Writer.Float(c.Speed.RunSpeed);
            Writer.Float(c.Speed.BerserkSpeed);
            #endregion
            /////////////////////////////////////////////////////// Premium Tickets
            #region Premium ticket
            Writer.Byte(0); //ITEM_MALL_GOLD_TIME_SERVICE_TICKET_4W
            #endregion
            /////////////////////////////////////////////////////// GM Check + Name
            #region GM Check + Name
            Writer.Text(c.Information.Name);
            #endregion
            /////////////////////////////////////////////////////// Character jobs
            #region Character Job / hunter thief trader ( old job things )
                //Writer info with job name when on job
                /*if (c.Job.state == 1 && c.Job.Jobname != "0")
                {
                    Writer.Text(c.Job.Jobname);
                    Writer.Byte(3);
                    Writer.Byte(1);
                    Writer.DWord(0);
                    Writer.DWord(0);
                    Writer.DWord(0);
                    Writer.Byte(0);
                    Writer.Byte(0);
                    Writer.Byte(0);
                }
                //Write basic info noname
                if (c.Job.Jobname == "0")
                {
                    Writer.Word(0);
                    Writer.Byte(3);
                    Writer.Byte(1);
                    Writer.DWord(0);
                    Writer.DWord(0);
                    Writer.DWord(0);
                    Writer.Byte(0);
                    Writer.Byte(0);
                    Writer.Byte(0);
                }
                //Write no info
                else
                {
                    Writer.Word(0);
                    Writer.Byte(0);
                    Writer.Byte(1);
                    Writer.DWord(0);
                    Writer.DWord(0);
                    Writer.DWord(0);
                    Writer.Byte(0);
                    Writer.Byte(0);
                    Writer.Byte(0);
                }*/
            #endregion
            #region New job system
            if (c.Job.state == 1)
            {
                Writer.Text(c.Job.Jobname);
                Writer.Byte(1);
                Writer.Byte(c.Job.level);//Level job
                Writer.Byte(c.Information.Level);//Level char
                Writer.Byte(1); // job level? myb
                Writer.LWord(0);// job exp probably y
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Byte(0);
            }
            else
            {

                Writer.Word(0);
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Byte(2); // job type
                Writer.Byte(1); // job level? myb
                Writer.LWord(0);// job exp probably y
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Byte(0);
            }

            #endregion
                /////////////////////////////////////////////////////// Pvp / Pk State
            #region Pvp / Pk State
            if (c.Information.Pvpstate == 1 || c.Information.Murderer)
            {
                Writer.Byte(0x22);
            }
            else if (c.Information.Pvpstate == 0 || !c.Information.Murderer)
            {
                Writer.Byte(0xFF);
            }
            #endregion
            /////////////////////////////////////////////////////// Guide Data 
            #region Guide Data this data stacks on itself so if guide id is 0400000000000000 and next guide is 0300000000000000 the data to send is 0700000000000000

            for (int i = 0; i < 8; ++i)//Main Guide Packet Info
            {
                Writer.Byte(c.Guideinfo.G1[i]);//Reads From Int Array
            }
            #endregion
            /////////////////////////////////////////////////////// Account / Gm Check
            #region Account ID + Gm Check
            Writer.DWord(c.Account.ID);
            Writer.Byte(0);//c.Information.GM
            #endregion
            /////////////////////////////////////////////////////// Quickbar + Autopotion
            #region Bar information
            Writer.Byte(7);
            PacketReader reader = new PacketReader(System.IO.File.ReadAllBytes(Environment.CurrentDirectory + @"\player\info\quickbar\" + c.Information.Name + ".dat"));
            PlayerQuickBar(reader, Writer);
            reader = new PacketReader(System.IO.File.ReadAllBytes(Environment.CurrentDirectory + @"\player\info\autopot\" + c.Information.Name + ".dat"));
            PlayerAutoPot(reader, Writer);
            #endregion
            /////////////////////////////////////////////////////// Academy
            #region Academy
            Writer.Byte(0); // number of player in academy
            /* // if we have players there 
             Writer.Byte(1);
             Writer.Text("asd"); 
             */
            Writer.Byte(0);//added byte today for 1.310
            Writer.Byte(0);
            Writer.Word(1); 
            Writer.Word(1);
            Writer.Byte(0);
            Writer.Byte(1);
            #endregion
            return Writer.GetBytes();
        }
예제 #32
0
파일: Mastery.cs 프로젝트: CarlosX/DarkEmu
 public static void SPUpdate(int Index_)
 {
     PacketWriter writer = new PacketWriter();
     writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_SKILLPOINTS);
     writer.AppendByte(2);
     writer.AppendDword(Player.Stats[Index_].Skillpoints);
     writer.AppendByte(0);
     ServerSocket.Send(writer.getWorkspace(), Index_);
     DatabaseCore.WriteQuery("UPDATE characters SET sp='{0}' WHERE name='{1}'", Player.Stats[Index_].Skillpoints, Player.General[Index_].CharacterName);
 }
예제 #33
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();
        }
예제 #34
0
파일: Items.cs 프로젝트: CarlosX/DarkEmu
        public static unsafe void MoveItem(byte* ptr, int Index_)
        {
            Silkroad.C_S.MOVE_ITEM* tmpPtr = (Silkroad.C_S.MOVE_ITEM*)ptr;

            PacketWriter writer = new PacketWriter();
            switch (tmpPtr->Type)
            {
                case 0:

                    int[] CharacterItemIndex = DatabaseCore.Item.GetIndexByName(Player.General[Index_].CharacterName);
                    Silkroad.Item_ SourceItem_ = Silkroad.GetItemById(DatabaseCore.Item.ItemId[CharacterItemIndex[tmpPtr->Source]]);
                    Silkroad.Item_ DestinationItem_ = Silkroad.GetItemById(DatabaseCore.Item.ItemId[CharacterItemIndex[tmpPtr->Destination]]);

                    if (SourceItem_.ITEM_TYPE_NAME.Contains("FRPVP_VOUCHER"))
                    {
                        if (Player.Stats[Index_].Level >= 10 && CheckItemGender(SourceItem_, Index_))
                        {
                            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ANIMATION_CAPE);
                            writer.AppendDword(Player.General[Index_].UniqueID);
                            writer.AppendWord(0x102);
                            writer.AppendByte(0xA);

                            ServerSocket.SendPacketIfPlayerIsSpawned(writer.getWorkspace(), Index_);
                            Timers.UsingItemTimer[Index_].Interval = 10000;
                            Player.Objects[Index_].SourceItemIndex = CharacterItemIndex[tmpPtr->Source];
                            Player.Objects[Index_].DestinationItemIndex = CharacterItemIndex[tmpPtr->Destination];
                            Timers.UsingItemTimer[Index_].Start();
                        }
                        else
                        {
                            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ITEM_MOVEMENT);
                            writer.AppendWord(0x1002);
                            ServerSocket.Send(writer.getWorkspace(), Index_);
                        }
                    }
                    else
                    {
                        if (tmpPtr->Destination < 13)
                        {
                            if (!SourceItem_.ITEM_TYPE_NAME.Contains("ETC"))
                            {
                                if (!CheckItemGender(SourceItem_, Index_))
                                {
                                    writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ITEM_MOVEMENT);
                                    writer.AppendWord(0x1602);
                                    ServerSocket.Send(writer.getWorkspace(), Index_);
                                    return;
                                }
                                else if (!CheckItemLevel(SourceItem_, Index_))
                                {
                                    writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ITEM_MOVEMENT);
                                    writer.AppendWord(0x1002);
                                    ServerSocket.Send(writer.getWorkspace(), Index_);
                                    return;
                                }

                                if (tmpPtr->Destination == 6)
                                    Player.General[Index_].WeaponType = SourceItem_.CLASS_C;

                                Silkroad.Item_ WeaponItem = Silkroad.GetItemById(DatabaseCore.Item.ItemId[CharacterItemIndex[6]]);

                                Console.WriteLine(WeaponItem.CLASS_C);
                                if (tmpPtr->Destination == 6 && DatabaseCore.Item.ItemId[CharacterItemIndex[7]] != 0 && (Player.General[Index_].WeaponType != 2 && Player.General[Index_].WeaponType != 3 && Player.General[Index_].WeaponType != 7 && Player.General[Index_].WeaponType != 10 && Player.General[Index_].WeaponType != 15))
                                {
                                    byte unequipped = UnEnquipShield(Index_, CharacterItemIndex, CharacterItemIndex[7]);
                                    if (unequipped != 255)
                                        MoveItemToDatabase(CharacterItemIndex[7], unequipped, Player.General[Index_].CharacterName);
                                }

                                if (tmpPtr->Destination == 7 && DatabaseCore.Item.ItemId[CharacterItemIndex[6]] != 0 && (WeaponItem.CLASS_C != 2 && WeaponItem.CLASS_C != 3 && WeaponItem.CLASS_C != 7 && WeaponItem.CLASS_C != 10 && WeaponItem.CLASS_C != 15))
                                {
                                    byte unequipped = UnEnquipWeapon(Index_, CharacterItemIndex, CharacterItemIndex[6]);
                                    if (unequipped != 255)
                                        MoveItemToDatabase(CharacterItemIndex[6], unequipped, Player.General[Index_].CharacterName);
                                }

                                EquipItem(Index_, CharacterItemIndex[tmpPtr->Source], CharacterItemIndex[tmpPtr->Destination]);
                            }
                            else
                            {
                                if (!(tmpPtr->Destination == 7 && (Player.General[Index_].WeaponType == 6 || Player.General[Index_].WeaponType == 12) && DatabaseCore.Item.ItemId[CharacterItemIndex[7]] != 0))
                                    return;
                            }
                        }
                        if (tmpPtr->Source < 13)
                            UnEquipItem(Index_, CharacterItemIndex[tmpPtr->Source], CharacterItemIndex[tmpPtr->Destination]);

                        writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ITEM_MOVEMENT);
                        writer.AppendByte(1);
                        writer.AppendByte(tmpPtr->Type);
                        writer.AppendByte(tmpPtr->Source);
                        writer.AppendByte(tmpPtr->Destination);
                        writer.AppendWord(tmpPtr->Amount);
                        writer.AppendByte(0);
                        ServerSocket.Send(writer.getWorkspace(), Index_);

                        MoveItemToDatabase(CharacterItemIndex[tmpPtr->Source], CharacterItemIndex[tmpPtr->Destination], Player.General[Index_].CharacterName);
                    }
                    Stats.OnStatPacket(Index_);
                    break;
                case 7:
                    CharacterItemIndex = DatabaseCore.Item.GetIndexByName(Player.General[Index_].CharacterName);

                    int ItemIndex = Item.ItemAmount;
                    Item.General[ItemIndex].Pk2ID = DatabaseCore.Item.ItemId[CharacterItemIndex[tmpPtr->Source]];
                    Item.General[ItemIndex].UniqueID = (uint)random.Next(76000000, 79999999);
                    Item.General[ItemIndex].Plus = DatabaseCore.Item.PlusValue[CharacterItemIndex[tmpPtr->Source]];
                    Item.General[ItemIndex].Durability = DatabaseCore.Item.Durability[CharacterItemIndex[tmpPtr->Source]];
                    Item.General[ItemIndex].Pickable = true;
                    Item.General[ItemIndex].Quantity = DatabaseCore.Item.Quantity[CharacterItemIndex[tmpPtr->Source]];
                    Item.Position[ItemIndex].XSector = Player.Position[Index_].XSector;
                    Item.Position[ItemIndex].YSector = Player.Position[Index_].YSector;
                    byte randomplace = (byte)random.Next(1, 7);
                    Item.Position[ItemIndex].X = Player.Position[Index_].X + randomplace;
                    Item.Position[ItemIndex].Z = Player.Position[Index_].Z;
                    Item.Position[ItemIndex].Y = Player.Position[Index_].Y + randomplace;
                    Item.General[ItemIndex].DroppedByUniqueId = Player.General[Index_].UniqueID;
                    Item.ItemAmount++;

                    writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ITEM_MOVEMENT);
                    writer.AppendByte(1);
                    writer.AppendByte(tmpPtr->Type);
                    writer.AppendByte(tmpPtr->Source);
                    ServerSocket.Send(writer.getWorkspace(), Index_);

                    Silkroad.Item_ tmpItem = Silkroad.GetItemById(DatabaseCore.Item.ItemId[CharacterItemIndex[tmpPtr->Source]]);

                    byte[] tmpBuffer = new byte[0];
                    if (tmpItem.ITEM_TYPE_NAME.Contains("CH") || tmpItem.ITEM_TYPE_NAME.Contains("EU"))
                    {
                        writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_SPAWN);
                        writer.AppendDword(DatabaseCore.Item.ItemId[CharacterItemIndex[tmpPtr->Source]]);
                        writer.AppendByte(DatabaseCore.Item.PlusValue[CharacterItemIndex[tmpPtr->Source]]);
                        writer.AppendDword(Item.General[ItemIndex].UniqueID);
                        writer.AppendByte(Item.Position[ItemIndex].XSector);
                        writer.AppendByte(Item.Position[ItemIndex].YSector);
                        writer.AppendFloat(Item.Position[ItemIndex].X);
                        writer.AppendFloat(Item.Position[ItemIndex].X);
                        writer.AppendFloat(Item.Position[ItemIndex].Y);
                        writer.AppendWord(0xAAA6);
                        writer.AppendByte(0);
                        writer.AppendByte(0);
                        writer.AppendByte(6);
                        writer.AppendDword(Item.General[ItemIndex].DroppedByUniqueId);
                        tmpBuffer = writer.getWorkspace();
                    }
                    else if (tmpItem.ITEM_TYPE_NAME.Contains("ETC"))
                    {
                        writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_SPAWN);
                        writer.AppendDword(DatabaseCore.Item.ItemId[CharacterItemIndex[tmpPtr->Source]]);
                        writer.AppendDword(Item.General[ItemIndex].UniqueID);
                        writer.AppendByte(Item.Position[ItemIndex].XSector);
                        writer.AppendByte(Item.Position[ItemIndex].YSector);
                        writer.AppendFloat(Item.Position[ItemIndex].X);
                        writer.AppendFloat(Item.Position[ItemIndex].X);
                        writer.AppendFloat(Item.Position[ItemIndex].Y);
                        writer.AppendWord(0xAAA6);
                        writer.AppendByte(0);
                        writer.AppendByte(0);
                        writer.AppendByte(6);
                        writer.AppendDword(Item.General[ItemIndex].DroppedByUniqueId);
                        tmpBuffer = writer.getWorkspace();
                    }

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

                    DatabaseCore.WriteQuery("UPDATE items SET itemid='0',plusvalue='0' ,durability='30' WHERE itemnumber='item{0}' AND owner='{1}'", tmpPtr->Source, Player.General[Index_].CharacterName);
                    Stats.OnStatPacket(Index_);

                    DeleteFromDatabase(CharacterItemIndex[tmpPtr->Source]);

                    break;
                case 10:
                    if (Player.Stats[Index_].Gold != 0)
                    {
                        PacketReader reader = new PacketReader(ptr, 5);
                        reader.ModifyIndex(1);
                        uint goldamount = reader.ReadDword();

                        ItemIndex = Item.ItemAmount;
                        if (goldamount < 10000)
                            Item.General[ItemIndex].Pk2ID = 1;
                        else if (goldamount >= 10000 && goldamount <= 500000)
                            Item.General[ItemIndex].Pk2ID = 2;
                        else if (goldamount >= 500001)
                            Item.General[ItemIndex].Pk2ID = 3;

                        Item.General[ItemIndex].UniqueID = (uint)random.Next(76000000, 79999999);
                        Item.General[ItemIndex].Plus = 0;
                        Item.General[ItemIndex].Durability = 0;
                        Item.General[ItemIndex].Pickable = true;
                        Item.General[ItemIndex].Quantity = goldamount;
                        Item.Position[ItemIndex].XSector = Player.Position[Index_].XSector;
                        Item.Position[ItemIndex].YSector = Player.Position[Index_].YSector;
                        randomplace = (byte)random.Next(1, 7);
                        Item.Position[ItemIndex].X = Player.Position[Index_].X + randomplace;
                        Item.Position[ItemIndex].Z = Player.Position[Index_].Z;
                        Item.Position[ItemIndex].Y = Player.Position[Index_].Y + randomplace;
                        Item.General[ItemIndex].DroppedByUniqueId = Player.General[Index_].UniqueID;
                        Item.ItemAmount++;

                        writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_SPAWN);
                        if (goldamount < 10000)
                            writer.AppendDword(1);
                        else if (goldamount >= 10000 && goldamount <= 500000)
                            writer.AppendDword(2);
                        else if (goldamount >= 500001)
                            writer.AppendDword(3);
                        writer.AppendDword(goldamount);
                        writer.AppendDword(Item.General[ItemIndex].UniqueID);
                        writer.AppendByte(Item.Position[ItemIndex].XSector);
                        writer.AppendByte(Item.Position[ItemIndex].YSector);
                        writer.AppendFloat(Item.Position[ItemIndex].X);
                        writer.AppendFloat(Item.Position[ItemIndex].X);
                        writer.AppendFloat(Item.Position[ItemIndex].Y);
                        writer.AppendWord(0xDC72);
                        writer.AppendByte(0);
                        writer.AppendByte(0);
                        writer.AppendByte(6);
                        writer.AppendDword(0);

                        tmpBuffer = writer.getWorkspace();

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

                        Player.Stats[Index_].Gold -= goldamount;
                        writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_NEW_GOLD_AMOUNT);
                        writer.AppendByte(1);
                        writer.AppendLword(Player.Stats[Index_].Gold);
                        writer.AppendByte(0);
                        ServerSocket.Send(writer.getWorkspace(), Index_);

                        writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ITEM_MOVEMENT);
                        writer.AppendByte(1);
                        writer.AppendByte(10);
                        writer.AppendDword(goldamount);
                        ServerSocket.Send(writer.getWorkspace(), Index_);

                        DatabaseCore.WriteQuery("UPDATE characters SET gold='{0}' WHERE name='{1}'", Player.Stats[Index_].Gold, Player.General[Index_].CharacterName);

                    }
                    break;
            }
        }
예제 #35
0
 public static void CreateDeSpawnPacket(ref PacketWriter writer, uint monsterid)
 {
     writer.AppendDword(monsterid);
 }
예제 #36
0
파일: Items.cs 프로젝트: CarlosX/DarkEmu
        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_);
                }
            }
        }
예제 #37
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Inventory item movement
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public static byte[] MoveItem(byte type, byte fromSlot, byte toSlot, short quantity, long gold, string action)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_ITEM_MOVE);
            switch (action)
            {
            case "MOVE_INSIDE_INVENTORY":
                Writer.Byte(1);
                Writer.Byte(type);
                Writer.Byte(fromSlot);
                Writer.Byte(toSlot);
                Writer.Word(quantity);
                Writer.Byte(0);
                break;

            case "MOVE_INSIDE_STORAGE":
                Writer.Bool(true);
                Writer.Byte(1);
                Writer.Byte(fromSlot);
                Writer.Byte(toSlot);
                Writer.Word(quantity);
                break;

            case "MOVE_INSIDE_GUILD_STORAGE":
                Writer.Byte(1);
                Writer.Byte(0x1D);        //Type
                Writer.Byte(fromSlot);
                Writer.Byte(toSlot);
                Writer.Word(quantity);
                break;

            case "MOVE_TO_STORAGE":
                Writer.Byte(1);
                Writer.Byte(2);
                Writer.Byte(fromSlot);
                Writer.Byte(toSlot);
                break;

            case "MOVE_TO_GUILD_STORAGE":
                Writer.Byte(1);
                Writer.Byte(0x1E);
                Writer.Byte(fromSlot);
                Writer.Byte(toSlot);
                break;

            case "MOVE_FROM_STORAGE":
                Writer.Byte(1);
                Writer.Byte(3);
                Writer.Byte(fromSlot);
                Writer.Byte(toSlot);
                break;

            case "MOVE_FROM_GUILD_STORAGE":
                Writer.Byte(1);
                Writer.Byte(0x1F);
                Writer.Byte(fromSlot);
                Writer.Byte(toSlot);
                break;

            case "MOVE_WAREHOUSE_GOLD":
                Writer.Bool(true);
                Writer.Byte(type);
                Writer.LWord(gold);
                break;

            case "MOVE_GENDER_CHANGE":
                Writer.Byte(1);
                Writer.Byte(fromSlot);
                Writer.Byte(0x13);
                Writer.Byte(2);
                break;

            case "DELETE_ITEM":
                Writer.Byte(1);
                Writer.Byte(type);
                Writer.Byte(fromSlot);
                if (type == 0x0F)
                {
                    Writer.Byte(4);
                }
                break;

            case "DELETE_GOLD":
                Writer.Byte(1);
                Writer.Byte(type);
                Writer.LWord(gold);
                break;
            }
            return(Writer.GetBytes());
        }
예제 #38
0
파일: Items.cs 프로젝트: CarlosX/DarkEmu
        private static byte UnEnquipWeapon(int Index_, int[] CharacterItemIndex, int CharacterItemSourceIndex)
        {
            Silkroad.Item_ SourceItem = Silkroad.GetItemById(DatabaseCore.Item.ItemId[CharacterItemSourceIndex]);

            if (DatabaseCore.Item.ItemId[CharacterItemSourceIndex] != 0 && SourceItem.CLASS_C != 2 && SourceItem.CLASS_C != 3)
            {
                Player.Stats[Index_].MinPhy -= (ushort)SourceItem.MIN_LPHYATK;
                Player.Stats[Index_].MaxPhy -= (ushort)SourceItem.MIN_HPHYATK;
                Player.Stats[Index_].MinMag -= (ushort)SourceItem.MIN_LMAGATK;
                Player.Stats[Index_].MaxMag -= (ushort)SourceItem.MIN_HMAGATK;
                Player.General[Index_].WeaponType = 0;

                byte freeslot = FreeSlot(CharacterItemIndex);

                PacketWriter writer = new PacketWriter();

                writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ITEM_UNEQUIP);
                writer.AppendDword(Player.General[Index_].UniqueID);
                writer.AppendByte(6);
                writer.AppendDword(DatabaseCore.Item.ItemId[CharacterItemSourceIndex]);

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

                writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ITEM_MOVEMENT);
                writer.AppendByte(1);
                writer.AppendByte(0);
                writer.AppendByte(6);
                writer.AppendByte(freeslot);
                writer.AppendWord(1);
                writer.AppendByte(0);
                ServerSocket.Send(writer.getWorkspace(), Index_);

                return freeslot;
            }
            return 255;
        }
예제 #39
0
        private static void OnCharnameCheck(PacketReader reader, int Index_)
        {
            PacketWriter writer = new PacketWriter();

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

            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_CHARACTER);
            writer.AppendByte(0x04);
            if (DatabaseCore.Character.GetIndexByName(name) < 1)
                writer.AppendByte(0x01);
            else
            {
                writer.AppendByte(0x02);
                writer.AppendByte(0x10);
            }
            ServerSocket.Send(writer.getWorkspace(), Index_);
        }
예제 #40
0
파일: Items.cs 프로젝트: CarlosX/DarkEmu
        public static byte[] CreateSpawnPacket(Item._General general,_Position pos)
        {
            PacketWriter writer = new PacketWriter();
            Silkroad.Item_ tmpItem = Silkroad.GetItemById(general.Pk2ID);
            if (tmpItem.ITEM_TYPE_NAME.Contains("CH") || tmpItem.ITEM_TYPE_NAME.Contains("EU"))
            {
                writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_SPAWN);
                writer.AppendDword(general.Pk2ID);
                writer.AppendByte(general.Plus);
                writer.AppendDword(general.UniqueID);
                writer.AppendByte(pos.XSector);
                writer.AppendByte(pos.YSector);
                writer.AppendFloat(pos.X);
                writer.AppendFloat(pos.X);
                writer.AppendFloat(pos.Y);
                writer.AppendWord(0xAAA6);
                writer.AppendByte(0);
                writer.AppendByte(0);
                writer.AppendByte(6);
                writer.AppendDword(general.DroppedByUniqueId);

            }
            else if (tmpItem.ITEM_TYPE_NAME.Contains("ETC"))
            {
                writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_SPAWN);
                writer.AppendDword(general.Pk2ID);
                if (general.Pk2ID == 1 || general.Pk2ID == 2 || general.Pk2ID == 3)
                    writer.AppendDword(general.Quantity);
                writer.AppendDword(general.UniqueID);
                writer.AppendByte(pos.XSector);
                writer.AppendByte(pos.YSector);
                writer.AppendFloat(pos.X);
                writer.AppendFloat(pos.X);
                writer.AppendFloat(pos.Y);
                writer.AppendWord(0xAAA6);
                writer.AppendByte(0);
                writer.AppendByte(0);
                writer.AppendByte(6);
                writer.AppendDword(general.DroppedByUniqueId);

            }
            return writer.getWorkspace();
        }
예제 #41
0
        public static void AddItemPacket(PacketWriter Writer, byte slot, int id, byte plus, short amount, int durability, int itemid, int bluecount, int modelid)
        {
            try
            {
                //Blues pre loading
                #region Load blues for items
                Systems.LoadBluesid(itemid);
                #endregion
                //Static information for packet
                #region Static packet info
                if (slot != 255)
                {
                    Writer.Byte(slot);              // slot
                }
                Writer.DWord(0);                    // sttaic 0
                Writer.DWord(id);                   // Item ID
                #endregion
                //Armor types and jewerly
                #region Armor related
                if (Data.ItemBase[id].Type == Global.item_database.ArmorType.ARMOR ||
                    Data.ItemBase[id].Type == Global.item_database.ArmorType.GARMENT ||
                    Data.ItemBase[id].Type == Global.item_database.ArmorType.GM ||
                    Data.ItemBase[id].Type == Global.item_database.ArmorType.HEAVY ||
                    Data.ItemBase[id].Type == Global.item_database.ArmorType.LIGHT ||
                    Data.ItemBase[id].Type == Global.item_database.ArmorType.PROTECTOR ||
                    Data.ItemBase[id].Type == Global.item_database.ArmorType.ROBE ||
                    Data.ItemBase[id].Itemtype == Global.item_database.ItemType.EARRING ||
                    Data.ItemBase[id].Itemtype == Global.item_database.ItemType.RING ||
                    Data.ItemBase[id].Itemtype == Global.item_database.ItemType.NECKLACE)
                {
                    Writer.Byte(plus);
                    Writer.Byte(0);                 //Durability + %
                    Writer.Byte(0);                 //Item Phy/Mag reinforce value %
                    Writer.Byte(0);                 //Physical defense power %
                    Writer.Byte(0);                 //Magical defense power %
                    Writer.Byte(0);                 //Static byte ?
                    Writer.Byte(0);                 //Static byte ?
                    Writer.Byte(0);                 //Static byte ?
                    Writer.Byte(0);                 //Static byte ?
                    Writer.DWord(durability);       //Durability

                    if (bluecount != 0)
                    {
                        Writer.Byte(Convert.ToByte(Data.ItemBlue[itemid].totalblue));
                        for (int i = 0; i <= Data.ItemBlue[itemid].totalblue - 1; i++)
                        {
                            Writer.DWord(Data.MagicOptions.Find(mg => (mg.Name == Convert.ToString(Data.ItemBlue[itemid].blue[i]))).ID);
                            Writer.DWord(Data.ItemBlue[itemid].blueamount[i]);
                        }
                    }
                    else
                    {
                        Writer.Byte(0);
                    }

                    Writer.Byte(1);
                    Writer.Byte(0);
                    Writer.Byte(2);
                    Writer.Byte(0);
                    Writer.Byte(3);
                    Writer.Byte(0);
                    return;
                }
                #endregion
                //Weaponry (Weapons).
                #region Weapons
                else if (Data.ItemBase[id].Itemtype == Global.item_database.ItemType.BLADE ||
                         Data.ItemBase[id].Itemtype == Global.item_database.ItemType.BOW ||
                         Data.ItemBase[id].Itemtype == Global.item_database.ItemType.EU_AXE ||
                         Data.ItemBase[id].Itemtype == Global.item_database.ItemType.EU_CROSSBOW ||
                         Data.ItemBase[id].Itemtype == Global.item_database.ItemType.EU_DAGGER ||
                         Data.ItemBase[id].Itemtype == Global.item_database.ItemType.EU_DARKSTAFF ||
                         Data.ItemBase[id].Itemtype == Global.item_database.ItemType.EU_HARP ||
                         Data.ItemBase[id].Itemtype == Global.item_database.ItemType.EU_STAFF ||
                         Data.ItemBase[id].Itemtype == Global.item_database.ItemType.EU_SWORD ||
                         Data.ItemBase[id].Itemtype == Global.item_database.ItemType.EU_TSTAFF ||
                         Data.ItemBase[id].Itemtype == Global.item_database.ItemType.EU_TSWORD ||
                         Data.ItemBase[id].Itemtype == Global.item_database.ItemType.GLAVIE ||
                         Data.ItemBase[id].Itemtype == Global.item_database.ItemType.SPEAR ||
                         Data.ItemBase[id].Itemtype == Global.item_database.ItemType.SWORD)
                {
                    Writer.Byte(plus);              //Item Plus Value
                    Writer.Byte(0x64);              //Durability + %
                    Writer.Byte(0);                 //Item Phy/Mag reinforce value %
                    Writer.Byte(0);                 //Attack rating / blocking ratio
                    Writer.Byte(0);                 //Magical defense power %
                    Writer.Byte(0);
                    Writer.Byte(0);
                    Writer.Byte(0);
                    Writer.Byte(0);
                    Writer.DWord(durability);

                    if (bluecount != 0)
                    {
                        Writer.Byte(Convert.ToByte(Data.ItemBlue[itemid].totalblue));
                        for (int i = 0; i <= Data.ItemBlue[itemid].totalblue - 1; i++)
                        {
                            Writer.DWord(Data.MagicOptions.Find(mg => (mg.Name == Convert.ToString(Data.ItemBlue[itemid].blue[i]))).ID);
                            Writer.DWord(Data.ItemBlue[itemid].blueamount[i]);
                        }
                    }

                    else
                    {
                        Writer.Byte(0);
                    }
                    Writer.Byte(1);
                    Writer.Byte(0);
                    Writer.Byte(2);
                    Writer.Byte(0);
                    Writer.Byte(3);
                    Writer.Byte(0);
                    return;
                }
                #endregion
                //Shields
                #region Shields
                else if (Data.ItemBase[id].Itemtype == Global.item_database.ItemType.CH_SHIELD ||
                         Data.ItemBase[id].Itemtype == Global.item_database.ItemType.EU_SHIELD)
                {
                    Writer.Byte(plus);              //Item Plus Value
                    Writer.Byte(0);                 //Durability + %
                    Writer.Byte(0);                 //Item Phy/Mag reinforce value %
                    Writer.Byte(9);                 //blocking ratio
                    Writer.Byte(0);                 //Magical defense power %
                    Writer.Byte(0);
                    Writer.Byte(0);
                    Writer.Byte(0);
                    Writer.Byte(0);
                    Writer.DWord(durability);       //Durability

                    if (bluecount != 0)
                    {
                        Writer.Byte(Convert.ToByte(Data.ItemBlue[itemid].totalblue));
                        for (int i = 0; i <= Data.ItemBlue[itemid].totalblue - 1; i++)
                        {
                            Writer.DWord(Data.MagicOptions.Find(mg => (mg.Name == Convert.ToString(Data.ItemBlue[itemid].blue[i]))).ID);
                            Writer.DWord(Data.ItemBlue[itemid].blueamount[i]);
                        }
                    }

                    else
                    {
                        Writer.Byte(0);
                    }
                    Writer.Byte(1);
                    Writer.Byte(0);
                    Writer.Byte(2);
                    Writer.Byte(0);
                    Writer.Byte(3);
                    Writer.Byte(0);
                    return;
                }
                #endregion
                //Avatars
                #region Avatars
                else if (Data.ItemBase[id].Type == Global.item_database.ArmorType.AVATAR ||
                         Data.ItemBase[id].Type == Global.item_database.ArmorType.AVATARATTACH ||
                         Data.ItemBase[id].Type == Global.item_database.ArmorType.AVATARHAT)
                {
                    Writer.Byte(plus);              //Item Plus Value
                    Writer.Byte(0);                 //Item Magical Reinforce value
                    Writer.Byte(0);                 //Item Phy reinforce value
                    Writer.Byte(0);
                    Writer.Byte(0);
                    Writer.Word(0);
                    Writer.Word(0);
                    Writer.DWord(durability);       //Item Durability
                    Writer.Byte(0);
                    Writer.Word(1);
                    Writer.Word(2);
                    Writer.Word(3);
                    return;
                }
                #endregion
                //Grabpets
                #region Grabpets
                else if (Data.ItemBase[id].Pettype == Global.item_database.PetType.GRABPET)
                {
                    Writer.Byte(0);           // State :0 = Not opened yet, 1 =  , 3 = Expired
                    Writer.DWord(0x00002432); //Time date probably
                    Writer.Word(0);
                    Writer.DWord(1);
                    Writer.Byte(0);
                    return;
                }
                #endregion
                //Attack pets
                #region Attackpets
                else if (Data.ItemBase[id].Pettype == Global.item_database.PetType.ATTACKPET)
                {
                    Writer.Byte(0);             //
                    Writer.Byte(2);             //
                    Writer.Byte(24);            // Level
                    Writer.Word(0);             //
                    Writer.Word(0);             //Petname
                    Writer.Byte(0);
                    return;
                }
                #endregion
                //Normal stones
                #region Stones
                else if (Data.ItemBase[id].Etctype == Global.item_database.EtcType.STONES)
                {
                    Writer.Word(amount);
                    Writer.Byte(0);//Assumability %
                    return;
                }
                #endregion
                //Monster masks
                #region Monster masks
                else if (Data.ItemBase[id].Etctype == Global.item_database.EtcType.MONSTERMASK)
                {
                    Writer.DWord(modelid);
                    return;
                }
                #endregion
                //Stall decoration
                #region  Stall decoration
                else if (Data.ItemBase[id].Etctype == Global.item_database.EtcType.STALLDECORATION)
                {
                    Writer.Byte(0);
                    Writer.Word(1);
                    return;
                }
                #endregion
                //Elixirs
                #region Elixirs
                else if (Data.ItemBase[id].Etctype == Global.item_database.EtcType.ELIXIR)
                {
                    Writer.Word(1);
                    return;
                }
                #endregion
                //Other items (To filter later).
                #region Other items
                //Need to add more and add more on fileload
                else if (Data.ItemBase[id].Itemtype == Global.item_database.ItemType.ARROW ||
                         Data.ItemBase[id].Itemtype == Global.item_database.ItemType.BOLT ||
                         Data.ItemBase[id].Etctype == Global.item_database.EtcType.HP_POTION ||
                         Data.ItemBase[id].Etctype == Global.item_database.EtcType.MP_POTION ||
                         Data.ItemBase[id].Etctype == Global.item_database.EtcType.VIGOR_POTION ||
                         Data.ItemBase[id].Etctype == Global.item_database.EtcType.SPEED_POTION ||
                         Data.ItemBase[id].Ticket == Global.item_database.Tickets.BEGINNER_HELPERS ||
                         Data.ItemBase[id].Etctype == Global.item_database.EtcType.ELIXIR ||
                         Data.ItemBase[id].Etctype == Global.item_database.EtcType.ALCHEMY_MATERIAL ||
                         Data.ItemBase[id].Etctype == Global.item_database.EtcType.EVENT ||
                         Data.ItemBase[id].Class_D == 3)
                {
                    Writer.Word(amount);
                    return;
                }
                else
                {
                    Writer.Byte(0);
                    Writer.Word(1);
                    return;
                }
                #endregion
            }
            catch (Exception ex)
            {
                Console.WriteLine("Load item error: {0}", ex);
            }
        }