Code Monkey home page Code Monkey logo

aoe2scenarioparser's Introduction

AoE2ScenarioParser

This is a project for editing parts of an aoe2scenario file from Age of Empires 2 Definitive Edition outside the in-game editor.

Getting started

Quick links

Documentation

Documentation can be found on GitHub Pages.

Discord

If you have any questions regarding the parser, join the discord!

Progress

Current up-to-date progress can be found on the changelog.md page. (Check the dev branch for non-released progress).

Features:

View Add Edit Remove
Triggers ✔️ ✔️ ✔️ ✔️
Conditions ✔️ ✔️ ✔️ ✔️
Effects ✔️ ✔️ ✔️ ✔️
Units n/a *1 ✔️ ✔️ ✔️
Map n/a *1 ✔️ ✔️ ✔️
Players n/a *1 ✔️* ✔️ ✔️*

*: You can disable or enable players like in the in-game editor (min 1, max 8).
*1: There's no overall formatting function to display these. Though, they can still be printed.

 

Support:

Scenario file version Read Write Reference
1.36 ✔️ ✔️ Version since therelease of the Definitive Edition
1.37 ✔️ ✔️ Version since game update: 35584 (February 27th, 2020)
Unchanged in:
- Update 36202 (March 30th, 2020)
- Update 36906 (April 29th, 2020)
- Update 37650 (May 27th, 2020)
- Hotfix 37906 (June 2nd, 2020)
- Update 39284 (July 20th, 2020)
- Hotfix 39515 (July 27th, 2020)
- Update 40220 (August 24th, 2020)
- Update 40874 (September 22nd, 2020)
- Update 41855 (October 20th, 2020)
1.40 ✔️ ✔️ Version since game update: 42848 (November 17th, 2020)
Unchanged in:
- Hotfix 43210 (November 24th, 2020)
1.41 ✔️ ✔️ Version since game update: 44725 (January 25th, 2021)
Unchanged in:
- Hotfix 44834 (January 28th, 2021)
- Hotfix 45185 (February 11th, 2021)
- Update 46265 (March 24th, 2021)
- Update 47820 (May 3rd, 2021)
1.42 ✔️ ✔️ Version since game update: 50292 (July 6th, 2021)
Unchanged in:
- Hotfix 50700 (July 13th, 2021)
1.43 ✔️ ✔️ Version since game update: 51737 (August 10th, 2021)
1.44 ✔️ ✔️ Version since game update: 54480 (October 5th, 2021)
Unchanged in:
- Hotfix 54684 (October 6th, 2021)
1.45 ✔️ ✔️ Version since game update: 56005 (November 17th, 2021)
Unchanged in:
- Update 58259 (January 31st, 2022)
1.46 ✔️ ✔️ Version since game update: 61321 (April 27th, 2022)
Unchanged in:
- Update 63482 (June 28th, 2021)
- Hotfix 63581 (July 6th, 2021)
1.47 ✔️ ✔️ Version since game update: 66692 (August 29th, 2022)
Unchanged in:
- Update 73855 (December 7th, 2022)
- Update 75350 (Console update) (January 31st, 2023)
- Update 78174 (March 8th, 2023)
- Hotfix 78757 (March 8th, 2023)
1.48 ✔️ ✔️ Version since game update: 81058 (April 11th, 2023)
Unchanged in:
- Hotfix 82587 (April 28th, 2023)
1.49 ✔️ ✔️ Version since game update: 83607 (May 16th, 2023)
Unchanged in:
- Hotfix 85208 (June 1st, 2023)
- Hotfix 85614 (June 6th, 2023)
- Update 87863 (June 27th, 2023)
- Update 90260 (July 26th, 2023)
- Update 93001 (September 6th, 2023)
1.51 ✔️ ✔️ Version since game update: 95810 (October 31th, 2023)
Unchanged in:
- Update 99311 (December 11th, 2023)
- Update 104954 (February 23th, 2024)
1.53 ✔️ ✔️ Version since game update: 107882 (March 13th, 2024)
Unchanged in:
- Update 108769 (March 26th, 2024)

Authors

  • Kerwin Sneijders (Main Author)
  • Alian713 (Dataset Wizard)

License

MIT License: Please see the LICENSE file.

aoe2scenarioparser's People

Contributors

