// TODO: Items validation. private void CreateCharacter(Packet inPacket) { int accountID = inPacket.ReadInt(); string name = inPacket.ReadString(); CharacterConstants.JobType jobType = (CharacterConstants.JobType)inPacket.ReadInt(); int face = inPacket.ReadInt(); int hair = inPacket.ReadInt(); int hairColor = inPacket.ReadInt(); byte skin = (byte)inPacket.ReadInt(); int topID = inPacket.ReadInt(); int bottomID = inPacket.ReadInt(); int shoesID = inPacket.ReadInt(); int weaponID = inPacket.ReadInt(); CharacterConstants.Gender gender = (CharacterConstants.Gender)inPacket.ReadByte(); bool error = false; if (ValidCharacterName(name)) { switch (gender) // TODO: these need error catching with item info. { case CharacterConstants.Gender.Male: if (!DataProvider.CreationData.MaleSkins.Any(x => x.Item1 == jobType && x.Item2 == skin) || !DataProvider.CreationData.MaleFaces.Any(x => x.Item1 == jobType && x.Item2 == face) || !DataProvider.CreationData.MaleHairs.Any(x => x.Item1 == jobType && x.Item2 == hair) || !DataProvider.CreationData.MaleHairColors.Any(x => x.Item1 == jobType && x.Item2 == hairColor) || !DataProvider.CreationData.MaleTops.Any(x => x.Item1 == jobType && x.Item2 == topID) || !DataProvider.CreationData.MaleBottoms.Any(x => x.Item1 == jobType && x.Item2 == bottomID) || !DataProvider.CreationData.MaleShoes.Any(x => x.Item1 == jobType && x.Item2 == shoesID) || !DataProvider.CreationData.MaleWeapons.Any(x => x.Item1 == jobType && x.Item2 == weaponID)) { error = true; } break; case CharacterConstants.Gender.Female: if (!DataProvider.CreationData.FemaleSkins.Any(x => x.Item1 == jobType && x.Item2 == skin) || !DataProvider.CreationData.FemaleFaces.Any(x => x.Item1 == jobType && x.Item2 == face) || !DataProvider.CreationData.FemaleHairs.Any(x => x.Item1 == jobType && x.Item2 == hair) || !DataProvider.CreationData.FemaleHairColors.Any(x => x.Item1 == jobType && x.Item2 == hairColor) || !DataProvider.CreationData.FemaleTops.Any(x => x.Item1 == jobType && x.Item2 == topID) || !DataProvider.CreationData.FemaleBottoms.Any(x => x.Item1 == jobType && x.Item2 == bottomID) || !DataProvider.CreationData.FemaleShoes.Any(x => x.Item1 == jobType && x.Item2 == shoesID) || !DataProvider.CreationData.FemaleWeapons.Any(x => x.Item1 == jobType && x.Item2 == weaponID)) { error = true; } break; default: error = false; break; } } if (error) { Log.SkipLine(); Log.Error("Failed to load character items on character creation!"); Log.SkipLine(); WvsGame.Stop(); } Character character = new Character(); character.AccountID = accountID; character.WorldID = WvsGame.WorldID; character.Name = name; character.Gender = gender; character.Skin = skin; character.Face = face; character.Hair = hair + hairColor; character.Level = 1; character.Job = jobType == CharacterConstants.JobType.Cygnus ? CharacterConstants.Job.Noblesse : jobType == CharacterConstants.JobType.Explorer ? CharacterConstants.Job.Beginner : CharacterConstants.Job.Aran; character.Strength = 12; character.Dexterity = 5; character.Intelligence = 4; character.Luck = 4; character.MaxHealth = 50; character.MaxMana = 5; character.Health = 50; character.Mana = 5; character.AbilityPoints = 0; character.SkillPoints = 0; character.Experience = 0; character.Fame = 0; character.Map = DataProvider.Maps[jobType == CharacterConstants.JobType.Cygnus ? 130030000 : jobType == CharacterConstants.JobType.Explorer ? 10000 : 914000000]; character.SpawnPoint = 0; character.Meso = 0; character.Items.Add(new Item(topID, equipped: true)); character.Items.Add(new Item(bottomID, equipped: true)); character.Items.Add(new Item(shoesID, equipped: true)); character.Items.Add(new Item(weaponID, equipped: true)); character.Items.Add(new Item(jobType == CharacterConstants.JobType.Cygnus ? 4161047 : jobType == CharacterConstants.JobType.Explorer ? 4161001 : 4161048), forceGetSlot: true); character.Keymap.Add(new Shortcut(KeymapKey.One, KeymapAction.AllChat)); character.Keymap.Add(new Shortcut(KeymapKey.Two, KeymapAction.PartyChat)); character.Keymap.Add(new Shortcut(KeymapKey.Three, KeymapAction.BuddyChat)); character.Keymap.Add(new Shortcut(KeymapKey.Four, KeymapAction.GuildChat)); character.Keymap.Add(new Shortcut(KeymapKey.Five, KeymapAction.AllianceChat)); character.Keymap.Add(new Shortcut(KeymapKey.Six, KeymapAction.SpouseChat)); character.Keymap.Add(new Shortcut(KeymapKey.Q, KeymapAction.QuestMenu)); character.Keymap.Add(new Shortcut(KeymapKey.W, KeymapAction.WorldMap)); character.Keymap.Add(new Shortcut(KeymapKey.E, KeymapAction.EquipmentMenu)); character.Keymap.Add(new Shortcut(KeymapKey.R, KeymapAction.BuddyList)); character.Keymap.Add(new Shortcut(KeymapKey.I, KeymapAction.ItemMenu)); character.Keymap.Add(new Shortcut(KeymapKey.O, KeymapAction.PartySearch)); character.Keymap.Add(new Shortcut(KeymapKey.P, KeymapAction.PartyList)); character.Keymap.Add(new Shortcut(KeymapKey.BracketLeft, KeymapAction.Shortcut)); character.Keymap.Add(new Shortcut(KeymapKey.BracketRight, KeymapAction.QuickSlot)); character.Keymap.Add(new Shortcut(KeymapKey.LeftCtrl, KeymapAction.Attack)); character.Keymap.Add(new Shortcut(KeymapKey.S, KeymapAction.AbilityMenu)); character.Keymap.Add(new Shortcut(KeymapKey.F, KeymapAction.FamilyList)); character.Keymap.Add(new Shortcut(KeymapKey.G, KeymapAction.GuildList)); character.Keymap.Add(new Shortcut(KeymapKey.H, KeymapAction.WhisperChat)); character.Keymap.Add(new Shortcut(KeymapKey.K, KeymapAction.SkillMenu)); character.Keymap.Add(new Shortcut(KeymapKey.L, KeymapAction.QuestHelper)); character.Keymap.Add(new Shortcut(KeymapKey.Semicolon, KeymapAction.Medal)); character.Keymap.Add(new Shortcut(KeymapKey.Quote, KeymapAction.ExpandChat)); character.Keymap.Add(new Shortcut(KeymapKey.Backtick, KeymapAction.CashShop)); character.Keymap.Add(new Shortcut(KeymapKey.Backslash, KeymapAction.SetKey)); character.Keymap.Add(new Shortcut(KeymapKey.Z, KeymapAction.PickUp)); character.Keymap.Add(new Shortcut(KeymapKey.X, KeymapAction.Sit)); character.Keymap.Add(new Shortcut(KeymapKey.C, KeymapAction.Messenger)); character.Keymap.Add(new Shortcut(KeymapKey.B, KeymapAction.MonsterBook)); character.Keymap.Add(new Shortcut(KeymapKey.M, KeymapAction.MiniMap)); character.Keymap.Add(new Shortcut(KeymapKey.LeftAlt, KeymapAction.Jump)); character.Keymap.Add(new Shortcut(KeymapKey.Space, KeymapAction.NpcChat)); character.Keymap.Add(new Shortcut(KeymapKey.F1, KeymapAction.Cockeyed)); character.Keymap.Add(new Shortcut(KeymapKey.F2, KeymapAction.Happy)); character.Keymap.Add(new Shortcut(KeymapKey.F3, KeymapAction.Sarcastic)); character.Keymap.Add(new Shortcut(KeymapKey.F4, KeymapAction.Crying)); character.Keymap.Add(new Shortcut(KeymapKey.F5, KeymapAction.Outraged)); character.Keymap.Add(new Shortcut(KeymapKey.F6, KeymapAction.Shocked)); character.Keymap.Add(new Shortcut(KeymapKey.F7, KeymapAction.Annoyed)); character.Save(); using (Packet outPacket = new Packet(InteroperabilityOperationCode.CharacterCreationResponse)) { outPacket.WriteInt(accountID); outPacket.WriteBytes(character.ToByteArray()); this.Send(outPacket); } }
public CreationData() { MaleSkins = new List <Tuple <CharacterConstants.JobType, byte> >(); FemaleSkins = new List <Tuple <CharacterConstants.JobType, byte> >(); MaleFaces = new List <Tuple <CharacterConstants.JobType, int> >(); FemaleFaces = new List <Tuple <CharacterConstants.JobType, int> >(); MaleHairs = new List <Tuple <CharacterConstants.JobType, int> >(); FemaleHairs = new List <Tuple <CharacterConstants.JobType, int> >(); MaleHairColors = new List <Tuple <CharacterConstants.JobType, byte> >(); FemaleHairColors = new List <Tuple <CharacterConstants.JobType, byte> >(); MaleTops = new List <Tuple <CharacterConstants.JobType, int> >(); FemaleTops = new List <Tuple <CharacterConstants.JobType, int> >(); MaleBottoms = new List <Tuple <CharacterConstants.JobType, int> >(); FemaleBottoms = new List <Tuple <CharacterConstants.JobType, int> >(); MaleShoes = new List <Tuple <CharacterConstants.JobType, int> >(); FemaleShoes = new List <Tuple <CharacterConstants.JobType, int> >(); MaleWeapons = new List <Tuple <CharacterConstants.JobType, int> >(); FemaleWeapons = new List <Tuple <CharacterConstants.JobType, int> >(); using (Log.Load("Character Creation Data")) { ForbiddenNames = new Datums("character_forbidden_names").Populate().Select(x => (string)x["forbidden_name"]).ToList(); foreach (Datum datum in new Datums("character_creation_data").Populate()) { string gender = (string)datum["gender"]; string charType = (string)datum["character_type"]; CharacterConstants.JobType jobType = charType == "aran" ? CharacterConstants.JobType.Aran : (charType == "cygnus" ? CharacterConstants.JobType.Cygnus : CharacterConstants.JobType.Explorer); switch ((string)datum["object_type"]) { case "skin": if (gender == "male" || gender == "both") { MaleSkins.Add(new Tuple <CharacterConstants.JobType, byte>(jobType, (byte)(int)datum["objectid"])); } if (gender == "female" || gender == "both") { FemaleSkins.Add(new Tuple <CharacterConstants.JobType, byte>(jobType, (byte)(int)datum["objectid"])); } break; case "face": if (gender == "male" || gender == "both") { MaleFaces.Add(new Tuple <CharacterConstants.JobType, int>(jobType, (int)datum["objectid"])); } if (gender == "female" || gender == "both") { FemaleFaces.Add(new Tuple <CharacterConstants.JobType, int>(jobType, (int)datum["objectid"])); } break; case "hair": if (gender == "male" || gender == "both") { MaleHairs.Add(new Tuple <CharacterConstants.JobType, int>(jobType, (int)datum["objectid"])); } if (gender == "female" || gender == "both") { FemaleHairs.Add(new Tuple <CharacterConstants.JobType, int>(jobType, (int)datum["objectid"])); } break; case "haircolor": if (gender == "male" || gender == "both") { MaleHairColors.Add(new Tuple <CharacterConstants.JobType, byte>(jobType, (byte)(int)datum["objectid"])); } if (gender == "female" || gender == "both") { FemaleHairColors.Add(new Tuple <CharacterConstants.JobType, byte>(jobType, (byte)(int)datum["objectid"])); } break; case "top": if (gender == "male" || gender == "both") { MaleTops.Add(new Tuple <CharacterConstants.JobType, int>(jobType, (int)datum["objectid"])); } if (gender == "female" || gender == "both") { FemaleTops.Add(new Tuple <CharacterConstants.JobType, int>(jobType, (int)datum["objectid"])); } break; case "bottom": if (gender == "male" || gender == "both") { MaleBottoms.Add(new Tuple <CharacterConstants.JobType, int>(jobType, (int)datum["objectid"])); } if (gender == "female" || gender == "both") { FemaleBottoms.Add(new Tuple <CharacterConstants.JobType, int>(jobType, (int)datum["objectid"])); } break; case "shoes": if (gender == "male" || gender == "both") { MaleShoes.Add(new Tuple <CharacterConstants.JobType, int>(jobType, (int)datum["objectid"])); } if (gender == "female" || gender == "both") { FemaleShoes.Add(new Tuple <CharacterConstants.JobType, int>(jobType, (int)datum["objectid"])); } break; case "weapon": if (gender == "male" || gender == "both") { MaleWeapons.Add(new Tuple <CharacterConstants.JobType, int>(jobType, (int)datum["objectid"])); } if (gender == "female" || gender == "both") { FemaleWeapons.Add(new Tuple <CharacterConstants.JobType, int>(jobType, (int)datum["objectid"])); } break; } } } }
// TODO: Items validation. private void CreateCharacter(Packet inPacket) { int accountID = inPacket.ReadInt(); string name = inPacket.ReadString(); CharacterConstants.JobType jobType = (CharacterConstants.JobType)inPacket.ReadInt(); int face = inPacket.ReadInt(); int hair = inPacket.ReadInt(); int hairColor = inPacket.ReadInt(); byte skin = (byte)inPacket.ReadInt(); int topID = inPacket.ReadInt(); int bottomID = inPacket.ReadInt(); int shoesID = inPacket.ReadInt(); int weaponID = inPacket.ReadInt(); CharacterConstants.Gender gender = (CharacterConstants.Gender)inPacket.ReadByte(); bool error = false; if (ValidCharacterName(name)) { switch (gender) // TODO: these need error catching with item info. { case CharacterConstants.Gender.Male: if (!DataProvider.CreationData.MaleSkins.Any(x => x.Item1 == jobType && x.Item2 == skin) || !DataProvider.CreationData.MaleFaces.Any(x => x.Item1 == jobType && x.Item2 == face) || !DataProvider.CreationData.MaleHairs.Any(x => x.Item1 == jobType && x.Item2 == hair) || !DataProvider.CreationData.MaleHairColors.Any(x => x.Item1 == jobType && x.Item2 == hairColor) || !DataProvider.CreationData.MaleTops.Any(x => x.Item1 == jobType && x.Item2 == topID) || !DataProvider.CreationData.MaleBottoms.Any(x => x.Item1 == jobType && x.Item2 == bottomID) || !DataProvider.CreationData.MaleShoes.Any(x => x.Item1 == jobType && x.Item2 == shoesID) || !DataProvider.CreationData.MaleWeapons.Any(x => x.Item1 == jobType && x.Item2 == weaponID)) { error = true; } break; case CharacterConstants.Gender.Female: if (!DataProvider.CreationData.FemaleSkins.Any(x => x.Item1 == jobType && x.Item2 == skin) || !DataProvider.CreationData.FemaleFaces.Any(x => x.Item1 == jobType && x.Item2 == face) || !DataProvider.CreationData.FemaleHairs.Any(x => x.Item1 == jobType && x.Item2 == hair) || !DataProvider.CreationData.FemaleHairColors.Any(x => x.Item1 == jobType && x.Item2 == hairColor) || !DataProvider.CreationData.FemaleTops.Any(x => x.Item1 == jobType && x.Item2 == topID) || !DataProvider.CreationData.FemaleBottoms.Any(x => x.Item1 == jobType && x.Item2 == bottomID) || !DataProvider.CreationData.FemaleShoes.Any(x => x.Item1 == jobType && x.Item2 == shoesID) || !DataProvider.CreationData.FemaleWeapons.Any(x => x.Item1 == jobType && x.Item2 == weaponID)) { error = true; } break; case CharacterConstants.Gender.Both: break; case CharacterConstants.Gender.Unset: break; default: break; } } if (error) { Log.SkipLine(); Log.Error("Failed to load character items on character creation!"); Log.SkipLine(); WvsGame.Stop(); } Character character = new Character { AccountID = accountID, WorldID = WvsGame.WorldID, Name = name, Appearance = { Gender = gender, Skin = skin, Face = face, Hair = hair + hairColor }, Stats = { Level = 1, Experience = 0, MaxHealth = 50, MaxMana = 5, Health = 50, Mana = 5, AbilityPoints = 0, SkillPoints = 0, Strength = 12, Dexterity = 5, Intelligence = 4, Luck = 4, Fame = 0, Meso = 0 }, Jobs = { Job = jobType == CharacterConstants.JobType.Cygnus ? CharacterConstants.Job.Noblesse : jobType == CharacterConstants.JobType.Explorer ? CharacterConstants.Job.Beginner : CharacterConstants.Job.Aran }, Map = DataProvider.Maps[ jobType == CharacterConstants.JobType.Cygnus ? 130030000 : jobType == CharacterConstants.JobType.Explorer ? 10000 : 914000000], SpawnPoint = 0, }; character.Items.AddItemToInventory(new Item(topID, equipped: true)); character.Items.AddItemToInventory(new Item(bottomID, equipped: true)); character.Items.AddItemToInventory(new Item(shoesID, equipped: true)); character.Items.AddItemToInventory(new Item(weaponID, equipped: true)); switch (jobType) { case CharacterConstants.JobType.Cygnus: character.Items.AddItemToInventory(new Item(4161047)); // Noblesse Guide break; case CharacterConstants.JobType.Explorer: character.Items.AddItemToInventory(new Item(4161001)); // Beginner's Guide break; case CharacterConstants.JobType.Aran: // Legend character.Items.AddItemToInventory(new Item(4161048)); // Legend's Guide break; default: throw new ArgumentOutOfRangeException(); } character.Keymap.InitiateDefaultKeymap(); character.Save(); using (Packet outPacket = new Packet(InteroperabilityOperationCode.CharacterCreationResponse)) { outPacket.WriteInt(accountID); outPacket.WriteBytes(character.ToByteArray()); Send(outPacket); } }