Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S/V RNG manipulation #168

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions Pokemon_Seeds.csv
Original file line number Diff line number Diff line change
@@ -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
333 changes: 333 additions & 0 deletions item_dupe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,333 @@
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
8s
A 0.1s
2s
"""#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
0.1s
X 0.1s
1s
A 0.1s
40s
B 0.1s
2s
A 0.1s
10s
LOOP 8
B 0.1s
1s
10s
""" #left looking at printer
PRINT_ITEM_R = """
15s
R 0.1s
0.1s
X 0.1s
1s
A 0.1s
40s
B 0.1s
2s
A 0.1s
10s
LOOP 8
B 0.1s
1s
10s
""" #left looking at printer
PRINT_ITEM_L = """
15s
L 0.1s
0.1s
X 0.1s
1s
A 0.1s
40s
B 0.1s
2s
A 0.1s
10s
LOOP 8
B 0.1s
1s
10s
""" #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 24, 1, 2025, 13, 12, 9
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.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("<Menu>")
def update_current(item): #keeps track of current date time setting
global current_time #going to change current
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])}")
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)

if __name__ == "__main__":
#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.07
#start_flag = 0
# INIT NXBT
import nxbt

#START THE NXBT SYSTEM
nx = nxbt.Nxbt()

#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
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")
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)