divy1211 avatar ksneijders avatar newtonerdai avatar pvallet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

aoe2scenarioparser's Issues

AI files are not correctly read and saved

When reading a scenario with AI files the reading results in a warning:

Extra data found in the file (1197591 bytes):
	'b'\x01\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x14\x00\x00\x00AI (HD 
	version).per\x00XK\x11\x00; The official HD/2013 Edition AI - created by Promiskuitiv and 
	Archon\r\n; Get in contact with Promi.......

Any examples of how to create a variable condition?

Here is my code, but when I save the condition, it throws error

    trigger_manager.add_variable(1, "hello")
    condition = trigger.add_condition(Condition.VARIABLE_VALUE)
    condition.amount_or_quantity = 1
    condition.variable = 1
    condition.comparision = 0
    condition.inverted = 0

TypeError occurred in: Condition data
	Data: [ConditionStruct]
	Datatype: [DataType] 1 * ConditionStruct

TypeError occurred in: Trigger data
	Data: [TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct, TriggerStruct]
	Datatype: [DataType] 98 * TriggerStruct

Changing map size causes weird behavior

Here's a simple code example

from AoE2ScenarioParser.scenarios.aoe2_de_scenario import AoE2DEScenario

scenario_folder = "path"

input_path = scenario_folder + "default0.aoe2scenario"
source_scenario = AoE2DEScenario.from_file(input_path)

map_manager = source_scenario.map_manager
unit_manager = source_scenario.unit_manager

print(str(map_manager.map_size))

map_manager.map_size = 240

print(str(map_manager.map_size))

for tile in map_manager.get_square_1d(x1=0, y1=0, x2=10, y2=10):
    print("x = " + str(tile.x) + " y = " + str(tile.y))

It spit outs obviously incorrect x y values. get_square_2d seems to behave the exact same.

Creating API Documentation

API documentation for the project would help users get a better overview of all available functionality.
An API documentation would especially be useful for all AoE2Object subclasses.
Having an API doc for all other parts would be a nice-to-have.

I've looked into it for a day or two but wasn't able to get great results that would be worth exploring further without taking (presumably) weeks of my time which I currently don't have.

My current 'progress' can be found on the branch rework/apidocs.


If anyone has worked with any sort of API generation tool before and would love to help, please contact me.
Easiest would be via discord at: MrKirby # 5063

Map size being set to zero

If one attempts to set map size to the value it already holds, the map size is set to 0.

map_manager.map_size = 10
print(map_manager.map_size)
map_manager.map_size = 10
print(map_manager.map_size)

Gives

10
0

Easy enough to work around with an If statement to check if the value is already what you want, but this seems like unintended behavior.

Scenario Crash After duplicate triggers

Hello.
This time it is an error that occurs after duplicating triggers.
In VS it gives me this message:
File writing finished successfully.
File successfully written to: 'C:\Users\xaero\Games\Age of Empires 2 DE\76561198062020840\resources_common\scenario\CBA DoGo Edition.aoe2scenario'

Also in the game apparently everything is fine

imagen

But when I open the map

imagen

I have backup of the map and I was able to recover it, but when retrying duplicate trigger the same error occurred

The Code:

from AoE2ScenarioParser.scenarios.aoe2_de_scenario import AoE2DEScenario
from AoE2ScenarioParser.datasets.players import PlayerId
from AoE2ScenarioParser.objects.support.trigger_select import TS

input_path = r"C:\Users\xaero\Games\Age of Empires 2 DE\76561198062020840\resources\_common\scenario\CBA DoGo Edition.aoe2scenario"
output_path = r"C:\Users\xaero\Games\Age of Empires 2 DE\76561198062020840\resources\_common\scenario\CBA DoGo Edition.aoe2scenario"
scenario = AoE2DEScenario.from_file(input_path)

trigger_manager = scenario.trigger_manager
copied_triggers = trigger_manager.copy_trigger_per_player(
    from_player=PlayerId.ONE,
    trigger_select=TS.index(2832),
    create_copy_for_players=[
        PlayerId.TWO, PlayerId.THREE, PlayerId.FOUR, PlayerId.FIVE, PlayerId.SIX, PlayerId.SEVEN, PlayerId.EIGHT
    ]
)

scenario.write_to_file(output_path)

