Пример #1
0
    def __init__(self, parser_obj=None, data=None):
        retrievers = [
            Retriever("Unit count", DataType("u32"), save_as="unit_count"),
            Retriever("Units", DataType(UnitStruct), set_repeat="{unit_count}")
        ]

        super().__init__("Player Units", retrievers, parser_obj, data)
Пример #2
0
    def __init__(self, parser_obj=None, data=None):
        retrievers = [
            Retriever("ASCII, Pregame cinematic filename", DataType("str16")),
            Retriever("ASCII, Victory cinematic filename", DataType("str16")),
            Retriever("ASCII, Loss cinematic filename", DataType("str16")),
            # Retriever("Separator (! in some version)", DataType("1")),
        ]

        super().__init__("Cinematics", retrievers, parser_obj)
Пример #3
0
    def __init__(self, parser_obj=None, data=None):
        retrievers = [
            Retriever("Terrain ID", DataType("u8")),
            Retriever("Elevation", DataType("u8")),
            Retriever("Unused", DataType("u8")),
            Retriever("Separator?", DataType("4"))
        ]

        super().__init__("Terrain", retrievers, parser_obj, data)
    def __init__(self, parser_obj=None, data=None):
        retrievers = [
            Retriever("Active", DataType("u32")),
            Retriever("Human", DataType("u32")),
            Retriever("Civilization", DataType("u32")),
            Retriever("CTY mode", DataType("u32"))
        ]

        super().__init__("Player Data #1", retrievers, parser_obj, data)
Пример #5
0
    def __init__(self, parser_obj=None, data=None):
        retrievers = [
            Retriever("Per-player diplomacy", DataType(PlayerDiplomacyStruct, repeat=16)),
            Retriever("Individual Victories", DataType("60", repeat=16*12)),  # 12 Conditions per (16) Player(s).
            Retriever("Separator", DataType("u32")),
            Retriever("Per-player allied victory", DataType("u32", repeat=16)),  # Ignored -> PlayerDataThree
            Retriever("Unknown", DataType("4")),
        ]

        super().__init__("Diplomacy", retrievers, parser_obj)
    def __init__(self, parser_obj=None, data=None):
        retrievers = [
            Retriever("ASCII, Background filename", DataType("str16")),
            Retriever("Picture Version", DataType("u32")),
            Retriever("Bitmap width", DataType("u32")),
            Retriever("Bitmap height", DataType("s32")),
            Retriever("Picture Orientation", DataType("s16")),
            # Retriever("	BITMAPINFOHEADER", DataType("u32")),
        ]

        super().__init__("Background Image", retrievers, parser_obj)
Пример #7
0
    def __init__(self, parser_obj=None, data=None):
        retrievers = [
            Retriever("Version", DataType("c4")),
            Retriever("Header length", DataType("u32")),
            Retriever("Savable", DataType("s32")),
            Retriever("Timestamp of last save", DataType("u32")),
            Retriever("Scenario instructions", DataType("str32")),
            Retriever("Individual victories used", DataType("u32")),
            Retriever("Player count", DataType("u32")),
            Retriever("Data", DataType("36")),
            Retriever("Creator name", DataType("str32")),
            Retriever("Data", DataType("4")),
        ]

        super().__init__("File Header", retrievers, parser_obj)
Пример #8
0
    def __init__(self, parser_obj=None, data=None):
        retrievers = [
            Retriever("Trigger Version", DataType("f64")),
            Retriever("Trigger instructions start", DataType("s8")),
            Retriever("Number of triggers",
                      DataType("s32"),
                      save_as="number_of_triggers"),
            Retriever("Trigger data",
                      DataType(TriggerStruct),
                      set_repeat="{number_of_triggers}"),
            Retriever("Trigger display order array",
                      DataType("u32"),
                      set_repeat="{number_of_triggers}"),
        ]

        super().__init__("Triggers", retrievers, parser_obj)
Пример #9
0
    def __init__(self, parser_obj=None, data=None):
        retrievers = [
            Retriever("X position", DataType("f32")),
            Retriever("Y position", DataType("f32")),
            Retriever("Z position", DataType("f32")),
            Retriever("ID", DataType("u32")),
            Retriever("Unit 'constant'", DataType("u16")),
            Retriever("Status", DataType("u8")),
            Retriever("Rotation, in radians", DataType("f32")),
            Retriever("Initial animation frame", DataType("u16")),
            Retriever("Garrisoned in: ID", DataType("s32")),
        ]

        super().__init__("Unit", retrievers, parser_obj, data)
