public Character_items Create(int CharacterId) { CharItem = new Character_items(); CharItem.CharacterId = CharacterId; CharItem.Counts = _Count; CharItem.Entry = Info.Entry; CharItem.ModelId = _ModelId; CharItem.SlotId = _SlotId; CharMgr.CreateItem(CharItem); return(CharItem); }
static public void DeleteItem(Character_items Itm) { Log.Info("DeleteItem", "Guid=" + Itm.Guid + ",CharId=" + Itm.CharacterId); lock (_Items) { if (_CharItems.ContainsKey(Itm.CharacterId)) { _CharItems[Itm.CharacterId].Remove(Itm); } _Items[Itm.Guid] = null; } CharMgr.Database.DeleteObject(Itm); }
public bool Load(Character_items Item) { if (Item == null) { return(false); } Info = WorldMgr.GetItem_Info(Item.Entry); if (Info == null) { Log.Error("ItemInterface", "Load : Info==null,Entry=" + Item.Entry); return(false); } CharItem = Item; return(true); }
static public bool CreateItem(Character_items Item) { lock (_Items) for (long i = 0; i < _Items.Length; ++i) { if (_Items[i] == null) { Item.Guid = i; LoadItem(Item); Database.AddObject(Item); return(true); } } Log.Error("CreateItem", "Maximum number of items reaches !"); return(false); }
static public void LoadItem(Character_items CharItem) { lock (_Items) { _Items[CharItem.Guid] = CharItem; if (!_CharItems.ContainsKey(CharItem.CharacterId)) { _CharItems.Add(CharItem.CharacterId, new List <Character_items>() { CharItem }); } else { _CharItems[CharItem.CharacterId].Add(CharItem); } } }
static public IList <Character_mail> GetCharMail(int characterId) { IList <Character_mail> Mails = Database.SelectObjects <Character_mail>(string.Format("CharacterId = {0}", characterId)); if (Mails != null) { foreach (Character_mail Mail in Mails) { foreach (uint Guid in Mail.ItemsReq) { Character_items Req = _Items[Guid]; if (Req != null) { Mail.ItemsReqInfo.Add(Req); } } } } return(Mails); }
static public void F_CREATE_CHARACTER(BaseClient client, PacketIn packet) { GameClient cclient = client as GameClient; CreateInfo Info; Info.slot = packet.GetUint8(); Info.race = packet.GetUint8(); Info.career = packet.GetUint8(); Info.sex = packet.GetUint8(); Info.model = packet.GetUint8(); Info.NameSize = packet.GetUint16(); packet.Skip(2); byte[] Traits = new byte[8]; packet.Read(Traits, 0, Traits.Length); packet.Skip(7); string Name = packet.GetString(Info.NameSize); if (!CharMgr.NameIsUsed(Name)) { CharacterInfo CharInfo = CharMgr.GetCharacterInfo(Info.career); if (CharInfo == null) { Log.Error("ON_CREATE", "Can not find career :" + Info.career); return; } Log.Success("OnCreate", "Creating new Character : " + Name); Character Char = new Character(); Char.AccountId = cclient._Account.AccountId; Char.bTraits = Traits; Char.Career = Info.career; Char.CareerLine = CharInfo.CareerLine; Char.ModelId = Info.model; Char.Name = Name; Char.Race = Info.race; Char.Realm = CharInfo.Realm; Char.RealmId = Program.Rm.RealmId; Char.Sex = Info.sex; if (!CharMgr.CreateChar(Char)) { Log.Error("CreateCharacter", "Hack : can not create more than 10 characters!"); return; } Character_items Citm = null; CharacterInfo_item[] Items = CharMgr.GetCharacterInfoItem(Char.CareerLine); for (int i = 0; i < Items.Length; ++i) { if (Items[i] == null) { continue; } Citm = new Character_items(); Citm.Counts = Items[i].Count; Citm.CharacterId = Char.CharacterId; Citm.Entry = Items[i].Entry; Citm.ModelId = Items[i].ModelId; Citm.SlotId = Items[i].SlotId; CharMgr.CreateItem(Citm); } Character_value CInfo = new Character_value(); CInfo.CharacterId = Char.CharacterId; CInfo.Level = 1; CInfo.Money = 0; CInfo.Online = false; CInfo.RallyPoint = CharInfo.RallyPt; CInfo.RegionId = CharInfo.Region; CInfo.Renown = 0; CInfo.RenownRank = 1; CInfo.RestXp = 0; CInfo.Skills = CharInfo.Skills; CInfo.Speed = 100; CInfo.WorldO = CharInfo.WorldO; CInfo.WorldX = CharInfo.WorldX; CInfo.WorldY = CharInfo.WorldY; CInfo.WorldZ = CharInfo.WorldZ; CInfo.Xp = 0; CInfo.ZoneId = CharInfo.ZoneId; CharMgr.Database.AddObject(CInfo); Char.Value = new Character_value[1] { CInfo }; } PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_RESPONSE); Out.WritePascalString(cclient._Account.Username); cclient.SendTCP(Out); }
public static byte[] BuildCharactersList(int AccountId) { Log.Debug("BuildCharactersList", "AcocuntId = " + AccountId); Character[] Chars = GetAccountChar(AccountId)._Chars; int count = 0; PacketOut Out = new PacketOut(0); Out.Position = 0; Character Char = null; for (int k = 0; k < MAX_SLOT; ++k) { Char = Chars[k]; if (Char != null) { List <Character_items> Items = CharMgr.GetItemChar(Char.CharacterId); /**** char slot start ****/ Out.FillString(Char.Name, 48); // name Out.WriteByte(Char.Value[0].Level); // Level Out.WriteByte(Char.Career); //career Out.WriteByte(Char.Realm); // realm Out.WriteByte(Char.Sex); // gender Out.WriteUInt16R(Char.ModelId); //model id Out.WriteUInt16R(Char.Value[0].ZoneId); // zone id Out.Fill(0, 12); // unk Character_items Item = null; for (UInt16 SlotId = 14; SlotId < 30; ++SlotId) { Item = Items.Find(item => item != null && item.SlotId == SlotId); if (Item == null) { Out.WriteInt32(0); Out.WriteInt32(0); } else { Out.WriteInt32((int)Item.ModelId); Out.WriteUInt16R(0); // primary dye Out.WriteUInt16R(0); // secondary dye } } Out.WriteUInt32(0x00); // 0x00000000 for (int i = 0; i < 4; i++) { Out.WriteUInt32(0xFF000000); Out.WriteUInt32(0x00); } Out.WriteUInt32(0xFF000000); //weapons for (UInt16 SlotId = 10; SlotId < 13; ++SlotId) { Item = Items.Find(item => item != null && item.SlotId == SlotId); if (Item == null) { Out.WriteUInt32(0); } else { Out.WriteUInt16R((ushort)Item.ModelId); Out.WriteUInt16(0); } } Out.Fill(0, 8); Out.WriteUInt16(0xFF00); Out.WriteByte(0); Out.WriteByte(Char.Race); // char slot position Out.WriteUInt16(0x00); //unk /* //Traits [8 bytes] * Out.WriteByte(1); //face * Out.WriteByte(4); //jewel * Out.WriteByte(4); //scar * Out.WriteByte(0); //hair * Out.WriteByte(3); //hair color * Out.WriteByte(2); //skin color * Out.WriteByte(0); //eye color * Out.WriteByte(5); //metal color */ Out.Write(Char.bTraits, 0, Char.bTraits.Length); Out.Fill(0, 14); //unk count++; } } for (int i = 0; i < (MAX_SLOT - count); ++i) { Out.Write(new byte[284], 0, 284); } return(Out.ToArray()); }
static public byte[] BuildCharacters(int AccountId) { Log.Debug("BuildCharacters", "AcocuntId = " + AccountId); Character[] Chars = GetAccountChar(AccountId)._Chars; UInt16 Count = 0; // On Compte le nombre de personnages existant du joueur for (UInt16 c = 0; c < Chars.Length; ++c) { if (Chars[c] != null) { ++Count; } } PacketOut Out = new PacketOut(0); Out.Position = 0; Out.WriteUInt16(Count); Character Char = null; for (int i = 0; i < MAX_SLOT; ++i) { Char = Chars[i]; if (Char == null) { Out.Write(new byte[280], 0, 280); } else { List <Character_items> Items = CharMgr.GetItemChar(Char.CharacterId); Out.FillString(Char.Name, 48); Out.WriteByte(Char.Value[0].Level); Out.WriteByte(Char.Career); Out.WriteByte(Char.Realm); Out.WriteByte(Char.Sex); Out.WriteByte(Char.ModelId); Out.WriteUInt16(Char.Value[0].ZoneId); Out.Write(new byte[5], 0, 5); Character_items Item = null; for (UInt16 SlotId = 14; SlotId < 30; ++SlotId) { Item = Items.Find(item => item != null && item.SlotId == SlotId); if (Item == null) { Out.WriteUInt32(0); } else { Out.WriteUInt32R(Item.ModelId); } Out.Write(new byte[4], 0, 4); } Out.Write(new byte[6], 0, 6); for (int j = 0; j < 5; ++j) { Out.Write(new byte[6], 0, 6); Out.WriteUInt16(0xFF00); } for (UInt16 SlotId = 10; SlotId < 13; ++SlotId) { Item = Items.Find(item => item != null && item.SlotId == SlotId); Out.WriteUInt16(0); if (Item == null) { Out.WriteUInt16(0); } else { Out.WriteUInt16R((ushort)Item.ModelId); } } Out.Write(new byte[10], 0, 10); Out.WriteUInt16(0xFF00); Out.WriteByte(0); Out.WriteByte(Char.Race); Out.WriteUInt16(0); Out.Write(Char.bTraits, 0, Char.bTraits.Length); Out.Write(new byte[10], 0, 10); } } return(Out.ToArray()); }
static public void F_MAIL(BaseClient client, PacketIn packet) { GameClient cclient = client as GameClient; if (!cclient.IsPlaying() || !cclient.Plr.IsInWorld()) { return; } Player Plr = cclient.Plr; byte Type = packet.GetUint8(); switch (Type) { case 0: // Mailbox closed { } break; case 1: // Mail sent { Plr.MlInterface.BuildMail(packet); } break; case 2: // Open mail case 3: // Return mail case 4: // Delete mail case 5: // Mark as read/unread case 7: // Take Item case 8: // Take money { byte Page = packet.GetUint8(); UInt32 Guid = ByteOperations.ByteSwap.Swap(packet.GetUint32()); Character_mail Mail = Plr.MlInterface.GetMail(Guid); switch (Type) { case 2: if (!Mail.Opened) { Mail.Opened = true; CharMgr.SaveMail(Mail); Plr.MlInterface.SendMailCounts(); Plr.MlInterface.SendMailBox(); } Plr.MlInterface.SendMail(Mail); break; case 3: //TODO Plr.MlInterface.SendResult(GameData.MailResult.TEXT_MAIL_RESULT11); break; case 4: Plr.MlInterface.RemoveMail(Mail); Plr.MlInterface.SendMailCounts(); Plr.MlInterface.SendMailBox(); break; case 5: packet.Skip(4); Mail.Opened = (packet.GetUint8() == 1); CharMgr.SaveMail(Mail); Plr.MlInterface.SendMailCounts(); Plr.MlInterface.SendMailBox(); break; case 7: packet.Skip(4); byte itemnum = packet.GetUint8(); if (Mail.ItemsReqInfo.Count < itemnum + 1) { return; } UInt16 FreeSlot = Plr.ItmInterface.GetFreeInventorySlot(); if (FreeSlot == 0) { Plr.SendLocalizeString("", GameData.Localized_text.TEXT_OVERAGE_CANT_TAKE_ATTACHMENTS); return; } Character_items item = Mail.ItemsReqInfo.ElementAt(itemnum); Plr.ItmInterface.CreateItem(item.Entry, item.Counts); Mail.ItemsReqInfo.Remove(item); CharMgr.SaveMail(Mail); Plr.MlInterface.SendMailUpdate(Mail); Plr.MlInterface.SendMail(Mail); break; case 8: if (Mail.Money > 0) { Plr.AddMoney(Mail.Money); Mail.Money = 0; } // Take as many items as you can before inventory is full foreach (Character_items curritem in Mail.ItemsReqInfo.ToArray()) { UInt16 Slot = Plr.ItmInterface.GetFreeInventorySlot(); if (Slot == 0) { Plr.SendLocalizeString("", GameData.Localized_text.TEXT_OVERAGE_CANT_TAKE_ATTACHMENTS); break; } Plr.ItmInterface.CreateItem(curritem.Entry, curritem.Counts); Mail.ItemsReqInfo.Remove(curritem); } CharMgr.SaveMail(Mail); Plr.MlInterface.SendMailUpdate(Mail); Plr.MlInterface.SendMail(Mail); break; } } break; } }