Edith1: Only 1 duplicate trigger appears in the code, but there were approximately 80 duplicates for 8 players
Edith2: I tested again duplicating just 1 trigger, but got the same error T_T

Feature Request: Export and import triggers using a plain text file (JSON/XML) for manual editing

I do not know if that function exists but if it would not be useful to put the possibility of exporting to a plain text file (for example an XML) that contains the triggers of a scan so that one can edit it manually and then import it to another scenario or modify until correcting an existing one. This would serve to have trigger templates to be able to alter it to our needs. Not only change what conditions go to each player but edit more for example types of armor, quantity of it, names of civilizations etc. Even to share trigger tables. Something similar to what could be done with the AOKTS
What do you think?

[Help] Get access to DataHeaderPiece in a legal way

Hi,

Description:
Recently I am writing a small tool to help me re-index all the units and re-set next_unit_id_to_place.
1
The code looks like this:

units = scenario.unit_manager.get_all_units()
index = 0
for unit in units:
    if unit.reference_id >= 0:
        unit.reference_id = index
        index = index + 1
data._parsed_data["DataHeaderPiece"].next_unit_id_to_place = index

Question:
Would you mind telling me whether there is a legal way to modify the DataHeader without getting access to a private variable?

bidict dependency is missing in PyPI

After running

 pip install AoE2ScenarioParser==0.0.17

Then running the following in Python 3.8

from AoE2ScenarioParser.aoe2_scenario import AoE2Scenario

Will result in the error:

ModuleNotFoundError: No module named 'bidict'

A temporary fix is running pip install bidict but a long term solution would be to include bidict as a dependency for AoE2Scenario

How can I export triggers from one scenario to another?

I am not a programmer, however I have managed to understand some of the logic of this code

I have tried to export the triggers from one scenario to others already created.

first I run the commands:

from AoE2ScenarioParser.scenarios.aoe2_de_scenario import AoE2DEScenario

input_path =  "D:/Documents/My Games/Age of Empires 2/escenario1/1.aoe2scenario"
output_path = "D:/Documents/My Games/Age of Empires 2/escenario2/2.aoe2scenario"

scenario = AoE2DEScenario.from_file(input_path)
trigger_manager = scenario.trigger_manager

then to the scribe in the secondary stage I put this:

scenario.write_to_file(output_path)

and it only makes a copy of all the elements (units, terrains, players, triggers etc)

I have tried testing with these commands.

from AoE2ScenarioParser.objects.support.trigger_select import TS

input_path =  "D:/Documents/My Games/Age of Empires 2/escenario1/1.aoe2scenario"
output_path = "D:/Documents/My Games/Age of Empires 2/escenario2/2.aoe2scenario"

trying to only load triggers and not all resources
but I get an error

[Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object 'TriggerSelect' has no attribute 'from_file'](url)

Obviously that's not the case, but as I said, I am not a pytrhon programmer but I already tried everything that occurred to me and I have not been successful

could you help me?

Does get_trigger() not accept trigger_index or display_index as parms any more?

My Python version: 3.8.2
My AoE2ScenarioParser version: 0.0.9

When I am testing the example for get_trigger() in TRIGGERS.md - Editing triggers, conditions or effects:

trigger = trigger_manager.get_trigger(trigger_index=0)
trigger = trigger_manager.get_trigger(display_index=0)

then Errors raised:

TypeError: get_trigger() got an unexpected keyword argument 'trigger_index'
TypeError: get_trigger() got an unexpected keyword argument 'display_index'

Here is the source code of get_trigger():

def get_trigger(self, trigger_select: TriggerSelect) -> TriggerObject:

Seemingly the function has changed after TRIGGERS.md submitted.

Variable Names

Hello, I'm currently using AoE2ScenarioParser-0.1.5 and when I load a scenario and print all triggers with print(trigger_manager.get_summary_as_string()) all used variables seem to be named "VariableStruct". If I write the file and open it on AoE2DE I see the variable names were indeed changed to VariableStruct and if I try to change their name there is a high chance of crashing my game. I don't know if it is related to some recent update of AoE2DE. Anyway, I'd also like to thank you for this -very- useful tool.

UnknownStructureError 1.42 | Add support for the new scenarios from Update 50292

Hello. It is me again.
This time I think it has to do with the new version of AOE2, it had worked quite well in the last few weeks, however just today I get this error:

