-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUltimaVHack.py
More file actions
203 lines (174 loc) · 6.67 KB
/
UltimaVHack.py
File metadata and controls
203 lines (174 loc) · 6.67 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
#Derick Bui
#016505734
#Open the SAVED.GAM hex file
fileOpen = open("SAVED.GAM", encoding = "latin1")
#Reads, encode, and store file
f = fileOpen.read()
encodedF = bytearray(f, "latin1") #Holds array of ints
#This function formats hex in little endian
def littleEndianTime(value):
value = hex(value)
if (len(value) == 5):
bit1 = "0" + value[2]
bit2 = value[3] + value[4]
return [int(bit2, 16), int(bit1, 16)]
elif (len(value) == 6):
bit1 = value[2] + value[3]
bit2 = value[4] + value[5]
return [int(bit2, 16), int(bit1, 16)]
elif (len(value) == 3) or (len(value) == 4):
return [int(value, 0), 0]
else:
print("Not valid")
return
#User choice menu when changing offsets
userInput = 0
while (userInput != "x"):
print("Offset Choices")
print("2. Main Character Stats")
print("34. Shamino Stats")
print("66. Iolo Stats")
print("98. Mariah Stats")
print("130. Geoffrey Stats")
print("162. Janna Stats")
print("194. Julia Stats")
print("226. Dupre Stats")
print("258. Katrina Stats")
print("290. Sentri Stats")
print("322. Gwenno Stats")
print("354. Johne Stats")
print("386. Gorne Stats")
print("418. Maxwell Stats")
print("450. Toshi Stats")
print("482. Saduj Stats")
print("514. Gold (0-9999)")
print("516. Food (0-9999)")
print("518. Keys (0-100)")
print("519. Gems (0-100)")
print("520. Torches (0-100)")
print("522. Margic Carpet (0-100)")
print("523. Skull Keys (0-100)")
print("536. Black Badge (0-1)")
print("576. Magic Axe (0-99)")
print("682. Sulphurous Ash (0-100)")
print("683. Ginseng (0-100)")
print("684. Garlic (0-100)")
print("685. Spider Silk (0-100)")
print("687. Black Pearl (0-100)")
print("693. Party Amount (1-6)")
print("c. Check Values In Offsets (Shows 600 offsets)")
print("x. Exit")
userInput = input("Type in offset you want to change in game (decimal): ")
if userInput.isnumeric():
userInput = int(userInput)
#For changing selected character stats
if (userInput == 2) or (userInput == 34) or (userInput == 66) or (userInput == 98) or (userInput == 130) or (userInput == 162) or (userInput == 194) or (userInput == 226) or (userInput == 258) or (userInput == 290) or (userInput == 322) or (userInput == 354) or (userInput == 386) or (userInput == 418) or (userInput == 450) or (userInput == 382):
#For offset total
totalOffSet = userInput
print("Stat offsets to choose from character: ")
print("12. Strength (1-100)")
print("13. Dexterity (1-100)")
print("14. Intelligence (1-100)")
print("15. Magic (1-100)")
print("16. Health (1-999)")
print("18. Max Health (1-999)")
print("20. Experience (1-9999)")
#Add offset using the layout pattern on the file
addOffSet = input("Type in stat offset you want to change (decimal): ")
if not addOffSet.isnumeric():
print("Error on input. Cancel changes")
else:
addOffSet = int(addOffSet)
totalOffSet = totalOffSet + addOffSet #Offset of character stat change
#For offsets using decimals 1-100
if (addOffSet == 12) or (addOffSet == 13) or (addOffSet == 14) or (addOffSet == 15):
setStat = input("Enter amount in stat (1-100): ")
if setStat.isnumeric():
setStat = int(setStat)
if (setStat >= 1) and (setStat <= 100): #Stats changed in offset 12, 13, 14, 15
print("Character stat set")
encodedF[totalOffSet] = setStat
else:
print("Invalid stat, cancel changes")
else:
print("Error in input, cancel changes")
#For offsets using decimals 1-999
elif (addOffSet == 16) or (addOffSet == 18):
setStat = input("Enter amount in stat (1-999): ")
if setStat.isnumeric():
setStat = int(setStat)
twoValues = littleEndianTime(setStat)
encodedF[totalOffSet] = twoValues[0]
encodedF[totalOffSet + 1] = twoValues[1]
print("Character stat set")
#For offsets using decimals 1-9999
elif (addOffSet == 20):
setStat = input("Enter amount in stat (1-9999): ")
if setStat.isnumeric():
setStat = int(setStat)
twoValues = littleEndianTime(setStat)
encodedF[totalOffSet] = twoValues[0]
encodedF[totalOffSet + 1] = twoValues[1]
print("Character stat set")
else:
print("Invalid stat offset, cancel changes")
#Change item numbers involving numbers 0-99
elif (userInput == 518) or (userInput == 519) or (userInput == 520) or (userInput == 522) or (userInput == 523) or (userInput == 576) or (userInput == 682) or (userInput == 683) or (userInput == 684) or (userInput == 685) or (userInput == 687):
setAmount = input("Set amount of items (0-99): ")
if setAmount.isnumeric():
setAmount = int(setAmount)
if (setAmount >= 0) and (setAmount <= 100):
encodedF[userInput] = setAmount
print("Item amount changed")
else:
print("Number out of range, cancel changes")
else:
print("Error in input, cancel changes")
#Change item number involving numbers 0-9999
elif (userInput == 514) or (userInput == 516):
setAmount = input("Set amount of items (0-9999): ")
if setAmount.isnumeric():
setAmount = int(setAmount) # Still working on this
twoValues = littleEndianTime(setStat)
encodedF[totalOffSet] = twoValues[0]
encodedF[totalOffSet + 1] = twoValues[1]
print("Item Amount Changed")
else:
print("Error in input, cancel changes")
#One choice item (black badge)
elif (userInput == 536):
setAmount = input("Enter amount of the item (0-1): ")
if setAmount.isnumeric():
setAmount = int(setAmount)
if (setAmount == 0):
encodedF[userInput] = 0
print("Item Amount Changed")
elif (setAmount == 1):
encodedF[userInput] = 255
print("Item Amount Changed")
else:
print("Input error, cancel changes")
else:
print("Error in input, cancel changes")
#Selects how many people in the party
elif (userInput == 693):
partyAmount = input("How many in the party (1-6): ")
if partyAmount.isnumeric():
partyAmount = int(partyAmount)
if (partyAmount >= 1) or (partyAmount <= 6):
encodedF[userInput] = partyAmount
else:
print("Number out of range, cancel changes")
else:
print("Error in input, cancel changes")
#Check all values in offsets up to 600
elif (userInput == "c"):
for i in range(600):
print(str(i) + ". " + str(encodedF[i]))
elif (userInput != "x"): #For any offset not listed
print("Invalid choice")
fileOpen.close
#Write file in byte form
newFile = open("SAVED.GAM", "wb+")
newFile.write(encodedF)
newFile.close()