Byte() public method

public Byte ( ) : byte
return byte
示例#1
0
 void RenameParty()
 {
     try
     {
         //Create new packet reader
         PacketReader reader = new PacketReader(PacketInformation.buffer);
         //First integer is party id
         int partyid = reader.Int32();
         //Second integer is not needed
         int NotNeeded = reader.Int32();
         //Byte party type
         byte ptype = reader.Byte();
         //Byte party purpose
         byte purpose = reader.Byte();
         //Byte minimum level
         byte minlevel = reader.Byte();
         //Byte max level to enter party
         byte maxlevel = reader.Byte();
         //Party name lenght
         short namel = reader.Int16();
         //Party name each character is a word value using text3
         string pname = reader.Text3();
         //Create new packet writer
         PacketWriter Writer = new PacketWriter();
         //Add opcode to server packet
         Writer.Create(Systems.SERVER_PARTY_CHANGENAME);
         //Write static byte 1
         Writer.Byte(1);
         //Write party id
         Writer.DWord(partyid);
         //Write dword 0
         Writer.DWord(0);
         //Write party type
         Writer.Byte(ptype);
         //Write party purpose
         Writer.Byte(purpose);
         //Write party minimum level
         Writer.Byte(minlevel);
         //Write party max level
         Writer.Byte(maxlevel);
         //Write party name
         Writer.Text3(pname);
         //Send bytes to client
         client.Send(Writer.GetBytes());
     }
     //If a error happens
     catch (Exception ex)
     {
         //Write the exception to the log
         Systems.Debugger.Write(ex);
     }
 }
