Skip to content

Python Project 4. semester. Aimbot for the multiplayer shooter "Doomstein98".

License

Notifications You must be signed in to change notification settings

majohab/Doomstein98-Aimbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Doomstein98-Aimbot

Python project 4. semester. Aimbot for the multiplayer shooter "Doomstein98". It works by capturing a image of a browser window via pysimplegui. Then a yolov3 neural network detects the players in the image. Now the player closest to the middle of the window (usually where the crosshair is placed) is determined. Following this the mouse will be moved to the closest player and the left mouse button will be clicked (to shoot the player). At this state the code is fully working but i have not trained a custom version of the yolov3 net, so to test the code we will use a video which will show the full functionality of the code. More on that under demo. Training a custom model would exceed the given timeframe but will be done in the future.

Requirements

For the CNN we will need a pretrained .weights file and a config file. You can use your own configuration or download files from pjreddie.com.

Provided configuration (tested working)

  1. Choose the correct pretrained configuration
    We will use the net "YOLOv3-416" which has a input sie of 416x416 and is trained on the coco dataset.
  2. Create an .names file
    The .names file contains all class names that the network is trained for. Conveniently the .names file for the coco dataset is provided in this repository under ./yolov3/coco.names.
  3. Download the .config and .weights file from pjreddie.com.
    Choose the following line and click on cfg and weights to download the files. In case of the cfg file copy the content and create a "yolov3.cfg" file under ./yolov3/ and paste.
YOLOv3-416	COCO trainval	test-dev	55.3	65.86 Bn	35	cfg	weights
  1. Define filepaths and input size.
    Define the filepaths and input size in the .cfg file under ./cfg/object_detector.cfg. As you remember the chosen version of yolo has a input size of 416x416. The result should look like this:
[CNN]
cfg = ./yolov3/yolov3.cfg
names = ./yolov3/coco.names
weights = ./yolov3/yolov3.weights

[PARAMETERS]
width = 416
height = 416

If you saved the files somewhere else then change the filepaths accordingly. You can use multiple .cfg files for different versions of yolo but you will have to specify which .cfg file to use in the input parameters of the program

Custom configuration

  1. Get the .names, .cfg and .weights file of your trained net.
  2. Save them in the directory of choice.
  3. Configure the filepaths in a new .cfg file under ./cfg/
  4. Use your created .cfg file as an input argument.

Dependencies

This script uses an number of python libraries. They can be installed either through pip or pipenv.

  1. Installation with pip.
    You may want to install the packages into a virtual environment to prevent problems with already installed versions of the packages. Install the requirements.txt file with:
pip install requirements.txt
  1. Installation with pipenv.
    Pipenv automaticly creates a virtual environment for the project. To install dependencies and start virtual environment with:
pipenv install
pipenv shell

Usage

To use this script you need to execute the "main.py" script. It uses a number of parameters that you will need to specify with the execution call.

  1. Start the script.
    Navigate to the folder and call the script with the argument "-h" to get a explanation of the possible arguments.
python main.py
  1. Define nessecary arguments.
    The script needs a set of arguments to work. First of all it needs a configuration file that specifies which neural network to use. That congif file was created earlier in the requirements section. It can be specified with -cfg. Next you need to specify the name of the window in which the game runs. It is usually stated on top of the window. Google Chrome specifies der Window name in the following format <Tab name> - Google Chrome. For other applications you will need to find out the name on your own. Additionally you can set the FOVOFFSET values. These parameters change by how much the mouse is moved based on the pixel values of the detected player. You may need to tweak them for your system or game to accurately aim at players. Both the x and y directions have pre defined values by me but you may have to tweak them. If you want to see what the neural network detects then set the debug flag to True. This will bring up a video feed with the frames and their bounding boxes.
    You can read about the additional parameters and how to use them here:
python main.py <argument> <value> ...
  -h, --help            show this help message and exit
  -cfg CONFIG, --config CONFIG
                        Path to the .cfg file containing the config of the network
  -lt LOGGING_TYPE, --logging_type LOGGING_TYPE
                        Sets the desired logging mode. Possible types are central (one log file for all classes) and decentral (every class has its own log file). This
                        parameter is optional (standart central).
  -dbg DEBUG_FLAG, --debug_flag DEBUG_FLAG
                        Flag that turns on the debug mode. The value has to be a boolean value. This parameter is optional.
  -wdn WINDOW_NAME, --window_name WINDOW_NAME
                        The window name of the game where the aimbot should run. The value has to be a string value. This parameter is optional.
  -fovx FOVOFFSETX, --fovoffsetx FOVOFFSETX
                        The value to correct distortion in the x axis. The value has to be a float value. This parameter is optional.
  -fovy FOVOFFSETY, --fovoffsety FOVOFFSETY
                        The value to correct distortion in the y axis. The value has to be a float value. This parameter is optional.
  -llvl LOGGING_LEVEL, --logging_level LOGGING_LEVEL
                        Sets the desired logging level of the logger. Possible types are debug and info. This parameter is optional (standart level info).
  1. Start the detection
    After you started the script. Open the window of your choice and press "+" to start the aimbot. After you are done playing press and hold "+" to stop the detection.

Demo

Because at this moment the player models will not be detected by the trained version of yolo we use the following video as a demo of the capabilities of the script. If you are using Google chrome and the provided configuration of yolo as described in the requirements section you should not need to specify any arguments as explained under usage because the deafult values are cofigured for this example. The only thing you may need to tweak is the FOVOFFSET parameters as they differ from system to system. So what you basicly need to do is:

  1. Open this video on youtube
  2. Start the script as described under usage. Without any parameters except the FOVOFFSET as explained earlier
  3. Switch to the chrome tab to start the script.

Sources

While most of the code is self written the basic concept is inspired by the following sources. Code which is inspired by the following sources is marked in the docstring.
[1] https://github.com/monokim/AIMBOT-YOLO/blob/master/aimbot.py - Basic concept
[2] https://pysource.com/2019/06/27/yolo-object-detection-using-opencv-with-python/ - object detection with opencv

About

Python Project 4. semester. Aimbot for the multiplayer shooter "Doomstein98".

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages