forked from fayaz12g/totk-aar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.py
221 lines (179 loc) · 11.2 KB
/
script.py
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
import os
import struct
import sys
import ast
import subprocess
scaling_factor = float(sys.argv[1])
centered_HUD = ast.literal_eval(sys.argv[2])
blyt_folder = str(sys.argv[3])
shift_factor = (1 - scaling_factor) / scaling_factor
print("Centered HUD value is set to ", centered_HUD)
print("The scaling factor is ", scaling_factor)
def float_to_hex(f):
"""
Converts float values into hex, strips the 0x prefix and prepends zeroes to
always have length 8
"""
return hex(struct.unpack('>I', struct.pack('<f', f))[0]).lstrip('0x').rjust(8,'0')
file_names = os.listdir(blyt_folder)
file_names.remove('AppMenuBG_00.bflyt')
print("Removing AppMenuBG_00.bflyt")
file_names.remove('AppMenuOverlay_00.bflyt')
print("Removing AppMenuOverlay_00.bflyt")
file_names.remove('PauseMenuBG_00.bflyt')
print("Removing PauseMenuBG_00.bflyt")
file_names.remove('ShopMenuParasailBG_00.bflyt')
print("Removing ShopMenuParasailBG_00.bflyt")
file_names.remove('ShortCutBG_00.bflyt')
print("Removing ShortCutBG_00.bflyt")
file_names.remove('TitleMenuBG_00.bflyt')
print("Removing TitleMenuBG_00.bflyt")
file_names.remove('PaMap_00.bflyt')
print("Removing PaMap_00.bflyt")
file_names.remove('EventFade_00.bflyt')
print("Removing EventFade_00.bflyt")
file_names.remove('EventFadeWipe_00.bflyt')
print("Removing EventFadeWipe_00.bflyt")
file_names.remove('AttentionLockOn_00.bflyt')
print("Removing AttentionLockOn_00.bflyt")
file_names.remove('EnemyInfo_00.bflyt')
print("Removing EnemyInfo_00.bflyt")
file_names.remove('BalloonMessage_00.bflyt')
print("Removing BalloonMessage_00.bflyt")
file_names.remove('AttentionBalloon_00.bflyt')
print("Removing AttentionBalloon_00.bflyt")
for name in file_names:
file_loc = blyt_folder + "\\" + name
with open(file_loc, 'rb') as f:
content = f.read().hex()
# Scale RootPane by scaling_factor
x = float_to_hex(scaling_factor)
source_str = '526F6F7450616E650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000803F'
replace_str = '526F6F7450616E65000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' + x
content = content.replace(source_str.lower(), replace_str.lower())
print("Modifying more files")
# Scale BG_00 by inverse scaling_factor
x = float_to_hex(1/scaling_factor)
source_str = '42475F3030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000803F'
replace_str = '42475F303000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' + x
content = content.replace(source_str.lower(), replace_str.lower())
print("Modifying more files")
# Scale BG_00 by inverse scaling_factor
x = float_to_hex(1/scaling_factor)
source_str = '42475F3030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000803F'
replace_str = '42475F303000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' + x
content = content.replace(source_str.lower(), replace_str.lower())
print("Modifying even more files")
if name == 'LoadingFade_00.bflyt':
# Scale N_Base
x = float_to_hex(1/scaling_factor)
source_str = '4E5F426173655F303000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000803F'
replace_str = '4E5F426173655F30300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' + x
content = content.replace(source_str.lower(), replace_str.lower())
print("Modifying ", name)
# Shift N_Logo
x = float_to_hex(610 * shift_factor)
source_str = '4E5F4C6F676F5F3030000000000000000000000000000000000000000000000000000000'
replace_str = '4E5F4C6F676F5F30300000000000000000000000000000000000000000000000' + x
content = content.replace(source_str.lower(), replace_str.lower())
print("Modifying ", name)
# Shift N_Tips
x = float_to_hex(-879 * shift_factor)
source_str = '4E5F546970735F3030000000000000000000000000000000000000000000000000000000'
replace_str = '4E5F546970735F30300000000000000000000000000000000000000000000000' + x
content = content.replace(source_str.lower(), replace_str.lower())
print("Modifying ", name)
# Shift N_Status
x = float_to_hex(897 * shift_factor)
source_str = '4E5F5374617475735F303000000000000000000000000000000000000000000000000000'
replace_str = '4E5F5374617475735F3030000000000000000000000000000000000000000000' + x
content = content.replace(source_str.lower(), replace_str.lower())
print("Modifying ", name)
if name == 'PauseMenuOverlay_00.bflyt':
# Scale P_FooterBase
x = float_to_hex(1/scaling_factor)
source_str = '505F466F6F746572426173655F303000000000000000000000000000000000000000000000000000000000000000000000000000000000000000803F'
replace_str = '505F466F6F746572426173655F30300000000000000000000000000000000000000000000000000000000000000000000000000000000000' + x
content = content.replace(source_str.lower(), replace_str.lower())
print("Modifying ", name)
# Scale S_DecoScissor
x = float_to_hex(1/scaling_factor)
source_str = '535F4465636F53636973736F725F303000000000000000000000000000000000000000000000F841000000000000000000000000000000000000803F'
replace_str = '535F4465636F53636973736F725F303000000000000000000000000000000000000000000000F84100000000000000000000000000000000' + x
content = content.replace(source_str.lower(), replace_str.lower())
print("Modifying ", name)
if name == 'CameraPointer_00.bflyt':
# Scale N_InOutScop
x = float_to_hex(1/scaling_factor)
source_str = '4E5F496E4F757453636F70655F303000000000000000000000000000000000000000000000000000000000000000000000000000000000000000803F'
replace_str = '4E5F496E4F757453636F70655F30300000000000000000000000000000000000000000000000000000000000000000000000000000000000' + x
content = content.replace(source_str.lower(), replace_str.lower())
print("Modifying ", name)
# Scale W_shadow_01
x = float_to_hex(1/scaling_factor)
source_str = '575F536861646F775F30310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000803F'
replace_str = '575F536861646F775F3031000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' + x
content = content.replace(source_str.lower(), replace_str.lower())
print("Modifying ", name)
if name == 'AppMap_00.bflyt':
# Scale N_BlurInOut_00
x = float_to_hex(1/scaling_factor)
source_str = '4E5F426C7572496E4F75745F30300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000803F'
replace_str = '4E5F426C7572496E4F75745F3030000000000000000000000000000000000000000000000000000000000000000000000000000000000000' + x
content = content.replace(source_str.lower(), replace_str.lower())
print("Modifying ", name)
# Scale N_BlurInOut_01
x = float_to_hex(1/scaling_factor)
source_str = '4E5F426C7572496E4F75745F30310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000803F'
replace_str = '4E5F426C7572496E4F75745F3031000000000000000000000000000000000000000000000000000000000000000000000000000000000000' + x
content = content.replace(source_str.lower(), replace_str.lower())
print("Modifying ", name)
# Scale N_BlurInOut_02
x = float_to_hex(1/scaling_factor)
source_str = '4E5F426C7572496E4F75745F30320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000803F'
replace_str = '4E5F426C7572496E4F75745F3032000000000000000000000000000000000000000000000000000000000000000000000000000000000000' + x
content = content.replace(source_str.lower(), replace_str.lower())
print("Modifying ", name)
# Scale N_BlurInOut_03
x = float_to_hex(1/scaling_factor)
source_str = '4E5F426C7572496E4F75745F30330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000803F'
replace_str = '4E5F426C7572496E4F75745F3033000000000000000000000000000000000000000000000000000000000000000000000000000000000000' + x
content = content.replace(source_str.lower(), replace_str.lower())
print("Modifying ", name)
if not centered_HUD:
if name == 'EnvironmentInfo_00.bflyt':
# Shift RootPane
x = float_to_hex(588 * shift_factor * scaling_factor / 0.74)
source_str = '526F6F7450616E6500000000000000000000000000000000000000000000000000000000'
replace_str = '526F6F7450616E65000000000000000000000000000000000000000000000000' + x
content = content.replace(source_str.lower(), replace_str.lower())
print("Modifying ", name)
if name == 'PlayerStatus_00.bflyt':
# Shift RootPane
x = float_to_hex(-600 * shift_factor * scaling_factor / 0.74)
source_str = '526F6F7450616E6500000000000000000000000000000000000000000000000000000000'
replace_str = '526F6F7450616E65000000000000000000000000000000000000000000000000' + x
content = content.replace(source_str.lower(), replace_str.lower())
print("Modifying ", name)
if name == 'PlayerStatus3D_00.bflyt':
# Shift N_ExtraStaminaTarget_01
x = float_to_hex(-760 * (1 + shift_factor))
source_str = '45787472615374616D696E615461726765745F303100000000000000000000403AC4'
replace_str = '45787472615374616D696E615461726765745F3031000000000000000000' + x
content = content.replace(source_str.lower(), replace_str.lower())
print("Modifying ", name)
if name == 'AppMap_00.bflyt':
# Shift RootPane
x = float_to_hex(600 * shift_factor * scaling_factor / 0.74)
source_str = '526F6F7450616E6500000000000000000000000000000000000000000000000000000000'
replace_str = '526F6F7450616E65000000000000000000000000000000000000000000000000' + x
content = content.replace(source_str.lower(), replace_str.lower())
print("Modifying ", name)
# Shift N_MiniMap
x = float_to_hex(-600 * shift_factor * scaling_factor / 0.74)
source_str = '4E5F4D696E694D61705F3030000000000000000000000000000000000000000000000000'
replace_str = '4E5F4D696E694D61705F30300000000000000000000000000000000000000000' + x
content = content.replace(source_str.lower(), replace_str.lower())
print("Modifying ", name)
with open(file_loc, 'wb') as f:
f.write(bytes.fromhex(content))