The Grid
We'll represent the arena as a 32×32 square grid, in which only one entity (player/boss/minion) may occupy a given square at any point in time. This should be large enough for most scenarios but can be expanded as we define more complex encounters if needed.
Movement
Meters per Tick
To define movement within the grid, we need to first define player speed. MMORPGs like WoW set a base movement rate around 6.4 meters per second (or 7 yards/s). Using a standard speed of 6.4 meters per second, a player moves 0.64 meters per single 0.1s engine tick.
Ticks per Square
If we establish that each square of the grid is 2 × 2 meters, we can determine the number of ticks it takes to move one square in an orthogonal direction (North/East/South/West):
To find the diagonal movement speed across squares (North-East, South-East, South-West, North-West), we use the Euclidean distance formula to find the diagonal length of the square:
Then we can find the number of ticks it takes to move across 1 square diagonally:
Simplifying for Stability
Since our game engine ticks every 0.1 seconds, it won't resolve movement gracefully if there are floating points in our tick math. A common best practice is to round these to whole numbers and accept a slight amount of error. For our simulation we'll set the following rules:
This makes orthogonal movement a tiny bit slower and diagonal movement a tiny bit faster, but overall makes for a much more stable state for entity position.
Implementing Movement
Every engine tick of 0.1s we'll increment a counter and only when we've reached the number of ticks per square (3 for orthogonal, 5 for diagonal) will we actually move the entity to the next square in the path. This ensures that an entity is always occupying only a single grid space, not overlapping.
Pathing
Under the hood, we'll be using a pathfinding method known as A* (A-star) pathing in order to determine the shortest path between starting and destination coordinates, taking into consideration obstacles an entity must navigate around. See easystarjs.com for more information.
Details and Pathing Logic / Gambits TBD. The javascript library is also not decided — easystarjs was the first one I came across, but there are others with pros and cons.