Created
March 19, 2025 11:28
-
-
Save oldnapalm/4bc4971571add06d19954faa2928ed7e to your computer and use it in GitHub Desktop.
Upgrade Zwift bike to level 5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import sys | |
| import time | |
| import user_storage_pb2 | |
| # from assets\global.wad\bikes\levels | |
| levels = { | |
| "entry": { | |
| "distance": [100000, 130000, 160000, 190000, 220000], | |
| "elevation": [1000, 1250, 1500, 1750, 2000], | |
| "time": [7200, 10800, 14400, 18000, 21600], | |
| "price": [25000, 50000, 75000, 100000, 150000] | |
| }, | |
| "mid_range": { | |
| "distance": [160000, 200000, 240000, 280000, 320000], | |
| "elevation": [1550, 1900, 2250, 2600, 2950], | |
| "time": [14400, 18000, 21600, 25200, 28800], | |
| "price": [50000, 100000, 150000, 200000, 250000] | |
| }, | |
| "high_end": { | |
| "distance": [200000, 260000, 320000, 380000, 440000], | |
| "elevation": [2000, 2500, 3000, 3500, 4000], | |
| "time": [21600, 25200, 28800, 32400, 36000], | |
| "price": [100000, 200000, 350000, 500000, 750000] | |
| }, | |
| "concept": { | |
| "distance": [550000, 1050000, 1600000, 2150000, 2650000], | |
| "elevation": [11000, 13000, 15000, 17000, 19000], | |
| "time": [72000, 108000, 144000, 180000, 216000], | |
| "price": [400000, 800000, 1200000, 2600000, 5000000] | |
| } | |
| } | |
| if len(sys.argv) < 3 or not sys.argv[2] in levels: | |
| print("Use %s <signature> [entry | mid_range | high_end | concept]" % sys.argv[0]) | |
| exit() | |
| bike_signature = sys.argv[1] | |
| bike_type = sys.argv[2] | |
| user_storage = user_storage_pb2.UserStorage() | |
| user_storage_file = "user_storage.bin" | |
| if os.path.isfile(user_storage_file): | |
| with open(user_storage_file, "rb") as f: | |
| user_storage.ParseFromString(f.read()) | |
| found = False | |
| for f in user_storage.attributes: | |
| if "bike_progress" in f.DESCRIPTOR.fields_by_name and f.bike_progress.signature == bike_signature: | |
| found = True | |
| break | |
| if not found: | |
| f = user_storage.attributes.add() | |
| f.bike_progress.signature = bike_signature | |
| f.bike_progress.level = 5 | |
| f.bike_progress.total_distance = sum(levels[bike_type]["distance"]) | |
| f.bike_progress.total_elevation = sum(levels[bike_type]["elevation"]) | |
| f.bike_progress.total_moving_time = sum(levels[bike_type]["time"]) | |
| t = int(time.time() * 1000) - sum(levels[bike_type]["time"]) * 1000 | |
| f.bike_progress.time = t | |
| f.bike_progress.last_upgrade = t + sum(levels[bike_type]["time"]) * 1000 | |
| f.bike_progress.percentage = 1 | |
| del f.bike_progress.bike_upgrades[:] | |
| for i, p in enumerate(levels[bike_type]["price"]): | |
| u = f.bike_progress.bike_upgrades.add() | |
| l = i + 1 | |
| u.time = t + sum(levels[bike_type]["time"][:l]) * 1000 | |
| u.level = l | |
| u.price = p | |
| print(f) | |
| with open(user_storage_file, "wb") as f: | |
| f.write(user_storage.SerializeToString()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment