-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDatatypes.py
303 lines (252 loc) · 7.43 KB
/
Datatypes.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
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
import enum
import math
import Packet
class StatType:
class Stats(enum.IntEnum):
MaximumHP = 0
HP = 1
Size = 2
MaximumMP = 3
MP = 4
NextLevelExperience = 5
Experience = 6
Level = 7
Inventory0 = 8
Inventory1 = 9
Inventory2 = 10
Inventory3 = 11
Inventory4 = 12
Inventory5 = 13
Inventory6 = 14
Inventory7 = 15
Inventory8 = 16
Inventory9 = 17
Inventory10 = 18
Inventory11 = 19
Attack = 20
Defense = 21
Speed = 22
Vitality = 26
Wisdom = 27
Dexterity = 28
Effects = 29
Stars = 30
Name = 31
Texture1 = 32
Texture2 = 33
MerchandiseType = 34
Credits = 35
MerchandisePrice = 36
PortalUsable = 37
AccountId = 38
AccountFame = 39
MerchandiseCurrency = 40
ObjectConnection = 41
MerchandiseRemainingCount = 42
MerchandiseRemainingMinutes = 43
MerchandiseDiscount = 44
MerchandiserankRequirement = 45
HealthBonus = 46
ManaBonus = 47
AttackBonus = 48
DefenseBonus = 49
SpeedBonus = 50
VitalityBonus = 51
WisdomBonus = 52
DexterityBonus = 53
OwnerAccountId = 54
RankRequired = 55
NameChosen = 56
CharacterFame = 57
CharacterFameGoal = 58
Glowing = 59
SinkLevel = 60
AltTextureIndex = 61
GuildName = 62
GuildRank = 63
OxygenBar = 64
XpBoosterActive = 65
XpBoostTime = 66
LootDropBoostTime = 67
LootTierBoostTime = 68
HealthPotionCount = 69
MagicPotionCount = 70
Backpack0 = 71
Backpack1 = 72
Backpack2 = 73
Backpack3 = 74
Backpack4 = 75
Backpack5 = 76
Backpack6 = 77
Backpack7 = 78
HasBackpack = 79
Skin = 80
PetInstanceId = 81
PetName = 82
PetType = 83
PetRarity = 84
PetMaximumLevel = 85
PetFamily = 86
PetPoints0 = 87
PetPoints1 = 88
PetPoints2 = 89
PetLevel0 = 90
PetLevel1 = 91
PetLevel2 = 92
PetAbilityType0 = 93
PetAbilityType1 = 94
PetAbilityType2 = 95
NewConStat = 96
FortuneTokens = 97
SupporterPointsStat = 98
SupporterStat = 99
ChallengerStarBGStat = 100
id = None
def __init__(self, ttype):
self.id = self.Stats(ttype)
def isutf8(self):
return self.id in (
self.Stats.Name, self.Stats.AccountId, self.Stats.OwnerAccountId, self.Stats.GuildName, self.Stats.PetName)
class StatData:
id: StatType = None
IntValue = 0
StringValue = ""
def __init__(self, superclass: Packet.Packet):
self.sprcls = superclass
def isStringData(self):
return self.id.isutf8()
def read(self):
self.id = StatType(self.sprcls.read_byte())
if self.isStringData():
self.StringValue = self.sprcls.read_string()
else:
self.IntValue = self.sprcls.read_int32()
return self.id, self.StringValue, self.IntValue
def write(self):
self.sprcls.write_byte(self.id.id.value)
if self.isStringData():
self.sprcls.write_string(self.StringValue)
else:
self.sprcls.write_int32(self.IntValue)
class Location:
x = 0.0
y = 0.0
def __init__(self, superclass: Packet.Packet):
self.sprcls = superclass
def read(self):
self.x = self.sprcls.read_float()
self.y = self.sprcls.read_float()
return self.x, self.y
def write(self):
self.sprcls.write_float(self.x)
self.sprcls.write_float(self.y)
def DistanceSquaredTo(self, location):
dx = location.x - self.x
dy = location.y - self.y
return dx * dx + dy * dy
def DistanceTo(self, location):
return math.sqrt(self.DistanceSquaredTo(location))
def GetAngle(self, l1, l2):
dX = l2.x - l1.x
dY = l2.y - l1.y
return math.atan2(dY, dX)
def GetAngle2(self, x1, y1, x2, y2):
dX = x2 - x1
dY = y2 - y1
return math.atan2(dX, dY)
class MoveRecord:
time = 0
x = 0
y = 0
def __init__(self, superclass: Packet.Packet):
self.sprcls = superclass
def read(self):
self.time = self.sprcls.read_int32()
self.x = self.sprcls.read_float()
self.y = self.sprcls.read_float()
return self.time, self.x, self.y
def write(self):
self.sprcls.write_int32(self.time)
self.sprcls.write_float(self.x)
self.sprcls.write_float(self.y)
class Status:
object_id = 0
position: Location = None
data = []
def __init__(self, superclass: Packet.Packet):
self.sprcls = superclass
def read(self):
self.object_id = self.sprcls.read_int32()
self.position = Location(self.sprcls)
self.position.read()
self.data = [None] * self.sprcls.read_int16()
for _ in range(len(self.data)):
statData = StatData(self.sprcls)
statData.read()
self.data[_] = statData
return self.object_id, self.position, self.data
def write(self):
self.sprcls.write_int32(self.object_id)
self.position.write()
self.sprcls.write_int16(len(self.data))
for status in self.data:
status.write()
class Tile:
x = 0
y = 0
type = 0
def __init__(self, superclass: Packet.Packet):
self.sprcls = superclass
def read(self):
self.x = self.sprcls.read_int16()
self.y = self.sprcls.read_int16()
self.type = self.sprcls.read_uint16()
return self.x, self.y, self.type
def write(self):
self.sprcls.write_int16(self.x)
self.sprcls.write_int16(self.y)
self.sprcls.write_uint16(self.type)
class Entity:
objecttype = 0
status: Status = None
def __init__(self, superclass: Packet.Packet):
self.sprcls = superclass
def read(self):
self.objecttype = self.sprcls.read_int16()
self.status = Status(self.sprcls)
self.status.read()
return self.objecttype, self.status
def write(self):
self.sprcls.write_int16(self.objecttype)
self.status.write()
class SlotObject:
objectid = 0
slotid = 0
objecttype = 0
def __init__(self, superclass: Packet.Packet):
self.sprcls = superclass
def read(self):
self.objectid = self.sprcls.read_int32()
self.slotid = self.sprcls.read_byte()
self.objecttype = self.sprcls.read_int32()
def write(self):
self.sprcls.write_int32(self.objectid)
self.sprcls.write_byte(self.slotid)
self.sprcls.write_int32(self.objecttype)
class Item:
itemItem = 0
slotType = 0
tradeable = False
included = False
def __init__(self, superclass: Packet.Packet):
self.sprcls = superclass
def read(self):
self.itemItem = self.sprcls.read_int32()
self.slotType = self.sprcls.read_int32()
self.tradeable = self.sprcls.read_boolean()
self.included = self.sprcls.read_boolean()
def write(self):
self.sprcls.write_int32(self.itemItem)
self.sprcls.write_int32(self.slotType)
self.sprcls.write_boolean(self.tradeable)
self.sprcls.write_boolean(self.included)