示例#2
0
文件: Npcs.cs 项目: CarlosX/DarkEmu
        /////////////////////////////////////////////////////////////////////////////////
        // Open Npc
        /////////////////////////////////////////////////////////////////////////////////
        protected void Open_NPC()
        {
            #region Open Npc
            try
            {
                Character.State.Busy = true;
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                Reader.UInt32();
                byte type = Reader.Byte();

                if (type == 1)
                {
                    client.Send(Packet.OpenNPC(type));
                }
                else
                {
                    client.Send(Packet.OpenNPC(type));
                }
                Reader.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            #endregion
        }
示例#3
0
 public void Connect()
 {
     //Wrap our function inside a catcher
     try
     {
         //Open our packet reader
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         byte type = Reader.Byte();
         Reader.Skip(3);
         string ID = Reader.Text();
         string PW = Reader.Text();
         Reader.Close();
         //Set login result information
         int LoginResult = LoginUser(ID, ref PW, ref Player, true);
         //If the login is succesfull
         if (LoginResult == 0)
         {
             //Send succes packet
             client.Send(Packet.ConnectSuccess());
         }
         //If the login is wrong
         else
         {
             //Disconnect the user
             client.Disconnect(PacketInformation.Client);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Client connect error {0}", ex);
         Systems.Debugger.Write(ex);
     }
 }
示例#4
0
文件: Jobs.cs 项目: CarlosX/DarkEmu
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // Create Job Alias
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 public void MakeAlias()
 {
     try
     {
         ///////////////////////////////////////////////////////////////////////////////////////////////////
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         int id = Reader.Int32();
         byte type = Reader.Byte();
         short nLenght = Reader.Int16();
         string name = Reader.String(nLenght);
         ///////////////////////////////////////////////////////////////////////////////////////////////////
         Console.WriteLine(name);
         MsSQL ms = new MsSQL("SELECT * FROM character_jobs WHERE job_alias='" + name + "'");
         int checkjob = ms.Count();
         ///////////////////////////////////////////////////////////////////////////////////////////////////
         client.Send(Packet.MakeAlias(name, type));
         if (checkjob == 0)
         {
             client.Send(Packet.MakeAlias(name, type));
             MsSQL.UpdateData("UPDATE character_jobs SET job_alias='" + name + "' WHERE character_name='" + Character.Information.Name + "'");
         }
         else if (checkjob >= 0)
         {
             client.Send(Packet.MakeAliasError(name, type));
         }
     }
     catch (Exception ex)
     {
         Systems.Debugger.Write(ex);
     }
 }
示例#5
0
        /////////////////////////////////////////////////////////////////////////////////
        // Friend add response
        /////////////////////////////////////////////////////////////////////////////////
        void FriendAddResponse()
        {
            try
            {
                PacketReader reader = new PacketReader(PacketInformation.buffer);
                int Inviterid = reader.Int32();
                int Myid = reader.Int32();
                byte State = reader.Byte();
                reader.Close();

                Systems sys = GetPlayer(Inviterid);
                if (sys != null)
                {
                    if (State == 0)
                    {
                        //Declined
                        client.Send(Packet.FriendDecline(Character.Information.Name));
                        sys.client.Send(Packet.FriendDecline(Character.Information.Name));
                    }
                    else
                    {
                        //Accepted
                        sys.client.Send(Packet.FriendData(Myid, 2, Character.Information.Name, Character, false));
                        client.Send(Packet.FriendData(Inviterid, 2, sys.Character.Information.Name, sys.Character, false));
                        MsSQL.InsertData("INSERT INTO friends (owner,friend_name,model_info) VALUES ('" + Character.Information.CharacterID + "','" + sys.Character.Information.CharacterID + "','" + sys.Character.Information.Model + "')");
                        MsSQL.InsertData("INSERT INTO friends (owner,friend_name,model_info) VALUES ('" + sys.Character.Information.CharacterID + "','" + Character.Information.CharacterID + "','" + Character.Information.Model + "')");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Friend Add Response Error {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
示例#6
0
文件: Stall.cs 项目: CarlosX/DarkEmu
        public void StallBuy()
        {
            try
            {
                if (!Character.Network.Stall.isOpened) return;
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                byte stallslot = Reader.Byte();

                stall currentStall = Character.Network.Stall;
                stall.stallItem sitem = currentStall.ItemList.Find(i => (i.stallSlot == stallslot));

                // stall buyer update
                byte slot = GetFreeSlot();
                if (slot <= 12) return;
                if (Character.Information.Gold >= (long)sitem.price)
                {
                    Character.Information.Gold -= (long)sitem.price;
                    client.Send(Packet.UpdateGold(Character.Information.Gold));
                    SaveGold();
                }
                else return; //insufficent gold

                // staller update
                if (currentStall.ItemList.Contains(sitem))
                {
                    Systems staller = GetPlayer(currentStall.ownerID);
                    staller.Character.Information.Gold += (long)sitem.price;
                    staller.client.Send(Packet.UpdateGold(staller.Character.Information.Gold));

                    MsSQL.UpdateData("update character set gold='" + staller.Character.Information.Gold + "' where id='" + staller.Character.Information.CharacterID + "'");
                    //MsSQL.UpdateData("delete from char_items where itemnumber='item" + sitem.Item.Slot + "' AND owner='" + staller.Character.Information.CharacterID + "'");
                    Systems.MsSQL.InsertData("UPDATE char_items SET owner='" + Character.Information.CharacterID + "',slot='" + slot + "',itemnumber='item" + slot + "' WHERE owner='" + staller.Character.Information.CharacterID + "' AND itemid='" + sitem.Item.ID + "' AND id='" + sitem.Item.dbID + "' AND storagetype='0'");
                    //take item out from stall
                    if (currentStall.ItemList.Count == 1)
                    {
                        staller.Character.Stall.Stallactive = false;
                        Character.Stall.Stallactive = false;
                    }
                    currentStall.ItemList.Remove(sitem);
                    client.Send(Packet.StallBuyItem(stallslot, 1));
                    currentStall.Send(Packet.StallBuyItem2(Character.Information.Name, stallslot, currentStall.ItemList));
                }
                else
                {
                    Disconnect("ban");
                    Console.WriteLine("Autobanned user: "******" Due to hacking");
                }
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
示例#7
0
 public void CharacterScreen()
 {
     //Wrap our function inside a catcher
     try
     {
         //Open our packet reader
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         byte type = Reader.Byte();
         //Switch on byte type
         switch (type)
         {
             case 1:
                 //Character creation
                 CharacterCreate();
                 break;
             case 2:
                 //Character listening
                 client.Send(CharacterListing(Player));
                 break;
             case 3:
                 //Character deletion
                 CharacterDelete();
                 break;
             case 4:
                 //Character checking
                 CharacterCheck(PacketInformation.buffer);
                 break;
             case 5:
                 //Character restoring
                 CharacterRestore();
                 break;
             case 9:
                 //Character job information
                 CharacterJobInfo();
                 break;
             case 16:
                 //Select job
                 CharacterJobPick(PacketInformation.buffer);
                 break;
             default:
                 //We use this if we get a new case.
                 Console.WriteLine("Character Screen Type: " + type);
                 break;
         }
         //Close packet reader
         Reader.Close();
     }
     catch (Exception ex)
     {
         Console.WriteLine("Characterscreen switch error {0}", ex);
         Systems.Debugger.Write(ex);
     }
 }
示例#8
0
 void CharacterJobPick(byte[] buff)
 {
     //Wrap our function inside a catcher
     try
     {
         //Create new packet reader
         PacketReader Reader = new PacketReader(buff);
         //Skip first byte not used
         Reader.Skip(1);
         //Read name lenght
         short CharacterNameLEN = Reader.Int16();
         //Read character name
         string CharacterName = Reader.String(CharacterNameLEN);
         //Read job selection
         byte job = Reader.Byte();
         //Close packet reader
         Reader.Close();
         //Get row count from character to check if the current account and character match
         int NameCheck = MsSQL.GetRowsCount("SELECT * FROM character WHERE account='" + Player.AccountName + "'");
         //Get job information from database as integer
         int jobcheck = MsSQL.GetDataInt("SELECT jobtype FROM users WHERE id='" + Player.AccountName + "'", "jobtype");
         //If the name check is succesfull and account has no job set.
         if (jobcheck == 0 && NameCheck != 0)
         {
             //Write new job information to the database
             MsSQL.UpdateData("UPDATE users SET jobtype='" + job + "' WHERE id='" + Player.AccountName + "'");
         }
         //Send visual confirmation in packet
         PacketWriter writer = new PacketWriter();
         //Add opcode
         writer.Create(Systems.SERVER_CHARACTERSCREEN);
         //Write static byte 10
         writer.Byte(0x10);
         //Write succes byte 1
         writer.Byte(1);
         //Send bytes to client
         client.Send(writer.GetBytes());
     }
     //Catch any bad exception error
     catch (Exception ex)
     {
         //Write error information to the console
         Console.WriteLine("Job selection error {0}", ex);
         //Write error to debug log file
         Systems.Debugger.Write(ex);
     }
 }
示例#9
0
        void HandleRegisterIcon()
        {
            try
            {
                PacketReader reader = new PacketReader(PacketInformation.buffer);
                byte type = reader.Byte();
                int iconlenght = reader.Int32();
                string icon = reader.Text();
                reader.Close();

                string convertedicon = ConvertToHex(icon);
                //Save output to .dat file in hex formatting.
            }
            catch (Exception ex)
            {
                Console.WriteLine("Guild icon register error {0}", ex);
            }
        }
示例#10
0
        public void CharacterCheck(byte[] buff)
        {
            try
            {
                PacketReader Reader = new PacketReader(buff);
                Reader.Byte();

                string name = Reader.Text();
                Reader.Close();
                if (CharacterCheck(name))
                    client.Send(Packet.CharacterName(4));
                else client.Send(Packet.ScreenSuccess(4));
            }
            catch (Exception ex)
            {
                Console.WriteLine("CharacterCheck()");
                deBug.Write(ex);
                Console.WriteLine(ex);
            }
        }
示例#11
0
 public static void PlayerQuickBar(PacketReader Reader, PacketWriter Writer)
 {
     byte amm = 0;
     int[] skillid = new int[51];
     byte[] slotn = new byte[51];
     for (byte i = 0; i <= 50; i++)
     {
         slotn[i] = Reader.Byte();
         if (slotn[i] != 0)
         {
             skillid[i] = Reader.Int32();
             amm++;
         }
         else Reader.Skip(4);
     }
     Writer.Byte(amm);
     for (byte i = 0; i <= 50; i++)
     {
         if (slotn[i] != 0)
         {
             Writer.Byte(i);
             Writer.Byte(slotn[i]);
             Writer.DWord(skillid[i]);
         }
     }
     Reader.Close();
 }
示例#12
0
        void CharacterRequest()
        {
            try
            {
                //Open packet reader
                PacketReader Reader = new PacketReader(PacketInformation.buffer);

                //Get targeted player information
                Systems sys = GetPlayer(Character.Network.TargetID);

                if (this.Character.State.UnionApply && sys.Character.State.UnionApply)
                {
                    if (Reader.Byte() == 1 && Reader.Byte() == 0)
                    {
                        //Need to sniff decline packet info
                        Character.State.UnionApply = false;
                        sys.Character.State.UnionApply = false;
                    }
                    else
                    {
                        //Check for null and set unique id for union and insert our own guild.
                        if (sys.Character.Network.Guild.Unions == null)
                        {
                            int uniqueid = MsSQL.GetRowsCount("SELECT * FROM guild_unions");
                            sys.Character.Network.Guild.UniqueUnion = uniqueid + 1;
                            MsSQL.InsertData("INSERT INTO guild_unions (union_leader, union_guildid, union_unique_id) VALUES ('" + sys.Character.Network.Guild.Guildid + "','" + sys.Character.Network.Guild.Guildid + "','" + sys.Character.Network.Guild.UniqueUnion + "')");
                        }
                        //Update database
                        MsSQL.InsertData("INSERT INTO guild_unions (union_leader, union_guildid, union_unique_id) VALUES ('" + sys.Character.Network.Guild.Guildid + "','" + Character.Network.Guild.Guildid + "','" + sys.Character.Network.Guild.UniqueUnion + "')");

                        //Send union packet to newly joined player
                        client.Send(Packet.UnionInfo(this));

                        //Send update packet to all guilds in union
                        foreach (int member in Character.Network.Guild.Members)
                        {
                            //Make sure the member is there
                            if (member != 0)
                            {
                                //If the user is not the newly invited member get player info
                                Systems tomember = GetPlayerMainid(member);
                                //Send guild update packet
                                if (tomember != null)
                                {
                                    if (!tomember.Character.Network.Guild.SingleSend)
                                    {
                                        if (Character.Information.CharacterID != tomember.Character.Information.CharacterID)
                                        {
                                            tomember.Character.Network.Guild.SingleSend = true;
                                            tomember.client.Send(Packet.GuildUpdate(Character, 14, 0, 0, 0));
                                        }
                                    }
                                }
                            }
                        }
                        foreach (int member in Character.Network.Guild.UnionMembers)
                        {
                            //Make sure the member is there
                            if (member != 0)
                            {
                                //If the user is not the newly invited member get player info
                                Systems tomember = GetPlayerMainid(member);
                                //Send guild update packet
                                if (tomember != null)
                                {
                                    if (!tomember.Character.Network.Guild.SingleSend)
                                    {
                                        tomember.Character.Network.Guild.SingleSend = true;
                                        tomember.client.Send(Packet.GuildUpdate(Character, 14, 0, 0, 0));
                                    }
                                }
                            }
                        }
                        //Disable the bool again
                        foreach (int member in Character.Network.Guild.Members)
                        {
                            //Make sure member isnt null
                            if (member != 0)
                            {
                                //Get guildmember details
                                Systems guildmember = GetPlayerMainid(member);
                                //Make sure guildmember isnt null
                                if (guildmember != null)
                                {
                                    //Disable bool to allow resend new packets.
                                    guildmember.Character.Network.Guild.SingleSend = false;
                                }
                            }
                        }
                        //Disable the bool again
                        foreach (int member in Character.Network.Guild.UnionMembers)
                        {
                            //Make sure member isnt null
                            if (member != 0)
                            {
                                //Get guildmember details
                                Systems guildmember = GetPlayerMainid(member);
                                //Make sure guildmember isnt null
                                if (guildmember != null)
                                {
                                    //Disable bool to allow resend new packets.
                                    guildmember.Character.Network.Guild.SingleSend = false;
                                }
                            }
                        }
                        //Reset bools
                        Character.State.UnionApply = false;
                        sys.Character.State.UnionApply = false;
                    }
                }
                //------------------------------------- [ Exchange invite ] -------------------------------------//
                else if (this.Character.State.Exchanging && sys.Character.State.Exchanging)
                {

                    if (Reader.Byte() == 1 && Reader.Byte() == 0)
                    {

                        sys.client.Send(Packet.Exchange_Cancel());
                        Character.State.Exchanging = false;
                        sys.Character.State.Exchanging = false;
                    }
                    else
                    {
                        sys.client.Send(Packet.OpenExhangeWindow(1, this.Character.Information.UniqueID));
                        client.Send(Packet.OpenExhangeWindow(sys.Character.Information.UniqueID));

                        Character.Network.Exchange.Window = true;
                        Character.Network.Exchange.ItemList = new List<DarkEmu_GameServer.Global.slotItem>();
                        sys.Character.Network.Exchange.Window = true;
                        sys.Character.Network.Exchange.ItemList = new List<DarkEmu_GameServer.Global.slotItem>();
                    }
                }
                //------------------------------------- [ Guild invite ] -------------------------------------//
                else if (this.Character.State.GuildInvite && sys.Character.State.GuildInvite)
                {
                    //If byte equals 2 the type is denied
                    if (Reader.Byte() == 2)
                    {
                        //Denied request
                        Character.State.GuildInvite = false;
                        sys.Character.State.GuildInvite = false;
                        //Send refused packet to sender
                        sys.client.Send(Packet.IngameMessages(SERVER_GUILD, IngameMessages.UIIT_MSG_GUILDERR_JOIN_GUILD_REFUSED));
                    }
                    //If not denied we start adding the new member
                    else
                    {
                        //Invite guild member (Add member count + 1).
                        int guildmemberadd = sys.Character.Network.Guild.Members.Count + 1;
                        //Update database
                        MsSQL.InsertData("INSERT INTO guild_members (guild_id, guild_member_id, guild_rank, guild_points, guild_fortress, guild_grant, guild_perm_join, guild_perm_withdraw, guild_perm_union, guild_perm_storage, guild_perm_notice) VALUES ('" + sys.Character.Network.Guild.Guildid + "','" + Character.Information.CharacterID + "','10','0','1','" + "" + "','0','0','0','0','0')");
                        MsSQL.UpdateData("UPDATE guild SET guild_members_t='" + guildmemberadd + "' WHERE guild_name='" + sys.Character.Network.Guild.Name + "'");
                        //Reload new member and load character data for guildinfo
                        LoadPlayerGuildInfo(true);
                        //Send packets to network and spawned players
                        foreach (int member in Character.Network.Guild.Members)
                        {
                            //Make sure the member is there
                            if (member != 0)
                            {
                                //We dont send this info to the invited user.
                                if (member != Character.Information.CharacterID)
                                {
                                    //If the user is not the newly invited member get player info
                                    Systems tomember = GetPlayerMainid(member);
                                    //Send guild update packet
                                    tomember.LoadPlayerGuildInfo(true);
                                    tomember.client.Send(Packet.GuildUpdate(Character, 1, Character.Information.CharacterID, 0, 0));
                                    tomember.client.Send(Packet.GuildSetOnline(Character.Network.Guild, Character.Information.UniqueID));
                                    tomember.client.Send(Packet.GuildUpdate(Character, 6, Character.Information.CharacterID, 0, 0));
                                }
                                //Send information to the invited player
                                else
                                {
                                    //Send guild data packets to invited
                                    client.Send(Packet.SendGuildStart());
                                    client.Send(Packet.SendGuildInfo(Character.Network.Guild));
                                    client.Send(Packet.SendGuildEnd());
                                    //Load union data for new invited player
                                    LoadUnions();
                                }
                            }
                        }
                        //Set bools to false for new invite
                        Character.State.GuildInvite = false;
                        sys.Character.State.GuildInvite = false;
                    }
                }

                //------------------------------------- [ Party invite ] -------------------------------------//
                else
                {
                    //If invitation is accepted
                    if (Reader.Byte() == 1 && Reader.Byte() == 1)
                    {
                        //First we set our main checks (Check if player is in party or not).
                        if (Character.Network.Party != null)
                            return;
                        //Set bools for check
                        Character.Information.CheckParty = true;
                        sys.Character.Information.CheckParty = true;

                        //Set main party information
                        party JoiningParty = sys.Character.Network.Party;

                        //Check party type members allowed need message if full
                        if (JoiningParty.Type == 4 && JoiningParty.Members.Count > 3)
                        {
                            //Send party is full message to player
                            client.Send(Packet.IngameMessages(Systems.SERVER_PARTY_MESSAGES, IngameMessages.UIIT_MSG_PARTYERR_ALREADY_FULL));
                            return;
                        }
                        if (JoiningParty.Type == 5 && JoiningParty.Members.Count > 7)
                        {
                            //Send party is full message to player
                            client.Send(Packet.IngameMessages(Systems.SERVER_PARTY_MESSAGES, IngameMessages.UIIT_MSG_PARTYERR_ALREADY_FULL));
                            return;
                        }
                        //If the current count == 0 then add party and add me
                        if (JoiningParty.Members.Count == 0)
                        {
                            //Add ourselfs to the party list
                            JoiningParty.Members.Add(sys.Character.Information.UniqueID);
                            //Add our client to the party list
                            JoiningParty.MembersClient.Add(sys.client);
                            //Set party id
                            JoiningParty.ptid = Party.Count + 1;
                            //Set party network info
                            sys.Character.Network.Party = JoiningParty;
                            //Send permissions
                            sys.client.Send(Packet.Party_Member(sys.Character.Information.UniqueID));
                            //Send party data to leader
                            sys.client.Send(Packet.Party_DataMember(JoiningParty));
                            //Send party data packet to leader (Other player that joined).
                            sys.client.Send(Packet.Party_Data(2, Character.Information.UniqueID));
                            //Add invited member to the list
                            JoiningParty.Members.Add(Character.Information.UniqueID);
                            JoiningParty.MembersClient.Add(client);
                            //Set party info for invited member
                            Character.Network.Party = JoiningParty;
                            //Send permissions
                            client.Send(Packet.PartyOwnerInformation(Character.Information.UniqueID));
                            //Send party data
                            client.Send(Packet.Party_DataMember(JoiningParty));
                            //return
                            return;
                        }
                        //If there are more members in the current party
                        else
                        {
                            //Repeat for each member using count
                            for (byte b = 0; b <= JoiningParty.Members.Count - 1; b++)
                            {
                                //Get player information from [b]
                                Systems others = GetPlayer(JoiningParty.Members[b]);
                                //Send party data to member
                                others.client.Send(Packet.Party_Data(2, Character.Information.UniqueID));
                            }
                            //Add the invited member to list
                            JoiningParty.Members.Add(Character.Information.UniqueID);
                            //Add the invited client to the list
                            JoiningParty.MembersClient.Add(client);
                            //Set party
                            Character.Network.Party = JoiningParty;
                            //Send permissions
                            client.Send(Packet.PartyOwnerInformation(Character.Information.UniqueID));
                            //Send party data
                            client.Send(Packet.Party_DataMember(JoiningParty));
                            return;
                        }
                    }
                    //If denied request
                    else
                    {
                        //Send denied message to the player joining
                        client.Send(Packet.IngameMessages(Systems.SERVER_PARTY_MEMBER, IngameMessages.UIIT_MSG_PARTYERR_JOIN_PARTY_REFUSED));
                        //Set both bools to false so inviting can be done again
                        sys.Character.Information.CheckParty = false;
                        Character.Information.CheckParty = false;
                    }
                }
            }
            //Catch bad exception errors
            catch (Exception ex)
            {
                //Write information to the console
                Console.WriteLine("Request error: {0}", ex);
                //Write information to the debug log
                Debugger.Write(ex);
            }
        }
示例#13
0
        void Handle()
        {
            PacketReader Reader = new PacketReader(PacketInformation.buffer);
            byte iSlot = Reader.Byte();
            Global.slotItem uItemID = GetItem((uint)Character.Information.CharacterID, iSlot, 0);

            if (uItemID.ID == 0 || Character.State.Die) return;
            switch (uItemID.ID)
            {

                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Stall decoration
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                case 3847:
                case 3848:
                case 3849:
                case 3850:
                case 35482:
                case 35483:
                case 35484:
                    StallDeco(uItemID.ID, iSlot);
                    HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                    break;

                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Monster Masks
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                case 10364:
                    if (Character.Transformed) return;
                    //Load Mask
                    MonsterMasks(uItemID.ID, iSlot);
                    HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                    break;
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Forgotten world entrance
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                case 33235:
                    ForgottenWorld(uItemID.ID);
                    HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                    break;
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Repair items
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                case 3784:
                case 24432:
                case 35249:
                    if (!Character.Action.repair)
                    {
                        Character.Action.repair = true;
                        RepairTimer(30000);
                    //Check if there are any items that need repair
                    double durability = Data.ItemBase[uItemID.ID].Defans.Durability;
                    double currentdurability = Data.ItemBase[uItemID.dbID].Defans.Durability;

                        if (currentdurability < durability)
                        {
                            int countrepairs = MsSQL.GetRowsCount("SELECT * FROM char_items WHERE owner='" + Character.Information.CharacterID + "'");
                            if (countrepairs == 0)
                            {
                                //Do nothing client sends message automaticly
                            }
                            else
                            {
                                //Start repairing call handle
                                HandleRepair(iSlot, uItemID.dbID);
                                HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                            }
                        }
                    }
                    break;

                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Thief Return Scrolls
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                case 2128:
                    if (Character.Information.Scroll) return;
                    HandleThiefScroll(uItemID.ID);
                    HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                    break;
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Inventory Expansion
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                case 24456:
                    HandleInventoryExp(uItemID.ID);
                    HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                    break;
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Monster Summon Scrolls
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                case 3935:
                case 3936:
                case 3937:
                case 10133:
                case 10145:
                case 30925:
                    HandleSummon(Character.Information.Level);
                    HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                    break;
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Reverse return scrolls
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                case 3795:
                case 24467:
                    if (Character.Information.Scroll) return;
                    HandleReverse(Reader.Int16(),Reader.Byte(), Reader.Int32());
                    HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                    break;
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Premium Tickets
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                case 7490:
                case 24505:
                    HandlePremiumType(uItemID.ID);
                    HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                    break;
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Normal Return Scrolls
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                case 61:
                case 2198:
                case 2199:
                case 3769:
                case 19599:
                case 24684:
                    if (Character.Information.Scroll) return;
                    if (Timer.Movement != null)
                    {
                        Timer.Movement.Dispose();
                        Character.Position.Walking = false;
                    }
                    HandleReturnScroll(uItemID.ID);
                    HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                    break;
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // HP Potions
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                case 4:
                case 5:
                case 6:
                case 7:
                case 8:
                case 3817:
                case 3818:
                case 3819:
                case 5912:
                case 3765:
                    byte type = 1;
                    HandlePotion(type, uItemID.ID);
                    HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                    break;
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // MP Potions
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                case 11:
                case 12:
                case 13:
                case 14:
                case 15:
                case 3820:
                case 3821:
                case 3822:
                case 5913:
                    type = 2;
                    HandlePotion(type, uItemID.ID);
                    HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                    break;
                case 9:
                    type = 3;
                    HandlePotion(type, uItemID.ID);
                    HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                    break;
                case 16:
                    type = 4;
                    HandlePotion(type, uItemID.ID);
                    HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                    break;
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Vigor Potions
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                case 18:
                case 19:
                case 20:
                case 21:
                case 22:
                case 23:
                case 3739:
                case 4013:
                case 5881:
                case 5944:
                case 23316:
                    type = 5;
                    HandlePotion(type, uItemID.ID);
                    HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                    break;
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Special Transport
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                case 19601:
                case 22770:
                    if (!Character.Stall.Stallactive && !Character.Transport.Right && Character.Action.MonsterID.Count == 0 && !Character.State.Sitting && !Character.Information.Scroll)
                    {
                        bool r = HandleSpecialTrans(uItemID.ID);
                        if (!r)
                            HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                    }
                    break;
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Normal transports
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                case 2137:
                case 2138:
                case 2139:
                case 3909:
                case 23330:
                case 22953:
                case 23396:
                case 23395:
                case 22952:
                    if (!Character.Stall.Stallactive && !Character.Transport.Right && Character.Action.MonsterID.Count == 0 && !Character.State.Sitting && !Character.Information.Scroll)
                    {
                        if (this.Character.Information.Level >= Data.ItemBase[uItemID.ID].Level)
                        {
                            HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                            HandleHorseScroll(uItemID.ID);
                        }
                        else
                        {
                            //client.Send();// needs error

                        }
                    }
                    break;
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Global Chatting
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                case 3851:
                    HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                    string text = " " + Reader.Text3();
                    Reader.Close();
                    SendAll(Packet.ChatPacket(6, 0, text, Character.Information.Name));
                    break;
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Buff Items
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                case 7100:
                    SpecialBuff(3977);
                    HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                    break;
                case 7098:
                    SpecialBuff(3975);
                    HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                    break;
                case 23311:
                    if (Character.Information.Berserking) return;
                    int style = 1;
                    HandleRegenZerk(style, uItemID.ID);
                    HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                    break;
                case 23938:
                    if (Character.Information.Berserking) return;
                    style = 2;
                    HandleRegenZerk(style, uItemID.ID);
                    HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                    break;
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Grab Pets
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                case 23313:
                case 35578:
                case 35583:
                    if (!Character.Grabpet.Active && Character.Action.MonsterID.Count == 0)
                    {
                        bool r = HandleGrabPet(iSlot, uItemID.ID);
                        if (!r)
                            HandleUpdateSlotn(iSlot, uItemID, Reader.UInt16());
                    }
                    break;
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Attack Pets
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                /*
                case 22778:
                    if (!Character.Grabpet.Active && Character.Action.MonsterID.Count == 0)
                    {
                        bool r = HandleAttackPet(iSlot, uItemID.ID);
                        if (!r)
                            HandleUpdateSlotn(iSlot, uItemID, Reader.UInt16());
                    }
                    break;
                */
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Gender Switch Tools
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                case 24479:
                    //HandleGenderSwitch(iSlot, uItemID.ID);
                    //HandleUpdateSlotn(iSlot, uItemID, Reader.UInt16());
                    break;
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Balloons
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                case 24342:
                    //HandleBalloon(iSlot, 31157);
                    SpecialBuff(31182);
                    HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                    break;
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Default , Check item ID
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                default:
                    //Console.WriteLine("{0} Tried to use item {1} , The cast type: {2}", Character.Information.Name, Data.ItemBase[uItemID.ID].Name, uItemID.ID);
                    HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                    break;
            }
            Reader.Close();
        }
示例#14
0
        /////////////////////////////////////////////////////////////////////////////////
        // Item Switch
        /////////////////////////////////////////////////////////////////////////////////
        void ItemMain()
        {
            #region Item Actions
            try
            {
                if (Character.State.Die || Character.Information.Scroll) return;
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                byte iType = Reader.Byte();

                switch (iType)
                {
                    case 0:
                        if (Character.State.Busy) return;
                        ItemMove(Reader.Byte(), Reader.Byte(), Reader.Int16());
                        break;
                    case 1:
                        ItemMoveInStorage(Reader.Byte(), Reader.Byte(), Reader.Int16());
                        break;
                    case 2:
                        Player_MoveItemToStorage(Reader.Byte(), Reader.Byte(), Reader.Int32());
                        break;
                    case 3:
                        Player_MoveStorageItemToInv(Reader.Byte(), Reader.Byte(), Reader.Int32());
                        break;
                    case 4:
                        ItemMoveToExhangePage(Reader.Byte());
                        break;
                    case 5:
                        ItemMoveExchangeToInv(Reader.Byte());
                        break;
                    case 8:
                        Player_BuyItem(Reader.Byte(), Reader.Byte(), Reader.Int16(), Reader.Int32());
                        break;
                    case 9:
                        Player_SellItem(Reader.Byte(), Reader.Int16(), Reader.UInt16());
                        break;
                    case 7:
                        if (Character.State.Busy) return;
                        Player_DropItem(Reader.Byte());
                        break;
                    case 10:
                        if (Character.State.Busy) return;
                        Player_DropGold(Reader.UInt64());
                        break;
                    case 11:
                        Player_TakeGoldW(iType, Reader.Int64());
                        break;
                    case 12:
                        Player_GiveGoldW(iType, Reader.Int64());
                        break;
                    case 13:
                        ItemExchangeGold(Reader.Int64());
                        break;
                    case 16:
                        MovePetToPet(Reader.Int32(), Reader.Byte(), Reader.Byte(), Reader.Int16());
                        break;
                    case 24:
                        Player_BuyItemFromMall(Reader.Byte(), Reader.Byte(), Reader.Byte(), Reader.Byte(), Reader.Byte(), Reader.Text());
                        break;
                    case 26:
                        MoveItemFromPet(Reader.Int32(), Reader.Byte(), Reader.Byte());
                        break;
                    case 27:
                        MoveItemToPet(Reader.Int32(), Reader.Byte(), Reader.Byte());
                        break;
                    case 29:
                        ItemMoveInStorage(Reader.Byte(), Reader.Byte(), Reader.Int16());//Move inside guild storage
                        break;
                    case 30:
                        Player_MoveItemToStorage(Reader.Byte(), Reader.Byte(), Reader.Int32());//Move to guild storage
                        break;
                    case 31:
                        Player_MoveStorageItemToInv(Reader.Byte(), Reader.Byte(), Reader.Int32());//Move from guild storage
                        break;
                    case 32:
                        Player_GiveGoldW(iType, Reader.Int64());//Guild storage
                        break;
                    case 33:
                        Player_TakeGoldW(iType, Reader.Int64());//Guild storage
                        break;
                    case 35:
                        ItemAvatarUnEquip(Reader.Byte(), Reader.Byte());
                        break;
                    case 36:
                        ItemAvatarEquip(Reader.Byte(), Reader.Byte());
                        break;
                    default:
                        Print.Format("Unknown Item Function:{0}:{1}", iType, Decode.StringToPack(PacketInformation.buffer));
                        break;
                }
                Reader.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Item Switch Error {0}", ex);
            }
            #endregion
        }
示例#15
0
文件: Skills.cs 项目: CarlosX/DarkEmu
        void MovementSkill(PacketReader Reader)
        {
            try
            {
                if (!Character.Action.movementskill)
                {
                    Character.Action.movementskill = true;
                    MovementSkillTimer(Data.SkillBase[Character.Action.UsingSkillID].Properties1["tele"] + 500);
                    if (Character.Action.sAttack || Character.Action.sCasting) return;

                    if (Character.Stat.SecondMP < Data.SkillBase[Character.Action.UsingSkillID].Mana) { client.Send(Packet.ActionPacket(2, 4)); return; }
                    else
                    {
                        Character.Stat.SecondMP -= Data.SkillBase[Character.Action.UsingSkillID].Mana;
                        UpdateMp();
                        if (Timer.Movement != null) { Timer.Movement.Dispose(); Character.Position.Walking = false; }

                        byte xSec = Reader.Byte(), ySec = Reader.Byte();
                        int x = Reader.Int32(), z = Reader.Int32(), y = Reader.Int32();
                        Reader.Close();

                        float gamex = DarkEmu_GameServer.Formule.gamex((float)x, xSec);
                        float gamey = DarkEmu_GameServer.Formule.gamey((float)y, ySec);

                        float farkx = gamex - Character.Position.x;
                        float farky = gamey - Character.Position.y;

                        float hesapy = 0, hesapx = 0;

                        while (hesapx + hesapy < Data.SkillBase[Character.Action.UsingSkillID].Properties2["tele"] / 10)
                        {
                            Character.Position.x += (farkx / 30);
                            Character.Position.y += (farky / 30);
                            hesapx += Math.Abs((farkx / 30));
                            hesapy += Math.Abs((farky / 30));
                        }

                        PacketWriter Writer = new PacketWriter();

                        Writer.Create(SERVER_ACTION_DATA);
                        Writer.Byte(1);
                        Writer.Byte(2);
                        Writer.Byte(0x30);
                        int overid = Character.Ids.GetCastingID();
                        Writer.DWord(Character.Action.UsingSkillID);//skillid
                        Writer.DWord(Character.Information.UniqueID); //charid
                        Writer.DWord(overid);//overid
                        Writer.DWord(0);
                        Writer.Byte(8);
                        Writer.Byte(xSec);
                        Writer.Byte(ySec);
                        Writer.DWord(Formule.packetx(Character.Position.x, xSec));
                        Writer.DWord(0);
                        Writer.DWord(Formule.packety(Character.Position.y, ySec));

                        Send(Writer.GetBytes());

                        client.Send(Packet.ActionState(2, 0));

                        ObjectSpawnCheck();
                    }
                }
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
示例#16
0
        /////////////////////////////////////////////////////////////////////////////////
        // Create stones
        /////////////////////////////////////////////////////////////////////////////////
        public void AlchemyCreateStone()
        {
            try
            {
                //Open packet reader
                PacketReader reader = new PacketReader(PacketInformation.buffer);
                byte type = reader.Byte();
                byte type1 = reader.Byte();
                byte type2 = reader.Byte();
                byte tabletslot = reader.Byte();
                byte elementslot1 = reader.Byte();
                byte elementslot2 = reader.Byte();
                byte elementslot3 = reader.Byte();
                byte elementslot4 = reader.Byte();
                reader.Close();

                //Tablet information
                Global.slotItem tabletslotitem = GetItem((uint)Character.Information.CharacterID, tabletslot, 0);

                //Get stone information equaly to the tablet
                int stone = GetStoneFromTablet(tabletslotitem.ID);

                //Earth element information
                Global.slotItem element1slotitem = GetItem((uint)Character.Information.CharacterID, elementslot1, 0);
                //Water element information
                Global.slotItem element2slotitem = GetItem((uint)Character.Information.CharacterID, elementslot2, 0);
                //Fire element information
                Global.slotItem element3slotitem = GetItem((uint)Character.Information.CharacterID, elementslot3, 0);
                //Wind element information
                Global.slotItem element4slotitem = GetItem((uint)Character.Information.CharacterID, elementslot4, 0);

                //Check if the requirements are ok (Extra check amount).
                if (element1slotitem.Amount < Data.ItemBase[tabletslotitem.ID].EARTH_ELEMENTS_AMOUNT_REQ) return;
                if (element2slotitem.Amount < Data.ItemBase[tabletslotitem.ID].WATER_ELEMENTS_AMOUNT_REQ) return;
                if (element3slotitem.Amount < Data.ItemBase[tabletslotitem.ID].FIRE_ELEMENTS_AMOUNT_REQ) return;
                if (element2slotitem.Amount < Data.ItemBase[tabletslotitem.ID].WIND_ELEMENTS_AMOUNT_REQ) return;

                //Check if the requirements are ok (Extra check element name).
                if (Data.ItemBase[element1slotitem.ID].Name != Data.ItemBase[tabletslotitem.ID].EARTH_ELEMENTS_NAME) return;
                if (Data.ItemBase[element2slotitem.ID].Name != Data.ItemBase[tabletslotitem.ID].WATER_ELEMENTS_NAME) return;
                if (Data.ItemBase[element3slotitem.ID].Name != Data.ItemBase[tabletslotitem.ID].FIRE_ELEMENTS_NAME) return;
                if (Data.ItemBase[element4slotitem.ID].Name != Data.ItemBase[tabletslotitem.ID].WIND_ELEMENTS_NAME) return;

                //Update amount of elements
                element1slotitem.Amount -= (short)Data.ItemBase[tabletslotitem.ID].EARTH_ELEMENTS_AMOUNT_REQ;
                element2slotitem.Amount -= (short)Data.ItemBase[tabletslotitem.ID].WATER_ELEMENTS_AMOUNT_REQ;
                element3slotitem.Amount -= (short)Data.ItemBase[tabletslotitem.ID].FIRE_ELEMENTS_AMOUNT_REQ;
                element4slotitem.Amount -= (short)Data.ItemBase[tabletslotitem.ID].WIND_ELEMENTS_AMOUNT_REQ;

                ItemUpdateAmount(element1slotitem, Character.Information.CharacterID);
                ItemUpdateAmount(element2slotitem, Character.Information.CharacterID);
                ItemUpdateAmount(element3slotitem, Character.Information.CharacterID);
                ItemUpdateAmount(element4slotitem, Character.Information.CharacterID);

                //Update amount of tablet
                tabletslotitem.Amount -= 1;
                ItemUpdateAmount(tabletslotitem, Character.Information.CharacterID);

                //Send alchemy packet
                client.Send(Packet.StoneCreation(tabletslot));

                //Check for new free slots in inventory
                byte freeslot = GetFreeSlot();
                //Update database and insert new item
                AddItem(stone, 1, freeslot, Character.Information.CharacterID, 0);
                //Send visual packet add stone (creation works, just need to check why it sends 2x same packet).
                client.Send(Packet.GainElements(freeslot, stone, 1));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Stone creation error {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
示例#17
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Player Actions / Sit / Stand / Walk etc
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        void Doaction()
        {
            try
            {
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                List<int> toall = Character.Spawn;
                byte type = Reader.Byte();

                switch (type)
                {
                    case 2:
                        if (Character.Transport.Right)
                        {
                            Send(toall, Packet.SetSpeed(Character.Transport.Horse.UniqueID, Character.Transport.Horse.Speed1, Character.Transport.Horse.Speed2));
                            Send(toall, Packet.ChangeStatus(Character.Transport.Horse.UniqueID, type, 0));
                        }
                        Send(toall, Packet.ChangeStatus(Character.Information.UniqueID, type, 0));
                        break;
                    case 3:
                        if (Character.Transport.Right)
                        {
                            Send(toall, Packet.SetSpeed(Character.Transport.Horse.UniqueID, Character.Transport.Horse.Speed1, Character.Transport.Horse.Speed2));
                            Send(toall, Packet.ChangeStatus(Character.Transport.Horse.UniqueID, type, 0));
                        }
                        Send(toall, Packet.ChangeStatus(Character.Information.UniqueID, type, 0));
                        break;
                    case 4:
                        if (!Character.Stall.Stallactive && !Character.Transport.Right && !Character.Position.Walking && !Character.State.Die)
                        {
                            StartSitTimer(1000);
                        }
                        else
                        {
                            //Needs Error Packet InStall
                        }
                        break;
                    default:
                        Send(toall, Packet.ChangeStatus(Character.Information.UniqueID, type, 0));
                        break;
                }
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
示例#18
0
        /////////////////////////////////////////////////////////////////////////////////
        // Pet movement
        /////////////////////////////////////////////////////////////////////////////////
        void MovementPet()
        {
            try
            {
                //Open our packet reader
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                //This one happens to all pets.
                int petid = Reader.Int32();
                //We switch on type (2 = attack pet, 1 = horse).
                byte type = Reader.Byte();

                switch (type)
                {
                    //Horse pet movement
                    case 1:
                        byte movetype = Reader.Byte();

                        //Normal movement type
                        if (movetype == 1)
                        {
                            //Read xsector information
                            byte xsec = Reader.Byte();
                            //Read ysector information
                            byte ysec = Reader.Byte();
                            //Read x
                            float x = Reader.Int16();
                            //Read z
                            float z = Reader.Int16();
                            //Read y
                            float y = Reader.Int16();
                            Reader.Close();
                            //Make sure attack timer is gone
                            StopAttackTimer();
                            //Set pickup to false
                            Character.Action.PickUping = false;
                            //Set movement active
                            Character.Position.Walking = true;
                            //Calculate distance
                            double distance = Formule.gamedistance(Character.Position.x,
                                Character.Position.y,
                                Formule.gamex(x, xsec),
                                Formule.gamey(y, ysec));
                            //Set character position
                            Character.Position.xSec = xsec;
                            Character.Position.ySec = ysec;
                            Character.Position.wX = Formule.gamex(x, xsec) - Character.Position.x;
                            Character.Position.wZ = z;
                            Character.Position.wY = Formule.gamey(y, ysec) - Character.Position.y;

                            Character.Position.packetxSec = xsec;
                            Character.Position.packetySec = ysec;
                            Character.Position.packetX = (ushort)x;
                            Character.Position.packetZ = (ushort)z;
                            Character.Position.packetY = (ushort)y;

                            Send(Packet.Movement(new Global.vektor(petid, x, z, y, xsec, ysec)));
                            Character.Position.Time = (distance / (95.0 * 0.0768)) * 1000.0;
                            Character.Position.RecordedTime = Character.Position.Time;

                            StartMovementTimer((int)(Character.Position.Time * 0.1));
                        }
                        break;
                    //Attack pet movement
                    case 2:
                        //Set pet info
                        Character.Attackpet.Details.x = Character.Position.x;
                        Character.Attackpet.Details.y = Character.Position.y;
                        Character.Attackpet.Details.z = Character.Position.z;
                        Character.Attackpet.Details.xSec = Character.Position.xSec;
                        Character.Attackpet.Details.ySec = Character.Position.ySec;
                        //Target id information
                        int targetid = Reader.Int32();
                        Reader.Close();
                        //Set pet speed information
                        Send(Packet.SetSpeed(petid, 50, 100));//Need to make correct speed info later
                        //Check distances / target detailed.

                        //Send attack packet (new void pet attack to be created).
                        break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("movement pet error {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
示例#19
0
        protected void Save()
        {
            //Wrap our function inside a catcher
            try
            {
                //Open our packet reader
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                string player_path;
                byte[] file;
                //Switch on byte
                switch (Reader.Byte())
                {
                    case 1:
                        //Save quickbar information
                        player_path = Environment.CurrentDirectory + @"\player\info\quickbar\" + Character.Information.Name + ".dat";
                        file = System.IO.File.ReadAllBytes(player_path);

                        byte Slot = Reader.Byte();
                        byte sType = Reader.Byte();

                        Slot *= 5;

                        file[Slot] = sType;
                        file[Slot + 1] = Reader.Byte();
                        file[Slot + 2] = Reader.Byte();
                        file[Slot + 3] = Reader.Byte();
                        file[Slot + 4] = Reader.Byte();
                        System.IO.File.WriteAllBytes(player_path, file);
                        break;
                    case 2:
                        //Save autopotion information
                        player_path = Environment.CurrentDirectory + @"\player\info\autopot\" + Character.Information.Name + ".dat";
                        file = System.IO.File.ReadAllBytes(player_path);
                        file[0] = Reader.Byte();
                        file[1] = Reader.Byte();
                        file[2] = Reader.Byte();
                        file[3] = Reader.Byte();
                        file[4] = Reader.Byte();
                        file[5] = Reader.Byte();
                        file[6] = Reader.Byte();
                        System.IO.File.WriteAllBytes(player_path, file);
                        UpdateHp();
                        UpdateMp();
                        break;
                }
                Reader.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Save quickbar and autopotion error {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
示例#20
0
文件: Icons.cs 项目: CarlosX/DarkEmu
        public void RequestIcons()
        {
            PacketReader Reader = new PacketReader(PacketInformation.buffer);
            byte IconType = Reader.Byte();
            short IconHexLenght = Reader.Int16();
            string Icon = Reader.String(IconHexLenght);
            Reader.Close();
            //Need to figure out the string.. identification of the icon probably
            client.Send(Packet.IconSend(IconType, Icon));

            // Below is sniffed data
            /*
             * [S -> C][2114]
                01                                                Byte = Type icon (1 = Guild 2 = union).
                1C 01                                             Lenght of hex icon string

                // below is the hex string (Ascii) icon
                74 6D 28 73 81 2A 47 37 F6 13 99 62 8C 3F 4E 29   tm(s.*G7...b.?N)
                0F 04 CB 3D E6 5F FC 0B D6 07 03 DD 0D 72 9A 25   ...=._.......r.%
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                FE DC BA 98 76 54 32 10 0F 1E 2D 3C               ....vT2...-<....

                [C -> S][2114]
                02                                                ................
                0C 00                                             ................
                AE A5 BF 3C 23 65 0C 01 03 1E 27 3C               ...<#e....'<....
             */

            /*
            (Nukei)Discovered so far:
            client requests image by contacting 121.128.134.16 (gdmark.joymax.com) using HTTP protocol over port 15080
            like:
               http://gdmark.joymax.com:15080/SRO_CREST/A96_2132_1.crb (this files is saved in sro-client's RD folder as A96_2132.rd converted to BMP format)

            the returned header indicates, that the returned content is 256 Bytes in size (16 x 16 = 256).  the given type is "application".

            ToDo:
            1.	Why or when the client starts this request for images ?
            2.	Is the returned array of bytes 16x16 palette entries ?
            3.	if 2 is right, what palette is used ?

            Result:
            1. dont know :-P
            2. Yes, we get a paletted image in 16x16 size (without palette, without size, RAW pixel), so every byte is one pixel. pay attention that the Y coordinates are reversed, so the image is bottom up.
            3. discovered that it is the windows system palette !!

             * I dont know if the image really is transfered with 2114 packet !!!

            Tools used: PhotoShop, Wireshark, WinHex
             */
            /*Xsense:
             * Result:
             * 1. I believe send on guild name spawn by 1 byte indication active non active.
             * 1. Simple check would be a bool from database on creation of icon set to true,
             * 1. Deletion item / guild disband / union kick / leave would remove the bool information from db.
             * 2. Indexed color 8 bit setting. (Change extension to bmp / checked photoshop indications).
             * 3.
             * 4. RD should be cache folder, which server could check from registry path to see excisting icons.
             */

            /*
             (Rokky93) Discovered:

            I search a bit about CREST System of Joymax and found an interesting blog.So now i will tell you my results:

            1. Silkroad stores Guild Icons on a stand-alone FTP Server. You can find them in the Media.pk2/type.txt
            2. For example A96_2132_1.crb:
                A - type(Guild or Alliance)
                96- Server ID
                2132 - guild id
                1 - crest id

            When we want to convert it to bmp:
            1. Silkroad uses 16x16 pixel big 8bbp bitmaps with static color palette and no compression. The stored crests are 256B big.
            2. BMP Structure:
                header - static
                meta - static
                palette - static
                bitmap (crest file content) - dynamic

            When we want to send icons to Client
            1. We have to change the FTP Server in the Media.pk2
            2. We must send this packet to Client
                byte - type(alliance, guild) 00 or 01
                dword - guildid
                string - guildname
               dword - crestindex

               For example:
               type                 G
               serverId          187
               guildId             2929
               crestid             3

               Client makes this : G187_2929_3.crb and download them from server ( this is my  theory)

            GET /SRO_CREST/A239_282_3.crb HTTP/1.1
            Accept-Encoding: gzip, deflate
            User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E)
            Host: gdmark.joymax.com:15080
            Connection: Keep-Alive
            */
        }
示例#21
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Exchange Request Check
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        void Request()
        {
            try
            {
                PacketReader Reader = new PacketReader(PacketInformation.buffer);

                if (Reader.Byte() == 1 && Reader.Byte() == 0)
                {
                    Systems sys = GetPlayer(Character.Network.TargetID);
                    sys.client.Send(Packet.Exchange_Cancel());
                }
                else
                {
                    Systems sys = GetPlayer(Character.Network.TargetID);
                    sys.client.Send(Packet.OpenExhangeWindow(1, this.Character.Information.UniqueID));
                    client.Send(Packet.OpenExhangeWindow(sys.Character.Information.UniqueID));

                    Character.Network.Exchange.Window = true;
                    Character.Network.Exchange.ItemList = new List<DarkEmu_GameServer.Global.slotItem>();
                    sys.Character.Network.Exchange.Window = true;
                    sys.Character.Network.Exchange.ItemList = new List<DarkEmu_GameServer.Global.slotItem>();
                }
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
示例#22
0
 public static void PlayerAutoPot(PacketReader Reader, PacketWriter Writer)
 {
     Writer.Byte(Reader.Byte());
     Writer.Byte(Reader.Byte());
     Writer.Byte(Reader.Byte());
     Writer.Byte(Reader.Byte());
     Writer.Byte(Reader.Byte());
     Writer.Byte(Reader.Byte());
     Writer.Byte(Reader.Byte());
     Reader.Close();
 }
示例#23
0
        /////////////////////////////////////////////////////////////////////////////////
        // Movement
        /////////////////////////////////////////////////////////////////////////////////
        public void Movement()
        {
            try
            {
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                Character.Action.PickUping = false;
                byte Type = Reader.Byte();

                ////////////////////////////////////////////////////////////////////////////// Sky drome movement
                if (Type == 0)
                {
                    if (!Character.Stall.Stallactive && !Character.Action.PickUping && !Character.State.Die && !Character.Action.sCasting && !Character.Action.sAttack && !Character.Action.nAttack && !Character.Information.Scroll && !Character.State.Sitting && !Character.Information.SkyDroming)
                    {
                        /*
                        if (File.FileLoad.CheckCave(Character.Position.xSec, Character.Position.ySec))
                        {
                            return;
                        }
                        else
                        {

                            Character.Information.SkyDroming = true;
                            byte info = Reader.Byte();
                            ushort angle = Reader.UInt16();

                            Character.Information.Angle = angle / (65535.0 / 360.0);

                            Character.Position.packetxSec = Character.Position.xSec;
                            Character.Position.packetySec = Character.Position.ySec;
                            Character.Position.packetX = (ushort)Game.Formule.packetx(Character.Position.x, Character.Position.xSec);
                            Character.Position.packetY = (ushort)Game.Formule.packetx(Character.Position.x, Character.Position.xSec);

                            double distance = Formule.gamedistance(
                                Character.Position.x,
                                Character.Position.y,
                                Formule.gamex(Character.Position.x, Character.Position.xSec),
                                Formule.gamey(Character.Position.y, Character.Position.ySec));

                            Character.Position.Time = (distance / (Character.Speed.RunSpeed * 0.0768)) * 1000.0;
                            Character.Position.RecordedTime = Character.Position.Time;

                            PacketWriter Writer = new PacketWriter();
                            Writer.Create(Systems.SERVER_MOVEMENT);
                            Writer.DWord(Character.Information.UniqueID);
                            Writer.Byte(0);
                            Writer.Byte(info);
                            Writer.Word(angle);
                            Writer.Byte(1);
                            Writer.Byte(Character.Position.xSec);
                            Writer.Byte(Character.Position.ySec);
                            Writer.Word(Character.Position.packetX);
                            Writer.DWord(Character.Position.z);
                            Writer.Word(Character.Position.packetY);
                            Send(Writer.GetBytes());

                            StartSkyDromeTimer(1000);
                        }*/
                    }
                }

                //------------------------- Normal movement -------------------------//
                if (Type == 1)
                {
                    //If character is in a guild
                    if (Character.Network.Guild.Guildid != 0)
                    {
                        //Repeat for each client in the guild
                        foreach (Client memberclient in Character.Network.Guild.MembersClient)
                        {
                            //Make sure the client is not null
                            if (memberclient != null)
                            {
                                //Send update packet for location of player
                                memberclient.Send(Packet.GuildUpdate(Character, 10, Character.Information.UniqueID, 0, 0));
                            }
                        }
                    }

                    if (Character.Stall.Stallactive) return;
                    if (Character.Action.PickUping) return;
                    StopPickUpTimer();
                    if (Character.State.Die) return;
                    if (Character.Information.Scroll) return;
                    if (Character.State.Sitting) return;
                    if (Character.Information.SkyDroming)
                    {
                        StopSkyDromeTimer();
                    }
                    if (Character.Action.nAttack)
                    {
                        StopAttackTimer();
                        Character.Action.nAttack = false;
                    }
                    if (Character.Action.sAttack)
                    {
                        StopAttackTimer();
                        Character.Action.sAttack = false;
                    }
                    if (Character.Action.sCasting)
                    {
                        StopAttackTimer();
                        Character.Action.sCasting = false;
                    }
                    if (Character.Information.PvpWait)
                    {
                        Send(Packet.PvpInterupt(Character.Information.UniqueID));
                        Character.Information.PvpWait = false;
                        Character.Information.Pvptype = 0;
                        StopPvpTimer();
                    }
                    Character.Position.Walking = true;
                    byte xsec = Reader.Byte();
                    byte ysec = Reader.Byte();
                    float x, y, z;

                    if (!File.FileLoad.CheckCave(xsec, ysec))
                    {
                        x = Reader.Int16();
                        z = Reader.Int16();
                        y = Reader.Int16();
                        double distance = Formule.gamedistance(
                                Character.Position.x,
                                Character.Position.y,
                                Formule.gamex(x, xsec),
                                Formule.gamey(y, ysec));

                        Character.Position.xSec = xsec;
                        Character.Position.ySec = ysec;
                        Character.Position.wX = Formule.gamex(x, xsec) - Character.Position.x;
                        Character.Position.wZ = z;
                        Character.Position.wY = Formule.gamey(y, ysec) - Character.Position.y;

                        Character.Position.packetxSec = xsec;
                        Character.Position.packetySec = ysec;
                        Character.Position.packetX = (ushort)x;
                        Character.Position.packetZ = (ushort)z;
                        Character.Position.packetY = (ushort)y;

                        if (xsec != 0 && ysec != 0)
                        {
                            Send(Packet.Movement(new Global.vektor(Character.Information.UniqueID, x, z, y, xsec, ysec)));
                        }
                        if (Character.Information.Berserking)
                        {
                            Character.Position.Time = (distance / (Character.Speed.RunSpeed * 0.109)) * 1000.0;
                        }
                        else
                        {
                            Character.Position.Time = (distance / (Character.Speed.RunSpeed * 0.109)) * 1000.0;
                        }
                    }
                    else  // Added for cave telepad locations
                    {
                        x = Formule.cavegamex(Reader.Int16(),Reader.Int16()); //Reads the location and retunrs the coords for the cave postion x
                        z = Formule.cavegamez(Reader.Int16(), Reader.Int16()); //Reads the location and retunrs the coords for the cave postion z
                        y = Formule.cavegamey(Reader.Int16(), Reader.Int16()); //Reads the location and retunrs the coords for the cave postion y

                        double distance = Formule.gamedistance(Character.Position.x,Character.Position.y,Formule.cavegamex(x),Formule.cavegamey(y));

                        Character.Position.xSec = xsec;
                        Character.Position.ySec = ysec;
                        Character.Position.wX = Formule.cavegamex(x) - Character.Position.x;
                        Character.Position.wZ = z;
                        Character.Position.wY = Formule.cavegamey(y) - Character.Position.y;

                        Character.Position.packetxSec = xsec;
                        Character.Position.packetySec = ysec;
                        Character.Position.packetX = (ushort)x;
                        Character.Position.packetZ = (ushort)z;
                        Character.Position.packetY = (ushort)y;

                        if (xsec != 0 && ysec != 0)
                        {
                            Send(Packet.Movement(new Global.vektor(Character.Information.UniqueID, x, z, y, xsec, ysec)));
                        }
                        if (Character.Information.Berserking)
                        {
                            Character.Position.Time = (distance / (Character.Speed.BerserkSpeed * 0.0768)) * 1000.0;
                        }
                        else
                        {
                            Character.Position.Time = (distance / (Character.Speed.RunSpeed * 0.0768)) * 1000.0;
                        }
                    }

                    Reader.Close();

                    if (xsec != 0 && ysec != 0)
                    {
                        Send(Packet.Movement(new Global.vektor(Character.Information.UniqueID, x, z, y, xsec, ysec)));
                    }

                    if (Character.Grabpet.Active)
                    {
                        Send(Packet.Movement(new Global.vektor(Character.Grabpet.Details.UniqueID, x + rnd.Next(10, 25), z, y + rnd.Next(10, 25), xsec, ysec)));
                    }
                    if (Character.Attackpet.Active)
                    {
                        Send(Packet.Movement(new Global.vektor(Character.Attackpet.Details.UniqueID, x + rnd.Next(10, 25), z, y + rnd.Next(10, 25), xsec, ysec)));
                    }

                    Character.Position.RecordedTime = Character.Position.Time;
                    StartMovementTimer((int)(Character.Position.Time * 0.1));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Movement error: {0}", ex);
            }
        }
示例#24
0
文件: Chat.cs 项目: CarlosX/DarkEmu
        void Chat()
        {
            /*
             *  We use for each now, to make sure there wont be any issues
             *  Incase the list we send the packet to can have none connected clients.
             *  To prevent bugging of chat we repeat and check each client before sending.
             */
            try
            {
                //Set our list of ranged players
                List<int> Rangedplayers = Character.Spawn;
                //Create new packet reader for reading packet data
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                //Chat type byte (for our switch case).
                byte chatType = Reader.Byte();
                //Byte chat index
                byte chatIndex = Reader.Byte();
                //Link count byte
                byte linkCount = Reader.Byte();
                //Create switch to switch on type of chat (normal party etc).
                switch (chatType)
                {
                    //--------------------------------- [Normal chat] ---------------------------------//
                    case 1:
                        //Read written text from packet data
                        string Text = Reader.Text3();
                        //Close packet reader
                        Reader.Close();

                        // .additem 111 12
                        if (Character.Information.GM == 1 && Text[0] == '.')
                        {
                            gmCommands(Text);
                        }

                        //Repeat for each in range player
                        foreach (int member in Rangedplayers)
                        {
                            //Make sure the member is not null
                            if (member != 0)
                            {
                                //Make sure its not sending to our client
                                if (member != Character.Information.UniqueID)
                                {
                                    //Get member detail
                                    Systems memberinfo = GetPlayer(member);
                                    //Send packet to the in range player
                                    memberinfo.client.Send(Packet.ChatPacket(chatType, Character.Information.UniqueID, Text, null));
                                }
                            }
                        }
                        //Send chatindex packet to ourselfs
                        client.Send(Packet.ChatIndexPacket(chatType, chatIndex));
                        break;
                    //--------------------------------- [Normal chat pink] ---------------------------------//
                    case 3:
                        //Check if our character has gm rights or not
                        if (Character.Information.GM == 1)
                        {
                            //Read packet information (text typed).
                            Text = Reader.Text3();
                            //Close packet reader
                            Reader.Close();
                            //Repeat for each player in our range list
                            foreach (int member in Rangedplayers)
                            {
                                //Check if the member is not null
                                if (member != 0)
                                {
                                    //Make sure its not sending to our own client
                                    if (member != Character.Information.UniqueID)
                                    {
                                        //Get member detail
                                        Systems memberinfo = GetPlayer(member);
                                        //Send packet to the member
                                        memberinfo.client.Send(Packet.ChatPacket(chatType, Character.Information.UniqueID, Text, null));
                                    }
                                }
                            }
                            //Send chat index to our client
                            client.Send(Packet.ChatIndexPacket(chatType, chatIndex));
                            break;
                        }
                        //If character tried to use pink chat but isnt a gm
                        else
                        {
                            //We ban the player for hacking attempt.
                            Disconnect("ban");
                        }
                        break;
                    //--------------------------------- [Private chat] ---------------------------------//
                    case 2:
                        //Read from packet data who we are sending the message to
                        string Target = Reader.Text();
                        //Get information from the given player we send to
                        Systems Targetplayer = GetPlayerName(Target);
                        //Make sure the player sending to is not null
                        if (Targetplayer != null)
                        {
                            //Make sure the player is ingame (Not teleporting or such).
                            if (Targetplayer.Character.InGame)
                            {
                                //Read the message from the packet data
                                Text = Reader.Text3();
                                //Close the packet reader
                                Reader.Close();
                                //Send packet to our target
                                Targetplayer.client.Send(Packet.ChatPacket(chatType, 0, Text, this.Character.Information.Name));
                                //Send chatindex packet to ourselfs
                                client.Send(Packet.ChatIndexPacket(chatType, chatIndex));
                            }
                        }
                        break;
                    //--------------------------------- [Party chat] ---------------------------------//
                    case 4:
                        //Make sure the player is in a party
                        if (Character.Network.Party != null)
                        {
                            //Read the text the player has typed from packet data
                            Text = Reader.Text3();
                            //Close packet reader
                            Reader.Close();
                            //Repeat for each member in the party member list
                            foreach (int member in Character.Network.Party.Members)
                            {
                                //Make sure the member isnt null (0)
                                if (member != 0)
                                {
                                    //Get detailed info for the player
                                    Systems memberinfo = GetPlayer(member);
                                    //Send packet information to the member for chat
                                    memberinfo.client.Send(Packet.ChatPacket(chatType, Character.Information.UniqueID, Text, this.Character.Information.Name));
                                }
                            }
                            //Finally send chatindex packet to ourselfs
                            client.Send(Packet.ChatIndexPacket(chatType, chatIndex));
                        }

                        break;
                    //--------------------------------- [Guild chat] ---------------------------------//
                    case 5:
                        //Read message beeing send from packet data
                        Text = Reader.Text3();
                        //Close packet reader
                        Reader.Close();
                        //Repeat for each member in the guild member list
                        foreach (int member in Character.Network.Guild.Members)
                        {
                            //Make sure the member is not null (0)
                            if (member != 0)
                            {
                                //Get guild member detailed information
                                Systems Guildmember = GetPlayerMainid(member);
                                //Again check if the guild member is not null
                                if (Guildmember != null)
                                {
                                    //Send chat packet to the member
                                    Guildmember.client.Send(Packet.ChatPacket(chatType, Character.Information.UniqueID, Text, this.Character.Information.Name));
                                }
                            }
                        }
                        //Send chat index packet to our client
                        client.Send(Packet.ChatIndexPacket(chatType, chatIndex));

                        break;
                    //--------------------------------- [Global chat] ---------------------------------//
                    case 6:
                        //Get sender name from packet data
                        string Sender = Reader.Text();
                        //Get message from packet data
                        Text = Reader.Text3();
                        //Send to every client connected and logged in
                        SendAll(Packet.ChatPacket(chatType, Character.Information.UniqueID, " " + Text, Sender));
                        break;
                    //--------------------------------- [Notice chat] ---------------------------------//
                    case 7:
                        //Make sure the character sending is a gm
                        if (Character.Information.GM == 1)
                        {
                            //Get message from packet data
                            Text = Reader.Text3();
                            //Close packet reader
                            Reader.Close();
                            //Send to everyone ingame (using void sendnoticecon).
                            SendAll(sendnoticecon(chatType, Character.Information.UniqueID, Text, null));
                        }
                        //If the character is not a gm
                        else
                        {
                            //Disconnect and ban the player for hack attempt
                            Disconnect("ban");
                        }
                        break;
                    //--------------------------------- [Stall chat] ---------------------------------//
                    case 9:
                        //Read message from packet data
                        Text = Reader.Text3();
                        //Close packet reader
                        Reader.Close();
                        //Repeat for each member in the stall
                        foreach (int stallmember in Character.Network.Stall.Members)
                        {
                            //Make sure the stall member isnt null 0
                            if (stallmember != 0)
                            {
                                //Get stall member details
                                Systems member = GetPlayer(stallmember);
                                //Make sure the member isnt null
                                if (member != null)
                                {
                                    //Send chat packet to the member
                                    member.client.Send(Packet.ChatPacket(chatType, Character.Network.Stall.ownerID, Text, this.Character.Information.Name));
                                }
                            }
                        }
                        //Send chat index to ourselfs
                        client.Send(Packet.ChatIndexPacket(chatType, chatIndex));
                        break;
                    //--------------------------------- [Academy chat] ---------------------------------//
                    case 10:
                        //Todo academy system then chat.
                        break;
                    //--------------------------------- [Union chat] ---------------------------------//
                    case 11:
                        //Read message from packet data
                        Text = Reader.Text3();
                        //Close packet reader
                        Reader.Close();
                        //If the character has no union
                        if (!Character.Network.Guild.UnionActive)
                            //Return
                            return;
                        //Else for each member in the union
                        foreach (int member in Character.Network.Guild.UnionMembers)
                        {
                            //Make sure the union member is not null 0
                            if (member != 0)
                            {
                                //Get member detailed information
                                Systems tomember = GetPlayerMainid(member);
                                //Make sure the member is not null
                                if (tomember != null)
                                {
                                    //Make sure the member isnt ourself
                                    if(tomember.Character.Information.CharacterID != Character.Information.CharacterID)
                                    {
                                        //Send packet to the union member
                                        tomember.client.Send(Packet.ChatPacket(chatType, Character.Information.UniqueID, Text, Character.Information.Name));
                                    }
                                }
                            }
                        }
                        //Repeat for each member in the guild
                        foreach (int member in Character.Network.Guild.Members)
                        {
                            //Make sure the member isnt null 0
                            if (member != 0)
                            {
                                //Get member detailed information
                                Systems tomember = GetPlayerMainid(member);
                                //Make sure the member isnt null
                                if (tomember != null)
                                {
                                    //Make sure the member isnt ourself
                                    if (tomember.Character.Information.CharacterID != Character.Information.CharacterID)
                                    {
                                        //Send packet to the member
                                        tomember.Character.Network.Guild.SingleSend = false;
                                    }
                                }
                            }
                        }
                        //Finally send chat index packet to ourself
                        client.Send(Packet.ChatIndexPacket(chatType, chatIndex));
                        break;
                }
            }
            //If an exception error happens
            catch (Exception errorinformation)
            {
                //Write the information to the console
                Console.WriteLine("Chat error {0}", errorinformation);
                //Write the information to the log system
                Systems.Debugger.Write(errorinformation);
            }
        }
示例#25
0
文件: Timer.cs 项目: CarlosX/DarkEmu
        //##############################################################################
        // Start timers voids
        //##############################################################################
        void StartPvpTimer(int time)
        {
            //Need to add checks
            PacketReader reader = new PacketReader(PacketInformation.buffer);
            byte pvptype = reader.Byte();

            if (Timer.Pvp != null) Timer.Pvp.Dispose();
            Timer.Pvp = new Timer(new TimerCallback(Player_Pvp_CallBack), 0, time, 0);
            Send(Packet.PvpSystemWait(Character.Information.UniqueID));
            Character.Information.PvpWait = true;
            Character.Information.Pvptype = pvptype;
        }
示例#26
0
        public void Mastery_Up()
        {
            try
            {
                List<byte> Masteries = new List<byte>();
                MsSQL mastery = new MsSQL("SELECT * FROM mastery WHERE owner='"+Character.Information.CharacterID+"'");
                 using (SqlDataReader reader = mastery.Read())
                    {
                        while (reader.Read())
                        {
                            Masteries.Add(reader.GetByte(2));
                        }

                 }
                int totalmastery = 0;
                int masterylimit = 360;
                bool euchar = false;
                if (Character.Information.Model >= 10000 && Character.Information.Model <= 16000)
                {
                    masterylimit = 239;
                    euchar = true;
                }

                for(int i = 0;i < Masteries.Count;i++)
                {
                    totalmastery += Masteries[i];
                }
                if (totalmastery <= masterylimit)
                {
                    if (!Character.Action.upmasterytimer)
                    {
                        Character.Action.upmasterytimer = true;
                        MasteryupTimer(150);

                        PacketReader Reader = new PacketReader(PacketInformation.buffer);
                        int masteryid = Reader.Int32();
                        byte level = Reader.Byte();
                        byte m_index = MasteryGet(masteryid);

                        if (m_index == 0)
                        {
                            return;
                        }

                        if (!(Character.Information.SkillPoint < Data.MasteryBase[Character.Stat.Skill.Mastery_Level[m_index]]))
                        {
                            if (euchar == true)
                            {
                                if (Character.Stat.Skill.Mastery_Level[m_index] < Character.Information.Level)
                                {

                                    Character.Stat.Skill.Mastery_Level[m_index]++;
                                    Character.Information.SkillPoint -= Data.MasteryBase[Character.Stat.Skill.Mastery_Level[m_index]];

                                    client.Send(Packet.InfoUpdate(2, Character.Information.SkillPoint, 0));
                                    client.Send(Packet.MasteryUpPacket(masteryid, Character.Stat.Skill.Mastery_Level[m_index]));

                                    SaveMaster();

                                }
                            }
                            else
                            {
                                if (Character.Stat.Skill.Mastery_Level[m_index] < Character.Information.Level)
                                {
                                    if (!(Character.Stat.Skill.Mastery_Level[m_index] == 120))
                                    {
                                        Character.Stat.Skill.Mastery_Level[m_index]++;
                                        Character.Information.SkillPoint -= Data.MasteryBase[Character.Stat.Skill.Mastery_Level[m_index]];

                                        client.Send(Packet.InfoUpdate(2, Character.Information.SkillPoint, 0));
                                        client.Send(Packet.MasteryUpPacket(masteryid, Character.Stat.Skill.Mastery_Level[m_index]));

                                        SaveMaster();
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    //client.Send(Packet.IngameMessages(SERVER_ACTIONSTATE, IngameMessages.UIIT_STT_SKILL_LEARN_MASTERY_TOTAL_LIMIT));
                    return;
                }
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
示例#27
0
        //Will need to read this byte by byte to get the id for the server to record for the chardata
        public void Gameguide()
        {
            try
            {
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                bool Guideok = false;
                int[] b1 = new int[8];
                for (int b = 0; b < 8; ++b)//Reads Guide Data
                {
                    b1[b] = Reader.Byte();//Puts into a int Array
                }

                for (int gc = 0; gc < 8; ++gc)//This Checks The Last Send Guide Paket To Make Sure The Same Packet Is Not Read Twice
                {
                    if (b1[gc] == Character.Guideinfo.Gchk[gc])
                    {
                        Guideok = false;//If Guide Packet Has Been Sent Will Return False
                    }
                    else
                    {
                        Guideok = true;//If Guide Packet Is New Will Retun True And Break
                        break;
                    }
                }

                if (Guideok)
                {
                    for (int gc = 0; gc < 8; ++gc)// Guide Packet Check
                    {
                        Character.Guideinfo.Gchk[gc] = b1[gc];//Adds Packet To Int Array
                    }

                    for (int gi = 0; gi < 8; ++gi)//Guide Packet Update For Save And Teleport,Return,Etc
                    {
                        Character.Guideinfo.G1[gi] = Character.Guideinfo.G1[gi] + b1[gi];//Adds The Packet And Updates The Data
                    }
                    PacketWriter Writer = new PacketWriter();//Writes the Packet Responce For Guide Window
                    Writer.Create(Systems.SERVER_SEND_GUIDE);
                    Writer.Byte(1);
                    for (int b = 0; b < 8; ++b)
                    {
                        Writer.Byte(b1[b]);
                    }
                    client.Send(Writer.GetBytes());
                }
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
示例#28
0
        void ActionMain()
        {
            try
            {
                if (Character.State.Die || Character.Information.Scroll || Character.Action.Cast)
                    return;

                //Create new packet reader
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                //Read main action type
                byte type = Reader.Byte();
                //If attack action byte is not equal to 2
                if (type != 2)
                {
                    //Read player action byte
                    byte PlayerAction = Reader.Byte();
                    //Create switch on player actions
                    switch (PlayerAction)
                    {
                        //Normal attacking
                        case 1:
                            //If character is allready using normal attack
                            if (Character.Action.nAttack)
                            {
                                //Return
                                return;
                            }
                            //If the character is riding a horse
                            if (Character.Transport.Right)
                            {
                                //Return, because character cannot attack while riding a horse.
                                return;
                            }
                            //If the character is picking up a item
                            if (Character.Action.PickUping)
                            {
                                //Stop pick up timer
                                StopPickUpTimer();
                            }
                            //Skip non needed byte
                            Reader.Skip(1);
                            //Read integer target id (DWORD).
                            int TargetID = Reader.Int32();
                            //Close packet reader
                            Reader.Close();
                            //Set target id for usage later in attacking.
                            Character.Action.Object = GetObjects(TargetID);
                            //Set bool normal attack to true
                            Character.Action.nAttack = true;
                            //Set character target id
                            Character.Action.Target = TargetID;
                            //Start attacking
                            StartAttackTimer(1425);
                            break;
                        case 2://pickup
                            if (Character.Action.nAttack) return;
                            if (Character.Action.sAttack) return;
                            if (Character.Action.sCasting) return;
                            if (Character.Action.PickUping) return;

                            Reader.Byte();
                            int id2 = Reader.Int32();
                            Reader.Close();

                            Character.Action.Target = id2;
                            Character.Action.PickUping = true;
                            StartPickupTimer(600);
                            break;
                        case 3://trace
                            if (Character.Action.sAttack) return;
                            if (Character.Action.sCasting) return;
                            if (Character.State.Sitting) return;
                            if (Character.Stall.Stallactive) return;

                            Reader.Byte();
                            int id3 = Reader.Int32();
                            Character.Action.Target = id3;
                            Reader.Close();
                            client.Send(Packet.ActionState(1, 1));
                            Character.Action.PickUping = false;
                            Player_Trace(id3);
                            break;
                        case 4://use skill
                            Character.Action.UsingSkillID = Reader.Int32();
                            SkillMain(Reader.Byte(), Reader);
                            break;
                        case 5:
                            int id4 = Reader.Int32();
                            byte b_index = SkillGetBuffIndex(id4);
                            SkillBuffEnd(b_index);
                            break;
                        default:
                            Console.WriteLine("ActionMain case: " + Reader.Byte());
                            break;
                    }
                }

                else
                    StopAttackTimer();
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
示例#29
0
文件: Ranks.cs 项目: CarlosX/DarkEmu
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Job Ranks
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        void RankList()
        {
            try
            {
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                /////////////////////////////////////////////////////////////////////////////////////
                int Notneeded = Reader.Int32();
                byte Type = Reader.Byte();
                byte Choice = Reader.Byte();
                /////////////////////////////////////////////////////////////////////////////////////

                /////////////////////////////////////////////////////////////////////////////////////
                // Rank Trader
                /////////////////////////////////////////////////////////////////////////////////////
                if (Type == 1)
                {
                    /////////////////////////////////////////////////////////////////////////////////////
                    // Rank Trader Merchant Activity
                    /////////////////////////////////////////////////////////////////////////////////////
                    if (Choice == 0)
                    {
                        try
                        {
                            MsSQL readsql = new MsSQL("SELECT TOP 50 * FROM rank_job_activity WHERE job_type='1'");
                            int begin = 0;
                            int count = readsql.Count();
                            using (SqlDataReader readinfo = readsql.Read())
                            {
                                while (readinfo.Read())
                                {
                                    for (begin = 0; begin < count; )
                                    {
                                        begin++;
                                        if (begin.Equals(count))
                                        {
                                            client.Send(Packet.RankListsActivityTrader());
                                            return;
                                        }
                                    }
                                    return;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Rank Trader Merchant Activity error: " + ex);
                        }
                    }
                    /////////////////////////////////////////////////////////////////////////////////////
                    // Rank Trader Weekly Donation
                    /////////////////////////////////////////////////////////////////////////////////////
                    else if (Choice == 1)
                    {
                        try
                        {
                            MsSQL readsql = new MsSQL("SELECT TOP 50 * FROM rank_job_donate WHERE job_type='1'");
                            int begin = 0;
                            int count = readsql.Count();
                            using (SqlDataReader readinfo = readsql.Read())
                            {
                                while (readinfo.Read())
                                {
                                    for (begin = 0; begin < count; )
                                    {
                                        begin++;
                                        if (begin.Equals(count))
                                        {
                                            client.Send(Packet.RankListsDonateTrader());
                                            return;
                                        }
                                    }
                                    return;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Rank Trader Weekly Donation: " + ex);
                        }
                    }
                }
                /////////////////////////////////////////////////////////////////////////////////////
                // Rank List Thief
                /////////////////////////////////////////////////////////////////////////////////////
                else if (Type == 3)
                {
                    /////////////////////////////////////////////////////////////////////////////////////
                    // Rank List Thief Activity
                    /////////////////////////////////////////////////////////////////////////////////////
                    if (Choice == 0)
                    {
                        try
                        {
                            MsSQL readsql = new MsSQL("SELECT TOP 50 * FROM rank_job_activity WHERE job_type='3'");
                            int begin = 0;
                            int count = readsql.Count();
                            using (SqlDataReader readinfo = readsql.Read())
                            {
                                while (readinfo.Read())
                                {
                                    for (begin = 0; begin < count; )
                                    {
                                        begin++;
                                        if (begin.Equals(count))
                                        {
                                            client.Send(Packet.RankListsActivityThief());
                                            return;
                                        }
                                    }
                                    return;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Thief rank activity error: " + ex);
                        }
                    }
                    /////////////////////////////////////////////////////////////////////////////////////
                    // Rank List Thief Weekly Donation
                    /////////////////////////////////////////////////////////////////////////////////////
                    else if (Choice == 1)
                    {
                        try
                        {
                            MsSQL readsql = new MsSQL("SELECT TOP 50 * FROM rank_job_donate WHERE job_type='2'");
                            int begin = 0;
                            int count = readsql.Count();
                            using (SqlDataReader readinfo = readsql.Read())
                            {
                                while (readinfo.Read())
                                {
                                    for (begin = 0; begin < count; )
                                    {
                                        begin++;
                                        if (begin.Equals(count))
                                        {
                                            client.Send(Packet.RankListsDonateThief());
                                            return;
                                        }
                                    }
                                    return;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Rank List Thief Weekly Donation: " + ex);
                        }
                    }
                }
                /////////////////////////////////////////////////////////////////////////////////////
                // Rank List Hunter
                /////////////////////////////////////////////////////////////////////////////////////
                else if (Type == 2) //Type 2 = Hunter
                {
                    /////////////////////////////////////////////////////////////////////////////////////
                    // Rank List Hunter Activity
                    /////////////////////////////////////////////////////////////////////////////////////
                    if (Choice == 0)
                    {
                        try
                        {
                            MsSQL readsql = new MsSQL("SELECT TOP 50 * FROM rank_job_activity WHERE job_type='2'");
                            int begin = 0;
                            int count = readsql.Count();
                            using (SqlDataReader readinfo = readsql.Read())
                            {
                                while (readinfo.Read())
                                {
                                    for (begin = 0; begin < count; )
                                    {
                                        begin++;
                                        if (begin.Equals(count))
                                        {
                                            client.Send(Packet.RankListsActivityHunter());
                                            return;
                                        }
                                    }
                                    return;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Hunter rank activity error: " + ex);
                        }
                    }
                    /////////////////////////////////////////////////////////////////////////////////////
                    // Rank List Hunter Weekly Contribution
                    /////////////////////////////////////////////////////////////////////////////////////
                    else if (Choice == 1)
                    {
                        try
                        {
                            MsSQL readsql = new MsSQL("SELECT TOP 50 * FROM rank_job_donate WHERE job_type='3'");
                            int begin = 0;
                            int count = readsql.Count();
                            using (SqlDataReader readinfo = readsql.Read())
                            {
                                while (readinfo.Read())
                                {
                                    for (begin = 0; begin < count; )
                                    {
                                        begin++;
                                        if (begin.Equals(count))
                                        {
                                            client.Send(Packet.RankListsDonateHunter());
                                            return;
                                        }
                                    }
                                    return;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Hunter Weekly Contribution error: " + ex);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Job rank loading error : " + ex);
            }
        }
示例#30
0
        //###########################################################################################
        // Start teleporting
        //###########################################################################################
        void Teleport_Start()
        {
            try
            {
                lock (this)
                {
                    //Checks before we continue
                    if (Character.Action.PickUping) return;
                    //Timer checks
                    StopTimers();
                    //Open the packet reader
                    PacketReader Reader = new PacketReader(PacketInformation.buffer);
                    //Teleport id
                    int teleportidinfo = Reader.Int32();
                    //Number
                    byte number = Reader.Byte();
                    //Teleport selected
                    int teleportselect = Reader.Int32();
                    Reader.Close();
                    //Find price information
                    int price = Data.TeleportPrice.Find(pc => (pc.ID == number)).price;
                    //If the user has less gold then it costs
                    if (this.Character.Information.Gold < price)
                    {
                        //Send error message
                        this.client.Send(Packet.IngameMessages(SERVER_TELEPORTSTART, IngameMessages.UIIT_MSG_INTERACTION_FAIL_NOT_ENOUGH_MONEY));
                        return;
                    }
                    //If the user level is lower then the required level
                    if (Data.TeleportPrice.Find(dd => (dd.ID == teleportselect)).level > 0 && Character.Information.Level < Data.TeleportPrice.Find(dd => (dd.ID == teleportselect)).level)
                    {
                        client.Send(Packet.IngameMessages(SERVER_TELEPORTSTART, IngameMessages.UIIT_MSG_INTERACTION_FAIL_OUT_OF_REQUIRED_LEVEL_FOR_TELEPORT));
                        return;
                    }
                    //If the user is currently with job transport (TODO).

                    //Update players gold
                    this.Character.Information.Gold -= price;
                    //Update players gold in database
                    SaveGold();
                    //Close buffs
                    BuffAllClose();
                    //Send teleport packet #1
                    this.client.Send(Packet.TeleportStart());
                    //Set state
                    this.Character.InGame = false;
                    //Update location
                    Teleport_UpdateXYZ(Convert.ToByte(teleportselect));
                    //Despawn objects
                    ObjectDeSpawnCheck();
                    //Despawn player to other players
                    DeSpawnMe();
                    //Required
                    client.Send(Packet.TeleportStart2());
                    //Send loading screen image
                    this.client.Send(Packet.TeleportImage(Data.PointBase[Convert.ToByte(teleportselect)].xSec, Data.PointBase[Convert.ToByte(teleportselect)].ySec));
                    //Set bool
                    this.Character.Teleport = true;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Teleport select error {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }