Esempio n. 1
0
 def __init__(self, ptr, owner, udata):
     # ptr - pointer to the object
     # owner - Player datastructure who has this unit
     # udata - metadata, see `aoc_object_data.py`
     super(Primitive, self).__init__()
     self.ptr = ptr
     self.owner = owner
     self.udata = udata
     # Load data
     self.id = pm.int32(ptr +
                        0x8)  # Game ID keeps unchanged, no need for update
     self.hp = pm.float(ptr + 0x34)
     self.selected = pm.int8(ptr + 0x3a)
     self.status = pm.int8(ptr + 0x4C)
     # Load consts
     self.idle = False
     self.idle_time = 0
     self.idle_total_time = 0
     self.busy_time = 0
     self.busy_total_time = 0
     self.garrison = []
     self.research = None
     self.training = None
     self.position = None
     self.prev_hp = None
     self.queue = None
     self.construction = None
     self.group = 0
     self.created_time = GTime.time
     self.resource_amount = 0
     self.resource_type = ""
Esempio n. 2
0
 def update(self):
     self.prev_hp = self.hp
     self.hp = pm.float(self.ptr + 0x34)
     self.status = pm.int8(self.ptr + 0x4C)
     self.resource_amount = pm.float(self.ptr + 0x48)
     self.resource_type = Primitive.ResourceTable[pm.int8(self.ptr + 0x50)]
     self.position = pm.struct(self.ptr + 0x3c, "ff")
     self.selected = pm.int8(self.ptr + 0x3a)
Esempio n. 3
0
 def update(self):
     """Creates a list of objects."""
     self.clear()  # sucks but ok
     ptr_array = pm.pointer(self.ptr + 0x4)
     length = pm.uint32(self.ptr + 0x8)
     object_pointers = pm.struct(ptr_array, "I" * length)
     length = pm.int8(self.owner.ptr + 0x254)
     Objects.selected_pointers += pm.struct(self.owner.ptr + 0x160,
                                            "I" * length)
     for ptr in object_pointers:
         r = Objects._create_(ptr, self.owner)
         if r is not None:
             r.update()
             self.append(r)
             # Appends the object to the list and sets that the object will not be deleted
             Objects._all[self.owner][ptr] = [r, False]
             # adds it into selected objects
             if ptr in Objects.selected_pointers:
                 Objects.selected.append(r)
Esempio n. 4
0
    def update(self):
        # Check if the game is running: 0 not running, 1 running
        pm.update()
        if not pm.int32(pm.base_address + 0x9E0708):
            self.running = False
            return False

        # Second check.
        try:
            ptr = pm.pointer(
                pm.base_address + 0x006FDA30
            )  # three offsets are avaliable here: 006DC7F8, 006DDCA0, 006FDA30 each should point to the same address.. if not remove one   You need to check for each address in record game.
            pm.pointer(ptr + 0x184)
        except NullAddress:
            self.running = False
            return False

        # Third check. Time
        if pm.int32(ptr + 0x68) <= 0:
            return False

        self.running = True
        # And get the common stuff
        GTime.set(pm.int32(ptr + 0x68))
        self.screen_position = pm.struct(ptr + 0xD8, "ff")
        self.speed = pm.float(ptr + 0x16C)
        self.pov = self.players[pm.int8(ptr + 0x174) - 1]  # Must be -1
        if self.pov != self.player:
            if self.player is not None:
                self.player.pov = False
            self.player = self.pov  # Set the new pov
            self.player.pov = True
            self.__update_teams__()
        market_price = pm.struct(
            ptr + 0x238, "fff"
        )  # Wood, food, stone coeficient see spirit of the law - markets
        Objects.selected.clear()
        Objects.selected_pointers.clear()
        # Update all players data
        for player in self.players:
            player.update(market_price)
        self.gaia.update(market_price)
        return True
