-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathcaptureData.py
More file actions
143 lines (117 loc) · 4.7 KB
/
captureData.py
File metadata and controls
143 lines (117 loc) · 4.7 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
import bcsv
import msbt
import json
import sarc
import sys
import zstandard
from specs import *
messages_path = sys.argv[1]
bcsv_path = sys.argv[2]
def fixup(name):
#if name.startswith(b'\x0e\x002\x00'):
# name = name[6:]
#name = name.replace('\x0en\x1e\0', '<name>')
return name.decode('utf-16le')
output = {}
# MESSAGES
data = open(messages_path + '/String_EUen.sarc.zs', 'rb').read()
data = zstandard.ZstdDecompressor().decompress(data)
msgArc = sarc.SARC(data)
output['items'] = {}
outfitGroup = {}
for name in sorted(msgArc.list_files()):
if 'STR_ItemName' in name:
m = msbt.MSBT()
m.load(msgArc.get_file_data(name))
for label, msg in m.data.items():
if not label.endswith('_pl'):
item_id = int(label[label.rfind('_') + 1:], 10)
output['items'][item_id] = fixup(msg.text)
if 'STR_OutfitGroupColor' in name:
m = msbt.MSBT()
m.load(msgArc.get_file_data(name))
for label, msg in m.data.items():
key = label[:label.rfind('_')]
item_id = int(label[label.rfind('_') + 1:], 10)
try:
outfitGroup[key].append((item_id, fixup(msg.text)))
except KeyError:
outfitGroup[key] = [(item_id, fixup(msg.text))]
if 'STR_OutfitGroupName' in name:
m = msbt.MSBT()
m.load(msgArc.get_file_data(name))
key2 = name[name.rfind('_')+1:name.rfind('.')]
for label, msg in m.data.items():
key1 = label
name = fixup(msg.text)
for iid, col in outfitGroup[f'{key1}_{key2}']:
output['items'][iid] = f'{col} {name}'
m = msbt.MSBT()
m.load(msgArc.get_file_data('Npc/STR_NNpcName.msbt'))
species = 'ant,bea,brd,bul,cat,cbr,chn,cow,crd,der,dog,duk,elp,flg,goa,gor,ham,hip,hrs,kal,kgr,lon,mnk,mus,ocp,ost,pbr,pgn,pig,rbt,rhn,shp,squ,tig,wol'.split(',')
output['villagerNames'] = [{} for z in species]
for label, msg in m.data.items():
a = species.index(label[:3])
b = int(label[3:])
output['villagerNames'][a][b] = fixup(msg.text)
# dual stuff for these
justnames = (
('STR_HouseWallName.msbt', 'houseWallNames', 'StructureHouseWallParam', StructureHouseWallParam),
('STR_HouseDoorName.msbt', 'houseDoorNames', 'StructureHouseDoorParam', StructureHouseDoorParam),
('STR_HouseRoofName.msbt', 'houseRoofNames', 'StructureHouseRoofParam', StructureHouseRoofParam),
)
for msbt_name, json_key, fname, rowclass in justnames:
output[json_key] = {}
f = bcsv.File(rowclass)
f.load(open(bcsv_path + '/' + fname + '.bcsv', 'rb').read())
for row in f.rows:
output[json_key][row.UniqueID] = row.ModelName
m = msbt.MSBT()
m.load(msgArc.get_file_data(msbt_name))
for label, msg in m.data.items():
output[json_key][int(label)] = fixup(msg.text)
output['fg'] = {}
f = bcsv.File(FgMainParam)
f.load(open(bcsv_path + '/FgMainParam.bcsv', 'rb').read())
for row in f.rows:
output['fg'][row.UniqueID] = {'name': row.ModelName, 'item': row.DigItem}
output['outsideParts'] = {}
f = bcsv.File(FieldOutsideParts)
f.load(open(bcsv_path + '/FieldOutsideParts.bcsv', 'rb').read())
for row in f.rows:
output['outsideParts'][row.UniqueID] = row.ModelName
output['terrainUnits'] = {}
f = bcsv.File(FieldLandMakingUnitModelParam)
f.load(open(bcsv_path + '/FieldLandMakingUnitModelParam.bcsv', 'rb').read())
for row in f.rows:
output['terrainUnits'][row.UniqueID] = row.ModelName
evflags = (
('EventFlagsAocParam', EventFlagsAocParam, 'aoc', None),
('EventFlagsBcatParam', EventFlagsBcatParam, 'bcat', None),
('EventFlagsHouseParam', EventFlagsHouseParam, 'house', 'MaxValue'),
('EventFlagsLandParam', EventFlagsLandParam, 'land', 'MaxValue'),
('EventFlagsLandTempParam', EventFlagsLandTempParam, 'landTemp', 'MaxValue'),
('EventFlagsNpcMemoryParam', EventFlagsNpcMemoryParam, 'npcMemory', 'MaxValue'),
('EventFlagsNpcSaveParam', EventFlagsNpcSaveParam, 'npcSave', 'MaxValue'),
('EventFlagsNpcTempParam', EventFlagsNpcTempParam, 'npcTemp', 'MaxValue'),
('EventFlagsPlayerActivityParam', EventFlagsPlayerActivityParam, 'playerActivity', None),
('EventFlagsPlayerParam', EventFlagsPlayerParam, 'player', 'MaxValue'),
('EventFlagsPlayerTempParam', EventFlagsPlayerTempParam, 'playerTemp', 'MaxValue'),
('EventFlagsPlayerVisitParam', EventFlagsPlayerVisitParam, 'playerVisit', 'MaxValue'),
('EventFlagsLifeSupportAchievementParam', EventFlagsLifeSupportAchievementParam, 'miles', 'MaxLevel'),
('EventFlagsLifeSupportDailyParam', EventFlagsLifeSupportDailyParam, 'milesPlus', None),
)
output['eventFlags'] = {}
for (fname, rowclass, key, maxkey) in evflags:
f = bcsv.File(rowclass)
f.load(open(bcsv_path + '/' + fname + '.bcsv', 'rb').read())
output['eventFlags'][key] = []
for row in f.rows:
output['eventFlags'][key].append({
'id': row.UniqueID,
'enName': row.Key,
'jpName': row.Name,
})
if maxkey:
output['eventFlags'][key][-1]['maximum'] = getattr(row, maxkey)
json.dump(output, open('gameData.json', 'w'), indent=4, sort_keys=True)