Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Net.Sockets; using System.Threading; using System.Net; using System.Windows.Forms; namespace Ledybot { class GTSBot6 { //private System.IO.StreamWriter file = new StreamWriter(@"C:\Temp\ledylog.txt"); public enum gtsbotstates { botstart, startsearch, pressSeek, presssearch, findPokemon, trade, research, botexit, updatecomments, panic }; private TcpClient client = new TcpClient(); private string consoleName = "Ledybot"; private IPEndPoint serverEndPoint = null; private bool useLedySync = false; private const int SEARCHDIRECTION_FROMBACK = 0; private const int SEARCHDIRECTION_FROMBACKFIRSTPAGEONLY = 1; private const int SEARCHDIRECTION_FROMFRONT = 2; uint GTSPageSize; uint GTSPageIndex; uint GTSCurrentView; uint GTSListBlock; uint GTSBlockAll; uint GTSBlockStart; uint GTSBlockEnd; uint GTSBlockEntrySize; uint BoxInject; uint BoxScreen; uint PokemonToFind; uint PokemonToFindGender; uint PokemonToFindLevel; private int iPokemonToFind = 0; private int iPokemonToFindGender = 0; private int iPokemonToFindLevel = 0; private int iPID = 0; private string szIP; private bool bBlacklist = false; private bool bReddit = false; private int searchDirection = 0; private string szFC = ""; private string szPath; private byte[] principal = new byte[4]; public bool botstop = false; public bool PokemonFound { get; private set; } public uint CurrentView { get; private set; } public uint PageIndex { get; private set; } private int botState = 0; public int botresult = 0; Task<bool> waitTaskbool; private int commandtime = 250; private int delaytime = 150; private int o3dswaittime = 1000; private int listlength = 0; private int startIndex = 100; private byte[] blockbytes = new byte[256]; private byte[] block = new byte[256]; private int tradeIndex = -1; private uint addr_PageEntry = 0; private bool foundLastPage = false; private Tuple<string, string, int, int, int, ArrayList> details; private short dex; private string szNickname; private string country; private string subregion; private int iStartIndex; private int iEndIndex; private int iDirection; public string szTrainerName { get; private set; } public string Phrase { get; private set; } public string Message { get; private set; } private async Task<bool> isCorrectWindow(int expectedScreen) { await Task.Delay(o3dswaittime); await Program.helper.waitNTRread(0x00); int screenID = (int)Program.helper.lastRead; //file.WriteLine("Checkscreen: " + expectedScreen + " - " + screenID + " botstate:" + botState); //file.Flush(); return expectedScreen == screenID; } private Boolean canThisTrade(byte[] principal, string consoleName, string trainerName, string country, string region, string pokemon, string szFC, string page, string index) { 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"; byte[] toSend = Encoding.UTF8.GetBytes(szmessage); buffer = messageID.Concat(principal).Concat(toSend).ToArray(); clientStream.Write(buffer, 0, buffer.Length); clientStream.Flush(); byte[] message = new byte[4096]; try { //blocks until a client sends a message int bytesRead = clientStream.Read(message, 0, 4096); if (message[0] == 0x02) { Program.f1.banlist.Add(szFC); } return message[0] == 0x01; } catch { return false; //a socket error has occured } } public GTSBot6(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,string szIP) { this.iPokemonToFind = iPtF; this.iPokemonToFindGender = iPtFGender; this.iPokemonToFindLevel = iPtFLevel; this.iPID = iP; this.szIP = szIP; this.bBlacklist = bBlacklist; this.bReddit = bReddit; this.searchDirection = iSearchDirection; this.o3dswaittime = Int32.Parse(waittime); if (useLedySync) { this.useLedySync = useLedySync; int iPort = Int32.Parse(ledySyncPort); this.serverEndPoint = new IPEndPoint(IPAddress.Parse(ledySyncIp), iPort); client.Connect(serverEndPoint); } this.consoleName = consoleName; if (game == 3) // Omega Rubin and Alpha Sapphire { GTSPageSize = 0x08C69D698; GTSPageIndex = 0x08C6945C; GTSCurrentView = 0x08C6D6AC; GTSListBlock = 0x8C694F8; GTSBlockEntrySize = 0xA0; BoxInject = 0x8C9E134; BoxScreen = 0x1311B30; PokemonToFind = 0x08335290; PokemonToFindLevel = 0x08335298; PokemonToFindGender = 0x08335294; } if (game == 4) // X and Y { GTSPageSize = 0x08C66080; GTSPageIndex = 0x08C61E40; GTSCurrentView = 0x08C66090; GTSListBlock = 0x8C61EDC; GTSBlockEntrySize = 0xA0; //GTSBlockStart = 0x8C6656C; //GTSBlockEnd = 0x8C66568; //GTSBlockAll = 0x8C666A0; BoxInject = 0x8C861C8; PokemonToFind = 0x08334988; PokemonToFindLevel = 0x08334990; PokemonToFindGender = 0x0833498C; } } public async Task<int> RunBot() { byte[] pokemonIndex = new byte[2]; byte pokemonGender = 0x0; byte pokemonLevel = 0x0; byte[] full = BitConverter.GetBytes(iPokemonToFind); pokemonIndex[0] = full[0]; pokemonIndex[1] = full[1]; full = BitConverter.GetBytes(iPokemonToFindGender); pokemonGender = full[0]; full = BitConverter.GetBytes(iPokemonToFindLevel); pokemonLevel = full[0]; try { while (!botstop) { switch (botState) { case (int)gtsbotstates.botstart: if (bReddit) Program.f1.updateJSON(); botState = (int)gtsbotstates.pressSeek; break; case (int)gtsbotstates.updatecomments: Program.f1.updateJSON(); botState = (int)gtsbotstates.research; break; case (int)gtsbotstates.pressSeek: await Program.helper.waitbutton(Program.PKTable.keyA); await Task.Delay(1000); botState = (int)gtsbotstates.startsearch; break; case (int)gtsbotstates.startsearch: //Write wanted Pokemon, Level, Gender to Ram, won't Display it but works. ¯\_(ツ)_/¯ Program.f1.ChangeStatus("Setting Pokemon to find"); waitTaskbool = Program.helper.waitNTRwrite(PokemonToFind, pokemonIndex, iPID); waitTaskbool = Program.helper.waitNTRwrite(PokemonToFindGender, pokemonGender, iPID); waitTaskbool = Program.helper.waitNTRwrite(PokemonToFindLevel, pokemonLevel, iPID); botState = (int)gtsbotstates.presssearch; break; case (int)gtsbotstates.presssearch: Program.f1.ChangeStatus("Pressing seek button"); Program.helper.quicktouch(200, 180, commandtime); if (searchDirection == SEARCHDIRECTION_FROMBACK) { //This is the only Solution i found so far to change the PageIndex, write Value while Loading the Frame. await Task.Delay(1000); await Program.helper.waitNTRwrite(GTSPageIndex, (uint)startIndex, iPID); } await Task.Delay(4000); botState = (int)gtsbotstates.findPokemon; break; case (int)gtsbotstates.findPokemon: await Program.helper.waitNTRread(BoxScreen); if (Program.helper.lastRead.ToString() == "65794") { botState = (int)gtsbotstates.panic; break; } await Program.helper.waitNTRread(GTSPageSize); uint Entries = (Program.helper.lastRead - 1); CurrentView = Entries; if (searchDirection == SEARCHDIRECTION_FROMBACK) { // Change current Page, everytime + 100 while (!foundLastPage) { startIndex += 100; await Program.helper.waitNTRwrite(GTSPageIndex, (uint)startIndex, iPID); Program.f1.ChangeStatus("Moving to last page"); Program.helper.quickbuton(Program.PKTable.DpadLEFT, commandtime); await Task.Delay(commandtime + delaytime + 1000); Program.helper.quickbuton(Program.PKTable.DpadRIGHT, commandtime); await Task.Delay(commandtime + delaytime + 1000); await Program.helper.waitNTRread(GTSPageSize); Entries = (Program.helper.lastRead - 1); if (Entries < 99 || startIndex >= 500) // Hardcoded to 5 Pages { foundLastPage = true; CurrentView = Entries; } } } Program.f1.ChangeStatus("Looking for a Pokemon to Trade"); // Check the Trade Direction Back to Front or Front to Back if (searchDirection == SEARCHDIRECTION_FROMBACK || searchDirection == SEARCHDIRECTION_FROMBACKFIRSTPAGEONLY) { CurrentView = Entries; iStartIndex = (int)Entries; iEndIndex = 0; iDirection = -1; } else { CurrentView = 0; iStartIndex = 1; iEndIndex = (int)Entries + 1; iDirection = 1; } //There's no Address for ALL Page Entries, so it takes alot longer to find a Pokemon. (2min from Entry 100-1) for (int i = iStartIndex; i * iDirection < iEndIndex; i += iDirection) { //Get the Current Entry Data waitTaskbool = Program.helper.waitNTRread(GTSListBlock + (CurrentView * GTSBlockEntrySize), (uint)(256 * 100)); if (await waitTaskbool) { block = Program.helper.lastArray; //Collect Data int gender = block[0x2]; int level = block[0x3]; // int dlevel = block[0x7]; dex = BitConverter.ToInt16(block, 0x0); // int Item = BitConverter.ToInt16(block, 0x22); szNickname = Encoding.Unicode.GetString(block, 0x08, 24).Trim('\0'); szTrainerName = Encoding.Unicode.GetString(block, 0x40, 24).Trim('\0'); // Phrase = Encoding.Unicode.GetString(block, 0x5A, 30).Trim('\0'); //int countryIndex = BitConverter.ToInt16(block, 0x48); country = "-"; // No valid Country Array found :/ //Program.f1.countries.TryGetValue(countryIndex, out country); //Program.f1.getSubRegions(countryIndex); //int subRegionIndex = BitConverter.ToInt16(block, 0x236); subregion = "-"; // No valid Sub Region Array found :/ //Program.f1.regions.TryGetValue(subRegionIndex, out subregion); Array.Copy(block, 0x3C, principal, 0, 4); byte check = Program.f1.calculateChecksum(principal); byte[] friendcode = new byte[8]; Array.Copy(principal, 0, friendcode, 0, 4); friendcode[4] = check; long i_FC = BitConverter.ToInt64(friendcode, 0); szFC = i_FC.ToString().PadLeft(12, '0'); if (Program.f1.giveawayDetails.ContainsKey(dex)) { Program.f1.giveawayDetails.TryGetValue(dex, out details); if ((gender == 0 || gender == details.Item3) && (level == 0 || level == details.Item4)) { if (useLedySync && !Program.f1.banlist.Contains(szFC) && canThisTrade(principal, consoleName, szTrainerName, country, subregion, Program.PKTable.Species7[dex - 1], szFC, PageIndex + "", (i - 1) + "")) { //Check if Pokemon is from Gen7 szPath = details.Item1; PKHeX dump = new PKHeX(); dump.Data = PKHeX.decryptArray(System.IO.File.ReadAllBytes(szPath)); if (dex < 721 || dump.Version < 29) { PokemonFound = true; Program.f1.ChangeStatus("Found a pokemon to trade"); botState = (int)gtsbotstates.trade; break; } else { Program.f1.ChangeStatus("Looking for a Pokemon to Trade, Current Entry: " + (CurrentView) + "/" + (Entries)); CurrentView--; } } else if (!useLedySync) { if ((!bReddit || Program.f1.commented.Contains(szFC)) && !details.Item6.Contains(BitConverter.ToInt32(principal, 0)) && !Program.f1.banlist.Contains(szFC)) { szPath = details.Item1; //Check if Pokemon is from Gen7 szPath = details.Item1; PKHeX dump = new PKHeX(); dump.Data = PKHeX.decryptArray(System.IO.File.ReadAllBytes(szPath)); if (dex < 721 || dump.Version < 29) { PokemonFound = true; botState = (int)gtsbotstates.trade; break; } else { Program.f1.ChangeStatus("Looking for a Pokemon to Trade, Current Entry: " + (CurrentView) + "/" + (Entries)); CurrentView--; } } } } { Program.f1.ChangeStatus("Looking for a Pokemon to Trade, Current Entry: " + (CurrentView) + "/" + (Entries)); CurrentView--; } } else { Program.f1.ChangeStatus("Looking for a Pokemon to Trade, Current Entry: " + (CurrentView) + "/" + (Entries)); CurrentView--; } } } // No Pokemon found, return to Seek/Deposit Screen if (!PokemonFound) { Program.f1.ChangeStatus("No Pokemon Found"); botState = (int)gtsbotstates.research; break; } break; case (int)gtsbotstates.trade: // Trade Process Program.f1.ChangeStatus("Found a pokemon to trade"); //Inject Pokemon to Box1 Slot1 byte[] pkmEncrypted = System.IO.File.ReadAllBytes(szPath); byte[] cloneshort = PKHeX.encryptArray(pkmEncrypted.Take(232).ToArray()); string ek7 = BitConverter.ToString(cloneshort).Replace("-", ", 0x"); Program.scriptHelper.write(BoxInject, cloneshort, iPID); await Program.helper.waitNTRread(GTSPageIndex); PageIndex = (Program.helper.lastRead + 1); Program.f1.AppendListViewItem(szTrainerName, szNickname, country, subregion, Program.PKTable.Species6[dex - 1], szFC, (PageIndex / 100).ToString(), CurrentView.ToString()); //Ghetto Solution \o/ //Enter current viewed Entry, write wanted current view to RAM, quit current viewed Entry Program.helper.quickbuton(Program.PKTable.keyA, 200); await Task.Delay(2200); await Program.helper.waitNTRwrite(GTSCurrentView, (uint)CurrentView, iPID); Program.helper.quickbuton(Program.PKTable.keyB, 200); await Task.Delay(500); Program.helper.quickbuton(Program.PKTable.keyB, 200); await Task.Delay(2000); Program.helper.quickbuton(Program.PKTable.keyA, 200); await Task.Delay(3000); //Now we have the right Entry, enter current viewed Entry Program.helper.quickbuton(Program.PKTable.keyA, 200); await Task.Delay(500); Program.helper.quickbuton(Program.PKTable.keyA, 200); await Task.Delay(500); Program.helper.quickbuton(Program.PKTable.keyA, 200); Program.f1.ChangeStatus("Trading pokemon on page " + (PageIndex / 100).ToString() + " index " + CurrentView.ToString() + ""); await Task.Delay(10000); //In Case the Pokemon is already traded, go back to Seek/Deposit Screen Program.helper.quickbuton(Program.PKTable.keyB, 250); await Task.Delay(1000); Program.helper.quickbuton(Program.PKTable.keyB, 250); await Task.Delay(1000); // wait if trade is finished await Task.Delay(35000); PokemonFound = true; startIndex = 100; botState = (int)gtsbotstates.botstart; break; case (int)gtsbotstates.research: Program.helper.quickbuton(Program.PKTable.keyB, 250); await Task.Delay(3000); Program.helper.quickbuton(Program.PKTable.keyB, 250); await Task.Delay(3000); botState = (int)gtsbotstates.pressSeek; break; case (int)gtsbotstates.botexit: Program.f1.ChangeStatus("Stopped"); botstop = true; break; case (int)gtsbotstates.panic: if (!Program.Connected) { Program.scriptHelper.connect(szIP, 8000); } Program.f1.ChangeStatus("Recovery Mode"); //In case of a Communication Error Program.helper.quickbuton(Program.PKTable.keyA, 250); await Task.Delay(5000); // Spam B to get out of GTS for (int i = 0; i < 15; i++) { Program.helper.quickbuton(Program.PKTable.keyB, commandtime + 200); await Task.Delay(2000); } Program.helper.quicktouch(170, 2, 200); Program.helper.quicktouch(100, 50, 200); Program.helper.quickbuton(Program.PKTable.keyA, 250); Program.helper.quickbuton(Program.PKTable.keyA, 250); Program.helper.quickbuton(Program.PKTable.keyA, 250); await Task.Delay(10000); botState = (int)gtsbotstates.botstart; break; default: botresult = -1; botstop = true; break; } } } catch { botState = (int)gtsbotstates.panic; } if (this.serverEndPoint != null) { client.Close(); } return botresult; } public void RequestStop() { botstop = true; } } }
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
Lekguide
CSS | 11 hours ago | 0.38 KB
Disable Drag and Drop Image Improved Plugin i...
PHP | 21 hours ago | 1.31 KB
SAVE
22 hours ago | 0.06 KB
ZELAH
22 hours ago | 0.01 KB
z66is_archive.zip.txt
23 hours ago | 1.53 KB
programming
1 day ago | 0.03 KB
thought
1 day ago | 0.14 KB
STORY ENGINE
1 day ago | 1.14 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!