AoE2ScenarioParser.helper.exceptions.UnknownStructureError: The structure conditions could not be found with: DE:1.42

This is the code:

from AoE2ScenarioParser.scenarios.aoe2_de_scenario import AoE2DEScenario
from AoE2ScenarioParser.datasets.players import PlayerId
from AoE2ScenarioParser.objects.support.trigger_select import TS

input_path = r"C:\Users\xaero\Games\Age of Empires 2 DE\76561198062020840\resources\_common\scenario\CBA DoGo Edition.aoe2scenario"
output_path = r"C:\Users\xaero\Games\Age of Empires 2 DE\76561198062020840\resources\_common\scenario\CBA DoGo Edition.aoe2scenario"
scenario = AoE2DEScenario.from_file(input_path)

trigger_manager = scenario.trigger_manager
print(trigger_manager.get_summary_as_string())

T_T

Duplicate Triggers for each player & Copy Trigger Recursion Error

Hi, I'm new here and I would like to know what is the correct syntax to duplicate a trigger for each player:

from AoE2ScenarioParser.scenarios.aoe2_de_scenario import AoE2DEScenario
from AoE2ScenarioParser.datasets.players import PlayerId

input_path = r"C:\Users\xaero\Games\Age of Empires 2 DE\76561198062020840\resources\_common\scenario\CB_King_Edition_Doge.aoe2scenario"
output_path = r"C:\Users\xaero\Desktop\Escenarios AOE2"
scenario = AoE2DEScenario.from_file(input_path)

trigger_manager = scenario.trigger_manager

copied_triggers = trigger_manager.copy_trigger_per_player(
    from_player=PlayerId.ONE,
    trigger_select=TS.index(610),
    create_copy_for_players=[
        PlayerId.TWO, PlayerId.THREE, PlayerId.FOUR, PlayerId.FIVE, PlayerId.SIX, PlayerId.SEVEN, PlayerId.EIGHT 
    ]
)

scenario.write_to_file(output_path)

But I get this error
imagen

This is the trigger that I want to duplicate

imagen

I know this is a noob mistake, but I would like to know how to correct it.

Thanks

loading in standard maps (potential build order testing/optimization)

Nice work. Just wondering if this can be used to generate a map or a "scenario" of say Arabia in a 1v1, 2v2 setting. Having all of the coordinates of resources would be a backhanded way of developing a build order optimizer using a few basic hand coded constants (such as traversal distance, mining rates etc). Is thee any way to load in the standard map layouts?

Ty

Can't even get the example to work

Excuse me, maybe it is my low skills on python but I can't really get the script to work. I tried the most basic of the examples in the documentation (loading a file) but no matter what I do I still get this error message:

Traceback (most recent call last):
File "C:\Users\SantiPC\Desktop\AoE2ScenarioParser-0.1.28\trigger check.py", line 30, in
from AoE2ScenarioParser.scenarios.aoe2_de_scenario import AoE2DEScenario
File "C:\Users\SantiPC\Desktop\AoE2ScenarioParser-0.1.28\AoE2ScenarioParser\scenarios\aoe2_de_scenario.py", line 4, in
from AoE2ScenarioParser.objects.managers.de.trigger_manager_de import TriggerManagerDE
File "C:\Users\SantiPC\Desktop\AoE2ScenarioParser-0.1.28\AoE2ScenarioParser\objects\managers\de\trigger_manager_de.py", line 4, in
from AoE2ScenarioParser.objects.data_objects.trigger import Trigger
File "C:\Users\SantiPC\Desktop\AoE2ScenarioParser-0.1.28\AoE2ScenarioParser\objects\data_objects\trigger.py", line 16, in
from AoE2ScenarioParser.objects.support.uuid_list import UuidList
File "C:\Users\SantiPC\Desktop\AoE2ScenarioParser-0.1.28\AoE2ScenarioParser\objects\support\uuid_list.py", line 3, in
from typing_extensions import SupportsIndex
ModuleNotFoundError: No module named 'typing_extensions'

I have used this in the past and now that I need it again I had to update it. I did the pip install and everything, I'm 99% sure I've setup everything right but still I always get that message.

Documentation outdated?

using from AoE2ScenarioParser.datasets.units import UnitId gives me an import error, and TS is undefined

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.