Code Monkey home page Code Monkey logo

aoe2scenarioparser's Issues

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.

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.

[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?

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

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.

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

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.

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?

Documentation outdated?

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

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

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.......

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

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

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?

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

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.

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.