forked from nathan78906/steam-salien-cheat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjc.py
240 lines (218 loc) · 8.83 KB
/
jc.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
import requests
import json
from time import sleep
import datetime
# Get from: https://steamcommunity.com/saliengame/gettoken
TOKEN = "af637b688570f6b70c596d3f9834a452"
STEAMID = "76561198064637209"
s = requests.session()
s.headers.update({
'User-Agent': 'steam-salien-cheat on GitHub Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36',
'Referer': 'https://steamcommunity.com/saliengame/play/',
'Origin': 'https://steamcommunity.com',
'Accept': '*/*'
})
def steam64_to_steam3(commid):
if commid == "":
return commid
steamid64ident = 76561197960265728
steamidacct = int(commid) - steamid64ident
return steamidacct
def get_zone():
data = {
'active_only': 1,
'language':'english'
}
result = s.get("https://community.steam-api.com/ITerritoryControlMinigameService/GetPlanets/v0001/", params=data)
if result.status_code != 200:
print("Get planets errored... trying again(after 10s cooldown)")
sleep(10)
get_zone()
json_data = result.json()
valid = []
# check for boss zone TODO: find better way for this
for planet in json_data["response"]["planets"]:
info_data = {'id': planet["id"]}
info = s.get("https://community.steam-api.com/ITerritoryControlMinigameService/GetPlanet/v0001/", params=info_data)
if info.status_code != 200:
print("Get planet errored... trying the next planet")
continue
info_json = info.json()
for zone in info_json["response"]["planets"][0]["zones"]:
if not zone["captured"]:
if zone["type"] == 4 and zone["boss_active"] and not zone["captured"]:
valid += [(zone["type"], zone["zone_position"], zone["difficulty"], planet["id"], planet["state"]["name"], True)]
if zone["type"] == 3 and "capture_progress" in zone and zone["capture_progress"] < 0.9 and zone["capture_progress"] != 0:
valid += [(zone["type"], zone["zone_position"], zone["difficulty"], planet["id"], planet["state"]["name"], False)]
return sorted(valid, key = lambda x: (x[0], x[2]), reverse=True)[0]
def get_user_info():
data = {'access_token': TOKEN}
result = s.post("https://community.steam-api.com/ITerritoryControlMinigameService/GetPlayerInfo/v0001/", data=data)
if result.status_code != 200:
print("Getting user info errored... trying again(after 10s cooldown)")
sleep(10)
play_game()
if "active_zone_game" in result.json()["response"]:
print("Stuck on zone... trying to leave")
leave_game(result.json()["response"]["active_zone_game"])
if "active_boss_game" in result.json()["response"]:
print("Stuck on boss zone... trying to leave")
leave_game(result.json()["response"]["active_boss_game"])
if "active_planet" in result.json()["response"]:
return result.json()["response"]["active_planet"]
else:
return -1
def leave_game(current):
data = {
'gameid': current,
'access_token': TOKEN
}
result = s.post("https://community.steam-api.com/IMiniGameService/LeaveGame/v0001/", data=data)
if result.status_code != 200:
print("Leave planet {} errored... trying again(after 10s cooldown)".format(str(current)))
sleep(10)
play_game()
def join_planet(planet_id, planet_name):
data = {
'id': planet_id,
'access_token': TOKEN
}
result = s.post("https://community.steam-api.com/ITerritoryControlMinigameService/JoinPlanet/v0001/", data=data)
if result.status_code != 200:
print("Join planet {} ({}) errored... trying again(after 10s cooldown)".format(
str(planet_name),
str(planet_id)))
sleep(10)
play_game()
else:
print("Joined planet: {} ({}) \n".format(
str(planet_name),
str(planet_id)))
def join_zone(zone_position, difficulty):
dstr = {
1: 'Easy',
2: 'Medium',
3: 'Hard'
}
data = {
'zone_position': zone_position,
'access_token': TOKEN
}
result = s.post("https://community.steam-api.com/ITerritoryControlMinigameService/JoinZone/v0001/", data=data)
if result.status_code != 200 or result.json() == {'response':{}}:
print("Join zone {} errored... trying again(after 10s cooldown)".format(str(zone_position)))
sleep(10)
play_game()
else:
print("Joined zone: {} (Difficulty: {})".format(
str(zone_position),
dstr.get(difficulty, difficulty)))
def report_score(difficulty):
score = 600 * (2 ** (difficulty - 1))
data = {
'access_token': TOKEN,
'score': score,
'language':'english'
}
result = s.post("https://community.steam-api.com/ITerritoryControlMinigameService/ReportScore/v0001/", data=data)
if result.status_code != 200 or result.json() == {'response':{}}:
print("Report score errored... Current zone likely completed...\n")
play_game()
else:
res = result.json()["response"]
if "next_level_score" not in res:
print("Level: {} | Score: {} -> {}".format(
res["new_level"],
res["old_score"],
res["new_score"]))
else:
score_delta = int(res["next_level_score"]) - int(res["new_score"])
eta_seconds = int(score_delta // score) * 110
d = datetime.timedelta(seconds=eta_seconds)
print("Level: {} | Score: {} -> {} | Level-Up Score: {} ETA: {} {}\n".format(
res["new_level"],
res["old_score"],
res["new_score"],
res["next_level_score"],
d,
"Level UP!" if res["old_level"] != res["new_level"] else ""))
def play_boss(zone_position):
data = {
'zone_position': zone_position,
'access_token': TOKEN
}
result = s.post("https://community.steam-api.com/ITerritoryControlMinigameService/JoinBossZone/v0001/", data=data)
if result.status_code != 200 or result.json() == {'response':{}}:
print("Join boss zone {} errored... trying again(after 10s cooldown)".format(str(zone_position)))
sleep(10)
play_game()
else:
heal = 24
max_retries = 3
print("Joined boss zone: {}".format(str(zone_position)))
while 1:
sleep(5)
if heal == 0:
use_heal = 1
heal = 24
else:
use_heal = 0
damage_data = {
'access_token': TOKEN,
'use_heal_ability': use_heal,
'damage_to_boss': 1,
'damage_taken': 0
}
result = s.post("https://community.steam-api.com/ITerritoryControlMinigameService/ReportBossDamage/v0001/", data=damage_data)
if result.status_code != 200 or result.json() == {'response':{}}:
print("Report boss score errored... retrying")
if max_retries == 0:
break
max_retries = max_retries - 1
continue
res = result.json()["response"]
if res["waiting_for_players"]:
continue
if res["game_over"]:
break
print("Boss HP: {}/{} | Lasers: {} | Team Heals: {}\n".format(
res["boss_status"]["boss_hp"],
res["boss_status"]["boss_max_hp"],
res["num_laser_uses"],
res["num_team_heals"]))
for player in res["boss_status"]["boss_players"]:
STEAM3ID = steam64_to_steam3(STEAMID)
if player["accountid"] == STEAM3ID or STEAM3ID == "":
print("Name: {} | HP: {}/{} | XP Earned: {}".format(
player["name"],
player["hp"],
player["max_hp"],
player["xp_earned"]))
heal = heal - 1
def play_game():
print("Checking if user is currently on a planet")
current = get_user_info()
if current != -1:
print("Leaving current planet")
leave_game(current)
while 1:
print("Finding a planet and zone")
zone_type, zone_position, difficulty, planet_id, planet_name, boss = get_zone()
join_planet(planet_id, planet_name)
if boss:
play_boss(zone_position)
else:
join_zone(zone_position, difficulty)
print("Sleeping for 1 minute 50 seconds")
sleep(110)
report_score(difficulty)
get_user_info() # get user info and leave game, incase user gets stuck
while 1:
try:
play_game()
except KeyboardInterrupt:
print("User cancelled script")
exit(1)
except Exception as e:
print(e)
continue