Пример #10
0
    def __init__(self, parser_obj=None, data=None):
        retrievers = [
            Retriever("Number of unit sections",
                      DataType("u32"),
                      save_as="unit_sections"),
            Retriever("Player data #4", DataType(PlayerDataFourStruct,
                                                 repeat=8)),
            # Retriever("Unknown", DataType("4")),
            Retriever("Number of players?", DataType("u32")),
            # Retriever("Unknown (2)", DataType("115", repeat=8)),
            Retriever("Player data #3",
                      DataType(PlayerDataThreeStruct, repeat=8)),
            Retriever("Player Units",
                      DataType(PlayerUnitsStruct),
                      set_repeat="{unit_sections}"),
        ]

        super().__init__("Units", retrievers, parser_obj)
Пример #11
0
    def __init__(self, parser_obj=None, data=None):
        retrievers = [
            Retriever("Food, duplicate", DataType("f32")),
            Retriever("Wood, duplicate", DataType("f32")),
            Retriever("Gold, duplicate", DataType("f32")),
            Retriever("Stone, duplicate", DataType("f32")),
            Retriever("'Ore X', duplicate", DataType("f32")),
            Retriever("Trade Goods, duplicate", DataType("f32")),
            Retriever("Population limit", DataType("f32")),
        ]

        super().__init__("Player Data #4", retrievers, parser_obj, data)
Пример #12
0
    def __init__(self, parser_obj=None, data=None):
        retrievers = [
            Retriever("Gold", DataType("u32")),
            Retriever("Wood", DataType("u32")),
            Retriever("Food", DataType("u32")),
            Retriever("Stone", DataType("u32")),
            Retriever("Ore X (unused)", DataType("u32")),
            Retriever("Trade Goods", DataType("u32")),
            Retriever("Player color", DataType("u32"))
        ]

        super().__init__("Resources", retrievers, parser_obj, data)
    def __init__(self, parser_obj=None, data=None):
        retrievers = [
            Retriever("Strings", DataType("str16", repeat=32)),
            Retriever("AI names", DataType("str16", repeat=16)),
            Retriever("AI files", DataType(AIStruct, repeat=16)),
            Retriever("AI type", DataType("u8", repeat=16)),
            Retriever("Separator", DataType("u32")),
            Retriever("Resources", DataType(ResourcesStruct, repeat=16))
        ]

        super().__init__("Player Data #2", retrievers, parser_obj)
Пример #14
0
    def _read_file(self):
        print("File reading started...")
        self.parsed_header = collections.OrderedDict()
        self.parsed_data = collections.OrderedDict()
        header_generator = self._create_header_generator(
            settings.runtime.get("chunk_size"))
        data_generator = self._create_data_generator(
            settings.runtime.get("chunk_size"))

        for piece_object in header_structure:
            piece = piece_object(self.parser)
            # print("Reading", piece.piece_type + "...", end="")
            piece.set_data_from_generator(header_generator)
            self.parsed_header[type(piece).__name__] = piece
            # print("...Done!")
            # print(piece)

        for piece_object in file_structure:
            piece = piece_object(self.parser)
            piece.set_data_from_generator(data_generator)
            self.parsed_data[type(piece).__name__] = piece

        suffix = b''
        try:
            while True:
                suffix += self.parser.retrieve_value(
                    data_generator, Retriever("suffix data", DataType("1")))
        except StopIteration as e:
            # print(e)
            pass
        finally:
            # print("Suffix done", len(suffix))
            self.suffix = suffix

        print("File reading finished successfully.")

        om = AoE2ObjectManager(self.parsed_header, self.parsed_data)
        om.reconstruct()

        self._write_from_structure()
