Giter VIP home page Giter VIP logo

hashtonmartyn / aoe4-generated-map-debugger Goto Github PK

View Code? Open in Web Editor NEW

This project forked from drumsin/aoe4-generated-map-debugger

0.0 0.0 0.0 190 KB

A simple debugger for building AoE4 generated maps. Test and see the results of your terrainLayoutResult table in a web browser.

License: Creative Commons Zero v1.0 Universal

JavaScript 24.72% Lua 29.71% HTML 3.47% SCSS 41.72% Dockerfile 0.38%

aoe4-generated-map-debugger's Introduction

AoE4 Generated Map Debugger

Having to launch the game each time to see code changes is very time consuming. This debug tool helps solve this problem when building AoE4 generated maps. Test and see the results of your terrainLayoutResult table in any web browser.

Global Lua Variables

  • gridSize
  • gridHeight
  • gridWidth
  • worldTerrainWidth
  • worldTerrainHeight

Global Lua Functions

  • worldGetRandom() If you are getting random numbers, you must use worldGetRandom(), as that ties the map script to the seed for determinism across all players. (you will sync error without it)

Defined Lua Variables for Efficiency

Commonly named variables from the map generation starter template are defined in the debugger for speed and efficiency in testing. You may want to test out a small snippet of code without having to define these each time. If you use these variables, be sure to define them in your maps scar code. See example below:

  • mapHalfSize
  • mapQuarterSize
  • mapEighthSize

If using the above variables when testing, you will want to make sure they are defined in your map script.

mapHalfSize = math.ceil(gridSize/2)
mapQuarterSize = math.ceil(gridSize/4)
mapEighthSize = math.ceil(gridSize/8)

Code Samples

Try out some of these code samples by pasting them into the editor. Use them in your maps!

See community wiki on generated maps

Using Map Functions (Debug Entire Maps)

For legal reasons, THIS TOOL DOES NOT include any AoE4 source code and functions. e.g. PlacePlayerStartsRing, DrawStraightLineReturn, CreateTeamMappingTable, GetNeighbors, etc.

However, you can run this tool on your local disk and incorporate these map functions. Once you download or clone this repository, follow the steps below.

STEP 1

Using the Age of Empires IV Content Editor, open Data.sga located in the game directory:

Age of Empires IV\engine\archives\Data.sga

Navigate to:

data > scar > terrainlayout > library

Select these files below, right-click and select "Extract". You will extract these files and overwrite the existing files located in:

aoe4-generated-map-debugger/src/lua-imports/library/engine/

  • calculationfunctions.lua
  • distributionfunctions.lua
  • drawlinesfunctions.lua
  • getsquaresfuntions.lua
  • setsquaresfunctiona.lua
  • template_functions.lua

STEP 2

Again using the Age of Empires IV Content Editor. Open another Data.sga that's located in another directory (notice the path):

Age of Empires IV\cardinal\archives\Data.sga

Navigate to:

data > scar > terrainlayout > library

Select these files below, right-click and select "Extract". You will extract these files and overwrite the existing files located in:

aoe4-generated-map-debugger/src/lua-imports/library/cardinal/

  • map_setup.lua
  • playerresources.lua
  • player_starts.lua
  • review_functions.lua
  • tacticalregions.lua
  • template_functions.lua
  • xp1_functions.lua

STEP 3

You will need to install Node.js in order to bundle the tool with the newly added scripts.

Once Node.js is installed. Follow steps 2-5 under Installing and Running From Local Disk

Installing and Running From Local Disk

Requirements: Node.js

  1. Clone or download this repository.
  2. Navigate to the "aoe4-generated-map-debugger" directory from your command line.
  3. In your command line run these two commands.
npm install
npm run build
  1. After running npm run build, a "dist" directory is automatically created.
  2. Open aoe4-generated-map-debugger/dist/index.html with any web browser. Have fun!

Any files changed in the src directory, you will need to run: npm run build.

STEP 3 Alternative

This is entirely optional and is an alternative way to install and run the application. If you'd prefer to use docker instead of installing Node.js then follow these steps:

Requirements: Docker

  1. Clone or download this repository.
  2. Navigate to the "aoe4-generated-map-debugger" directory from your command line.
  3. In your command line run these two commands.
docker build --pull --rm -f "Dockerfile" -t aoe4generatedmapdebugger:latest "."
docker run -p 9000:9000 aoe4generatedmapdebugger:latest
  1. Open http://localhost:9000/ with any web browser. Have fun!

Any files changed in the src directory will require you to re-run the commands above.

Testing Player Starts

IMPORTANT: In order to test player start functions in the debugger you will have to install this tool on your local disk, followed by incorporating Lua scripts. See: Using Map Functions

In your editor code, define worldPlayerCount and playerTeams = {} before any player related functions. e.g. SetUpTeams(), CreateTeamMappingTable(), PlacePlayerStartsRing(), PlacePlayerStartsDivided()

This example below is testing with 6 players, 3 teams, and is defined before any player functions.

worldPlayerCount = 6
playerTeams[1] = 1 --player 1 on team 1
playerTeams[2] = 1 --player 2 on team 1
playerTeams[3] = 2 --player 3 on team 2
playerTeams[4] = 2 --player 4 on team 2
playerTeams[5] = 3 --player 5 on team 3
playerTeams[6] = 3 --player 6 on team 3

Troubleshooting

The number of terrain columns per row is overflowing and the generation doesn't look correct.

Check the "Meters per square" field option in the editor toolbar is set to the same value of what your map code is using.

When I copy a large portion of my code from the editor pane to paste elsewhere, my browser freezes and I have to close the window.

This is a known issue with the editor pane tool and the Chromium browser. Try using Firefox or Safari if this is an issue.

The grid in the right pane doesn't load. It's completely blank with no tiles.

There is a possibility that your browser security settings is blocking the web assembly (.wasm) file that parses the Lua code. In your browser settings, try lowering the security settings from a Strict mode to a Standard/Balanced mode.

Disclaimer

Nothing in this debug tool is made, distributed, or supported by Relic Entertainment Inc, World's Edge LLC, and Microsoft Corporation.

aoe4-generated-map-debugger's People

Contributors

drumsin avatar ceifa avatar hashtonmartyn avatar

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.