Example #1
0
 public static void WriteRefinement(WorldCharacter wchar, Packet pPacket)
 {
     //TODO: pPacket.WriteByte(Convert.ToByte(this.Inventory.GetEquippedUpgradesByType(ItemType.Weapon) << 4 | this.Inventory.GetEquippedUpgradesByType(ItemType.Shield)));
     pPacket.WriteByte(0xff); //this must be the above, but currently not cached
     pPacket.WriteByte(0xff);    		// UNK
     pPacket.WriteByte(0xff);    		// UNK
 }
Example #2
0
 public static void WriteLook(WorldCharacter wchar, Packet packet)
 {
     packet.WriteByte(Convert.ToByte(0x01 | (wchar.Character.Job << 2) | (Convert.ToByte(wchar.Character.LookInfo.Male)) << 7));
     packet.WriteByte(wchar.Character.LookInfo.Hair);
     packet.WriteByte(wchar.Character.LookInfo.HairColor);
     packet.WriteByte(wchar.Character.LookInfo.Face);
 }
Example #3
0
        public GuildAcademyMember(GuildAcademy Academy, WorldCharacter Character, DataRow Row)
        {
            this.Academy = Academy;
            this.Character = Character;

            Load(Row);
        }
Example #4
0
 public GuildAcademyMember(GuildAcademy Academy, WorldCharacter Character, DateTime RegisterDate, GuildAcademyRank Rank)
 {
     this.Academy = Academy;
     this.Character = Character;
     this.RegisterDate = RegisterDate;
     this.Rank = Rank;
 }
Example #5
0
 /// <summary>
 ///     Updates friend status using a <see cref="WorldCharacter" /> object.
 /// </summary>
 /// <param name="pCharacter">The WorldCharacter object with the new data.</param>
 public void Update(WorldCharacter pCharacter)
 {
     Map      = GetMapname(pCharacter.Character.PositionInfo.Map);
     Job      = pCharacter.Character.Job;
     Level    = pCharacter.Character.CharLevel;
     IsOnline = ClientManager.Instance.IsOnline(pCharacter.Character.Name);
 }
Example #6
0
        public void LoadBasic(WorldCharacter pChar)
        {
            try
            {
                locker.WaitOne();
                DataTable equips = null;
                using (var dbClient = Program.DatabaseManager.GetClient())
                {
                    equips = dbClient.ReadDataTable("SELECT * FROM equips WHERE Owner=" + pChar.ID + " AND Slot < 0");
                }

                if (equips != null)
                {
                    foreach (DataRow row in equips.Rows)
                    {
                        var loaded = Equip.LoadEquip(row);
                        EquippedItems.Add(loaded);
                    }
                }
            }
            finally
            {
                locker.ReleaseMutex();
            }
        }
Example #7
0
        public void ChangeDropType(WorldCharacter pBy, byte pDropState)
        {
            if (pBy.Character.Name != Master.Name)
            {
                return;         // only the master may change drop state!
            }
            this.DropState = (DropState)pDropState;

            UpdateDropStateToMembers();
        }
Example #8
0
 public static bool GetLoggedInCharacter(string Name, out WorldCharacter pChar)
 {
     Networking.WorldClient pClient = ClientManager.Instance.GetClientByCharname(Name);
        pChar = null;
     if (pClient != null)
     {
         pChar = pClient.Character;
         return true;
     }
     return false;
 }
Example #9
0
 public void ApprenticeLevelUP(WorldCharacter pChar)
 {
     MasterMember pMember = pChar.MasterList.Find(d => d.IsMaster == true);
     if (pMember != null)
     {
         //Todo Add Break if the difference is greater than 5
         AddApprenticeReward(pChar);
         MasterMember.UpdateLevel(pChar.Character.CharLevel, pChar.Character.Name);
         if(pMember.pMember.Character.Client != null)
         SendApprenticeLevelUp(pMember.pMember,pChar.Character.Name,pChar.Character.CharLevel);
     }
 }
