Hey there.
Inspired by the Coop Campaigns by Albtertha94 I thought about enlarging a few of the maps to create extra space for and additional human player!
After digging arround in soem ancient aoe.heavengames.com threads I actually found a solution.
Reading and following the Editing Scenario Data is mandator to work with my little tool.
For my examples I use the “Scx1-04-The Battle of the Metaurus.aoescn” scenario!
- Follow the first page of the Tutorial! I work with the Zlibnoh Compressor/Decompressor
It can also decompress and compress aoe DEs new .aoescn files.
When working with non empty scenarios the first part of removing the first 28 bytes is a little bit different.
We also need to delet the scenario introduction. But the you can farily easily recognice the “EC” start in the Hex file as soon as it only encodes gibberish.
After the successful operation you can now decompress the .aoescn to the .hex file.
In the hex file you can now search for “ÿÿÿ” or “9D FF FF FF” in HEX. There will be multiple versions of that. The one you are looking for will be followed by 8 byte where I don’t know what they are doing. But they have been added in the DE version and are not present in the legacy version.
After these the map size and the terrain data follows
In my case the mapsize is “90 00 00 00”
As the map is always squared it is follows by another “90 00 00 00”
After that terrain information is follows!
This is easily recognizable by the pattern of xx xx 00 as every tiles exists of 3 byte where the last one is always 00.
Summary
Now my script comes in! Note down the first byte of the map size! “90” in our case and delet everythink op to and including the map size!
Summary
After that the file should start with the terrain data.
Summary
Save this as another file so you still have the beginning of the file.
Open a commandline and execute either my .py python script or the compiled .exe as followed:
Map_ResizerV01.exe inputfile.hex outputfile.hex
The new file should be bigger! Otherwise you either decreased the size (not supported right now) or something went wrong!
Now we open the original .hex file we got from our uncompiler and paste everything up to and including the map size into the newly created .hex file.
Don’t forget to chane the map size from 90 to FF or what ever you expanded your map to! (You automatically override existing bytes when editiing in cygnus)
Summary
We now have everything back together to follow the 5. gage of the aoe.heavengames tutorial.
In short. You uncompress your newly expanded .hex file back to a .aoescn file.
Now you paste the bytes you deleted in the beginning back into your compressed files!
You save it, copy it into your scenarios folder and enjoy the enlarged map!
The black artefacts are a result of not matching elevation can easily be fixed by using the elevation tool!
Enjoy!
More details:
While aoe.heavens only describes how to resize an empty map. I quickly learned that all existing tiles are all in one realy long list. That means just adding the added tiles at the end of the list will result in some quite bizzar looking artefacts.
Here each row of terrain is 5tiles to short. So formerly matching terrain moves forward by 5 tiles each east to north row!
Thats why I created a small python script that adds the additional tiles at the end of each row of terrain.
Further things to improve would be!
-
Automatically detecting the start of the terrain data so less hex editing needs to be done by hand.
-
Including the initial hex editing and uncompressing as well as compressing into the script so it will be a 1 command action to change the map size. To be more accessible for less tech savvy folks.
-
Support map enlarging on the south to east or east to north axis.
this is problematic right now as everything already placed gets the coordinates starting in the east corner. So adding terrain there with my current script would just shift the terrain unterneath all placed objects.
If you are more skilled in python than I am or you got a great idea please let me know as help is always appreciated.
python script:
Summary
# Map_Resizer V0.1 by DesAnderes!
import sys
import binascii
import os
# get the Paths
inputpath = sys.argv[1]
ouputpath = sys.argv[2]
# read .hex file
############ = binascii.hexlify(open(inputpath, "rb").read())
# determin old map size in hex
print("Please Enter the scenario maplenth in hex")
maplength = int(input(),16)
print("The maplenght is: ", maplength)
# create a 2D array the size of the old map size i.e. FA = 250x250
maparray = [[""] * maplength for s in range(maplength)]
# number of byte per tile
splitindex = 6
# fill the 2D array with the corresponding tile information
i = 0
while i < maplength:
j = 0
while j < maplength:
maparray[i][j] = asciitosplit[splitindex - 6:splitindex]
j += 1
splitindex += 6
i += 1
# save the remaining part of the file
remainingascii = asciitosplit[splitindex - 6:]
# determin output map size in hex
print("Please Enter the new maplenth in hex")
newmaplength = int(input(),16)
#create and 2D array the size of the new map i.e. FF = 255x255
# 060100 is the placeholder terrain: 06 = dirt; 01 = elevation 1; 00 = end of tile
newmaparray = [["060100"] * newmaplength for t in range(newmaplength)]
""" override the 2D array of the new and larger map with the information of
the original smaller map
i.e. Fill 250x250 from 255x255 with the existing data.
All rows and columns < 250 will keep the place holder terrain.
"""
i = 0
while i < maplength:
j = 0
while j < maplength:
newmaparray[i][j] = maparray[i][j]
j += 1
i += 1
#check if output file already exisits, if yes: deletes the file
if os.path.isfile(ouputpath):
os.remove(ouputpath)
# creates and opens the output file
fo = open(ouputpath, mode = "wb")
# append the outputfile with the exisiting data
i = 0
while i < newmaplength:
j = 0
while j < newmaplength:
fo.write(binascii.a2b_hex(newmaparray[i][j]))
# print(str(i) + " : " + str(j))
j += 1
i += 1
fo.write(binascii.a2b_hex(remainingascii))
fo.close()