-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
179 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
screenshot.png | ||
screenshot.png | ||
last_game_xp.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,23 @@ | ||
|
||
# Dead by Daylight XP/Rift Farm | ||
|
||
In DBD you get 1 XP per second capped at 10 minutes, so this script will get you around 4950 XP (500 XP = 1 Rift Fragment) per hour (during my tests). | ||
|
||
Remember that you can get banned even thought I haven't heard about AFK bans. | ||
|
||
## Warnings | ||
|
||
**[!] This script may not work with your monitor! You can open `screenshot.png` file and change values at line 39.** | ||
|
||
**[!] You can't use your pc while using this script! The game has to be focused.** | ||
> [!WARNING] | ||
> This script is designed for 1920x1080 display. If you are using a higher resolution display please set it to 1920x1080 in windows' display settings. | ||
# An AFK Script for Dead by Daylight | ||
|
||
## Setup | ||
1. Download and unpack this repository | ||
2. Install python 3.11+ | ||
3. Install python requirements (setup.bat, first time only): | ||
``` | ||
pip install -r requirements.txt | ||
``` | ||
4. Run the script (start.bat): | ||
``` | ||
python run.py | ||
``` | ||
|
||
## Features | ||
|
||
- Auto queue | ||
|
||
## Roadmap | ||
|
||
- Statistics | ||
|
||
- Text recognition area selector. | ||
|
||
## Installation | ||
|
||
- If you don't know what git is you can [click here to download the zip](https://github.com/Pazdikan/dbd-xp-farm/archive/refs/heads/master.zip) and unpack it. | ||
|
||
## Usage | ||
- Run the game, select the killer and stay on the screen with ready button. | ||
- Run the `start.bat` file. | ||
|
||
You can bring perks like [Corrupt Intervention](https://deadbydaylight.fandom.com/wiki/Corrupt_Intervention) and [Hex: Ruin](https://deadbydaylight.fandom.com/wiki/Hex:_Ruin) to slow down the game (for full 10 minutes XP) | ||
- [X] Queueing | ||
- [X] Attacking | ||
- [X] Random Movement | ||
- [X] Total games and total XP counts | ||
- [ ] Different behaviour for different killers (eg. trapper = setting traps; dracula = shapeshifting) (for bloodpoints) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
colorama==0.4.4 | ||
mss==6.1.0 | ||
numpy==1.22.3 | ||
opencv_python==4.5.5.64 | ||
Pillow==9.1.1 | ||
psutil==5.9.0 | ||
PyAutoGUI==0.9.53 | ||
pynput==1.7.6 | ||
pytesseract==0.3.9 | ||
easyocr==1.7.1 | ||
mss==9.0.1 | ||
Pillow==10.4.0 | ||
PyAutoGUI==0.9.54 | ||
rich==13.8.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
import mss | ||
import pyautogui | ||
import easyocr | ||
import time | ||
from PIL import Image | ||
import os | ||
from enum import Enum | ||
import rich | ||
from rich.console import Console | ||
from rich.text import Text | ||
|
||
pyautogui.FAILSAFE = False | ||
|
||
def click_image(): | ||
try: | ||
pos = pyautogui.locateOnScreen('screenshot.png', confidence=(0.8)) | ||
if pos != None: | ||
pyautogui.click(pos[0] + 20, pos[1]) | ||
time.sleep(0.5) | ||
except: | ||
pass | ||
|
||
lobby_button = { | ||
"top": 927, | ||
"left": 1580, | ||
"width": 235, | ||
"height": 35 | ||
} | ||
|
||
endgame_button = { | ||
"top": 1000, | ||
"left": 1650, | ||
"width": 235, | ||
"height": 35 | ||
} | ||
|
||
games = 0 | ||
xp = 0 | ||
|
||
def take_and_read_screenshot(area): | ||
screenshot = sct.grab(area) | ||
image = Image.frombytes("RGB", screenshot.size, screenshot.bgra, "raw", "BGRX") | ||
image.save("screenshot.png") | ||
return reader.readtext("screenshot.png", detail=0) | ||
|
||
def take_and_read_xp_screenshot(): | ||
screenshot = sct.grab({ | ||
"top": 700, | ||
"left": 540, | ||
"width": 75, | ||
"height": 35 | ||
}) | ||
image = Image.frombytes("RGB", screenshot.size, screenshot.bgra, "raw", "BGRX") | ||
image.save("last_game_xp.png") | ||
return reader.readtext("last_game_xp.png", detail=0) | ||
|
||
console = rich.console.Console() | ||
console.set_window_title("DBD Auto AFK by Pazdikan") | ||
console.clear() | ||
console.log(Text("Initializing...")) | ||
console.log(Text("! IGNORE ALL ERRORS BELOW !", style="bold black on red")) | ||
|
||
|
||
if __name__ == '__main__': | ||
State = Enum('State', ['INGAME', 'INLOBBY', 'INQUEUE']) | ||
|
||
current_state = State.INLOBBY | ||
|
||
reader = easyocr.Reader(['en']) | ||
|
||
with mss.mss() as sct: | ||
console.clear() | ||
console.log(Text("Initialized!", style="green")) | ||
while True: | ||
if (current_state == State.INGAME): | ||
ocr = take_and_read_screenshot(endgame_button) | ||
|
||
if any("CONTINUE" in string for string in ocr): | ||
pyautogui.click(x=465, y=871) | ||
pyautogui.click(x=465, y=871) | ||
pyautogui.click(x=465, y=871) | ||
|
||
time.sleep(5) | ||
|
||
xp += int(take_and_read_xp_screenshot()[0]) | ||
|
||
time.sleep(5) | ||
|
||
click_image() | ||
click_image() | ||
click_image() | ||
console.log("Clicking CONTINUE (endgame)") | ||
current_state = State.INLOBBY | ||
|
||
games += 1 | ||
console.log(Text(f" Games Played: {games} ", style="black on green")) | ||
console.log(Text(f" Total XP Earned: {xp} ", style="black on yellow")) | ||
|
||
console.log("Setting state to INLOBBY") | ||
console.log("Waiting 30 seconds") | ||
time.sleep(30) | ||
console.log("Finished waiting") | ||
else: | ||
console.log("Performing random movement") | ||
pyautogui.keyDown("w") | ||
pyautogui.mouseDown() | ||
time.sleep(0.5) | ||
pyautogui.mouseUp() | ||
pyautogui.keyUp("w") | ||
time.sleep(10) | ||
else: | ||
pyautogui.moveTo(0, 0) | ||
|
||
ocr = take_and_read_screenshot(lobby_button) | ||
|
||
if any("PLAY" in string for string in ocr): | ||
click_image() | ||
click_image() | ||
click_image() | ||
console.log("Clicking PLAY in main menu") | ||
|
||
elif any("READY" in string for string in ocr): | ||
click_image() | ||
click_image() | ||
click_image() | ||
console.log("Clicking READY in found lobby") | ||
current_state = State.INGAME | ||
console.log("Setting state to INGAME") | ||
console.log("Waiting 120 seconds") | ||
time.sleep(120) # Loading from lobby to game (+ missing players etc.) | ||
console.log("Finished waiting") | ||
|
||
elif not ocr: | ||
ocr = take_and_read_screenshot(endgame_button) | ||
|
||
# Sometimes the game doesn't register the click | ||
# Script thinks it's in main menu but game is still in endgame | ||
if any("CONTINUE" in string for string in ocr): | ||
click_image() | ||
click_image() | ||
click_image() | ||
console.log("Clicking CONTINUE (endgame)") | ||
|
||
console.log("Waiting 30 seconds") | ||
time.sleep(30) | ||
console.log("Finished waiting") | ||
|
||
console.log("Waiting 5 seconds") | ||
time.sleep(5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pip install -r requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
pip install -r requirements.txt | ||
python main.py | ||
python run.py |