Пример #15
0
    def __init__(self, parser_obj=None, data=None):
        retrievers = [
            Retriever("Instructions", DataType("u32")),
            Retriever("Hints", DataType("u32")),
            Retriever("Victory", DataType("u32")),
            Retriever("Loss", DataType("u32")),
            Retriever("History", DataType("u32")),
            Retriever("Scouts", DataType("u32")),
            Retriever("ASCII Instructions", DataType("str16")),
            Retriever("ASCII Hints", DataType("str16")),
            Retriever("ASCII Victory", DataType("str16")),
            Retriever("ASCII Loss", DataType("str16")),
            Retriever("ASCII History", DataType("str16")),
            Retriever("ASCII Scouts", DataType("str16")),
        ]

        super().__init__("Messages", retrievers, parser_obj)
Пример #16
0
    def __init__(self, parser_obj=None, data=None):
        retrievers = [
            Retriever("Enabled", DataType("u32")),
            Retriever("Looping", DataType("s8")),
            Retriever("Description string Table ID", DataType("s32")),
            Retriever("Act as objective", DataType("u8")),
            Retriever("Description order (in objectives)", DataType("u32")),
            Retriever("Make header", DataType("u8")),
            Retriever("Short description string Table ID", DataType("s32")),
            Retriever("Display on screen", DataType("u8")),
            Retriever("Unknown", DataType("5")),
            Retriever("Mute objectives", DataType("u8")),
            # Retriever("Trigger starting time", DataType("u32")),
            Retriever("Trigger description", DataType("str32")),
            Retriever("Trigger name",
                      DataType("str32")),  # (max 44 characters in UI)
            Retriever("Short description", DataType("str32")),
            Retriever("Number of effects",
                      DataType("s32"),
                      save_as="number_of_effects"),
            Retriever("Effect data",
                      DataType(EffectStruct),
                      set_repeat="{number_of_effects}"),
            Retriever("Effect display order array",
                      DataType("s32"),
                      set_repeat="{number_of_effects}"),
            Retriever("Number of conditions",
                      DataType("s32"),
                      save_as="number_of_conditions"),
            Retriever("Condition data",
                      DataType(ConditionStruct),
                      set_repeat="{number_of_conditions}"),
            Retriever("Condition display order array",
                      DataType("s32"),
                      set_repeat="{number_of_conditions}"),
        ]

        super().__init__("Trigger", retrievers, parser_obj, data)
    def __init__(self, parser_obj=None, data=None):
        retrievers = [
            Retriever("Stance with each player", DataType("u32", repeat=16)),
        ]

        super().__init__("Player Diplomacy", retrievers, parser_obj, data)
Пример #18
0
    def __init__(self, parser_obj=None, data=None):
        retrievers = [
            Retriever("Per player number of disabled techs", DataType("u32", repeat=16), save_as="disabled_techs"),
            Retriever("Disabled technology IDs in player order", DataType("u32"), set_repeat="sum({disabled_techs})"),
            # Retriever("Per player extra number of disabled techs", DataType("u32", repeat=16)),  # Removed in DE?
            Retriever("Per player number of disabled units", DataType("u32", repeat=16), save_as="disabled_units"),
            Retriever("Disabled unit IDs in player order", DataType("u32"), set_repeat="sum({disabled_units})"),
            # Retriever("Per player extra number of disabled units", DataType("u32", repeat=16)),  # Removed in DE?
            Retriever("Per player number of disabled buildings",
                      DataType("u32", repeat=16), save_as="disabled_buildings"),
            Retriever("Disabled building IDs in player order",
                      DataType("u32"), set_repeat="sum({disabled_buildings})"),
            Retriever("Combat Mode", DataType("u32")),
            Retriever("Naval Mode", DataType("u32")),
            Retriever("All techs", DataType("u32")),
            Retriever("Per player starting age", DataType("u32", repeat=16)),  # 2: Dark 6 = Post | 1-8 players 9 GAIA
            Retriever("Unknown", DataType("36")),
        ]

        super().__init__("Options", retrievers, parser_obj)
