-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlearnset.py
More file actions
278 lines (266 loc) · 10.6 KB
/
Copy pathlearnset.py
File metadata and controls
278 lines (266 loc) · 10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
import os, sys
move_name_array = []
move_data_array = []
egg_parent_array = []
egg_child_array = []
movelist = []
unique_moves = []
def move_cleanup(move, mon):
if move == 'rocksmash':
move = 'brickbreak'
elif move == 'furystrikes':
move = 'furyswipes'
elif move == 'healinglight':
move = 'moonlight'
elif move == 'psychicm':
move = 'psychic'
elif move == 'freshsnack':
if mon == 'miltank':
move = 'milkdrink'
else:
move = 'softboiled'
elif move == 'dazzlingleam':
move = 'dazzlinggleam'
elif move == 'disarmvoice':
move = 'disarmingvoice'
return move
def insert_move(move, data, mon):
move = move_cleanup(move, mon)
try:
index = move_name_array.index(move)
if data in move_data_array[index]:
return
move_data_array[index] = move_data_array[index] + f', "{data}"'
except:
move_name_array.append(move)
move_data_array.append(f'"{data}"')
if move not in movelist:
movelist.append(move)
def insert_unique_move(move, mon):
move = move_cleanup(move, mon)
level = '25' if mon == 'lapras' else '1' # lapras event hardcode
insert_move(move, f'9L{level}', mon)
unique_moves.append(move)
def get_egg_index(mon):
try:
index = egg_parent_array.index(mon)
return index
except:
return -1
dir = sys.argv[1] # polishedcrystal
dir_base = dir + '/data/pokemon/base_stats/'
# build egg groups
eggpointers = open(dir + '/data/pokemon/egg_move_pointers.asm', 'r')
for line in eggpointers:
if line.find('NoEggSpeciesMoves') > -1 or line.find('Three Segment Form') > -1 or line.find('Red Form') > -1:
continue
if line.find('dw') > -1:
# parse egg names
egg_name = line[4:]
egg_name = egg_name[:egg_name.find('EggSpeciesMoves')]
egg_name = egg_name.strip()
if egg_name.find('Plain') > -1:
egg_name = egg_name[:egg_name.find('Plain')]
elif egg_name.find('Alolan') > -1:
egg_name = egg_name[:egg_name.find('Alolan')] + 'Alola'
elif egg_name.find('Galarian') > -1:
egg_name = egg_name[:egg_name.find('Galarian')] + 'Galar'
elif egg_name.find('Hisuian') > -1:
egg_name = egg_name[:egg_name.find('Hisuian')] + 'Hisui'
elif egg_name.find('Paldean') > -1:
egg_name = egg_name[:egg_name.find('Paldean')] + 'Paldea'
egg_name = egg_name.lower()
# parse mon names
mon_name = line[line.find(';')+1:]
mon_name = mon_name.strip()
if mon_name.find('Alolan Form') > -1:
mon_name = mon_name[:mon_name.find('(Alolan Form)')] + 'Alola'
elif mon_name.find('Galarian Form') > -1:
mon_name = mon_name[:mon_name.find('(Galarian Form)')] + 'Galar'
elif mon_name.find('Hisuian Form') > -1:
mon_name = mon_name[:mon_name.find('(Hisuian Form)')] + 'Hisui'
elif mon_name.find('Paldean Form') > -1:
mon_name = mon_name[:mon_name.find('(Paldean Form)')] + 'Paldea'
elif mon_name.find('Bloodmoon Form') > -1:
mon_name = mon_name[:mon_name.find('(Bloodmoon Form)')] + 'Bloodmoon'
if mon_name.find(' ') > -1:
mon_name = mon_name.replace(' ', '')
mon_name = mon_name.lower()
# build arrays
if(mon_name != egg_name):
egg_parent_array.append(mon_name)
egg_child_array.append(egg_name)
eggpointers.close()
# build learnsets
config = open('learnsets.ts', 'w')
config.write('export const Learnsets: {[k: string]: ModdedLearnsetData} = {\n')
unique = open('unique-moves.ts', 'w')
unique.write('export default [\n')
for file in sorted(os.listdir(dir_base)):
move_name_array.clear()
move_data_array.clear()
mon = file.replace('.asm', '')
if mon == 'egg':
continue
# separate name for levelup searching
mon_evo_name = mon
if mon_evo_name.find('_') > -1:
mon_evo_name = mon_evo_name.replace('_', '')
# Mewtwo exception (unique due to armoured alt-form sharing the same moveset under 'mewtwo' in evo attacks .asm)
if 'mewtwo' in mon_evo_name:
mon_evo_name = 'mewtwo'
# name formatting
if mon.find('_plain') > -1:
mon = mon.replace('_plain', '')
elif mon.find('_galarian') > -1:
mon = mon.replace('_galarian', 'galar')
elif mon.find('_alolan') > -1:
mon = mon.replace('_alolan', 'alola')
elif mon.find('_hisuian') > -1:
mon = mon.replace('_hisuian', 'hisui')
elif mon.find('_paldean') > -1:
mon = mon.replace('_paldean', 'paldea')
if mon.find('_') > -1:
mon = mon.replace('_', '')
if mon.find('taurospaldeafire') > -1:
mon = mon.replace('taurospaldeafire', 'taurospaldeablaze')
elif mon.find('taurospaldeawater') > -1:
mon = mon.replace('taurospaldeawater', 'taurospaldeaaqua')
elif mon.find('taurospaldea') > -1:
mon = mon.replace('taurospaldea', 'taurospaldeacombat')
config.write("\t" + mon + ": {\n\t\tlearnset: {\n")
# read levelup moves
search_table = False
skip_line = False
evosfile = open(dir + '/data/pokemon/evos_attacks.asm', 'r')
for line in evosfile:
# skip 'faithful' moves
if skip_line:
skip_line = False
continue
if line.find('if DEF(FAITHFUL)') > -1:
skip_line = True
continue
# check if current mons' table using exact string matching
line = line.lower()
words = line.split()
if len(words) >= 2 and words[0] == 'evos_attacks' and words[1] == mon_evo_name:
search_table = True
continue
if search_table and line.find('evos_attacks') > -1 or line.find('terminates') > -1:
break
# parse move
if search_table and line.find('learnset') > -1:
if line.find(';') > -1:
line = line[:line.find(';')] # skip comments
line = line[10:]
evo_move = line.split(',')
if evo_move[1].find('_') > -1:
evo_move[1] = evo_move[1].replace('_', '')
evo_move[1] = evo_move[1].strip()
insert_move(evo_move[1], f'9L{evo_move[0]}', mon)
evosfile.close()
# read base stats for tm/hm
basefile = open(dir_base + file, 'r')
for line in basefile:
if line.find('tmhm') > -1 and len(line) > 6:
list = line[6:]
list_data = list.split(',')
for move in list_data:
if move.find('_') > -1:
move = move.replace('_', '')
move = move.lower()
move = move.strip()
insert_move(move, '9M', mon)
# hardcode HP fairy
insert_move('hiddenpowerfairy', '9M', mon)
basefile.close()
# read egg moves
search_table = False
eggfile = open(dir + '/data/pokemon/egg_moves.asm')
for line in eggfile:
if line.find('EggSpeciesMoves') > -1:
egg_name = line[:line.find('EggSpeciesMoves')]
egg_name = egg_name.strip()
if egg_name.find('Plain') > -1:
egg_name = egg_name[:egg_name.find('Plain')]
elif egg_name.find('Alolan') > -1:
egg_name = egg_name[:egg_name.find('Alolan')] + 'Alola'
elif egg_name.find('Galarian') > -1:
egg_name = egg_name[:egg_name.find('Galarian')] + 'Galar'
elif egg_name.find('Hisuian') > -1:
egg_name = egg_name[:egg_name.find('Hisuian')] + 'Hisui'
elif egg_name.find('Paldean') > -1:
egg_name = egg_name[:egg_name.find('Paldean')] + 'Paldea'
egg_name = egg_name.lower()
egg_pointer = get_egg_index(mon)
if mon == egg_name or egg_pointer > -1 and egg_name == egg_child_array[egg_pointer]:
search_table = True
continue
if search_table and line.find('$ff') > -1:
break
if search_table and line.find('db') > -1:
if line.find(';') > -1:
line = line[:line.find(';')] # skip comments
move = line[4:]
move = move.replace('_', '')
move = move.lower()
move = move.strip()
insert_move(move, '9E', mon)
eggfile.close()
# read odd eggs
read_moves = False
oddeggfile = open(dir + '/data/events/odd_eggs.asm')
for line in oddeggfile:
if line.find('IS_EGG_MASK') > -1:
egg_name = line[4:]
egg_name = egg_name[:egg_name.find(',')]
egg_name = egg_name.strip().lower().replace('_', '')
egg_pointer = get_egg_index(mon)
if mon == egg_name or egg_pointer > -1 and egg_name == egg_child_array[egg_pointer]:
read_moves = True
continue
if read_moves:
move_list = line[4:].replace(' ', '').replace('_', '').replace('\n', '').lower()
move_list = move_list.split(',')
for move in move_list:
if move != 'nomove':
insert_move(move, '9E', mon)
read_moves = False
oddeggfile.close()
# read unique wild moves
unique_moves = []
read_moves = False
uniquemovefile = open(dir + '/data/pokemon/unique_wild_moves.asm')
for line in uniquemovefile:
if line.startswith('UniqueWildMoves:'):
read_moves = True
continue
if read_moves and 'unique_moves' in line and '0' not in line:
split = line.split(',')
move_index = 2
if 'YELLOW_FOREST' in line: # pikachu exception
move_index = 3
unique_mon_name = split[1].strip().lower().replace('_', '').replace(' ', '')
if unique_mon_name == mon:
unique_move_name = split[move_index].strip().lower().replace('_', '').replace(' ', '')
unique_move_name = unique_move_name[:unique_move_name.find(';')]
insert_unique_move(unique_move_name, mon)
uniquemovefile.close()
# insert all moves
for i in range(len(move_name_array)):
config.write(f'\t\t\t{move_name_array[i]}: [{move_data_array[i]}],\n')
config.write('\t\t},\n\t},\n')
if len(unique_moves) > 0:
unique.write('\t{\n\t\t"name": ' + f'"{mon}",\n\t\t"moves": [\n')
for move in unique_moves:
unique.write(f'\t\t\t"{move}",\n')
unique.write('\t\t],\n\t},\n')
config.write('};\n')
config.close()
unique.write('];\n')
unique.close()
movefile = open('moves.ts', 'w')
for move in movelist:
movefile.write('\t' + move + ': {\n\t\tinherit: true,\n\t},\n')
movefile.close()