Example #10
0
 public void InviteNewMember(WorldCharacter pSender, string pTarget)
 {
     if (!ClientManager.Instance.IsOnline(pTarget))
     {
         return;
     }
     if (Master.Name != pSender.Character.Name)
     {
         return;                                            // only the master may invite new Members
     }
     GroupManager.Instance.Invite(pSender.Client, pTarget); // trololol
 }
Example #11
0
        public static Friend Create(WorldCharacter pCharacter)
        {
            Friend friend = new Friend
            {
                ID = pCharacter.Character.ID,
                Name = pCharacter.Character.Name,
                Level = pCharacter.Character.CharLevel,
                Job = pCharacter.Character.Job,
                Map = GetMapname(pCharacter.Character.PositionInfo.Map),
                UniqueID = (uint)pCharacter.Character.AccountID,
                IsOnline = pCharacter.IsIngame,
                client = pCharacter.Client,
            };

            return friend;
        }
Example #12
0
        public static Friend Create(WorldCharacter pCharacter)
        {
            var friend = new Friend
            {
                ID       = pCharacter.Character.ID,
                Name     = pCharacter.Character.Name,
                Level    = pCharacter.Character.CharLevel,
                Job      = pCharacter.Character.Job,
                Map      = GetMapname(pCharacter.Character.PositionInfo.Map),
                UniqueID = (uint)pCharacter.Character.AccountID,
                IsOnline = pCharacter.IsIngame,
                client   = pCharacter.Client
            };

            return(friend);
        }
Example #13
0
        public Friend AddFriend(WorldCharacter pChar)
        {
            Friend pFrend   = pChar.friends.Find(f => f.Name == pChar.Character.Name);
            Friend pFrendby = pChar.friendsby.Find(f => f.Name == pChar.Character.Name);
            Friend friend   = Friend.Create(pChar);

            if (pFrend != null)
            {
                Program.DatabaseManager.GetClient().ExecuteQuery("INSERT INTO Friends (CharID,FriendID,Pending) VALUES ('" + pChar.Character.ID + "','" + this.Character.ID + "','1')");
            }
            if (pFrendby == null)
            {
                this.friendsby.Add(friend);
            }
            Program.DatabaseManager.GetClient().ExecuteQuery("INSERT INTO Friends (CharID,FriendID) VALUES ('" + this.Character.ID + "','" + pChar.Character.ID + "')");
            friends.Add(friend);

            return(friend);
        }
Example #14
0
 public static void WriteEquipment(WorldCharacter wchar, Packet packet)
 {
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.Helm));
     packet.WriteUShort(Settings.Instance.ShowEquips ? wchar.GetEquipBySlot(ItemSlot.Weapon) : (ushort)0xffff);
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.Armor));
     packet.WriteUShort(Settings.Instance.ShowEquips ? wchar.GetEquipBySlot(ItemSlot.Weapon2) : (ushort)0xffff);
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.Pants));
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.Boots));
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.CostumeBoots));
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.CostumePants));
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.CostumeArmor));
     packet.Fill(6, 0xff);              // UNK
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.Glasses));
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.CostumeHelm));
     packet.Fill(2, 0xff);              // UNK
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.CostumeWeapon));
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.Wing));
     packet.Fill(2, 0xff);              // UNK
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.Tail));
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.Pet));
 }
