def __init__(self, owner): # ptr - pointer to a player ptr_civ_name = pm.pointer(owner.ptr + 0x1AE0) self.owner = owner self.name = pm.string(ptr_civ_name + 4) self.code = Civilization.strings.index(self.name) self.icon = Civilization.icons[self.code]
def __get_name__(number, ptr_ai): """ Get players name, if AI grabs """ ptr = pm.pointer(pm.base_address + 0x6Da30C) ptr = pm.pointer(ptr + 0xD54) ptr = pm.pointer(ptr + 0xb0 + 0x60 * (number - 1) + 0xC) try: name = pm.string(ptr, 32) except: name = "" name = name if name else f"Player #{number}" if pm.int32(ptr_ai + 0x8) == 3: name += " [AI]" return name
def _check_idle_(self): ## Checking if unit is idle need to write better way # Load pointer try: pointer = pm.pointer(self.ptr + 0x14) except NullAddress: print("WARNING aoc_object_unit.py in `_check_idle_(self)`: NULL pointer!") self.idle = False return if pointer in Unit.graphics_data: # Is it in look-up table? self.idle = Unit.graphics_data[pointer] else: # Load it inot the lookup table try: splitted_name = pm.string(pointer+0x50).split("_") result = len(splitted_name) > 1 and "FN" in splitted_name[-1] # idle through graphics.. suuucks Unit.graphics_data[pointer] = result self.idle = result except UnicodeDecodeError: print("WARNING aoc_object_unit.py in `_check_idle_(self)`: Couldn't parse SLP filename!") self.idle = False