Esempio n. 5
0
    def update(self):
        """ Fills the players list"""
        self.up = True
        ptr = pm.pointer(pm.base_address + 0x006EEFB4)
        ptr = pm.pointer(ptr + 0x0)
        ptr = pm.pointer(ptr + 0x60)
        ptr = pm.pointer(ptr + 0xCE4)

        if not ptr:  # ptr is null if not in the lobby
            return False

        self.victory = Lobby.VICTORY_OPTIONS[pm.int32(ptr + 0x50)]
        self.victory_time_or_score = pm.int32(ptr + 0x54)  # Time is in years!
        self.map_size = Lobby.MAP_SIZE_OPTIONS[pm.int32(ptr + 0x90)]
        self.reveal_map = Lobby.REVEAL_MAP_OPTIONS[pm.int32(ptr + 0x9c)]
        self.resources = Lobby.RESOURCES_OPTIONS[pm.int32(ptr + 0xa0)]
        self.starting_age = Lobby.STARTING_AGE_OPTIONS[pm.int32(ptr + 0xa4)]
        self.ending_age = Lobby.STARTING_AGE_OPTIONS[pm.int32(ptr + 0xa8)]
        self.game_speed = pm.float(ptr + 0x3b4 + 8 * 8)
        self.treaty_length = pm.int32(ptr + 0x3b8 + 8 * 8)
        self.population_limit = pm.int32(ptr + 0x3bC + 8 * 8)

        for i in range(Lobby.SKIP_GAIA, 9):
            p = ptr + 0x48 + 0x68 * i
            number = pm.int32(p + 0x50)  # Get player number

            if number == -1:  # A resets it
                self.players[i] = LobbyPlayer()
            else:
                # Update player's stuff
                player = self.players[i]
                player.number = number
                player.team = pm.int32(p + 0x0)
                player.deathmatch_rating = pm.int32(p + 0x44)
                player.rating = pm.int32(p + 0x48)
                player.color = pm.int32(p + 0x4C)
                player.name = pm.byte_string(
                    pm.pointer(p + 0xC)) if i > 0 else b"Gaia"
                player.ai = False if player.name and player.name is not "Gaia" else True
                player.civ = None

        self.teams_together = not bool(pm.int8(ptr + 0x3c2 + 8 * 8))
        self.all_techs = bool(pm.int8(ptr + 0x3c3 + 8 * 8))
        self.lock_teams = bool(pm.int8(ptr + 0x3c5 + 8 * 8))
        self.lock_speed = bool(pm.int8(ptr + 0x3c6 + 8 * 8))
        self.record_game = bool(pm.int8(ptr + 0x3cc + 8 * 8))
        self.allow_cheats = bool(pm.int8(ptr + 0x3cf + 8 * 8))
        return True
Esempio n. 6
0
    def update(self):
        # Check if the game is running
        pm.update()
        if not pm.int32(pm.base_address + 0x9C8FB0):
            self.running = False
            return False
        # Second check.
        try:
            ptr = pm.pointer(pm.base_address + 0x006E62D8)
            pm.pointer(ptr + 0x184)
        except NullAddress:
            self.running = False
            return False

        # Third check. Time
        if pm.int32(ptr + 0x68) <= 0:
            return False

        self.running = True
        # And get the common stuff
        GTime.set(pm.int32(ptr + 0x68))
        self.screen_position = pm.struct(ptr + 0xD8, "ff")
        self.speed = pm.float(ptr + 0x16C)
        self.pov = self.players[pm.int8(ptr + 0x174) - 1]  # Must be -1
        if self.pov != self.player:
            if self.player is not None:
                self.player.pov = False
            self.player = self.pov  # Set the new pov
            self.player.pov = True
            self.__update_teams__()
        market_price = pm.struct(
            ptr + 0x238, "fff"
        )  # Wood, food, stone coeficient see spirit of the law - markets
        Objects.selected.clear()
        Objects.selected_pointers.clear()
        # Update all players data
        for player in self.players:
            player.update(market_price)
        self.gaia.update(market_price)
        return True