1
0
forked from Hay1tsme/artemis

Fixing level calculation saving & loading on SAO

This commit is contained in:
Midorica 2023-05-29 20:57:02 -04:00
parent 2b4ac06389
commit a2fe11d654
4 changed files with 467 additions and 6 deletions

View File

@ -3,6 +3,7 @@ import json, logging
from typing import Any, Dict
import random
import struct
import csv
from core.data import Data
from core import CoreConfig
@ -29,7 +30,6 @@ class SaoBase:
def handle_c122(self, request: Any) -> bytes:
#common/get_maintenance_info
resp = SaoGetMaintResponse(int.from_bytes(bytes.fromhex(request[:4]), "big")+1)
return resp.make()
@ -438,11 +438,29 @@ class SaoBase:
exp = int(profile["rank_exp"]) + 100 #always 100 extra exp for some reason
col = int(profile["own_col"]) + int(req_data.base_get_data[0].get_col)
# Calculate level based off experience and the CSV list
with open(r'titles/sao/data/PlayerRank.csv') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
line_count = 0
data = []
rowf = False
for row in csv_reader:
if rowf==False:
rowf=True
else:
data.append(row)
for i in range(0,len(data)):
if exp>=int(data[i][1]) and exp<int(data[i+1][1]):
player_level = int(data[i][0])
break
# Update profile
updated_profile = self.game_data.profile.put_profile(
req_data.user_id,
profile["user_type"],
profile["nick_name"],
profile["rank_num"],
player_level,
exp,
col,
profile["own_vp"],

View File

@ -0,0 +1,121 @@
HeroLogLevelId,RequireExp
1,0,
2,1000,
3,1200,
4,1400,
5,1600,
6,1900,
7,2200,
8,2500,
9,2800,
10,3100,
11,3500,
12,3900,
13,4300,
14,4700,
15,5100,
16,5550,
17,6000,
18,6450,
19,6900,
20,7350,
21,7850,
22,8350,
23,8850,
24,9350,
25,9850,
26,10450,
27,11050,
28,11650,
29,12250,
30,12850,
31,13550,
32,14250,
33,14950,
34,15650,
35,16350,
36,17150,
37,17950,
38,18750,
39,19550,
40,20350,
41,21250,
42,22150,
43,23050,
44,23950,
45,24850,
46,25850,
47,26850,
48,27850,
49,28850,
50,29850,
51,30950,
52,32050,
53,33150,
54,34250,
55,35350,
56,36550,
57,37750,
58,38950,
59,40150,
60,41350,
61,42650,
62,43950,
63,45250,
64,46550,
65,47850,
66,49250,
67,50650,
68,52050,
69,53450,
70,54850,
71,56350,
72,57850,
73,59350,
74,60850,
75,62350,
76,63950,
77,65550,
78,67150,
79,68750,
80,70350,
81,72050,
82,73750,
83,75450,
84,77150,
85,78850,
86,80650,
87,82450,
88,84250,
89,86050,
90,87850,
91,89750,
92,91650,
93,93550,
94,95450,
95,97350,
96,99350,
97,101350,
98,103350,
99,105350,
100,107350,
101,200000,
102,300000,
103,450000,
104,600000,
105,800000,
106,1000000,
107,1250000,
108,1500000,
109,1800000,
110,2100000,
111,2100000,
112,2100000,
113,2100000,
114,2100000,
115,2100000,
116,2100000,
117,2100000,
118,2100000,
119,2100000,
120,2100000,
1 HeroLogLevelId,RequireExp
2 1,0,
3 2,1000,
4 3,1200,
5 4,1400,
6 5,1600,
7 6,1900,
8 7,2200,
9 8,2500,
10 9,2800,
11 10,3100,
12 11,3500,
13 12,3900,
14 13,4300,
15 14,4700,
16 15,5100,
17 16,5550,
18 17,6000,
19 18,6450,
20 19,6900,
21 20,7350,
22 21,7850,
23 22,8350,
24 23,8850,
25 24,9350,
26 25,9850,
27 26,10450,
28 27,11050,
29 28,11650,
30 29,12250,
31 30,12850,
32 31,13550,
33 32,14250,
34 33,14950,
35 34,15650,
36 35,16350,
37 36,17150,
38 37,17950,
39 38,18750,
40 39,19550,
41 40,20350,
42 41,21250,
43 42,22150,
44 43,23050,
45 44,23950,
46 45,24850,
47 46,25850,
48 47,26850,
49 48,27850,
50 49,28850,
51 50,29850,
52 51,30950,
53 52,32050,
54 53,33150,
55 54,34250,
56 55,35350,
57 56,36550,
58 57,37750,
59 58,38950,
60 59,40150,
61 60,41350,
62 61,42650,
63 62,43950,
64 63,45250,
65 64,46550,
66 65,47850,
67 66,49250,
68 67,50650,
69 68,52050,
70 69,53450,
71 70,54850,
72 71,56350,
73 72,57850,
74 73,59350,
75 74,60850,
76 75,62350,
77 76,63950,
78 77,65550,
79 78,67150,
80 79,68750,
81 80,70350,
82 81,72050,
83 82,73750,
84 83,75450,
85 84,77150,
86 85,78850,
87 86,80650,
88 87,82450,
89 88,84250,
90 89,86050,
91 90,87850,
92 91,89750,
93 92,91650,
94 93,93550,
95 94,95450,
96 95,97350,
97 96,99350,
98 97,101350,
99 98,103350,
100 99,105350,
101 100,107350,
102 101,200000,
103 102,300000,
104 103,450000,
105 104,600000,
106 105,800000,
107 106,1000000,
108 107,1250000,
109 108,1500000,
110 109,1800000,
111 110,2100000,
112 111,2100000,
113 112,2100000,
114 113,2100000,
115 114,2100000,
116 115,2100000,
117 116,2100000,
118 117,2100000,
119 118,2100000,
120 119,2100000,
121 120,2100000,

View File

@ -0,0 +1,301 @@
PlayerRankId,TotalExp,
1,0,
2,100,
3,300,
4,500,
5,800,
6,1100,
7,1400,
8,1800,
9,2200,
10,2600,,
11,3000,,
12,3500,,
13,4000,,
14,4500,,
15,5000,,
16,5500,,
17,6100,,
18,6700,,
19,7300,,
20,7900,,
21,8500,,
22,9100,,
23,9800,,
24,10500,
25,11200,
26,11900,
27,12600,
28,13300,
29,14000,
30,14800,
31,15600,
32,16400,
33,17200,
34,18000,
35,18800,
36,19600,
37,20400,
38,21300,
39,22200,
40,23100,
41,24000,
42,24900,
43,25800,
44,26700,
45,27600,
46,28500,
47,29500,
48,30600,
49,31800,
50,33100,
51,34500,
52,36000,
53,37600,
54,39300,
55,41100,
56,43000,
57,45000,
58,47100,
59,49300,
60,51600,
61,54000,
62,56500,
63,59100,
64,61800,
65,64600,
66,67500,
67,70500,
68,73600,
69,76800,
70,80100,
71,83500,
72,87000,
73,90600,
74,94300,
75,98100,
76,102000,
77,106000,
78,110100,
79,114300,
80,118600,
81,123000,
82,127500,
83,132100,
84,136800,
85,141600,
86,146500,
87,151500,
88,156600,
89,161800,
90,167100,
91,172500,
92,178000,
93,183600,
94,189300,
95,195100,
96,201000,
97,207000,
98,213100,
99,219300,
100,225600,
101,232000,
102,238500,
103,245100,
104,251800,
105,258600,
106,265500,
107,272500,
108,279600,
109,286800,
110,294100,
111,301500,
112,309000,
113,316600,
114,324300,
115,332100,
116,340000,
117,348000,
118,356100,
119,364300,
120,372600,
121,381000,
122,389500,
123,398100,
124,406800,
125,415600,
126,424500,
127,433500,
128,442600,
129,451800,
130,461100,
131,470500,
132,480000,
133,489600,
134,499300,
135,509100,
136,519000,
137,529000,
138,539100,
139,549300,
140,559600,
141,570000,
142,580500,
143,591100,
144,601800,
145,612600,
146,623500,
147,634500,
148,645600,
149,656800,
150,668100,
151,679500,
152,691000,
153,702600,
154,714300,
155,726100,
156,738000,
157,750000,
158,762100,
159,774300,
160,786600,
161,799000,
162,811500,
163,824100,
164,836800,
165,849600,
166,862500,
167,875500,
168,888600,
169,901800,
170,915100,
171,928500,
172,942000,
173,955600,
174,969300,
175,983100,
176,997000,
177,1011000,
178,1025100,
179,1039300,
180,1053600,
181,1068000,
182,1082500,
183,1097100,
184,1111800,
185,1126600,
186,1141500,
187,1156500,
188,1171600,
189,1186800,
190,1202100,
191,1217500,
192,1233000,
193,1248600,
194,1264300,
195,1280100,
196,1296000,
197,1312000,
198,1328100,
199,1344300,
200,1360600,
201,1377000,
202,1393500,
203,1410100,
204,1426800,
205,1443600,
206,1460500,
207,1477500,
208,1494600,
209,1511800,
210,1529100,
211,1546500,
212,1564000,
213,1581600,
214,1599300,
215,1617100,
216,1635000,
217,1653000,
218,1671100,
219,1689300,
220,1707600,
221,1726000,
222,1744500,
223,1763100,
224,1781800,
225,1800600,
226,1819500,
227,1838500,
228,1857600,
229,1876800,
230,1896100,
231,1915500,
232,1935000,
233,1954600,
234,1974300,
235,1994100,
236,2014000,
237,2034000,
238,2054100,
239,2074300,
240,2094600,
241,2115000,
242,2135500,
243,2156100,
244,2176800,
245,2197600,
246,2218500,
247,2239500,
248,2260600,
249,2281800,
250,2303100,
251,2324500,
252,2346000,
253,2367600,
254,2389300,
255,2411100,
256,2433000,
257,2455000,
258,2477100,
259,2499300,
260,2521600,
261,2544000,
262,2566500,
263,2589100,
264,2611800,
265,2634600,
266,2657500,
267,2680500,
268,2703600,
269,2726800,
270,2750100,
271,2773500,
272,2797000,
273,2820600,
274,2844300,
275,2868100,
276,2892000,
277,2916000,
278,2940100,
279,2964300,
280,2988600,
281,3013000,
282,3037500,
283,3062100,
284,3086800,
285,3111600,
286,3136500,
287,3161500,
288,3186600,
289,3211800,
290,3237100,
291,3262500,
292,3288000,
293,3313600,
294,3339300,
295,3365100,
296,3391000,
297,3417000,
298,3443100,
299,3469300,
300,3495600,
Can't render this file because it has a wrong number of fields in line 11.

View File

@ -2,6 +2,7 @@ import struct
from datetime import datetime
from construct import *
import sys
import csv
class SaoBaseRequest:
def __init__(self, data: bytes) -> None:
@ -493,9 +494,29 @@ class SaoGetHeroLogUserDataListResponse(SaoBaseResponse):
self.last_set_skill_slot5_skill_id = []
for i in range(len(hero_data)):
# Calculate level based off experience and the CSV list
with open(r'titles/sao/data/HeroLogLevel.csv') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
line_count = 0
data = []
rowf = False
for row in csv_reader:
if rowf==False:
rowf=True
else:
data.append(row)
exp = hero_data[i][4]
for e in range(0,len(data)):
if exp>=int(data[e][1]) and exp<int(data[e+1][1]):
hero_level = int(data[e][0])
break
self.user_hero_log_id.append(hero_data[i][2])
self.log_level.append(hero_data[i][3])
self.max_log_level_extended_num.append(hero_data[i][3])
self.log_level.append(hero_level)
self.max_log_level_extended_num.append(hero_level)
self.log_exp.append(hero_data[i][4])
self.last_set_skill_slot1_skill_id.append(hero_data[i][7])
self.last_set_skill_slot2_skill_id.append(hero_data[i][8])
@ -510,8 +531,8 @@ class SaoGetHeroLogUserDataListResponse(SaoBaseResponse):
self.user_hero_log_id = list(map(str,self.user_hero_log_id)) #str
self.hero_log_id = list(map(int,self.user_hero_log_id)) #int
self.log_level = list(map(int,self.log_level)) #short
self.max_log_level_extended_num = list(map(int,self.log_level)) #short
self.log_exp = list(map(int,self.log_level)) #int
self.max_log_level_extended_num = list(map(int,self.max_log_level_extended_num)) #short
self.log_exp = list(map(int,self.log_exp)) #int
self.possible_awakening_flag = 0 #byte
self.awakening_stage = 0 #short
self.awakening_exp = 0 #int