Esempio n. 1
0
        public static void LoadBlues(character c)
        {
            try
            {
                MsSQL ms = new MsSQL("SELECT * FROM char_items WHERE owner='"+ c.Information.CharacterID +"'");
                using (SqlDataReader reader = ms.Read())
                {
                    while (reader.Read())
                    {
                        int a = 10;
                        int b = 11;

                        int id = reader.GetInt32(0);
                        Global.itemblue it = new Global.itemblue();
                        it.blue = new ArrayList();
                        it.blueamount = new ArrayList();
                        it.totalblue = reader.GetInt32(9);
                        for (int i = 0; i <= it.totalblue; i++)
                        {
                            it.blue.Add(reader.GetString(a));
                            it.blueamount.Add(reader.GetInt32(b));
                            a += 2;
                            b += 2;
                        }

                        Data.ItemBlue[id] = it;

                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Blue error: {0}",ex);
            }
        }
Esempio n. 2
0
 public void CheckCharStats(character ch)
 {
     //Wrap our code inside a catcher
     try
     {
         //Stats checks
         if (ch.Stat.AttackPower < 0)
             Math.Abs(ch.Stat.AttackPower);
         if (ch.Stat.Hit < 0)
             Math.Abs(ch.Stat.Hit);
         if (ch.Stat.MagDef < 0)
             Math.Abs(ch.Stat.MagDef);
         if (ch.Stat.PhyDef < 0)
             Math.Abs(ch.Stat.PhyDef);
         if (ch.Stat.MinPhyAttack < 0)
             Math.Abs(ch.Stat.MinPhyAttack);
         if (ch.Stat.MinMagAttack < 0)
             Math.Abs(ch.Stat.MinMagAttack);
         if (ch.Stat.MaxPhyAttack < 0)
             Math.Abs(ch.Stat.MaxPhyAttack);
         if (ch.Stat.MaxMagAttack < 0)
             Math.Abs(ch.Stat.MaxMagAttack);
         if (ch.Information.XP < 0)
             Math.Abs(ch.Information.XP);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Check Char Stats Error {0}", ex);
         Systems.Debugger.Write(ex);
     }
 }
Esempio n. 3
0
 public static byte[] FriendData(int target, byte type, string name, character c, bool state)
 {
     PacketWriter Writer = new PacketWriter();
     Writer.Create(Systems.SERVER_FRIEND_DATA);
     switch (type)
     {
         case 2:
             //Friend invite accepted
             Writer.Byte(2);
             Writer.DWord(target); //Id
             Writer.Text(c.Information.Name);  //Name
             Writer.DWord(c.Information.Model); //Model
             break;
         case 3:
             //Remove friend from own list
             Writer.Byte(3);
             Writer.DWord(target);
             break;
         case 4:
             //Fried online / offline update
             Writer.Byte(4);
             Writer.DWord(target);
             Writer.Byte(state);
             break;
         case 5:
             //Send private message..
             Writer.Byte(8);
             Writer.Text(name);
             Writer.DWord(0);
             Writer.DWord(0);//time info
             break;
     }
     return Writer.GetBytes();
 }
Esempio n. 4
0
 public static bool CheckGuildMemberAdd(character c)
 {
     foreach (int member in c.Network.Guild.Members)
     {
         if (member == c.Information.CharacterID)
             return true;
     }
     return false;
 }
Esempio n. 5
0
 public static byte[] JoinFormedRequest(character requesting, character owner)
 {
     //Create new packet writer
     PacketWriter Writer = new PacketWriter();
     //Add opcode for packet
     Writer.Create(Systems.SERVER_PARTY_JOIN_FORMED);
     //Character model information (Req).
     Writer.DWord(requesting.Information.Model);
     //Leader id
     Writer.DWord(requesting.Information.UniqueID);
     //Party id
     Writer.DWord(owner.Network.Party.ptid);
     //Static
     Writer.DWord(0);
     Writer.DWord(0);
     Writer.Byte(0);
     Writer.Byte(0xFF);
     //Write character unique id
     Writer.DWord(requesting.Information.UniqueID);
     //Write character name
     Writer.Text(requesting.Information.Name);
     //Write model information
     Writer.DWord(requesting.Information.Model);
     //Write level information
     Writer.Byte(requesting.Information.Level);
     //Static
     Writer.Byte(0xAA);
     //X and Y Sector
     Writer.Byte(requesting.Position.xSec);
     Writer.Byte(requesting.Position.ySec);
     //Static
     Writer.Word(0);
     Writer.Word(0);
     Writer.Word(0);
     Writer.Word(1);
     Writer.Word(1);
     //If character is in a guild
     if (requesting.Network.Guild != null)
         //Write guild name
         Writer.Text(requesting.Network.Guild.Name);
     //If character is not in a guild
     else
         //Write word value 0
         Writer.Word(0);
     //Static
     Writer.Byte(0);
     Writer.DWord(0);
     Writer.DWord(0);
     //Return all bytes to send
     return Writer.GetBytes();
 }
Esempio n. 6
0
 //When player logs off
 public void RemoveMeFromGuildDisconnect(guild g, character c)
 {
     //Repeat for each client in members of guild
     foreach (Client member in g.MembersClient)
     {
         //Make sure the client is not null
         if (member != null)
         {
             //Make sure the client is not the one of the player that logs off
             if (member != client)
             {
                 //Send packet to client
                 member.Send(Packet.GuildUpdate(c, 6, 0, 0, 0));
             }
         }
     }
 }
Esempio n. 7
0
        public static byte[] HonorRank(character c)
        {
            Systems.MsSQL ms = new Systems.MsSQL("SELECT * FROM rank_honor");
            PacketWriter Writer = new PacketWriter();
            int countinfo = ms.Count();

            Writer.Create(Systems.SERVER_HONOR_RANK);
            Writer.Byte(1);
            int i = 0;
            Writer.Byte(Convert.ToByte(countinfo));
            using (SqlDataReader reader = ms.Read())
            {
                while (reader.Read())
                {
                    byte rankicon = reader.GetByte(1);
                    string rankname = reader.GetString(2);
                    byte ranklevel = reader.GetByte(3);
                    byte ranklevelc = reader.GetByte(4);
                    int graduatesc = reader.GetInt32(5);
                    int rankposc = reader.GetInt32(6);

                    Writer.DWord(i + 1);
                    Writer.Byte(rankicon);
                    Writer.Text(rankname);
                    Writer.Byte(ranklevel);
                    Writer.Byte(ranklevelc);
                    Writer.DWord(graduatesc);
                    //If player has no guild, we write a 0 word value
                    if (c.Network.Guild.Name == null)
                    {
                        Writer.Word(0);
                    }
                    //If player has a guild we write the guild name.
                    else
                    {
                        Writer.Text(c.Network.Guild.Name);
                    }
                    i++;
                }
                ms.Close();
            }
            return Writer.GetBytes();
        }
Esempio n. 8
0
            public void QuestProcess(int questid, character Character)
            {
                switch (Data.QuestData[questid].Questname)
                {
                    case "SN_CON_QTUTORIAL_CH_01":
                        //Tutorial Quest (Static info for now) Still thinking of best options
                        //Any suggestion is welcome.

                        //The idea i have:
                        //(Set quest options and actions per quest ID string
                        //Ex: Talk to npc (Check completion quest task 1 / 2 etc).
                        //Then when final task is done add reward..
                        //All taken information will come from database (To see active and all other info).

                        Character.Quest.QuestActive = true;
                        Character.Quest.QuestDrop = 0;
                        Character.Quest.TalkToNpc = 0;
                        break;
                }
            }
Esempio n. 9
0
 public static byte[] FriendInviteTarget(character c)
 {
     PacketWriter Writer = new PacketWriter();
     Writer.Create(Systems.SERVER_FRIEND_INVITE_SEND);
     Writer.DWord(c.Information.CharacterID);
     Writer.DWord(c.Information.UniqueID);
     Writer.Text(c.Information.Name);
     return Writer.GetBytes();
 }
Esempio n. 10
0
 public static byte[] GuildStorageGold(character c)
 {
     PacketWriter Writer = new PacketWriter();
     Writer.Create(Systems.SERVER_GUILD_STORAGE_GOLD);
     Writer.LWord(c.Network.Guild.StorageGold);
     return Writer.GetBytes();
 }
Esempio n. 11
0
 public static void ClearObject(obj o)
 {
     character n = new character();
     try
     {
         switch (o.ID)
         {
             case 1954:
                 Systems.SendAll(Packet.Unique_Data(6, (int)1954, n.Information.Name));
                 Tiger = false;
                 DarkEmu_GameServer.GlobalUnique.StartTGUnique(rnd.Next(10, 20) * 60000, 600);   //Random spawn tiger girl
                 break;
             case 1982:
                 Systems.SendAll(Packet.Unique_Data(6, (int)1982, n.Information.Name));
                 Uri = false;
                 DarkEmu_GameServer.GlobalUnique.StartUriUnique(rnd.Next(10, 20) * 60000, 600);   //Random spawn urichi
                 break;
             case 2002:
                 Systems.SendAll(Packet.Unique_Data(6, (int)2002, n.Information.Name));
                 Isy = false;
                 DarkEmu_GameServer.GlobalUnique.StartIsyUnique(rnd.Next(10, 20) * 60000, 600);   //Random spawn isy
                 break;
             case 3810:
                 Systems.SendAll(Packet.Unique_Data(6, (int)3810, n.Information.Name));
                 Lord = false;
                 DarkEmu_GameServer.GlobalUnique.StartLordUnique(rnd.Next(10, 20) * 60000, 600);   //Random spawn lord yarkan
                 break;
             case 3875:
                 Systems.SendAll(Packet.Unique_Data(6, (int)3875, n.Information.Name));
                 Demon = false;
                 DarkEmu_GameServer.GlobalUnique.StartDemonUnique(rnd.Next(10, 20) * 60000, 600);   //Random spawn demon shaitan
                 break;
             case 3877:
                 Systems.SendAll(Packet.Unique_Data(6, (int)3877, n.Information.Name));
                 Roc_s = false;
                 DarkEmu_GameServer.GlobalUnique.StartRoc(rnd.Next(10, 20) * 60000, 600);   //Random spawn roc
                 break;
             case 5871:
                 Systems.SendAll(Packet.Unique_Data(6, (int)5871, n.Information.Name));
                 Cerb = false;
                 DarkEmu_GameServer.GlobalUnique.StartCerbUnique(rnd.Next(10, 20) * 60000, 600);   //Random spawn cerberus
                 break;
             case 14778:
                 Systems.SendAll(Packet.Unique_Data(6, (int)14538, n.Information.Name));
                 Ivy = false;
                 DarkEmu_GameServer.GlobalUnique.StartIvyUnique(rnd.Next(10, 20) * 60000, 600);   //Random spawn captain ivy
                 break;
             case 14839:
                 Systems.SendAll(Packet.Unique_Data(6, (int)22654, n.Information.Name));
                 Cerb = false;
                 DarkEmu_GameServer.GlobalUnique.StartMedusa(rnd.Next(10, 20) * 90000, 600);   //Random spawn medusa
                 break;
             case 32768:
                 Systems.SendAll(Packet.Unique_Data(6, (int)32768, n.Information.Name));
                 Neith_s = false;
                 DarkEmu_GameServer.GlobalUnique.StartNeith(rnd.Next(10, 20) * 90000, 600);   //Random spawn neith
                 break;
             case 32752:
                 Systems.SendAll(Packet.Unique_Data(6, (int)32752, n.Information.Name));
                 Sphinx_s = false;
                 DarkEmu_GameServer.GlobalUnique.StartSphinx(rnd.Next(10, 20) * 90000, 600);   //Random spawn sphinx
                 break;
             case 32770:
                 Systems.SendAll(Packet.Unique_Data(6, (int)32770, n.Information.Name));
                 Isis_s = false;
                 DarkEmu_GameServer.GlobalUnique.StartIsis(rnd.Next(10, 20) * 90000, 600);   //Random spawn isis
                 break;
         }
     }
     catch (Exception ex)
     {
         Systems.Debugger.Write(ex);
     }
 }
Esempio n. 12
0
 public static byte[] GuildUpdate(character c, byte type, int memberid, int permissions, int donatedgp)
 {
     PacketWriter Writer = new PacketWriter();
     Writer.Create(Systems.SERVER_GUILD_UPDATE);
     switch (type)
     {
         case 1:
             //Invited user to guild
             Writer.Byte(2);
             Writer.DWord(c.Information.CharacterID);
             Writer.Text(c.Information.Name);
             Writer.Byte(0x0A); //Check
             Writer.Byte(c.Information.Level);
             Writer.DWord(0);   //Permissions below
             Writer.DWord(0);
             Writer.DWord(0);
             Writer.DWord(0);
             Writer.DWord(0);
             Writer.Word(0);
             Writer.DWord(c.Information.Model); //Character Model For Icon In Guild
             Writer.Byte(0);
             Writer.Byte(c.Position.xSec);
             Writer.Byte(c.Position.ySec);
             Writer.DWord(0);
             Writer.DWord(0);
             Writer.Byte(1);
             break;
         case 2:
             //Disband guild
             Writer.Byte(1);
             break;
         case 3:
             //Transfer Leadership
             Writer.Byte(0x16);
             Writer.Byte(2);
             Writer.Byte(0x54);
             Writer.DWord(memberid);
             Writer.Byte(0);
             Writer.DWord(0xFFFFFFFF);
             Writer.Byte(1);
             Writer.DWord(c.Information.CharacterID);
             Writer.Byte(0x0A);
             Writer.DWord(0);
             Writer.Byte(0);
             break;
         case 4:
             //Change permissions
             Writer.Byte(0x16);
             Writer.Byte(1);
             Writer.Byte(0x10);
             Writer.DWord(c.Information.CharacterID);
             Writer.DWord(permissions);
             break;
         case 5:
             //Guild upgrade
             Writer.Byte(5);
             Writer.Byte(0x0C);//Members allowed? 12
             Writer.Byte(c.Network.Guild.Level);
             Writer.DWord(c.Network.Guild.PointsTotal);
             break;
         //Invite user online
         case 6:
             //Static byte 6
             Writer.Byte(6);
             //Write member id
             Writer.DWord(c.Information.CharacterID);
             //Static byte 2
             Writer.Byte(2);
             //Online byte (If online byte = 0, If offline byte = 1).
             Writer.Byte(Convert.ToBoolean(c.Information.Online) ? 0 : 1);
             break;
         case 7:
             //User online / offline
             Writer.Byte(3);
             Writer.DWord(c.Information.CharacterID);
             Writer.Byte(2);
             break;
         case 8:
             //Update player level
             Writer.Byte(6);
             Writer.DWord(c.Information.CharacterID);
             Writer.Byte(1);
             Writer.Byte(c.Information.Level);
             break;
         case 9:
             //Update gp information guild
             Writer.Byte(6);
             Writer.DWord(c.Information.CharacterID);
             Writer.Byte(8);
             Writer.DWord(c.Network.Guild.DonateGP);
             break;
         case 10:
             //Update user location
             Writer.Byte(6);
             Writer.DWord(c.Information.CharacterID);
             Writer.Byte(0x80);//need to check
             Writer.Byte(c.Position.xSec);
             Writer.Byte(c.Position.ySec);
             break;
         case 11:
             //Guild message update
             Writer.Byte(0x05);
             Writer.Byte(0x10);
             Writer.Text(c.Network.Guild.NewsTitle);
             Writer.Text(c.Network.Guild.NewsMessage);
             break;
         case 12:
             //Leave guild
             Writer.Byte(3);
             Writer.DWord(c.Information.CharacterID);
             Writer.Byte(1);
             break;
         case 13:
             //Donated gp #1
             Writer.Byte(5);
             Writer.Byte(8);
             Writer.DWord(donatedgp);
             break;
         case 14:
             //Union invite send
             Writer.Byte(c.Network.Guild.TotalMembers);
             Writer.DWord(c.Network.Guild.Guildid);
             Writer.Text(c.Network.Guild.Name);
             Writer.Byte(c.Network.Guild.Level);
             Writer.Text(c.Information.Name);
             Writer.DWord(c.Information.Model);
             Writer.Byte(0x11);//??
             break;
     }
     return Writer.GetBytes();
 }
Esempio n. 13
0
        public void GotoPlayer(character Player, double distance)
        {
            try
            {
                this.StopMovement();

                float farkx = Player.Position.x + 2; // later have to modify
                float farky = Player.Position.y;

                //Systems.aRound(ref Player.aRound, ref farkx, ref farky);

                this.xSec = (byte)((farkx / 192) + 135);
                this.ySec = (byte)((farky / 192) + 92);

                //don't follow the player into the town.
                /*bool inTown = Data.safeZone.Exists(
                    delegate(Global.region r)
                    {
                        if (r.SecX == this.xSec && r.SecY == this.ySec)
                        {
                            return true;
                        }
                        return false;
                    });*/

                Send(Packet.Movement(new DarkEmu_GameServer.Global.vektor(this.UniqueID,
                    (float)Formule.packetx((float)farkx, Player.Position.xSec),
                    (float)Player.Position.z,
                    (float)Formule.packety((float)farky, Player.Position.ySec),
                    this.xSec,
                    this.ySec)));

                /*if (inTown)
                {
                    StopAttackTimer();
                    this.Attacking = false;

                    this.GetDie = true;
                    this.Die = true;
                    this.DeSpawnMe();

                    return;
                }*/

                // Keep track of the current position of the mob.
                this.wx = farkx - this.x;
                this.wy = farky - this.y;
                // Calc for time if mob follows initalise speed info Run
                WalkingTime = (double)(distance / (this.SpeedRun * 0.0768)) * 1000.0;
                RecordedTime = WalkingTime;

                this.StartMovement((int)(WalkingTime / 10));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Follow Player Error: {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 14
0
 public static byte[] SendGuildInfo2(character c)
 {
     PacketWriter Writer = new PacketWriter();
     Writer.Create(Systems.SERVER_GUILD_ONLINE);
     Writer.DWord(c.Information.UniqueID);               // Guildmaster ID
     Writer.DWord(c.Network.Guild.Guildid);              // Guild ID
     Writer.Text(c.Network.Guild.Name);
     if (c.Network.Guild.GrantName != "")
         Writer.Text(c.Network.Guild.GrantName);         // Guildmaster grand name len
     else
         Writer.Word(0);
     Writer.DWord(0);                                    // ?
     Writer.DWord(0);                                    // ?
     Writer.DWord(0);                                    // ? Amount of guilds in union ?
     Writer.Byte(1);                                     // ?
     Writer.Byte(1);
     return Writer.GetBytes();
 }
Esempio n. 15
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();
        }
Esempio n. 16
0
        public static byte[] ObjectSpawn(character c)
        {
            PacketWriter Writer = new PacketWriter();
            Writer.Create(Systems.SERVER_SOLO_SPAWN);
            /////////////////////////////////////////////////////// Character basic info
            #region Basic info
            Writer.DWord(c.Information.Model);
            Writer.Byte(c.Information.Volume);                      //Char Volume
            Writer.Byte(c.Information.Title);                       //Char Title
            Writer.Byte(c.Information.Pvpstate);                    //Pvp state
            if (c.Information.Pvpstate != 0) c.Information.PvP = true;
            Writer.Bool((c.Information.Level < 20 ? true : false)); //Beginners Icon

            Writer.Byte(c.Information.Slots);                       // Amount of items
            #endregion
            /////////////////////////////////////////////////////// Item info
            #region Item info
            Function.Items.PrivateItemPacket(Writer, c.Information.CharacterID, 8, 0,true);
            Writer.Byte(5);
            Function.Items.PrivateItemPacket(Writer, c.Information.CharacterID, 5, 1,true);
            Writer.Byte(0);
            #endregion
            /////////////////////////////////////////////////////// Character Location / id
            #region Location info / state
            Writer.DWord(c.Information.UniqueID);
            Writer.Byte(c.Position.xSec);
            Writer.Byte(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));
            Writer.Word(0);//angle
            Writer.Bool(c.Position.Walking);
            Writer.Byte(1); // walk:0 run:1 ;)
            //This should send the location information while moving. and where we moving
            if (c.Position.Walking)
            {
                Writer.Byte(c.Position.packetxSec);
                Writer.Byte(c.Position.packetySec);

                if (!DarkEmu_GameServer.File.FileLoad.CheckCave(c.Position.packetxSec, c.Position.packetySec))
                {
                    Writer.Word(c.Position.packetX);
                    Writer.Word(c.Position.packetZ);
                    Writer.Word(c.Position.packetY);
                }
                else
                {
                    if(c.Position.packetX < 0)
                    {
                        Writer.Word(c.Position.packetX);
                        Writer.Word(0xFFFF);
                    }
                    else
                    {
                        Writer.DWord(c.Position.packetX);
                    }

                    Writer.DWord(c.Position.packetZ);

                    if(c.Position.packetY < 0)
                    {
                        Writer.Word(c.Position.packetY);
                        Writer.Word(0xFFFF);
                    }
                    else
                    {
                        Writer.DWord(c.Position.packetY);
                    }
                }
                /*byte[] x = BitConverter.GetBytes(c.Position.packetX);
                Array.Reverse(x);
                Writer.Buffer(x);

                Writer.Word(c.Position.packetZ);

                byte[] y = BitConverter.GetBytes(c.Position.packetY);
                Array.Reverse(y);
                Writer.Buffer(y);*/

            }
            else
            {
                Writer.Byte(1);
                Writer.Word(0);//angle
            }

            Writer.Byte((byte)(c.State.LastState == 128 ? 2 : 1));

            Writer.Byte(0);
            //Info : If a player spawns at your location and is walking it send byte 3, else 0 byte.
            if (c.Transport.Right)
                Writer.Byte(c.Transport.Horse.Walking == true ? 3 : 0);
            else
            Writer.Byte(c.Position.Walking == true ? 3 : 0);

            Writer.Byte((byte)(c.Information.Berserking ? 1 : 0));
            Writer.Byte(0);
            Writer.Float(c.Speed.WalkSpeed);
            Writer.Float(c.Speed.RunSpeed);
            Writer.Float(c.Speed.BerserkSpeed);

            Writer.Byte(c.Action.Buff.count);
            for (byte b = 0; b < c.Action.Buff.SkillID.Length; b++)
            {
                if (c.Action.Buff.SkillID[b] != 0)
                {
                    Writer.DWord(c.Action.Buff.SkillID[b]);
                    Writer.DWord(c.Action.Buff.OverID[b]);
                }
            }
            #endregion
            /////////////////////////////////////////////////////// Character Job information / name
            #region Job information & name
            Writer.Text(c.Information.Name);
            Writer.Byte(0);
            if (c.Transport.Right)
            {
                Writer.Byte(1);
                Writer.Byte(0);
                Writer.DWord(c.Transport.Horse.UniqueID);
            }

            else
            {
                Writer.Byte(0);
                Writer.Byte(0);
            }

            Writer.Byte(0);
            if (c.Network.Stall != null && c.Network.Stall.ownerID == c.Information.UniqueID)
                Writer.Byte(0x04);
            else
                Writer.Byte(0);
            //Writer.Byte(0);

            if (c.Network.Guild.Guildid > 0)
            {
                Writer.Text(c.Network.Guild.Name);
                if (c.Network.Guild.GrantName != "")
                {
                    Writer.DWord(0);//Icon ?
                    Writer.Text(c.Network.Guild.GrantName);
                }
                else
                {
                    Writer.DWord(0);//Icon
                    Writer.Word(0);//No grantname
                }
            }
            else
            {
                Writer.Word(0);//No guild
                Writer.DWord(0);//No icon
                Writer.Word(0);//No grantname
            }

            Writer.DWord(0);//need to check not static
            Writer.DWord(0);
            Writer.DWord(0);

            Writer.Byte(0);
            Writer.Byte(0);
            if (c.Network.Stall != null && c.Network.Stall.ownerID == c.Information.UniqueID)
            {
                Writer.Text3(c.Network.Stall.StallName);
                Writer.DWord(c.Information.StallModel);
            }
            Writer.Byte(0);

            #endregion
            /////////////////////////////////////////////////////// Pvp state
            #region pvpstate
            if (c.Information.Pvpstate > 0 || c.Information.Murderer)
            {
                Writer.Byte(0x22);
            }
            else
            {
                Writer.Byte(0xFF);
            }
            #endregion
            Writer.Byte(4);
            return Writer.GetBytes();
        }
Esempio n. 17
0
 ///////////////////////////////////////////////////////////////////////////
 public static byte[] SpawnPortal(obj o, character c, int itemid)
 {
     PacketWriter Writer = new PacketWriter();
     Writer.Create(Systems.SERVER_SOLO_SPAWN);
     Writer.DWord(o.ID);
     Writer.DWord(o.UniqueID);
     Writer.Byte(o.xSec);
     Writer.Byte(o.ySec);
     Writer.Float(Formule.packetx((float)o.x, o.xSec));
     Writer.Float(o.z);
     Writer.Float(Formule.packety((float)o.y, o.ySec));
     Writer.Word(0);
     Writer.Byte(1);
     Writer.Byte(0);
     Writer.Byte(1);
     Writer.Byte(6);
     Writer.Text(c.Information.Name);
     Writer.DWord(itemid);
     Writer.Byte(1);
     return Writer.GetBytes();
 }
Esempio n. 18
0
 public static byte[] GuildStorageData(character c)
 {
     Systems.MsSQL getstorage = new Systems.MsSQL("SELECT * FROM char_items WHERE guild_storage_id='" + c.Network.Guild.Guildid + "' AND storagetype='3'");
     int itemcount = getstorage.Count();
     PacketWriter Writer = new PacketWriter();
     Writer.Create(Systems.SERVER_GUILD_STORAGE3);
     Writer.Byte(c.Network.Guild.StorageSlots);
     Writer.Byte(itemcount);
     if (itemcount != 0)
     {
         using (System.Data.SqlClient.SqlDataReader reader = getstorage.Read())
         {
             while (reader.Read())
             {
                 Item.AddItemPacket(Writer, reader.GetByte(5), reader.GetInt32(2), reader.GetByte(4), reader.GetInt16(6), reader.GetInt32(7), reader.GetInt32(0), reader.GetInt32(9), reader.GetInt32(30));
             }
         }
     }
     getstorage.Close();
     return Writer.GetBytes();
 }
Esempio n. 19
0
        public void IngameLogin()
        {
            //Wrap our function inside a catcher
            try
            {
                //Create new packet reader
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                //Read character name from packet
                string CharacterName = Reader.Text();
                //Close reader
                Reader.Close();
                //Anti hack checking sql query
                Systems.MsSQL ms = new Systems.MsSQL("SELECT name FROM character WHERE account='" + Player.AccountName + "' AND name='" + CharacterName + "'");
                //Check if the player account and character belongs together (count row).
                int checkinfo = ms.Count();
                //If there's no result
                if (checkinfo == 0)
                {
                    //Optional ban user here for hacking.

                    //Disconnect the user if hack attempt
                    client.Disconnect(this.client.clientSocket);
                    return;
                }
                //If there's a result we continue loading
                else
                {

                    //Create new character definition details
                    Character = new character();
                    //Set character name
                    Character.Information.Name = CharacterName;
                    //Set player id
                    Character.Account.ID = Player.ID;
                    //Load player data
                    PlayerDataLoad();
                    //Load job data
                    LoadJobData();
                    //Check same character
                    checkSameChar(CharacterName, Character.Information.UniqueID);
                    //Check character stats
                    CheckCharStats(Character);
                    //Lock while we add new client
                    lock (Systems.clients)
                    {
                        //Add new client
                        Systems.clients.Add(this);
                    }
                    //Send login screen packet
                    client.Send(Packet.LoginScreen());
                    //Send player data load start packet
                    client.Send(Packet.StartPlayerLoad());
                    //Send player data load data
                    client.Send(Packet.Load(Character));
                    //Send end load for player data
                    client.Send(Packet.EndPlayerLoad());
                    //Update online status in database
                    MsSQL.UpdateData("UPDATE character SET online='1' WHERE id='" + Character.Information.CharacterID + "'");
                    //Set PVP State
                    MsSQL.UpdateData("UPDATE character SET Pvpstate='0' WHERE id='" + Character.Information.CharacterID + "'");
                    //Update server information (Players online).
                    UpdateServerInfo();
                    //Open our timers for spawn checks etc.
                    OpenTimer();
                    //Load blue data for character
                    LoadBlues(Character);
                    //Create new list for equiped items
                    List<Global.slotItem> EquipedItems = new List<Global.slotItem>();
                    //For each equiped item under slot 13
                    for (byte q = 0; q < 13; q++)
                    {
                        //Add items to the list
                        EquipedItems.Add(GetItem((uint)Character.Information.CharacterID, q, 0));
                    }
                    //Load blues for each item
                    foreach (Global.slotItem sitem in EquipedItems)
                    {
                        //Check if the dictionary contains our blue id on item
                        if (Data.ItemBlue.ContainsKey(sitem.dbID))
                        {
                            //If exists, load blue for the item
                            LoadBluesid(sitem.dbID);
                            //If blue amount is not 0
                            if (Data.ItemBlue[sitem.dbID].totalblue != 0)
                                //Add blue to stats and information
                                AddRemoveBlues(this, sitem, true);
                        }
                    }
                    //Default luck (Will be based on tickets increasment etc.
                    this.Character.Blues.Luck = 100;
                }
            }
            //Catch bad exception errors
            catch (Exception ex)
            {
                //Write to debug log
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 20
0
 //On leave / disband / kick
 public void SetWaitTime(character c)
 {
     //Update database information
     MsSQL.UpdateData("UPDATE character SET GuildJoining='1',GuildTime='dateadd(dd,3,getdate())' WHERE name='"+ c.Information.Name +"'");
     c.Information.JoinGuildWait = true;
 }
Esempio n. 21
0
 /////////////////////////////////////////////////////////////////////////////////
 // Get matching degree elements for item
 /////////////////////////////////////////////////////////////////////////////////
 public List<int> GetDegreeElements(int itemid, character c)
 {
     try
     {
         List<int> elements = new List<int>();
         for (int i = 0; i < Data.ItemBase.Length; i++)
         {
             if (Data.ItemBase[i] != null)
             {
                 if (Data.ItemBase[i].Etctype == Global.item_database.EtcType.ELEMENTS && Data.ItemBase[i].Degree == Data.ItemBase[itemid].Degree)
                 {
                     if (i != 0)
                         elements.Add(i);
                 }
             }
         }
         return elements;
     }
     catch (Exception ex)
     {
         Systems.Debugger.Write(ex);
     }
     return null;
 }
Esempio n. 22
0
 public static byte GetAmmoSlot(character ch)
 {
     MsSQL ms = new MsSQL("SELECT * FROM char_items WHERE owner='" + ch.Information.CharacterID + "' AND (itemid='62' OR itemid='3655' OR itemid='10376' OR itemid='10727')");
     byte ammo = 0;
     using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
     {
         while (reader.Read())
         {
             ammo = reader.GetByte(5);
         }
         ms.Close();
         return Convert.ToByte(ammo);
     }
 }
Esempio n. 23
0
 public static byte[] PlayerStat(character c)
 {
     PacketWriter Writer = new PacketWriter();
     Writer.Create(Systems.SERVER_PLAYERSTAT);
     Writer.DWord((int)c.Stat.MinPhyAttack);
     Writer.DWord((int)c.Stat.MaxPhyAttack);
     Writer.DWord((int)c.Stat.MinMagAttack);
     Writer.DWord((int)c.Stat.MaxMagAttack);
     Writer.Word((ushort)c.Stat.PhyDef);
     Writer.Word((ushort)c.Stat.MagDef);
     Writer.Word((ushort)c.Stat.Hit);
     Writer.Word((ushort)c.Stat.Parry);
     Writer.DWord((int)c.Stat.Hp);
     Writer.DWord((int)c.Stat.Mp);
     Writer.Word((ushort)c.Stat.Strength);
     Writer.Word((ushort)c.Stat.Intelligence);
     return Writer.GetBytes();
 }
Esempio n. 24
0
 /////////////////////////////////////////////////////////////////////////////////
 // Get player inventory items (We will use this for stacking and checking).
 // So herer's the simple one ive made we can use to check player inventory
 /////////////////////////////////////////////////////////////////////////////////
 public static List<byte> GetPlayerItems(character c)
 {
     List<byte> items = new List<byte>();
     MsSQL ms = new MsSQL("SELECT * FROM char_items WHERE owner='" + c.Information.CharacterID + "'");
     using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
     {
         while (reader.Read())
         {
             items.Add(reader.GetByte(5));
         }
     }
     ms.Close();
     return items;
 }
Esempio n. 25
0
        public static byte[] SendFriendList(byte count, character c)
        {
            PacketWriter Writer = new PacketWriter();
            Writer.Create(Systems.SERVER_SEND_FRIEND_LIST);
            //Groups
            Systems.MsSQL ms = new Systems.MsSQL("SELECT * FROM friends_groups WHERE playerid='"+ c.Information.CharacterID  +"'");
            int groupcount = ms.Count();
            groupcount = groupcount + 1;
            Writer.Byte((byte)groupcount);

            Writer.Word(0);
            Writer.Text("NonClassified");
            int groupid = 0;
            using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
            {
                while (reader.Read())
                {
                    string groupname = reader.GetString(2);
                    groupid = groupid +1;
                    Writer.Word((short)groupid);
                    Writer.Text(groupname);
                }
            }
            //Friends
            Writer.Byte(count);
            ms = new Systems.MsSQL("SELECT * FROM friends WHERE owner='"+ c.Information.CharacterID  +"'");
            using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
            {
                while (reader.Read())
                {
                    int model       = Systems.MsSQL.GetDataInt("SELECT * FROM character WHERE id='" + reader.GetInt32(2) + "'", "chartype");
                    int status      = Systems.MsSQL.GetDataInt("SELECT * FROM character WHERE id='" + reader.GetInt32(2) + "'", "Online");
                    int charid      = Systems.MsSQL.GetDataInt("SELECT * FROM character WHERE id='" + reader.GetInt32(2) + "'", "id");
                    string charname = Systems.MsSQL.GetData("SELECT * FROM character WHERE id='" + reader.GetInt32(2) + "'", "name");
                    string groupname = reader.GetString(4);

                    Writer.DWord(charid);               // Friend CharID
                    Writer.Text(charname);              // Friend Name
                    Writer.DWord(model);                // Friend Model Type
                    if (groupname == "none")
                        Writer.Word(0);
                    else
                        Writer.Word(groupid);

                    if (status != 0)
                    {
                        Writer.Byte(0);                 // Friend is online
                    }
                    else
                    {
                        Writer.Byte(1);                 // Inverted, Friend is offline
                    }
                }
                reader.Close();
            }
            ms.Close();
            return Writer.GetBytes();
        }
Esempio n. 26
0
        public static byte[] ObjectSpawnJob(character c)
        {
            PacketWriter Writer = new PacketWriter();
            Writer.Create(Systems.SERVER_SOLO_SPAWN);

            /////////////////////////////////////////////////////// Character basic info
            #region Basic info
            Writer.DWord(c.Information.Model);
            Writer.Byte(c.Information.Volume);                      //Char Volume
            Writer.Byte(c.Information.Title);                       //Char Title
            Writer.Byte(c.Information.Pvpstate);                    //Pvp state
            if (c.Information.Pvpstate != 0) c.Information.PvP = true;
            Writer.Bool((c.Information.Level < 20 ? true : false)); //Beginners Icon

            Writer.Byte(c.Information.Slots);                       // Amount of items
            #endregion
            /////////////////////////////////////////////////////// Item info
            #region Item info
            Function.Items.PrivateItemPacket(Writer, c.Information.CharacterID, 8, 0,true);
            Writer.Byte(5);
            Function.Items.PrivateItemPacket(Writer, c.Information.CharacterID, 5, 1,true);
            Writer.Byte(0);
            #endregion
            /////////////////////////////////////////////////////// Character Location / id
            #region Location info / state
            Writer.DWord(c.Information.UniqueID);
            Writer.Byte(c.Position.xSec);
            Writer.Byte(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));
            Writer.Word(0);//angle
            Writer.Bool(c.Position.Walking);
            Writer.Byte(1); // walk:0 run:1 ;)

            if (c.Position.Walking)
            {
                Writer.Byte(c.Position.packetxSec);
                Writer.Byte(c.Position.packetySec);

                if (!DarkEmu_GameServer.File.FileLoad.CheckCave(c.Position.packetxSec, c.Position.packetySec))
                {
                    Writer.Word(c.Position.packetX);
                    Writer.Word(c.Position.packetZ);
                    Writer.Word(c.Position.packetY);
                }
                else
                {
                    if (c.Position.packetX < 0)
                    {
                        Writer.Word(c.Position.packetX);
                        Writer.Word(0xFFFF);
                    }
                    else
                    {
                        Writer.DWord(c.Position.packetX);
                    }

                    Writer.DWord(c.Position.packetZ);

                    if (c.Position.packetY < 0)
                    {
                        Writer.Word(c.Position.packetY);
                        Writer.Word(0xFFFF);
                    }
                    else
                    {
                        Writer.DWord(c.Position.packetY);
                    }
                }
            }
            else
            {
                Writer.Byte(1);
                Writer.Word(0);//angle
            }

            Writer.Byte((byte)(c.State.LastState == 128 ? 2 : 1));
            Writer.Byte(0);
            Writer.Byte(3);
            Writer.Byte((byte)(c.Information.Berserking ? 1 : 0));

            Writer.Float(c.Speed.WalkSpeed);
            Writer.Float(c.Speed.RunSpeed);
            Writer.Float(c.Speed.BerserkSpeed);

            Writer.Byte(c.Action.Buff.count);
            for (byte b = 0; b < c.Action.Buff.SkillID.Length; b++)
            {
                if (c.Action.Buff.SkillID[b] != 0)
                {
                    Writer.DWord(c.Action.Buff.SkillID[b]);
                    Writer.DWord(c.Action.Buff.OverID[b]);
                }
            }
            #endregion
            /////////////////////////////////////////////////////// Character Job information / name
            #region Job information & name
            Writer.Text(c.Job.Jobname);
            Writer.Byte(1);
            Writer.Byte(c.Job.level);//Level job
            Writer.Byte(c.Information.Level);//Level char
            Writer.Byte(0);

            if (c.Transport.Right)
            {
                Writer.Byte(1);
                Writer.Byte(0);
                Writer.DWord(c.Transport.Horse.UniqueID);
            }

            else
            {
                Writer.Byte(0);
                Writer.Byte(0);
            }

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

            if (c.Network.Guild.Guildid > 0)
            {
                Writer.Text(c.Network.Guild.Name);
            }
            else
            {
                Writer.Word(0);//No guild
            }

            Writer.Byte(0);
            Writer.Byte(0xFF);
            Writer.Byte(4);
            #endregion
            return Writer.GetBytes();
        }
Esempio n. 27
0
 /////////////////////////////////////////////////////////////////////////////////
 // Get matching degree stones for item
 /////////////////////////////////////////////////////////////////////////////////
 public List<int> GetStonesDegree(int itemid, character c)
 {
     try
     {
         List<int> stones = new List<int>();
         for (int i = 0; i < Data.ItemBase.Length; i++)
         {
             if (Data.ItemBase[i] != null)
             {
                 if (Data.ItemBase[i].Etctype == Global.item_database.EtcType.STONES && Data.ItemBase[i].Degree == Data.ItemBase[itemid].Degree)
                 {
                     if (i != 0)
                         stones.Add(i);
                 }
             }
         }
         return stones;
     }
     catch (Exception ex)
     {
         Systems.Debugger.Write(ex);
     }
     return null;
 }
Esempio n. 28
0
        public void AddObject(character c)
        {
            if (added % 10 == 0)
                this.StartData();
            /////////////////////////////////////////////////////// Character basic info
            #region Basic info
            buff_data[added / 10].DWord(c.Information.Model);
            buff_data[added / 10].Byte(c.Information.Volume);                      //Char Volume
            buff_data[added / 10].Byte(c.Information.Title);                       //Char Title
            buff_data[added / 10].Byte(c.Information.Pvpstate);                    //Pvp state
            if (c.Information.Pvpstate != 0) c.Information.PvP = true;
            buff_data[added / 10].Bool((c.Information.Level < 20 ? true : false)); //Beginners Icon
            buff_data[added / 10].Byte(c.Information.Slots);                       // Amount of items
            #endregion
            /////////////////////////////////////////////////////// Item info
            #region Item info
            Function.Items.PrivateItemPacket(buff_data[added / 10], c.Information.CharacterID, 8, 0,true);
            buff_data[added / 10].Byte(5);

            Function.Items.PrivateItemPacket(buff_data[added / 10], c.Information.CharacterID, 5, 1,true);
            buff_data[added / 10].Byte(0);
            #endregion
            /////////////////////////////////////////////////////// Character Location / id
            #region Location info / state
            buff_data[added / 10].DWord(c.Information.UniqueID);
            buff_data[added / 10].Byte(c.Position.xSec);
            buff_data[added / 10].Byte(c.Position.ySec);
            buff_data[added / 10].Float(Formule.packetx(c.Position.x, c.Position.xSec));
            buff_data[added / 10].Float(c.Position.z);
            buff_data[added / 10].Float(Formule.packety(c.Position.y, c.Position.ySec));
            buff_data[added / 10].Word(0);
            buff_data[added / 10].Bool(c.Position.Walking);
            buff_data[added / 10].Byte(1); // walk:0 run:1 ;)
            if (c.Position.Walking)
            {
                buff_data[added / 10].Byte(c.Position.packetxSec);
                buff_data[added / 10].Byte(c.Position.packetySec);

                if (!DarkEmu_GameServer.File.FileLoad.CheckCave(c.Position.packetxSec, c.Position.packetySec))
                {
                    buff_data[added / 10].Word(c.Position.packetX);
                    buff_data[added / 10].Word(c.Position.packetZ);
                    buff_data[added / 10].Word(c.Position.packetY);
                }
                else
                {
                    if(c.Position.packetX < 0)
                    {
                        buff_data[added / 10].Word(c.Position.packetX);
                        buff_data[added / 10].Word(0xFFFF);
                    }
                    else
                    {
                        buff_data[added / 10].DWord(c.Position.packetX);
                    }

                    buff_data[added / 10].DWord(c.Position.packetZ);

                    if(c.Position.packetY < 0)
                    {
                        buff_data[added / 10].Word(c.Position.packetY);
                        buff_data[added / 10].Word(0xFFFF);
                    }
                    else
                    {
                        buff_data[added / 10].DWord(c.Position.packetY);
                    }
                }
            }
            else
            {
                buff_data[added / 10].Byte(0);
                buff_data[added / 10].Word(0);
            }

            buff_data[added / 10].Byte((byte)(c.State.LastState == 128 ? 2 : 1));
            buff_data[added / 10].Byte(0);
            buff_data[added / 10].Byte(1);
            buff_data[added / 10].Byte((byte)(c.Information.Berserking ? 1 : 0));

            buff_data[added / 10].Float(c.Speed.WalkSpeed);
            buff_data[added / 10].Float(c.Speed.RunSpeed);
            buff_data[added / 10].Float(c.Speed.BerserkSpeed);

            buff_data[added / 10].Byte(c.Action.Buff.count);
            for (byte b = 0; b < c.Action.Buff.SkillID.Length; b++)
            {
                if (c.Action.Buff.SkillID[b] != 0)
                {
                    buff_data[added / 10].DWord(c.Action.Buff.SkillID[b]);
                    buff_data[added / 10].DWord(c.Action.Buff.OverID[b]);
                }
            }
            #endregion
            /////////////////////////////////////////////////////// Character Job information / name
            #region Job information & name
            //if (c.Jobinformation.Onjob)
            //{
            //    buff_data.Text(c.Jobinformation.Jobname);
            //    buff_data.Byte(1);
            //}
            // else if (!c.Jobinformation.Onjob)
            //{
            //    buff_data.Text(c.Information.Name);
            //    buff_data.Byte(2);
            //}
            buff_data[added / 10].Text(c.Information.Name);
            buff_data[added / 10].Byte(2);
            buff_data[added / 10].Byte(1);
            buff_data[added / 10].Byte(0);

            if (c.Transport.Right)
            {
                buff_data[added / 10].Byte(1);
                buff_data[added / 10].Byte(0);
                buff_data[added / 10].DWord(c.Transport.Horse.UniqueID);
            }

            else
            {
                buff_data[added / 10].Byte(0);
                buff_data[added / 10].Byte(0);
            }

            buff_data[added / 10].Byte(0);

            if (c.Network.Stall != null && c.Network.Stall.ownerID == c.Information.UniqueID)
                buff_data[added / 10].Byte(0x04);
            else
                buff_data[added / 10].Byte(0);

            buff_data[added / 10].Byte(0);

            if (c.Network.Guild.Guildid != 0)
            {
                buff_data[added / 10].Text(c.Network.Guild.Name);
                if (c.Network.Guild.GrantName != "")
                {
                    buff_data[added / 10].DWord(0);
                    buff_data[added / 10].Text(c.Network.Guild.GrantName);
                }
                else
                {
                    buff_data[added / 10].DWord(0);
                    buff_data[added / 10].Word(0);
                }
            }
            else
            {
                buff_data[added / 10].Word(0);
                buff_data[added / 10].DWord(0);
                buff_data[added / 10].Word(0);
            }

            buff_data[added / 10].DWord(0);  //GUILD AMBLEM
            buff_data[added / 10].DWord(0);  //UNION ID
            buff_data[added / 10].DWord(0);

            buff_data[added / 10].Byte(0); //myb it is 0 or 1
            buff_data[added / 10].Byte(0);

            if (c.Network.Stall != null && c.Network.Stall.ownerID == c.Information.UniqueID)
            {
                buff_data[added / 10].Text3(c.Network.Stall.StallName);
                buff_data[added / 10].DWord(c.Information.StallModel);
            }

            buff_data[added / 10].Byte(0);

            #endregion
            /////////////////////////////////////////////////////// Pvp state
            #region pvpstate
            if (c.Information.Pvpstate > 0 || c.Information.Murderer)
            {
                buff_data[added / 10].Byte(0x22);
            }
            else
            {
                buff_data[added / 10].Byte(0xFF);
            }
            #endregion
            #region Pvpstate for jobs etc
            /*if (c.Jobinformation.Onjob)
            {
                buff_data.Byte(0xFF);
                buff_data.Byte(1);
            }
            else
            {
                buff_data.Byte(4);
            }
             */
            #endregion
            added++;
        }
Esempio n. 29
0
        void LoadTicket(character c)
        {
            //We wrap our function inside a catcher
            try
            {
                //First we get our data from the database.
                MsSQL ms = new MsSQL("SELECT * FROM character_tickets WHERE owner ='" + c.Information.CharacterID + "' AND active='1'");
                //Check if we have a active ticket
                int CheckActive = ms.Count();

                //Now if we have one active we continue
                if (CheckActive == 1)
                {
                    //Open new sql data reader
                    using (SqlDataReader reader = ms.Read())
                    {
                        //While sql data reader is reading
                        while (reader.Read())
                        {
                            //Set our ticket to active so they cannot use double premium tickets
                            Character.Premium.Active = true;
                            //We can use Character.Information.CharacterID but on safe side we read from db to make sure.
                            Character.Premium.OwnerID = reader.GetInt32(1);
                            //Get the id information to calculate the % gaining and type etc etc..
                            Character.Premium.TicketItemID = reader.GetInt32(2);
                            //Get unique id (incase we need it).
                            Character.Premium.TicketID = reader.GetInt32(0);
                            //Get the start time of the ticket
                            Character.Premium.StartTime = reader.GetDateTime(3);
                        }
                    }
                    //Close our data reader
                    ms.Close();
                    //Calculate remaining time left.
                    TimeSpan Timecheck = Convert.ToDateTime(Character.Premium.StartTime) - DateTime.Now;
                    double TimeRemaining = Timecheck.TotalMinutes;
                    //Finally we send our packet to the user (Icon).
                    client.Send(Packet.PremiumTicketData(Character.Premium.TicketItemID, Convert.ToInt32(TimeRemaining)));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Premium ticket loading error {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }