mirror of
https://github.com/fishyboteso/fishyboteso.git
synced 2024-08-30 18:32:13 +00:00
Merge pull request #19 from SemjonKerner/interaction_jitter
Feature: Add Random Delay to Interactions
This commit is contained in:
@ -16,6 +16,7 @@ import keyboard
|
|||||||
|
|
||||||
from fishy.helper.config import config
|
from fishy.helper.config import config
|
||||||
|
|
||||||
|
import random
|
||||||
|
|
||||||
class FishEvent:
|
class FishEvent:
|
||||||
fishCaught = 0
|
fishCaught = 0
|
||||||
@ -24,6 +25,7 @@ class FishEvent:
|
|||||||
fish_times = []
|
fish_times = []
|
||||||
hole_start_time = 0
|
hole_start_time = 0
|
||||||
FishingStarted = False
|
FishingStarted = False
|
||||||
|
jitter = False
|
||||||
previousState = State.IDLE
|
previousState = State.IDLE
|
||||||
|
|
||||||
# initialize these
|
# initialize these
|
||||||
@ -32,9 +34,17 @@ class FishEvent:
|
|||||||
uid = None
|
uid = None
|
||||||
sound = False
|
sound = False
|
||||||
|
|
||||||
|
def _fishing_sleep(waittime, lower_limit_ms = 16, upper_limit_ms = 2500):
|
||||||
|
reaction = 0.0
|
||||||
|
if FishEvent.jitter and upper_limit_ms > lower_limit_ms:
|
||||||
|
reaction = float( random.randrange(lower_limit_ms, upper_limit_ms) )/1000.0
|
||||||
|
max_wait_t = waittime+reaction if waittime+reaction <= 2.5 else 2.5
|
||||||
|
time.sleep(max_wait_t)
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
subscribe()
|
subscribe()
|
||||||
|
FishEvent.jitter = config.get("jitter", False)
|
||||||
FishEvent.action_key = config.get("action_key", 'e')
|
FishEvent.action_key = config.get("action_key", 'e')
|
||||||
FishEvent.collect_key = config.get("collect_key", 'r')
|
FishEvent.collect_key = config.get("collect_key", 'r')
|
||||||
FishEvent.collect_allow_auto = config.get("collect_allow_auto", False)
|
FishEvent.collect_allow_auto = config.get("collect_allow_auto", False)
|
||||||
@ -77,9 +87,10 @@ def on_hook():
|
|||||||
keyboard.press_and_release(FishEvent.action_key)
|
keyboard.press_and_release(FishEvent.action_key)
|
||||||
|
|
||||||
if FishEvent.collect_allow_auto:
|
if FishEvent.collect_allow_auto:
|
||||||
time.sleep(0.1)
|
_fishing_sleep(0.1)
|
||||||
keyboard.press_and_release('r')
|
keyboard.press_and_release('r')
|
||||||
time.sleep(0.1)
|
_fishing_sleep(0.1)
|
||||||
|
_fishing_sleep(0.0)
|
||||||
|
|
||||||
|
|
||||||
def on_look():
|
def on_look():
|
||||||
|
@ -53,6 +53,7 @@ def start_semifisher_config(gui: 'GUI'):
|
|||||||
gui.config.set("collect_key", collect_key_entry.get(), False)
|
gui.config.set("collect_key", collect_key_entry.get(), False)
|
||||||
gui.config.set("collect_allow_auto", collect_allow_auto.instate(['selected']), False)
|
gui.config.set("collect_allow_auto", collect_allow_auto.instate(['selected']), False)
|
||||||
gui.config.set("borderless", borderless.instate(['selected']), False)
|
gui.config.set("borderless", borderless.instate(['selected']), False)
|
||||||
|
gui.config.set("jitter", jitter.instate(['selected']), False)
|
||||||
gui.config.set("sound_notification", sound.instate(['selected']), False)
|
gui.config.set("sound_notification", sound.instate(['selected']), False)
|
||||||
gui.config.save_config()
|
gui.config.save_config()
|
||||||
|
|
||||||
@ -107,5 +108,9 @@ def start_semifisher_config(gui: 'GUI'):
|
|||||||
sound = Checkbutton(controls_frame, var=BooleanVar(value=config.get("sound_notification")))
|
sound = Checkbutton(controls_frame, var=BooleanVar(value=config.get("sound_notification")))
|
||||||
sound.grid(row=5, column=1)
|
sound.grid(row=5, column=1)
|
||||||
|
|
||||||
|
Label(controls_frame, text="Human-Like Delay: ").grid(row=6, column=0, pady=(5, 5))
|
||||||
|
jitter = Checkbutton(controls_frame, var=BooleanVar(value=config.get("jitter")))
|
||||||
|
jitter.grid(row=6, column=1)
|
||||||
|
|
||||||
controls_frame.pack(padx=(5, 5), pady=(5, 5))
|
controls_frame.pack(padx=(5, 5), pady=(5, 5))
|
||||||
top.start()
|
top.start()
|
||||||
|
Reference in New Issue
Block a user