Пример #19
0
    def __init__(self, parser_obj=None, data=None):
        retrievers = [
            Retriever("Condition type", DataType("s32")),
            Retriever("Check, (21)", DataType("s32")),  # Was always: 0x10
            Retriever(
                "Amount (Quantity)",
                DataType("s32")),  # Also technology state, also Difficulty
            Retriever("Resource Type/Tribute list", DataType("s32")),
            Retriever("Unit object", DataType("s32")),
            Retriever("Next object", DataType("s32")),  # Old: Unit ID
            Retriever("Object list", DataType("s32")),
            Retriever("Player", DataType("s32")),
            Retriever("Technology", DataType("s32")),
            Retriever("Timer", DataType("s32")),
            Retriever("Unknown", DataType("s32")),
            Retriever("Area 1 X", DataType("s32")),
            Retriever("Area 1 Y", DataType("s32")),
            Retriever("Area 2 X", DataType("s32")),
            Retriever("Area 2 Y", DataType("s32")),
            Retriever("Object Group", DataType("s32")),
            Retriever(
                "Object Type", DataType("s32")
            ),  # -1: None, 1: Other, 2: Building, 3: Civilian, 4: Military
            Retriever("AI Signal", DataType("s32")),
            Retriever("Inverted", DataType("s32")),
            Retriever("Unknown (3)", DataType("s32")),
            Retriever("Variable", DataType("s32")),  # Number == VariableX
            Retriever("Comparison",
                      DataType("s32")),  # 0: ==, 1: <, 2: >, 3: <=, 4 >=
            Retriever("Target player", DataType("s32")),
        ]

        super().__init__("Condition", retrievers, parser_obj, data)
Пример #20
0
    def __init__(self, parser_obj=None, data=None):
        retrievers = [
            Retriever("Separator", DataType("u32")),
            Retriever("Conquest required", DataType("u32")),
            Retriever("Ruins", DataType("u32")),
            Retriever("Artifacts", DataType("u32")),
            Retriever("Discovery", DataType("u32")),
            Retriever("Explored % of map required", DataType("u32")),
            Retriever("Gold", DataType("u32")),
            Retriever("All custom conditions required?", DataType("u32")),
            Retriever("Mode", DataType("u32")),
            Retriever("Required score for score victory", DataType("u32")),
            Retriever("Time for timed game, in 10ths of a year",
                      DataType("u32")),
        ]

        super().__init__("Global Victory", retrievers, parser_obj)
