diff --git a/Ledybot/Form1.cs b/Ledybot/Form1.cs index d234f7c..a5c3f93 100644 --- a/Ledybot/Form1.cs +++ b/Ledybot/Form1.cs @@ -20,12 +20,14 @@ public partial class MainForm : Form public LogDelegate delLastLog; public string lastlog = ""; public int pid = 0; + public int game = 0; public PKHeX dumpedPKHeX = new PKHeX(); - public uint boxOff = 0x330D9838; - public uint wcOff = 0x331397E4; - public uint partyOff = 0x34195E10; - private uint eggOff = 0x3313EDD8; + public uint boxOff; + public uint wcOff; + + public uint partyOff; + private uint eggOff; private bool botWorking = false; private bool botStop = false; @@ -96,7 +98,28 @@ public void getGame(object sender, EventArgs e) pid = Convert.ToInt32("0x" + splitlog.Substring(0, 8), 16); Program.helper.pid = pid; Program.scriptHelper.write(0x3E14C0, BitConverter.GetBytes(0xE3A01000), pid); + game = 0; + MessageBox.Show("Connection Successful!"); + + boxOff = 0x330D9838; + wcOff = 0x331397E4; + partyOff = 0x34195E10; + eggOff = 0x3313EDD8; + + } else if(log.Contains("momiji")) + { + string splitlog = log.Substring(log.IndexOf(", pname: momiji") - 8, log.Length - log.IndexOf(", pname: momiji")); + pid = Convert.ToInt32("0x" + splitlog.Substring(0, 8), 16); + Program.helper.pid = pid; + Program.scriptHelper.write(0x3F341C, BitConverter.GetBytes(0xE3A01000), pid); + Program.scriptHelper.write(0x3F3420, BitConverter.GetBytes(0xE3A01000), pid); + game = 1; MessageBox.Show("Connection Successful!"); + + boxOff = 0x33015AB0; + wcOff = 0x33075BF4; + partyOff = 0x33F7FA44; + eggOff = 0x3307B1E8; } } @@ -196,7 +219,7 @@ private async void btn_Start_Click(object sender, EventArgs e) { tradeDirection = 2; } - GTSBot7 = new GTSBot7(pid, combo_pkmnList.SelectedIndex + 1, combo_gender.SelectedIndex, combo_levelrange.SelectedIndex ,cb_Blacklist.Checked, cb_Reddit.Checked, tradeDirection, tb_waittime.Text, tb_consoleName.Text, cb_UseLedySync.Checked, tb_LedySyncIP.Text, tb_LedySyncPort.Text); + GTSBot7 = new GTSBot7(pid, combo_pkmnList.SelectedIndex + 1, combo_gender.SelectedIndex, combo_levelrange.SelectedIndex ,cb_Blacklist.Checked, cb_Reddit.Checked, tradeDirection, tb_waittime.Text, tb_consoleName.Text, cb_UseLedySync.Checked, tb_LedySyncIP.Text, tb_LedySyncPort.Text, game); Task Bot = GTSBot7.RunBot(); int result = await Bot; if (botStop) diff --git a/Ledybot/GTSBot7.cs b/Ledybot/GTSBot7.cs index 4572f27..0f6aaf0 100644 --- a/Ledybot/GTSBot7.cs +++ b/Ledybot/GTSBot7.cs @@ -16,7 +16,7 @@ class GTSBot7 { //private System.IO.StreamWriter file = new StreamWriter(@"C:\Temp\ledylog.txt"); - + public enum gtsbotstates { botstart, startsearch, pressSeek, openpokemonwanted, openwhatpokemon, typepokemon, presssearch, startfind, findfromend, findfromstart, trade, research, botexit, updatecomments, quicksearch, panic }; private TcpClient client = new TcpClient(); @@ -28,30 +28,31 @@ public enum gtsbotstates { botstart, startsearch, pressSeek, openpokemonwanted, private const int SEARCHDIRECTION_FROMBACKFIRSTPAGEONLY = 1; private const int SEARCHDIRECTION_FROMFRONT = 2; - private uint addr_PageSize = 0x32A6A1A4; //How many entries are on the current GTS page - private uint addr_PageEndStartRecord = 0x32A6A68C; //This address holds the address to the last block in the entry-block-list - private uint addr_PageStartStartRecord = 0x32A6A690; //This address holds the address to the first block in the entry block-list - private uint addr_PageCurrentView = 0x305ea384; //Current selected entry in the list - private uint addr_PageStartingIndex = 0x32A6A190; //To determine on which page we are, 0 = first page, 100 = second page, etc - private uint addr_ListOfAllPageEntries = 0x32A6A7C4; //Startingaddress of all up to 100 trade entries of the current page + private uint addr_PageSize; //How many entries are on the current GTS page + private uint addr_PageEndStartRecord; //This address holds the address to the last block in the entry-block-list + private uint addr_PageStartStartRecord; //This address holds the address to the first block in the entry block-list + private uint addr_PageCurrentView; //Current selected entry in the list + private uint addr_PageStartingIndex; //To determine on which page we are, 0 = first page, 100 = second page, etc + private uint addr_ListOfAllPageEntries; //Startingaddress of all up to 100 trade entries of the current page + + private uint addr_box1slot1; //To inject the pokemon into box1slot1 - private uint addr_box1slot1 = 0x330d9838; //To inject the pokemon into box1slot1 - private uint addr_SearchPokemonNameField = 0x301118D4; //Holds the currently typed in name in the "search pokemon" window + //private uint addr_SearchPokemonNameField = 0x301118D4; //Holds the currently typed in name in the "search pokemon" window - private uint addr_currentScreen = 0x00674802; //Hopefully a address to tell us in what screen we are (roughly) + private uint addr_currentScreen; //Hopefully a address to tell us in what screen we are (roughly) - private uint addr_pokemonToFind = 0x32A6A180; - private uint addr_pokemonToFindGender = 0x32A6A184; - private uint addr_pokemonToFindLevel = 0x32A6A188; + private uint addr_pokemonToFind; + private uint addr_pokemonToFindGender; + private uint addr_pokemonToFindLevel; - private int val_PlazaScreen = 0x00; - private int val_Quit_SeekScreen = 0x3F2B; - private int val_SearchScreen = 0x4128; //also in the box during selecting etc - private int val_WhatPkmnScreen = 0x4160; - private int val_GTSListScreen = 0x4180; - private int val_BoxScreen = 0x4120; - private int val_system = 0x41A8; //during error, saving, early sending - private int val_duringTrade = 0x3FD5; //trade is split in several steps, sometimes even 0x00 + private int val_PlazaScreen; + private int val_Quit_SeekScreen; + private int val_SearchScreen; //also in the box during selecting etc + private int val_WhatPkmnScreen; + private int val_GTSListScreen; + private int val_BoxScreen; + private int val_system; //during error, saving, early sending + private int val_duringTrade; //trade is split in several steps, sometimes even 0x00 private int iPokemonToFind = 0; private int iPokemonToFindGender = 0; @@ -98,7 +99,7 @@ private Boolean canThisTrade(byte[] principal, string consoleName, string traine NetworkStream clientStream = client.GetStream(); byte[] buffer = new byte[4096]; byte[] messageID = { 0x00 }; - string szmessage = consoleName + '\t' + trainerName + '\t' + country + '\t' + region + '\t' + pokemon + '\t' + page + "\t" + index +"\t"; + string szmessage = consoleName + '\t' + trainerName + '\t' + country + '\t' + region + '\t' + pokemon + '\t' + page + "\t" + index + "\t"; byte[] toSend = Encoding.UTF8.GetBytes(szmessage); buffer = messageID.Concat(principal).Concat(toSend).ToArray(); @@ -109,7 +110,7 @@ private Boolean canThisTrade(byte[] principal, string consoleName, string traine { //blocks until a client sends a message int bytesRead = clientStream.Read(message, 0, 4096); - if(message[0] == 0x02) + if (message[0] == 0x02) { Program.f1.banlist.Add(szFC); } @@ -122,7 +123,7 @@ private Boolean canThisTrade(byte[] principal, string consoleName, string traine } } - public GTSBot7(int iP, int iPtF, int iPtFGender, int iPtFLevel, bool bBlacklist, bool bReddit, int iSearchDirection, string waittime, string consoleName, bool useLedySync, string ledySyncIp, string ledySyncPort) + public GTSBot7(int iP, int iPtF, int iPtFGender, int iPtFLevel, bool bBlacklist, bool bReddit, int iSearchDirection, string waittime, string consoleName, bool useLedySync, string ledySyncIp, string ledySyncPort, int game) { this.iPokemonToFind = iPtF; this.iPokemonToFindGender = iPtFGender; @@ -140,6 +141,60 @@ public GTSBot7(int iP, int iPtF, int iPtFGender, int iPtFLevel, bool bBlacklist, client.Connect(serverEndPoint); } this.consoleName = consoleName; + + if (game == 0) + { + addr_PageSize = 0x32A6A1A4; //How many entries are on the current GTS page + addr_PageEndStartRecord = 0x32A6A68C; //This address holds the address to the last block in the entry-block-list + addr_PageStartStartRecord = 0x32A6A690; //This address holds the address to the first block in the entry block-list + addr_PageCurrentView = 0x305ea384; //Current selected entry in the list + addr_PageStartingIndex = 0x32A6A190; //To determine on which page we are, 0 = first page, 100 = second page, etc + addr_ListOfAllPageEntries = 0x32A6A7C4; //Startingaddress of all up to 100 trade entries of the current page + + addr_box1slot1 = 0x330D9838; //To inject the pokemon into box1slot1 + + addr_currentScreen = 0x00674802; //Hopefully a address to tell us in what screen we are (roughly) + + addr_pokemonToFind = 0x32A6A180; + addr_pokemonToFindGender = 0x32A6A184; + addr_pokemonToFindLevel = 0x32A6A188; + + val_PlazaScreen = 0x00; + val_Quit_SeekScreen = 0x3F2B; + val_SearchScreen = 0x4128; //also in the box during selecting etc + val_WhatPkmnScreen = 0x4160; + val_GTSListScreen = 0x4180; + val_BoxScreen = 0x4120; + val_system = 0x41A8; //during error, saving, early sending + val_duringTrade = 0x3FD5; //trade is split in several steps, sometimes even 0x00 + } + else if (game == 1) + { + addr_PageSize = 0x329921A4; + addr_PageEndStartRecord = 0x3299268C; + addr_PageStartStartRecord = 0x32992690; + addr_PageCurrentView = 0x305CD9F4; + addr_PageStartingIndex = 0x32992190; + addr_ListOfAllPageEntries = 0x329927C4; + + addr_box1slot1 = 0x33015AB0; + + addr_currentScreen = 0x006A610A; + + addr_pokemonToFind = 0x32992180; + addr_pokemonToFindGender = 0x32992184; + addr_pokemonToFindLevel = 0x32992188; + + val_PlazaScreen = 0x00; + val_Quit_SeekScreen = 0x3F2B; + val_SearchScreen = 0x412A; + val_WhatPkmnScreen = 0x1040; + val_GTSListScreen = 0x4180; + val_BoxScreen = 0x4120; + val_system = 0x1C848; + val_duringTrade = 0x3FD5; + } + } public async Task RunBot() @@ -158,7 +213,7 @@ public async Task RunBot() int panicAttempts = 0; while (!botstop) { - if(botState != (int)gtsbotstates.panic) + if (botState != (int)gtsbotstates.panic) { panicAttempts = 0; } @@ -281,7 +336,8 @@ public async Task RunBot() if (searchDirection == SEARCHDIRECTION_FROMBACK || searchDirection == SEARCHDIRECTION_FROMBACKFIRSTPAGEONLY) { await Program.helper.waitNTRread(addr_PageEndStartRecord); - }else + } + else { await Program.helper.waitNTRread(addr_PageStartStartRecord); } @@ -342,7 +398,7 @@ public async Task RunBot() string subregion = "-"; Program.f1.regions.TryGetValue(subRegionIndex, out subregion); int ipage = Convert.ToInt32(Math.Floor(startIndex / 100.0)) + 1; - if (useLedySync && !Program.f1.banlist.Contains(szFC) && canThisTrade(principal, consoleName, szTrainerName, country, subregion, Program.PKTable.Species7[dexnumber - 1], szFC, ipage +"", (i-1)+"")) + if (useLedySync && !Program.f1.banlist.Contains(szFC) && canThisTrade(principal, consoleName, szTrainerName, country, subregion, Program.PKTable.Species7[dexnumber - 1], szFC, ipage + "", (i - 1) + "")) { Program.f1.ChangeStatus("Found a pokemon to trade"); tradeIndex = i - 1; @@ -565,7 +621,7 @@ public async Task RunBot() //still in GTS list screen //write index we want to trade int page = Convert.ToInt32(Math.Floor(startIndex / 100.0)) + 1; - Program.f1.ChangeStatus("Trading pokemon on page "+ page + " index " + tradeIndex +""); + Program.f1.ChangeStatus("Trading pokemon on page " + page + " index " + tradeIndex + ""); waitTaskbool = Program.helper.waitNTRwrite(addr_PageCurrentView, BitConverter.GetBytes(tradeIndex), iPID); if (await waitTaskbool) { @@ -596,12 +652,12 @@ public async Task RunBot() { details.Item6.Add(BitConverter.ToInt32(principal, 0)); } - Program.f1.AppendListViewItem(szTrainerName, szNickname, country, subregion, Program.PKTable.Species7[dexnumber - 1], szFC, page+"", tradeIndex + ""); + Program.f1.AppendListViewItem(szTrainerName, szNickname, country, subregion, Program.PKTable.Species7[dexnumber - 1], szFC, page + "", tradeIndex + ""); //Inject the Pokemon to box1slot1 Program.scriptHelper.write(addr_box1slot1, cloneshort, iPID); //spam a to trade pokemon Program.helper.quickbuton(Program.PKTable.keyA, commandtime); - await Task.Delay(commandtime + delaytime + 2500 +o3dswaittime); + await Task.Delay(commandtime + delaytime + 2500 + o3dswaittime); Program.helper.quickbuton(Program.PKTable.keyA, commandtime); await Task.Delay(commandtime + delaytime); Program.helper.quickbuton(Program.PKTable.keyA, commandtime); @@ -779,7 +835,7 @@ public async Task RunBot() } else { - if(panicAttempts == 0) + if (panicAttempts == 0) { panicAttempts++; botState = (int)gtsbotstates.panic; @@ -797,7 +853,7 @@ public async Task RunBot() break; } } - if(this.serverEndPoint != null) + if (this.serverEndPoint != null) { client.Close(); } diff --git a/Ledybot/Ledybot.csproj b/Ledybot/Ledybot.csproj index 40e7428..8894635 100644 --- a/Ledybot/Ledybot.csproj +++ b/Ledybot/Ledybot.csproj @@ -37,9 +37,8 @@ 165Ledyba.ico - - ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll - True + + ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll diff --git a/Ledybot/packages.config b/Ledybot/packages.config index 9d64bf3..e4ac9c6 100644 --- a/Ledybot/packages.config +++ b/Ledybot/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file