Dinones / Nintendo-Switch-Pokemon-Shiny-Hunter

Search for shiny pokémon on your Nintendo Switch while sleeping!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool



Search for shiny pokémon on your Nintendo Switch while sleeping!

GitHub Repo Stars Discord

Key FeaturesInstallationGetting StartedTroubleshootingCredits



⠀Key Features

⠀ Use your computer or Raspberry Pi to automatically search for shiny pokémon.

⠀ Works on physical games running on a Nintendo Switch, not emulators.

⠀ Compatible with all games that have static encounters (see compatible games).

⠀ Automatically saves a video of the shiny encounter.

⠀Installation

Download or clone the repository.

git clone https://github.com/Dinones/Nintendo-Switch-Pokemon-Shiny-Hunter.git 

Linux and Raspberry Pi OS

sudo apt-get install python3-tk

Go to the project folder and install the libraries.

sudo pip install -r Requirements.txt

Please Note: NXBT needs root privileges to toggle the BlueZ Input plugin. If you don't feel comfortable running this program as root, you can disable the Input plugin manually, and install NXBT as a regular user. I've always run the program as root, so you may need to investigate how to adapt it (Visit NXBT repository to learn more).

Windows and MacOS

Install a Linux Virtual Machine and follow the installation steps for Linux and Raspberry Pi OS. The program has been tested using Raspberry Pi OS 11 (Bullseye) and Virtual Box with XUbuntu 22.04.3. You can find a step-by-step guide on how to setup the Virtual Machine here.

⠀Getting Started

Material List

⠀Capture card that converts HDMI input into USB output.
⠀Nintendo Switch Dock.
⠀HDMI cable.

Setting Up the Nintendo Switch

Place the Nintendo Switch into the Dock. Connect the dock to the official Nintendo Switch charger. Connect the HDMI output of the Dock to the input of your capture card. Finally, connect your capture card to your computer / Raspberry via USB. If your game is not digital, insert the game card in the Nintendo.

NOTE: The program will always open the first game slot. Make sure the pokémon game you want to run is in the first position. If it's not, you can simply start the game and it'll move to the beginning.

Once in the home screen, go to Controllers > "Change Grip/Order Menu". Remove both controllers from the Nintendo Switch and make sure they're not connected via bluetooth. (See steps here).

⠀Detecting the Capture Card

Execute /Sub_Programs/Find_Video_Capture.py. It will print all the video capture devices found. Multiple devices may appear even if you only have one device connected: webcams and some drivers may raise extra devices.

To discover which is the good one, note all the detected devices. You will have to change the VIDEO_CAPTURE_INDEX variable of the Constants.py file. Now, execute /Utils/Game_Capture.py. It will open a window showing what is being captured. Repeat the process until you find the desired device.

⠀Selecting the Shiny Pokémon

CAUTION: Make sure the desired shiny pokémon has not been shiny locked in the game.

Once you have selected your pokemon you have execute /Sub_Programs/Find_Color_Range.py. It will open the following interface:

Now, you have to find on internet one image for each, the normal pokémon and the shiny one. Download them, and select the images using the two buttons that appear on the top of the interface.

Once both images are loaded in the interface, you can start moving the color slides. Follow the instructions that appear on the interface until you get a similar result to this one:

As you can see, the image above has white pixels, while the one below does not. It doesn't matter if there are a few white pixels in the image below, just make sure they don't form a large grouping. Keep in mind that the better accuracy you achieve, the better the program will work. It's a good idea to spend some time trying to get precise results.

Once you have detected the colors, you can press the "Toggle Check Match" button. It will open a new window where you should see rectangles around the areas where the color is present. If any rectangle appears, your area is too small to be detected, try finding another color with larger area.

Once you've found the color ranges that fit the requirements, change the LOWER_COLOR and UPPER_COLOR variables in the Constants.py file to the new values.

⠀Controlling the Nintendo Switch

Before executing the main program, check NXBT is successfully working in your system. Please, visit NXBT repository and perform the demo testing.

It may not be working at the beginning, try restarting the computer and bluetooth systems, you can use rfkill block bluetooth and rfkill unblock bluetooth. If you are not able to connect your computer to the Nintendo, please, report to NXBT.

⠀Running the Shiny Hunter

NOTE: If your player needs to move forward some steps before entering the combat, change the WALK_FORWARD_BEFORE_COMBAT option to True in the Constants.py file.

Execute the Shiny_Hunter.py file. The controller should connect in a few seconds and the program will start it execution. For every combat, it will save an screenshot of the pokémon in /Media/Results/ folder, just in case it missdetects the shiny pokémon you could check why. It will also save a video for each encounter in /Media/ folder, it always ovewrites the old video file, don't worry about your disk space. If you want to disable these features, change the SAVE_SCREENSHOTS and RECORD_VIDEO options to False in the Constants.py file.

If you find a shiny pokémon and you want to search for another one, you must reset the number of the /Media/Attempts.txt file to zero, to keep track of the current resets for the new pokémon. It's also recomendable to delete all the images generated in the /Media/Results/ folder.

⠀Troubleshooting

Unable to install opencv-python library

In some Raspberry Pi OS versions and other operating systems, OpenCV may take forever to install, eventually raising an error. If this happens, force the installation of the version 4.5.3.56 by running: pip install opencv-python==4.5.3.56.

Error when installing the dbus-python package

This error can occur due to missing dbus-related libraries on some Linux distributions. To fix this in most cases, libdbus-glib-1-dev and libdbus-1-dev need to be installed with your system's package manager:

sudo apt-get install libdbus-glib-1-dev libdbus-1-dev

⠀Issues

Failed to allocate XXX bytes in function 'OutOfMemoryError'

After some hours running, program may crash due to it has ran out of memory, this error only raises on Raspberry Pi. Still working on it, a new version will be uploaded as soon as possible.

⠀Credits

A big thank to all the contributors of NXBT repository. The whole program resolves around its work. Also thank to Learn Code By Gaming youtube channel, where I learnt most of what I know about image processing and object detection.

About

Search for shiny pokémon on your Nintendo Switch while sleeping!


Languages

Language:Python 100.0%