Пример #21
0
    def __init__(self, parser_obj=None, data=None):
        retrievers = [
            Retriever("Effect type", DataType("s32"),
                      save_as="effect_type"),  # CONFIRMED
            Retriever(
                "Check, (46)", DataType("s32")
            ),  # always 0x17, now 0x2e (46)?                       # CONFIRMED
            Retriever("AI script goal", DataType("s32")),  # CONFIRMED
            Retriever("AA Quantity",
                      DataType("u8"),
                      set_repeat=
                      "1 if {effect_type} == 31 or {effect_type} == 28 else 0"
                      ),  # CONFIRMED
            Retriever("AA Armor/Attack Type",
                      DataType("s24"),
                      set_repeat=
                      "1 if {effect_type} == 31 or {effect_type} == 28 else 0"
                      ),  # CONFIRMED
            Retriever("Quantity",
                      DataType("s32"),
                      set_repeat=
                      "1 if {effect_type} != 31 and {effect_type} != 28 else 0"
                      ),  # CONFIRMED
            Retriever("Tribute List", DataType("s32")),  # CONFIRMED
            Retriever("Diplomacy", DataType("s32")),  # CONFIRMED
            Retriever("Number of units selected",
                      DataType("s32"),
                      save_as="number_of_units_selected"),  # CONFIRMED
            Retriever("Unknown", DataType("s32")),  # UNUSED
            Retriever("Object list unit ID", DataType("s32")),  # CONFIRMED
            Retriever("Player Source", DataType("s32")),  # CONFIRMED
            Retriever("Player Target", DataType("s32")),  # CONFIRMED
            Retriever("Technology", DataType("s32")),  # CONFIRMED
            Retriever("String ID", DataType("s32")),  # CONFIRMED
            Retriever("Unknown2", DataType("s32")),  # UNUSED
            Retriever("Display Time (display instructions)",
                      DataType("s32")),  # CONFIRMED
            Retriever("Trigger ID (activate/deactivate)",
                      DataType("s32")),  # CONFIRMED
            Retriever("Location X", DataType("s32")),  # CONFIRMED
            Retriever("Location Y", DataType("s32")),  # CONFIRMED
            Retriever("Area 1 X", DataType("s32")),  # CONFIRMED
            Retriever("Area 1 Y", DataType("s32")),  # CONFIRMED
            Retriever("Area 2 X", DataType("s32")),  # CONFIRMED
            Retriever("Area 2 Y", DataType("s32")),  # CONFIRMED
            Retriever("Object Group", DataType("s32")),  # CONFIRMED
            Retriever("Object Type", DataType("s32")),  # CONFIRMED
            Retriever("Instruction Panel Position",
                      DataType("s32")),  # CONFIRMED
            Retriever("Attack Stance", DataType("s32")),  # CONFIRMED
            Retriever("Time unit (second, minutes, years)",
                      DataType("s32")),  # CONFIRMED
            Retriever("Enabled/Victory", DataType("s32")),  # CONFIRMED
            Retriever("Food", DataType("s32")),  # CONFIRMED
            Retriever("Wood", DataType("s32")),  # CONFIRMED
            Retriever("Stone", DataType("s32")),  # CONFIRMED
            Retriever("Gold", DataType("s32")),  # CONFIRMED
            Retriever("Item ID", DataType("s32")),  # CONFIRMED
            Retriever("Flash Object", DataType("s32")),  # CONFIRMED
            Retriever("Force Research Technology",
                      DataType("s32")),  # CONFIRMED
            Retriever("Visibility State", DataType("s32")),  # CONFIRMED
            Retriever("Scroll (Set view)", DataType("s32")),  # CONFIRMED
            Retriever("Operation", DataType("s32")),  # CONFIRMED
            Retriever("Object list unit ID 2", DataType("s32")),  # CONFIRMED
            Retriever("Button Location", DataType("s32")),  # CONFIRMED
            Retriever("AI signal Value", DataType("s32")),  # CONFIRMED
            Retriever("Unknown3", DataType("s32")),  # UNUSED
            Retriever("Object attributes", DataType("s32")),  # CONFIRMED
            Retriever("From Variable", DataType("s32")),  # CONFIRMED
            Retriever("Variable/Timer", DataType("s32")),  # CONFIRMED
            Retriever("Facet", DataType("s32")),  # CONFIRMED
            Retriever("Unknown4", DataType("s32")),  # UNUSED
            Retriever("Play Sound", DataType("s32")),  # CONFIRMED
            Retriever("Message", DataType("str32")),  # CONFIRMED
            Retriever("Sound (event) name", DataType("str32")),  # CONFIRMED
            Retriever("Selected Object(s) ID",
                      DataType("s32"),
                      set_repeat="{number_of_units_selected}"),  # CONFIRMED
        ]

        super().__init__("Effect", retrievers, parser_obj, data)
Пример #22
0
    def __init__(self, parser_obj=None, data=None):
        retrievers = [
            Retriever("Next unit ID to place", DataType("u32")),
            Retriever("Version", DataType("f32")),
            Retriever("Player names", DataType("c256", repeat=16)),
            Retriever("String table player names", DataType("u32", repeat=16)),
            Retriever("Player data#1", DataType(PlayerDataOneStruct,
                                                repeat=16)),
            Retriever("Conquest mode", DataType("u8")),
            Retriever("Mission items Counter", DataType("u16"), save_as="mic"),
            Retriever("Mission available", DataType("u16")),
            Retriever("Mission timeline", DataType("f32")),
            Retriever("Mission item", DataType("30"), set_repeat="{mic}"),
            Retriever("Unknown", DataType("64")),
            Retriever("Filename", DataType("str16"))
        ]

        super().__init__("Data Header", retrievers, parser_obj)
Пример #23
0
    def __init__(self, parser_obj=None, data=None):
        retrievers = [
            Retriever("Separator??", DataType("2")),
            Retriever("Unknown String", DataType("str16")),
            Retriever("Separator?? (2)", DataType("2")),
            Retriever("Map color mood", DataType("str16")),
            Retriever("Collide and Correcting", DataType("u8")),
            Retriever("Player 1 camera, Y", DataType("s32")),
            Retriever("Player 1 camera, X", DataType("s32")),
            Retriever("AI Type", DataType("s8")),
            Retriever("Map Width", DataType("s32"), save_as="map_width"),
            Retriever("Map Height", DataType("s32"), save_as="map_height"),
            Retriever("Terrain data",
                      DataType(TerrainStruct),
                      set_repeat="{map_width}*{map_height}"),
        ]

        super().__init__("Map", retrievers, parser_obj)