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
|
#!/usr/bin/python3
# This consolidates server databases
import os, traceback
MYSELF="serverdata/"
EVOLVED="../pre-renewal/server-data/"
MOUBOO="../server-data/"
REVOLT="../evol/server-data/"
# Rewrite db/re/item_db.conf
# Pets? Can't be carried over :< Homunculus? Same :<
# Skills? Eugh.
os.chdir("..")
item_db=[]
def parse(l, offset, prefix):
if "\tId:" in l:
tmp=l.split("Id:")
try:
tmp[1]=str(int(tmp[1]) + offset)
except ValueError:
print("%s invalid ID" % repr(tmp[1]))
except:
traceback.print_exc()
tmp[1]=str(offset*2-1)
l="Id: ".join(tmp).replace(" ", " ")
l+="\n"
elif "\tAegisName:" in l:
tmp=l.split("\"")
tmp[1]="%s_%s" % (prefix, tmp[1])
l="\"".join(tmp)
elif "\tName:" in l:
tmp=l.split("\"")
tmp[1]="%s %s" % (prefix, tmp[1])
l="\"".join(tmp)
elif "Sprite:" in l:
tmp=l.split("Sprite:")
try:
assert int(tmp[1]) > 1
tmp[1]=str(int(tmp[1]) + offset)
except ValueError:
print("%s invalid Sprite" % repr(tmp[1]))
except AssertionError:
pass
except:
traceback.print_exc()
tmp[1]=str(offset*2-1)
l="Sprite: ".join(tmp).replace(" ", " ")
l+="\n"
return l
#################################################################################
## Moubootaur Legends is a raw copy (prefix = 0)
with open("%s/db/re/item_db.conf" % MOUBOO, "r") as f:
for l in f:
#l=l.replace(" ", "\t")
## Add headers
if "== License ==" in l:
item_db.append("//=========================================================================\n")
item_db.append("// This file is generated automatically.\n")
item_db.append("// Please do not edit it directly.\n")
## Save the line
item_db.append(l)
while not ")" in item_db[-1]:
item_db=item_db[:-1]
item_db=item_db[:-1]
print("\033[32;1mMoubootaur Legends OK\033[0m")
## Legacy/Evolved has an offset of 10k
with open("%s/db/pre-re/item_db.conf" % EVOLVED, "r") as f:
for l in f:
l=l.replace(" ", "\t")
if "item_db:" in l:
continue
l=parse(l, 10000, "L")
##############################
## Recalc Stats
if "\tAtk:" in l:
tmp=l.split(":")
try:
tmp[1]=str(min(int(int(tmp[1]) * 1.1), 999))
except ValueError:
print("%s invalid ATK" % repr(tmp[1]))
except:
traceback.print_exc()
l=": ".join(tmp)
l+="\n"
if "\tDef:" in l:
tmp=l.split(":")
try:
tmp[1]=str(min(int(int(tmp[1]) * 1.1), 100))
except ValueError:
print("%s invalid DEF" % repr(tmp[1]))
except:
traceback.print_exc()
l=": ".join(tmp)
l+="\n"
## TODO: ATKSpd
##############################
item_db.append(l)
while not ")" in item_db[-1]:
item_db=item_db[:-1]
item_db=item_db[:-1]
print("\033[32;1mLegacy/Evolved OK\033[0m")
## rEvolt has an offset of 20k
with open("%s/db/re/item_db.conf" % REVOLT, "r") as f:
for l in f:
l=l.replace(" ", "\t")
if "item_db:" in l:
continue
l=parse(l, 20000, "R")
item_db.append(l)
while not ")" in item_db[-1]:
item_db=item_db[:-1]
#item_db=item_db[:-1]
print("\033[32;1mrEvolt OK\033[0m")
## Save the final item database
with open(MYSELF+"db/re/item_db.conf", "w") as f:
for l in item_db:
f.write(l)
print("\033[33;1mSaved! Databases merged!\033[0m")
|