From b238e26b68b327e1d04e71aca7b55982d6ec4415 Mon Sep 17 00:00:00 2001 From: DeathBerry-dev Date: Sat, 18 Jan 2025 18:52:27 +1100 Subject: [PATCH 1/3] S/V RNG manipulation RNG manipulation for the item maker in the scarlet and violet DLC --- Pokemon_Seeds.csv | 35 ++++++ item_dupe.py | 308 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 343 insertions(+) create mode 100644 Pokemon_Seeds.csv create mode 100644 item_dupe.py diff --git a/Pokemon_Seeds.csv b/Pokemon_Seeds.csv new file mode 100644 index 0000000..4604b0a --- /dev/null +++ b/Pokemon_Seeds.csv @@ -0,0 +1,35 @@ +2033;02;08;10;48;09;EXP_Candy_XL +2037;05;08;06;23;39;Ability_Patch +2018;01;24;09;29;28;Gold_Bottle_Cap +2056;08;06;15;52;42;PP_Max +2055;09;02;10;54;50;Master_Ball +2049;01;02;01;20;22;Safari_Ball +2034;09;01;02;33;39;Fast_Ball +2057;08;02;07;24;45;Level_Ball +2057;11;21;04;28;37;Lure_Ball +2056;07;31;09;23;57;Heavy_Ball +2059;10;07;02;39;54;Love_Ball +2046;12;11;02;23;17;Friend_Ball +2031;10;08;05;26;34;Moon_Ball +2028;04;07;04;15;56;Sport_Ball +2043;10;23;16;32;45;Dream_Ball +2023;09;24;08;27;16;Beast_Ball +2005;05;21;15;30;56;Normal_Tera_Shards +2054;08;05;03;35;10;Fire_Tera_Shards +2027;04;22;14;01;45;Water_Tera_Shards +2040;11;15;04;12;36;Electric_Tera_Shards +2004;03;31;02;00;57;Grass_Tera_Shards +2018;11;08;10;00;51;Ice_Tera_Shards +2025;07;25;18;12;50;Fighting_Tera_Shards +2001;09;03;02;14;28;Poison_Tera_Shards +2016;05;15;14;18;09;Ground_Tera_Shards +2055;06;10;06;03;31;Flying_Tera_Shards +2039;06;02;02;15;13;Psychic_Tera_Shards +2044;08;29;13;04;46;Bug_Tera_Shards +2046;09;09;00;48;46;Rock_Tera_Shards +2057;01;05;02;09;53;Ghost_Tera_Shards +2026;02;07;09;55;41;Dragon_Tera_Shards +2020;11;08;19;53;56;Dark_Tera_Shards +2019;03;30;06;49;09;Steel_Tera_Shards +2055;01;13;14;40;36;Fairy_Tera_Shards +2044;05;11;19;56;47;Stellar_Tera_Shards \ No newline at end of file diff --git a/item_dupe.py b/item_dupe.py new file mode 100644 index 0000000..a1fcbca --- /dev/null +++ b/item_dupe.py @@ -0,0 +1,308 @@ +import time +from random import randint + +import nxbt +from nxbt import Buttons +from nxbt import Sticks +#MACROS +DIALOG_SETUP = """ +0.1s +L_STICK@-50+50 0.1s +A 0.1s +4s +A 0.1s +1s +"""#left on "I would like to print something" +NAVIGATE_TIME = """ +1s +HOME 0.1s +5s +DPAD_DOWN 0.1s +0.5s +LOOP 5 + DPAD_RIGHT 0.1s + 0.1s +1s +A 0.1s +1s +DPAD_DOWN 3s +1s +A 0.1s +1s +LOOP 3 + DPAD_DOWN 0.1s + 0.1s + +LOOP 2 + DPAD_DOWN 0.1s +0.1s + +LOOP 2 + DPAD_DOWN 0.1s + 0.1s +A 0.1s +1s +LOOP 2 + DPAD_DOWN 0.1s + 0.1s +0.1s +A 0.1s +1s +""" #left on date and time +TIMING = """ +0.1s +HOME 0.1s +1s +A 0.1s +1s +""" #left in game for timer +PRINT_ITEM = """ +15s +X 0.1s +1s +A 0.1s +7s +A 0.1s +20s +A 0.1s +1s +A 0.1s +1s +LOOP 8 + B 0.1s + 0.9s +""" #left looking at printer +PRINT_ITEM_R = """ +15s +R 0.1s +1s +X 0.1s +1s +A 0.1s +7s +A 0.1s +20s +A 0.1s +1s +A 0.1s +1s +LOOP 8 + B 0.1s + 0.9s +""" #left looking at printer +PRINT_ITEM_L = """ +15s +L 0.1s +1s +X 0.1s +1s +A 0.1s +7s +A 0.1s +20s +A 0.1s +1s +A 0.1s +1s +LOOP 8 + B 0.1s + 0.9s +""" #left looking at printer +TURN_OFF = """ +1s +HOME 0.1s +1s +DPAD_DOWN 0.1s +0.5s +LOOP 4 + DPAD_RIGHT 0.1s + 0.3s +0.5s +A 0.1s +0.1s +A 0.1s +""" +def random_colour(): + return [ + randint(0, 255), + randint(0, 255), + randint(0, 255), + ] +def generate_seeds(): #creates Dict of date/time for items/bonus + with open("Pokemon_Seeds.csv", "r") as seeds: + ref = {} + for item in seeds: + parts = item.strip() + parts = parts.split(";") + ref[parts[-1]] = int(parts[2]), int(parts[1]), int(parts[0]), int(parts[3]), int(parts[4]), int(parts[5]) + return ref +def item_input(): #Select item + print(f"Avaliable items:{seed_name()}") + while True: + item_select = input(f"Type which item you would like:") + if item_select in seed: + return seed[item_select] + else: + print("incorrect input") +def mode_set(input_item, mode): #sets mode based on item selected + if mode == 1: + return bonus_check(input_item) + elif mode == 5: + return input_item + else: + raise ValueError +def bonus_check(item): #selects what bonus is required based on item + if item in balls: + return 12, 1, 2025, 23, 35, 8 + else: + return 11, 1, 2025, 21, 59, 9 +def ball_list(): #set bonus select filter + ref = [] + for item in seed: + if "Ball" in item: + ref.append(item) + return ref +def repeat_amount(): #sets amount of repeats to be done + while True: + repeat = int(input(f"Type how many times to repeat:")) + try: + if abs(repeat) > 0: + return abs(repeat) + except: + pass + print("incorrect input") +def seed_name(): #creates list of names for items to input + ref = [] + for name in seed: + ref.append(name) + return ref + +def time_change_setup(current_time, item): #changes date time settings + print("changing time settings") + date_change(current_time[0], item[0]) #day + nx.press_buttons(controller_index, [Buttons.DPAD_RIGHT], block=True) + date_change(current_time[1], item[1]) #month + nx.press_buttons(controller_index, [Buttons.DPAD_RIGHT], block=True) + date_change(current_time[2], item[2]) #year + nx.press_buttons(controller_index, [Buttons.DPAD_RIGHT], block=True) + date_change(current_time[3], item[3]) #hour + nx.press_buttons(controller_index, [Buttons.DPAD_RIGHT], block=True) + date_change(current_time[4], item[4]) #minute + nx.press_buttons(controller_index, [Buttons.DPAD_RIGHT], block=True) + print(f"time set to {item}") +def date_change(current, target): #inputs for date/time changes + dif = current - target + if dif > 0: + for repeat in range(0, abs(dif)): + nx.press_buttons(controller_index, [Buttons.DPAD_DOWN], block=True) + elif dif < 0: + for repeat in range(0, abs(dif)): + nx.press_buttons(controller_index, [Buttons.DPAD_UP], block=True) + elif dif == 0: + return + else: + return ValueError +def timer(item): #timer TM + print(f"countdown target {item}s") + global start_flag + timing = float(item) - delay + nx.press_buttons(controller_index, [Buttons.A], block=True)#start countdown + start_flag = time.perf_counter() + macro_id = nx.macro(controller_index, TIMING, block=False) + while True: + if time_check() >= timing: + nx.press_buttons(controller_index, [Buttons.A]) + print(f"timer completed at {time_check():.6f}") + break + print("") +def update_current(item): #keeps track of current date time setting + global current_time #going to change current + print(time_check()) + runtime = time.strftime("%M:%S", time.gmtime(time_check())) #time thats lapsed + print(f"runtime was {runtime}s") + runtime_parts = runtime.split(":") #split into min, sec + print(f"{int(item[4])}+{int(runtime_parts[0])}") + minute_update = int(item[4]) + int(runtime_parts[0]) + if minute_update >= 60: + minute_update -= 60 + time_elapsed = tuple((item[0], item[1], item[2], (item[3]+1), minute_update, 0)) + #print("added an hour") + else: + time_elapsed = tuple((item[0], item[1], item[2], item[3], minute_update, 0)) + #print("only added minutes") + current_time = time_elapsed + print(f"time set to {current_time}") +def print_job(mode): #keeps track of Job amount is set to + global job_set + if job_set < mode: + print("Setting Job to 5\nPrinting...") + macro_id = nx.macro(controller_index, PRINT_ITEM_R, block=True) #print item + job_set = mode + elif job_set > mode: + print("setting job to 1\nPrinting...") + macro_id = nx.macro(controller_index, PRINT_ITEM_L, block=True) #print item + job_set = mode + else: + macro_id = nx.macro(controller_index, PRINT_ITEM, block=True) +def return_default(): + print("returning to default posistion") + macro_id = nx.macro(controller_index, DIALOG_SETUP, block=True) #sets up Dialog for next print + print("Returning to Date and Time settings") + macro_id = nx.macro(controller_index, NAVIGATE_TIME, block=True) #time paused +def print_main(): #main LOOP + macro_id = nx.macro(controller_index, NAVIGATE_TIME) + print(f"set date and time to {default_time}") + input("Press ENTER to continue...") + #item = item_input() + item = seed["EXP_Candy_XL"] + repeat = repeat_amount() + for i in range(0, repeat): + print(f"\nPrinting batch {i+1}") + print("\nsetting up bonus") + item_print(item, 1) + print("\nprinting frist batch") + item_print(item, 5) + print("\nprinting last batch") + item_print(item, 5) + print("\nRepeats have completed") +def item_print(input_item, mode): #setup and print + item = mode_set(input_item, mode) + time_change_setup(current_time[:-1], item[:-1]) + timer(item[-1]) #runs timer and returns start_flag + print_job(mode) + return_default() + update_current(item) +def time_check(): + return time.perf_counter() - start_flag + +if __name__ == "__main__": + #set_up + #Global Variables + default_time = (1, 1, 2025, 0, 0, 0) + current_time = default_time + job_set = 5 + seed = generate_seeds() + balls = ball_list() + delay = 1.0006 + #start_flag = 0 + # Init NXBT + import nxbt + + # Start the NXBT service + nx = nxbt.Nxbt() + + # Create a Pro Controller and wait for it to connect + controller_index = nx.create_controller(nxbt.PRO_CONTROLLER) + nx.wait_for_connection(controller_index) + + print("Connected") + #player set up intructions + print("Before continuing please make sure you have completed the following intructions") + print("Open pokemon and print 1 item with job amount 5") + print("Turn and talk to NPC and leave on 'I would like to print something'") + print("Have date and time set to YY:MM:DD 24hour clock") + print("leave cursor on year") + print("WARNING: make sure there is no current bonus") + #Program Starts HERE + print_main() + macro_id = nx.macro(controller_index, TURN_OFF) From 6c3a3f5fab7a439bd3ad5bfaef866d38b549111f Mon Sep 17 00:00:00 2001 From: DeathBerry-dev Date: Sun, 19 Jan 2025 14:05:03 +1100 Subject: [PATCH 2/3] Updated 1.1 Fixed timer, has had no loss in testing so far --- item_dupe.py | 119 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 72 insertions(+), 47 deletions(-) diff --git a/item_dupe.py b/item_dupe.py index a1fcbca..74f3788 100644 --- a/item_dupe.py +++ b/item_dupe.py @@ -9,9 +9,9 @@ 0.1s L_STICK@-50+50 0.1s A 0.1s -4s +8s A 0.1s -1s +2s """#left on "I would like to print something" NAVIGATE_TIME = """ 1s @@ -32,11 +32,9 @@ LOOP 3 DPAD_DOWN 0.1s 0.1s - LOOP 2 DPAD_DOWN 0.1s 0.1s - LOOP 2 DPAD_DOWN 0.1s 0.1s @@ -58,55 +56,53 @@ """ #left in game for timer PRINT_ITEM = """ 15s +0.1s X 0.1s 1s A 0.1s -7s +40s +B 0.1s +2s A 0.1s -20s -A 0.1s -1s -A 0.1s -1s +10s LOOP 8 B 0.1s - 0.9s + 1s +10s """ #left looking at printer PRINT_ITEM_R = """ 15s R 0.1s -1s +0.1s X 0.1s 1s A 0.1s -7s -A 0.1s -20s -A 0.1s -1s +40s +B 0.1s +2s A 0.1s -1s +10s LOOP 8 B 0.1s - 0.9s + 1s +10s """ #left looking at printer PRINT_ITEM_L = """ 15s L 0.1s -1s +0.1s X 0.1s 1s A 0.1s -7s +40s +B 0.1s +2s A 0.1s -20s -A 0.1s -1s -A 0.1s -1s +10s LOOP 8 B 0.1s - 0.9s + 1s +10s """ #left looking at printer TURN_OFF = """ 1s @@ -153,7 +149,7 @@ def mode_set(input_item, mode): #sets mode based on item selected raise ValueError def bonus_check(item): #selects what bonus is required based on item if item in balls: - return 12, 1, 2025, 23, 35, 8 + return 24, 1, 2025, 13, 12, 9 else: return 11, 1, 2025, 21, 59, 9 def ball_list(): #set bonus select filter @@ -176,7 +172,6 @@ def seed_name(): #creates list of names for items to input for name in seed: ref.append(name) return ref - def time_change_setup(current_time, item): #changes date time settings print("changing time settings") date_change(current_time[0], item[0]) #day @@ -209,16 +204,18 @@ def timer(item): #timer TM nx.press_buttons(controller_index, [Buttons.A], block=True)#start countdown start_flag = time.perf_counter() macro_id = nx.macro(controller_index, TIMING, block=False) - while True: - if time_check() >= timing: - nx.press_buttons(controller_index, [Buttons.A]) - print(f"timer completed at {time_check():.6f}") - break + #while True: + #if (time.perf_counter() - start_flag) >= timing: + #nx.press_buttons(controller_index, [Buttons.A]) + #print(f"timer completed at {(time.perf_counter() - start_flag):.6f}") + #break + time.sleep(timing - (time.perf_counter() - start_flag)) + nx.press_buttons(controller_index, [Buttons.A]) print("") def update_current(item): #keeps track of current date time setting global current_time #going to change current - print(time_check()) - runtime = time.strftime("%M:%S", time.gmtime(time_check())) #time thats lapsed + print(time.perf_counter() - start_flag) + runtime = time.strftime("%M:%S", time.gmtime(time.perf_counter() - start_flag)) #time thats lapsed print(f"runtime was {runtime}s") runtime_parts = runtime.split(":") #split into min, sec print(f"{int(item[4])}+{int(runtime_parts[0])}") @@ -272,37 +269,65 @@ def item_print(input_item, mode): #setup and print print_job(mode) return_default() update_current(item) -def time_check(): - return time.perf_counter() - start_flag if __name__ == "__main__": - #set_up - #Global Variables + #GLOBAL VARIABLES default_time = (1, 1, 2025, 0, 0, 0) current_time = default_time job_set = 5 seed = generate_seeds() balls = ball_list() - delay = 1.0006 + delay = 1.07 #start_flag = 0 - # Init NXBT + # INIT NXBT import nxbt - # Start the NXBT service + #START THE NXBT SYSTEM nx = nxbt.Nxbt() - # Create a Pro Controller and wait for it to connect + #CREATE A PRO CONTROLLER AND WAIT FOR CONNECTION controller_index = nx.create_controller(nxbt.PRO_CONTROLLER) nx.wait_for_connection(controller_index) print("Connected") - #player set up intructions + #PLAYER SET UP INTRUCTIONS print("Before continuing please make sure you have completed the following intructions") print("Open pokemon and print 1 item with job amount 5") print("Turn and talk to NPC and leave on 'I would like to print something'") print("Have date and time set to YY:MM:DD 24hour clock") print("leave cursor on year") print("WARNING: make sure there is no current bonus") - #Program Starts HERE - print_main() + macro_id = nx.macro(controller_index, NAVIGATE_TIME) + print(f"set date and time to {default_time}") + input("Press ENTER to continue...") + #PROGRAM STARTS HERE + #input_item = item_input() + input_item = seed["EXP_Candy_XL"] + repeat = repeat_amount() + for i in range(0, repeat): + print(f"\nPrinting batch {i+1}") + print("\nsetting up bonus") + #item_print(item, 1) + item = mode_set(input_item, 1) + time_change_setup(current_time[:-1], item[:-1]) + timer(item[-1]) + print_job(1) + return_default() + update_current(item) + print("\nprinting frist batch") + #item_print(item, 5) + item = mode_set(input_item, 5) + time_change_setup(current_time[:-1], item[:-1]) + timer(item[-1]) + print_job(5) + return_default() + update_current(item) + print("\nprinting last batch") + #item_print(item, 5) + item = mode_set(input_item, 5) + time_change_setup(current_time[:-1], item[:-1]) + timer(item[-1]) + print_job(5) + return_default() + update_current(item) macro_id = nx.macro(controller_index, TURN_OFF) From 0533b56bab5002fd5c48b98bc5df0b28b4596608 Mon Sep 17 00:00:00 2001 From: DeathBerry-dev Date: Sun, 19 Jan 2025 14:12:54 +1100 Subject: [PATCH 3/3] update 1.1.1 forgot to enable user input for item selection --- item_dupe.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/item_dupe.py b/item_dupe.py index 74f3788..078ace9 100644 --- a/item_dupe.py +++ b/item_dupe.py @@ -301,8 +301,8 @@ def item_print(input_item, mode): #setup and print print(f"set date and time to {default_time}") input("Press ENTER to continue...") #PROGRAM STARTS HERE - #input_item = item_input() - input_item = seed["EXP_Candy_XL"] + input_item = item_input() + #input_item = seed["EXP_Candy_XL"] repeat = repeat_amount() for i in range(0, repeat): print(f"\nPrinting batch {i+1}")