Example #15
0
        public static void WriteBasicCharInfo(WorldCharacter wchar, Packet packet)
        {
            packet.WriteInt(wchar.Character.ID); //charid
            packet.FillPadding(wchar.Character.Name, 0x10);
            packet.WriteInt(0);//unk
            packet.WriteShort((short)wchar.Character.CharLevel); //level
            packet.WriteByte(wchar.Character.Slot);
            MapInfo mapinfo;
            if (!DataProvider.Instance.Maps.TryGetValue(wchar.Character.PositionInfo.Map, out mapinfo))
            {
                Log.WriteLine(LogLevel.Warn, "{0} has an invalid MapID ({1})", wchar.Character.Name, wchar.Character.PositionInfo.Map);
                wchar.Character.PositionInfo.Map = 0;
                packet.FillPadding(mapinfo.ShortName, 0x0D); //townname
            }
            else
            {
                packet.FillPadding(mapinfo.ShortName, 0x0D); //townname
            }

            //packet.WriteByte(0); // UNK
            packet.WriteInt(0); // Random seed
            WriteLook(wchar,packet);
            WriteEquipment(wchar,packet);
            WriteRefinement(wchar,packet);
            packet.WriteByte(0);

            packet.WriteByte(0xF0);
            packet.WriteByte(0xFF);//unk
            packet.WriteByte(0xFF);

            packet.FillPadding(mapinfo.ShortName, 0x0c);
            packet.WriteInt(0); //pos
            packet.WriteInt(0); //pos
            packet.WriteUShort(0xdb78);
            packet.WriteUShort(4910);//unk
            packet.WriteUShort(25600);
            packet.Fill(4, 0);
        }
Example #16
0
 public void LoadBasic(WorldCharacter pChar)
 {
     try
     {
         locker.WaitOne();
         DataTable equips = null;
         using (DatabaseClient dbClient = Program.DatabaseManager.GetClient())
         {
             equips = dbClient.ReadDataTable("SELECT * FROM equips WHERE Owner=" + pChar.ID + " AND Slot < 0");
         }
         if (equips != null)
         {
             foreach (DataRow row in equips.Rows)
             {
                 Equip loaded = Equip.LoadEquip(row);
                 EquippedItems.Add(loaded);
             }
         }
     }
     finally
     {
         locker.ReleaseMutex();
     }
 }
Example #17
0
        public void AddMember(WorldCharacter Character, GuildAcademyRank Rank)
        {
            if (Character.Character.CharLevel < 10
                || Character.Character.CharLevel > 60)
                return;

            if (Character.IsInGuild
                || Character.IsInGuildAcademy)
            {
               Handlers.Handler38.SendAcademyResponse(Character.Client, Guild.Name, GuildAcademyResponse.AlreadyInAcademy);
                return;
            }

            lock (Guild.ThreadLocker)
            {
                if (Members.Count >= MaxMembers)
                {
                    Handlers.Handler38.SendAcademyResponse(Character.Client, Guild.Name, GuildAcademyResponse.AcademyFull);
                    return;
                }

                var registerDate = Program.CurrentTime;

                //add to sql
                using (var con = Program.DatabaseManager.GetClient().GetConnection())
                {
                    using (var cmd = con.CreateCommand())
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = "GuildAcademyMember_Create";

                        cmd.Parameters.Add(new MySqlParameter("@pGuildID", Guild.ID));
                        cmd.Parameters.Add(new MySqlParameter("@pCharacterID", Character.ID));
                        cmd.Parameters.Add(new MySqlParameter("@pRegisterDate", registerDate));
                        cmd.Parameters.Add(new MySqlParameter("@pRank", (byte)Rank));

                        switch (Convert.ToInt32(cmd.ExecuteScalar()))
                        {
                            case 0:

                                var member = new GuildAcademyMember(this, Character, registerDate, Rank);

                                //Add to list
                                Members.Add(member);

                                //Update character
                                Character.Guild = Guild;
                                Character.GuildAcademy = this;
                                Character.GuildAcademyMember = member;

                                //send packets to client
                                Handlers.Handler38.SendAcademyResponse(Character.Client, Guild.Name, GuildAcademyResponse.JoinSuccess);
                                using (var packet = new Packet(SH4Type.CharacterGuildacademyinfo))
                                {
                                    WriteInfo(packet);

                                    Character.Client.SendPacket(packet);
                                }

                                member.BroadcastGuildName();
                                using (var packet = new Packet(SH38Type.AcademyMemberJoined))
                                {
                                    member.WriteInfo(packet);

                                    Broadcast(packet);
                                    Guild.Broadcast(packet);
                                }

                                //send packet to zones
                                using (var packet = new InterPacket(InterHeader.ZONE_AcademyMemberJoined))
                                {
                                    packet.WriteInt(Guild.ID);
                                    packet.WriteInt(Character.ID);
                                    packet.WriteDateTime(registerDate);

                                    ZoneManager.Instance.Broadcast(packet);
                                }

                                break;

                            case -1:
                                Handlers.Handler38.SendAcademyResponse(Character.Client, Guild.Name, GuildAcademyResponse.AlreadyInAcademy);
                                return;
                            case -2:
                            default:
                                Handlers.Handler38.SendAcademyResponse(Character.Client, Guild.Name, GuildAcademyResponse.DatabaseError);
                                return;
                        }
                    }
                }
            }
        }
