import time import os import sys from demoparser2 import DemoParser import pandas as pd from colorama import init, Fore, Style init(autoreset=True) if len(sys.argv) < 2: print("Usage: python script.py ") sys.exit(1) demo_number = sys.argv[1] demo_file = f"walluigi{demo_number}.dem" NAME_WIDTH = 15 HP_WIDTH = 5 ARMOR_WIDTH = 6 HELMET_WIDTH = 6 COORD_WIDTH = 8 LAST_PLACE_WIDTH = 12 BALANCE_WIDTH = 7 DEFUSER_WIDTH = 8 DEFUSING_WIDTH = 8 DUCKED_WIDTH = 6 COLOR_WIDTH = 8 ID_WIDTH = 5 ALIVE_WIDTH = 6 TICK_WIDTH = 8 columns = [ ("Name", NAME_WIDTH), ("HP", HP_WIDTH), ("Armor", ARMOR_WIDTH), ("Helmet", HELMET_WIDTH), ("X", COORD_WIDTH), ("Y", COORD_WIDTH), ("Z", COORD_WIDTH), ("LastPlace", LAST_PLACE_WIDTH), ("Balance", BALANCE_WIDTH), ("Defuser", DEFUSER_WIDTH), ("Defusing", DEFUSING_WIDTH), ("Ducked", DUCKED_WIDTH), ("Color", COLOR_WIDTH), ("ID", ID_WIDTH), ("Alive", ALIVE_WIDTH), ] def format_field(value, width, color=None): text = str(value) text = text + " " * (width - len(text)) if len(text) < width else text[:width] if color: return color + text + Style.RESET_ALL return text while True: try: parser = DemoParser(demo_file) tick_list = parser.parse_ticks([ "X", "Y", "Z", "health", "is_alive", "balance", "player_color", "has_defuser", "has_helmet", "is_defusing", "armor_value", "last_place_name", "entity_id", "steamid", "name", "team_num", "ducked", "is_connected" ]) except: print("Demo not ready for parsing, retrying in 5 seconds.") time.sleep(5) continue most_recent_tick = tick_list["tick"].max() tick_list = tick_list[tick_list["tick"] == most_recent_tick] tick_list = tick_list[tick_list["is_connected"] == 0] tick_list = tick_list.drop_duplicates(subset=["entity_id"]) print("\033c", end="") print(f"===== Wall(uigi)Hacks: {demo_file} =====\n") header = " | ".join(f"{name:<{width}}" for name, width in columns) print(header) print("-" * len(header)) tick_list = tick_list.sort_values(by="entity_id", ascending=True) for _, row in tick_list.iterrows(): name = row.get("name", "Unknown") alive = row.get("is_alive") team_num = row.get("team_num", 0) if alive: name_color = Fore.CYAN if team_num == 3 else Fore.RED else: name_color = Fore.LIGHTBLACK_EX name_colored = format_field(name, NAME_WIDTH, name_color) hp = row.get("health", "(n/a)") if alive is True: hp_str = format_field(hp, HP_WIDTH, Fore.GREEN) elif alive is False: hp_str = format_field(hp, HP_WIDTH, Fore.RED) else: hp_str = format_field(hp, HP_WIDTH) defusing = row.get("is_defusing", False) defusing_str = format_field(defusing, DEFUSING_WIDTH, Fore.YELLOW) if defusing else format_field(defusing, DEFUSING_WIDTH) row_values = [ name_colored, hp_str, format_field(row.get("armor_value", "(n/a)"), ARMOR_WIDTH), format_field(row.get("has_helmet", "(n/a)"), HELMET_WIDTH), format_field(row.get("X", "(n/a)"), COORD_WIDTH), format_field(row.get("Y", "(n/a)"), COORD_WIDTH), format_field(row.get("Z", "(n/a)"), COORD_WIDTH), format_field(row.get("last_place_name", "(n/a)"), LAST_PLACE_WIDTH), format_field(row.get("balance", "(n/a)"), BALANCE_WIDTH), format_field(row.get("has_defuser", "(n/a)"), DEFUSER_WIDTH), defusing_str, format_field(row.get("ducked", False), DUCKED_WIDTH), format_field(row.get("player_color", "(n/a)"), COLOR_WIDTH), format_field(row.get("entity_id", "(n/a)"), ID_WIDTH), format_field(alive, ALIVE_WIDTH) ] print(" | ".join(row_values)) print("\n") time.sleep(1)