static void SetupWorld(WorldStream world) { string charname = null; world.CharacterCreateNameApproval += (sender, approvalState) => { if (1 == approvalState) { // approved. Send charactercreate and EnterWorld. world.SendCharacterCreate(new CharCreate { Class_ = 1, Haircolor = 255, BeardColor = 255, Beard = 255, Gender = 0, Race = 2, StartZone = 29, HairStyle = 255, Deity = 211, STR = 113, STA = 130, AGI = 87, DEX = 70, WIS = 70, INT = 60, CHA = 55, Face = 0, EyeColor1 = 9, EyeColor2 = 9, DrakkinHeritage = 1, DrakkinTattoo = 0, DrakkinDetails = 0, Tutorial = 0 }); world.SendEnterWorld(new EnterWorld { Name = charname, GoHome = false, Tutorial = false }); } else { // Denied. Let them try a different name. } }; world.CharacterList += (sender, chars) => { WriteLine($"Got {chars.Count} characters:"); if (0 == chars.Count) { charname = "JimTomShiner"; Console.WriteLine("0 Characters found. Simple char creation:"); Console.WriteLine($"1. Barbarian, Male, Warrior, Name is {charname}"); Console.WriteLine("Enter number of the character type you want and press Enter."); var selection = Console.ReadLine(); // Send char create packet with defaults. world.SendNameApproval(new NameApproval { Name = charname, Class = 3, Race = 1, Unknown = 214 }); } else { foreach (var character in chars) { WriteLine($"- {character.Name} - Level {character.Level}"); } Console.WriteLine("Enter a character number and press Enter."); var charNum = "1"; //Console.ReadLine(); charname = chars[Convert.ToInt32(charNum) - 1].Name; WriteLine(chars[0]); WriteLine($"Entering world with {charname}"); //world.ResetAckForZone(); world.SendEnterWorld(new EnterWorld { Name = charname, GoHome = false, Tutorial = false }); } }; world.ZoneServer += (sender, server) => { WriteLine($"Zone server info: {server.Host}:{server.Port}"); var zone = new ZoneStream(server.Host, server.Port, charname); SetupZone(zone); }; }
static void ConnectWorld(LoginStream ls, ServerListElement server) { WriteLine($"Selected {server}. Connecting."); var worldStream = new WorldStream(server.WorldIP, 9000, ls.AccountID, ls.SessionKey); string charName = null; worldStream.CharacterList += (_, chars) => { WriteLine("Select a character:"); WriteLine("0: Create a new character"); chars.ForEach((@char, i) => WriteLine($"{i + 1}: {@char.Name} - Level {@char.Level}")); int ret; while (!int.TryParse(Input("Character number"), out ret) || ret < 0 || chars.Count < ret) { } if (ret == 0) { CreateCharacter(); } else { worldStream.SendEnterWorld(new EnterWorld(charName = chars[ret - 1].Name, false, false)); } }; void CreateCharacter() { charName = Input("Name"); worldStream.SendNameApproval(new NameApproval { Name = charName, Class = 3, Race = 1, Unknown = 214 }); } worldStream.CharacterCreateNameApproval += (_, success) => { if (!success) { WriteLine("Name not approved by server"); CreateCharacter(); } else { WriteLine("Name approved, creating"); worldStream.SendCharacterCreate(new CharCreate { Class_ = 1, Haircolor = 255, BeardColor = 255, Beard = 255, Gender = 0, Race = 2, StartZone = 29, HairStyle = 255, Deity = 211, STR = 113, STA = 130, AGI = 87, DEX = 70, WIS = 70, INT = 60, CHA = 55, Face = 0, EyeColor1 = 9, EyeColor2 = 9, DrakkinHeritage = 1, DrakkinTattoo = 0, DrakkinDetails = 0, Tutorial = 0 }); } }; worldStream.ZoneServer += (_, zs) => { WriteLine($"Got zone server at {zs.Host}:{zs.Port}. Connecting"); ConnectZone(charName, zs.Host, zs.Port); }; }
#pragma warning restore 0649 public override void Setup() { string charname = null; world.CharacterCreateNameApproval += (sender, approvalState) => { if (1 == approvalState) { // approved. Send charactercreate and EnterWorld. world.SendCharacterCreate(new CharCreate { Class_ = 1, Haircolor = 255, BeardColor = 255, Beard = 255, Gender = 0, Race = 2, StartZone = 29, HairStyle = 255, Deity = 211, STR = 113, STA = 130, AGI = 87, DEX = 70, WIS = 70, INT = 60, CHA = 55, Face = 0, EyeColor1 = 9, EyeColor2 = 9, DrakkinHeritage = 1, DrakkinTattoo = 0, DrakkinDetails = 0, Tutorial = 0 }); world.SendEnterWorld(new EnterWorld { Name = charname, GoHome = false, Tutorial = false }); } else { // Denied. Let them try a different name. } }; buttonCreateCharacter.Click += (sender, args) => { charname = "JimTomShiner"; //Console.WriteLine($"1. Barbarian, Male, Warrior, Name is {charname}"); //Console.WriteLine("Enter number of the character type you want and press Enter."); //var selection = Console.ReadLine(); // Send char create packet with defaults. world.SendNameApproval(new NameApproval { Name = charname, Class = 3, Race = 1, Unknown = 214 }); }; world.CharacterList += (sender, chars) => { var i = 0; foreach (var character in chars) { charGrid.RowDefinitions.Add(new StripDefinition(StripType.Fixed, 25)); var namefield = new TextBlock { Text = character.Name, Font = charNameHeader.Font, TextSize = charNameHeader.TextSize, TextColor = charNameHeader.TextColor }; namefield.SetGridColumn(0); namefield.SetGridRow(i); charGrid.Children.Add(namefield); var classfield = new TextBlock { Text = ((ClassTypes)character.Class).GetClassName(), Font = charNameHeader.Font, TextSize = charNameHeader.TextSize, TextColor = charNameHeader.TextColor }; classfield.SetGridColumn(1); classfield.SetGridRow(i); charGrid.Children.Add(classfield); var levelfield = new TextBlock { Text = character.Level.ToString(), Font = charNameHeader.Font, TextSize = charNameHeader.TextSize, TextColor = charNameHeader.TextColor }; levelfield.SetGridColumn(2); levelfield.SetGridRow(i); charGrid.Children.Add(levelfield); var serverButton = new Button { MouseOverImage = buttonCreateCharacter.MouseOverImage, NotPressedImage = buttonCreateCharacter.NotPressedImage, PressedImage = buttonCreateCharacter.PressedImage }; var buttonLabel = new TextBlock { Text = "Play", Font = charNameHeader.Font, TextSize = 8, TextColor = charNameHeader.TextColor, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; serverButton.Content = buttonLabel; serverButton.SetGridColumn(3); serverButton.SetGridRow(i++); charGrid.Children.Add(serverButton); serverButton.Click += (s, e) => { ((Button)s).IsEnabled = false; world.ResetAckForZone(); world.SendEnterWorld(new EnterWorld { Name = character.Name, GoHome = false, Tutorial = false }); }; } }; world.ChatServerList += (sender, chatBytes) => { world.ChatServers.Add(new ChatServer(chatBytes)); }; world.ZoneServer += (sender, server) => { //WriteLine($"Zone server info: {server.Host}:{server.Port}"); var zone = new ZoneStream(server.Host, server.Port, charname); SetupZone(zone); }; }