Example #18
0
        public void InviteNewMember(WorldCharacter pSender, string pTarget)
        {
            if (!ClientManager.Instance.IsOnline(pTarget))
                return;
            if (Master.Name != pSender.Character.Name)
                return;		// only the master may invite new Members

            GroupManager.Instance.Invite(pSender.Client, pTarget); // trololol
        }
Example #19
0
        public Friend AddFriend(WorldCharacter pChar)
        {
            Friend pFrend = pChar.friends.Find(f => f.Name == pChar.Character.Name);
            Friend pFrendby = pChar.friendsby.Find(f => f.Name == pChar.Character.Name);
            Friend friend = Friend.Create(pChar);
            if (pFrend != null)
            {
                Program.DatabaseManager.GetClient().ExecuteQuery("INSERT INTO Friends (CharID,FriendID,Pending) VALUES ('" + pChar.Character.ID + "','" + this.Character.ID + "','1')");

            }
            if (pFrendby == null)
            {
                this.friendsby.Add(friend);
            }
            Program.DatabaseManager.GetClient().ExecuteQuery("INSERT INTO Friends (CharID,FriendID) VALUES ('" + this.Character.ID + "','" + pChar.Character.ID + "')");
            friends.Add(friend);

            return friend;
        }
Example #20
0
 public static void InvokeChangeMapEvent(WorldCharacter pChar)
 {
     OnCharacterChangeMap.Invoke(pChar);
 }
Example #21
0
 /// <summary>
 /// Updates friend status using a <see cref="WorldCharacter" /> object.
 /// </summary>
 /// <param name="pCharacter">The WorldCharacter object with the new data.</param>
 public void Update(WorldCharacter pCharacter)
 {
     this.Map = GetMapname(pCharacter.Character.PositionInfo.Map);
     this.Job = pCharacter.Character.Job;
     this.Level = pCharacter.Character.CharLevel;
     this.IsOnline = ClientManager.Instance.IsOnline(pCharacter.Character.Name);
 }
Example #22
0
 public static void invokeLoggetInEvent(WorldCharacter pChar)
 {
     OnCharacterLogin.Invoke(pChar);
 }
Example #23
0
 private static void SendCharOKResponse(WorldClient client, WorldCharacter character)
 {
     using (var packet = new Packet(SH5Type.CharCreationOK))
     {
         packet.WriteByte(1);
         PacketHelper.WriteBasicCharInfo(character, packet);
         client.SendPacket(packet);
     }
 }
Example #24
0
 public void BroadcastInRange(WorldCharacter pChar, Packet pPacket, bool ToAll)
 {
     pChar.BroucastPacket(pPacket);
 }
Example #25
0
 public OnCharacterLoginArgs(WorldCharacter pChar,OnCharacterLoginArgs args)
 {
 }
Example #26
0
        private void AddApprenticeReward(WorldCharacter pChar)
        {
            List<MasterRewardItem> Rewards = DataProvider.Instance.MasterRewards.FindAll(d => (byte)d.Job == pChar.Character.Job && d.Level == pChar.Character.CharLevel);
            MasterRewardItem rr = new MasterRewardItem
            {
                ItemID = 250,
                Count = 1,
            };
            ZoneConnection Conn = Program.GetZoneByMap(pChar.Character.PositionInfo.Map);
            if (Conn == null)
                return;

            using (var packet = new Packet(SH37Type.SendApprenticeReward))
            {

                packet.WriteByte((byte)Rewards.Count);//count
                foreach (var pReward in Rewards)
                {
                    packet.WriteUShort(pReward.ItemID);
                    packet.WriteByte(pReward.Count);
                    packet.WriteByte(0);//unk
                    InterHandler.SendAddReward(Conn, pReward.ItemID,pReward.Count,pChar.Character.Name);
                }
                pChar.Client.SendPacket(packet);
            }
        }
