cavepackety() публичный статический Метод

public static cavepackety ( float y ) : float
y float
Результат float
Пример #1
0
 /////////////////////////////////////////////////////////////////////////////////
 // Save position
 /////////////////////////////////////////////////////////////////////////////////
 #region Save position
 protected void SavePlayerPosition()
 {
     //Wrap our function inside a catcher
     try
     {
         //Update database
         if (!File.FileLoad.CheckCave(Character.Position.xSec, Character.Position.ySec))
         {
             MsSQL.UpdateData("update character set xsect='" + Character.Position.xSec +
                              "', ysect='" + Character.Position.ySec +
                              "', xpos='" + Math.Round(Formule.packetx(Character.Position.x, Character.Position.xSec)) +
                              "', ypos='" + Math.Round(Formule.packety(Character.Position.y, Character.Position.ySec)) +
                              "', zpos='" + Math.Round(Character.Position.z) +
                              "' where id='" + Character.Information.CharacterID + "'");
         }
         else
         {
             MsSQL.UpdateData("update character set xsect='" + Character.Position.xSec +
                              "', ysect='" + Character.Position.ySec +
                              "', xpos='" + Math.Round(Formule.cavepacketx(Character.Position.x)) +
                              "', ypos='" + Math.Round(Formule.cavepackety(Character.Position.y)) +
                              "', zpos='" + Math.Round(Character.Position.z) +
                              "' where id='" + Character.Information.CharacterID + "'");
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Save position error {0}", ex);
         Systems.Debugger.Write(ex);
     }
 }
Пример #2
0
 /////////////////////////////////////////////////////////////////////////////////
 // Cave movement teleport
 /////////////////////////////////////////////////////////////////////////////////
 public void Movement_CaveTeleport()// This was changed due to going in and out of caves to change the movment patten
 {
     try
     {
         // if our destination is caveteleport
         foreach (Global.CaveTeleports r in Data.CaveTeleports)
         {
             if (!File.FileLoad.CheckCave(Character.Position.xSec, Character.Position.ySec))
             {
                 if (Formule.gamedistance(Formule.packetx(Character.Position.x, Character.Position.xSec), Formule.packety(Character.Position.y, Character.Position.ySec), (float)r.x, (float)r.y) <= 10)
                 {
                     foreach (Global.cavepoint p in Data.cavePointBase)
                     {
                         if (p != null)
                         {
                             if (p.Name == r.name)
                             {
                                 TeleportCave(p.Number);
                                 break;
                             }
                         }
                     }
                     break;
                 }
             }
             else
             {
                 if (Formule.gamedistance(Formule.cavepacketx(Character.Position.x), Formule.cavepackety(Character.Position.y), (float)r.x, (float)r.y) <= 10)
                 {
                     foreach (Global.cavepoint p in Data.cavePointBase)
                     {
                         if (p != null)
                         {
                             if (p.Name == r.name)
                             {
                                 TeleportCave(p.Number);
                                 break;
                             }
                         }
                     }
                     break;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Systems.Debugger.Write(ex);
     }
 }
Пример #3
0
        public static byte[] Load(character c)
        {

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

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

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

                while (msreader.Read())
                {

                    short amount = msreader.GetInt16(6);

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

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

            //Avatar
            Writer.Byte(5);

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

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

            Writer.Byte(0);

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

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

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

            Writer.Byte(0);//new ?

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

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

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

            for (int i = 0; i < 8; ++i)//Main Guide Packet Info
            {
                Writer.Byte(c.Guideinfo.G1[i]);//Reads From Int Array
            }
            #endregion
            /////////////////////////////////////////////////////// Account / Gm Check
            #region Account ID + Gm Check
            Writer.DWord(c.Account.ID);
            Writer.Byte(0);//c.Information.GM
            #endregion
            /////////////////////////////////////////////////////// Quickbar + Autopotion
            #region Bar information
            Writer.Byte(7);
            PacketReader reader = new PacketReader(System.IO.File.ReadAllBytes(Environment.CurrentDirectory + @"\player\info\quickbar\" + c.Information.Name + ".dat"));
            PlayerQuickBar(reader, Writer);
            reader = new PacketReader(System.IO.File.ReadAllBytes(Environment.CurrentDirectory + @"\player\info\autopot\" + c.Information.Name + ".dat"));
            PlayerAutoPot(reader, Writer);
            #endregion
            /////////////////////////////////////////////////////// Academy
            #region Academy
            Writer.Byte(0); // number of player in academy
            /* // if we have players there 
             Writer.Byte(1);
             Writer.Text("asd"); 
             */
            Writer.Byte(0);//added byte today for 1.310
            Writer.Byte(0);
            Writer.Word(1); 
            Writer.Word(1);
            Writer.Byte(0);
            Writer.Byte(1);
            #endregion
            return Writer.GetBytes();
        }