Example #27
0
        public static void SendGetCharacterBroaucast(WorldCharacter pChar,FiestaLib.Networking.Packet pPacket)
        {
            ZoneConnection conn = Program.GetZoneByMap(pChar.Character.PositionInfo.Map);
            using (var packet = new InterPacket(InterHeader.GetBroadcastList))
            {

                packet.WriteString(pChar.Character.Name, 16);
                packet.WriteInt(pPacket.ToNormalArray().Length);
                packet.WriteBytes(pPacket.ToNormalArray());
                conn.SendPacket(packet);
            }
        }
Example #28
0
 public static void OneLoadGuildInCharacter(WorldCharacter pChar)
 {
     DatabaseClient dbClient = Program.DatabaseManager.GetClient();
      int GuildID = dbClient.ReadInt32("SELECT GuildID FROM guildmembers WHERE CharID='" + pChar.ID + "'");
      int AcademyID = dbClient.ReadInt32("SELECT GuildID FROM guildacademymembers WHERE CharID='" + pChar.ID + "'");
     if(AcademyID > 0 && GuildID == 0)
     {
         Data.Guilds.Guild g;
         if (!Data.Guilds.GuildManager.GetGuildByID(AcademyID, out g))
             return;
         pChar.GuildAcademy = g.Academy;
         pChar.IsInGuildAcademy = true;
     }
     else if(GuildID > 0 && AcademyID == 0)
     {
         Data.Guilds.Guild g;
         if (!Data.Guilds.GuildManager.GetGuildByID(GuildID, out g))
             return;
         pChar.Guild = g;
         pChar.GuildAcademy = g.Academy;
         pChar.IsInGuild = true;
         Data.Guilds.GuildMember GuildMember = g.Members.Find(m => m.Character.Character.Name == pChar.Character.Name);
         GuildMember.Character.Client = pChar.Client;
     }
 }
Example #29
0
 public static void InvokeLoggetOutInEvent(WorldCharacter pChar)
 {
     OnCharacterLogout.Invoke(pChar);
 }
Example #30
0
        public void ChangeDropType(WorldCharacter pBy, byte pDropState)
        {
            if (pBy.Character.Name != Master.Name)
                return;		// only the master may change drop state!
            this.DropState = (DropState)pDropState;

            UpdateDropStateToMembers();
        }
Example #31
0
 public static void InvokdeIngame(WorldCharacter pChar)
 {
     CharacterLogin.Invoke(pChar);
 }
Example #32
0
 public static void OnetestmapChange(WorldCharacter pChar)
 {
     Console.WriteLine(pChar.Character.PositionInfo.Map);
     Console.WriteLine(pChar.Character.PositionInfo.XPos);
     Console.WriteLine(pChar.Character.PositionInfo.YPos);
 }
Example #33
0
        public WorldCharacter CreateCharacter(string name, byte slot, byte hair, byte color, byte face, Job job, bool ismale)
        {
            if (Characters.ContainsKey(slot) || slot > 5)
                return null;
            //TODO: check if hair etc are actual beginner ones! (premium hack)
            //NOTE: Check the SHN's for this -> Moved to database
            BaseStatsEntry stats = DataProvider.Instance.JobBasestats[job];
            if (stats == null)
            {
                //NOTE be serious.. please
                // Log.WriteLine(LogLevel.Warn, "Houston, we have a problem! Jobstats not found for job {0}", job.ToString());
                Log.WriteLine(LogLevel.Error, "Jobstats not found for job {0}", job.ToString());
                return null;
            }
            Database.Storage.LookInfo newLook = new Database.Storage.LookInfo();
            Database.Storage.PositionInfo newPos = new Database.Storage.PositionInfo();
            Database.Storage.Character newchar = new Database.Storage.Character();
            newchar.AccountID = this.AccountID;
            newchar.CharLevel = 1;
            newchar.Name = name;
            newLook.Face = face;
            newLook.Hair = hair;
            newLook.HairColor = color;
            newchar.Job = (byte)job;
            newLook.Male = ismale;
            newchar.Slot = slot;
            newPos.XPos = 7636;
            newPos.YPos = 4610;
            newchar.HP = (short)stats.MaxHP;
            newchar.SP = (short)stats.MaxSP;
            newchar.HPStones = (short)stats.MaxHPStones;
            newchar.SPStones = (short)stats.MaxSPStones;
            newchar.LookInfo = newLook;
            newchar.PositionInfo = newPos;
            int charID = newchar.ID;
             DatabaseClient client = Program.DatabaseManager.GetClient();

             string query =
                 "INSERT INTO `characters` " +
                 "(`AccountID`,`Name`,`MasterJoin`,`Slot`,`Job`,`Male`,`Hair`,`HairColor`,`Face`," +
                 " `QuickBar`, `QuickBarState`, `ShortCuts`, `GameSettings`, `ClientSettings`) " +
                 "VALUES " +
                     "('" + newchar.AccountID +
                     "', '" + newchar.Name +
                     "', '" + DateTime.Now.ToDBString() +
                        "', " +		newchar.Slot +
                        ", " +		newchar.Job  +
                        ", " +		Convert.ToByte(newchar.LookInfo.Male) +
                        ", " +		newchar.LookInfo.Hair +
                        ", " +		newchar.LookInfo.HairColor +
                        ", " +		newchar.LookInfo.Face +
                        ", " +      "0" +
                        ", " +      "0" +
                        ", " +      "0" +
                        ", " +      "0" +
                        ", " +      "0" +
                        ")";
                client.ExecuteQuery(query);

            WorldCharacter tadaa = new WorldCharacter(newchar,this);
            ushort begineqp = GetBeginnerEquip(job);

            if (begineqp > 0)
            {
                sbyte eqp_slot = (sbyte)((job == Job.Archer) ? -10 : -12); //, (job == Job.Archer) ? (byte)12 : (byte)10, begineqp)
                Equip eqp = new Equip((uint)newchar.ID, begineqp, eqp_slot);
                tadaa.Inventory.AddToEquipped(eqp);
                client.ExecuteQuery("INSERT INTO equips (owner,slot,EquipID) VALUES ('"+tadaa.ID+"','"+eqp_slot+"','"+eqp.EquipID+"')");
            }
            Characters.Add(slot, tadaa);
            return tadaa;
        }
Example #34
0
 public static void invokeLevelUp(WorldCharacter pChar)
 {
     OnCharacterLevelUp.Invoke(pChar);
 }
Example #35
0
 public void RemoveMasterMember(WorldCharacter pChar,string name)
 {
     MasterMember pMember = pChar.MasterList.Find(d => d.pMemberName == name);
     WorldClient pClient = ClientManager.Instance.GetClientByCharname(name);
     if (pClient != null)
     {
         SendApprenticeRemoveMaster(pClient, pMember.pMemberName);
         pClient.Character.MasterList.Remove(pMember);
     }
     pMember.RemoveFromDatabase();
     pMember.RemoveFromDatabase(pChar.Character.ID, pMember.pMemberName);
     pChar.MasterList.Remove(pMember);
     pChar.UpdateMasterJoin();
 }
Example #36
0
 public bool GetCharacterByID(int ID, out WorldCharacter pChar)
 {
     World.Networking.WorldClient pclient = ClientManager.Instance.GetClientByCharID(ID);
        if (pclient != null)
        {
        pChar = pclient.Character;
        return true;
        }
        else
        {
        pChar = null;
       Character DBpChar  =  ReadMethods.ReadCharObjectByIDFromDatabase(ID,Program.DatabaseManager);
       WorldCharacter ReaderChar = new WorldCharacter(DBpChar, null);
       pChar = ReaderChar;
       if (DBpChar == null)
       {
           return false;
       }
       return true;
        }
 }