aI made a mod that implements my proposals on formations. I think the improvement is stark, here's a preview:
Some detail:
Assignment of units to formation places
This is already very similar to the current algorithm, the only difference is point 3.2. I tried hard to introduce it, but, for simple that it sounds, I can't seem to make it work. Sorting the array doesn't seem to have any effect, I noticed it's always the same units that take the farther positions, those left out by the others. I'm attaching the js file with attemted edits.
Also point 2 has seen an improvememt, similar to the one dealt in the next section.
Rotation movement
This had the greatest impact, in particular the second point. Makes formations a lot more usable I think. First point is dealt as in my last post of June 30.
Column formation
This was easiest. Not much to add about it.
Further considerations and questions
- I did quite some code refactoring, as much as I thought it would be acceptable. External use of some function may break, although it seems unlikely to me.
- I'm not sure I respected coding conventions either.
- Formations now don't get formed anymore in the mean direction of their members.
- Browsing Formation.js history, I was startled noticing that actually my proposals are nothing new and already where in the engine some time ago (rP14292, rP14300). I'm not sure what to do with this information.
- How is LoadFormation supposed to be used?
- The only way to make formation turns more natural than this, is to change how entities turn around obstacles, so that they do not do it on position, but rather sliding around the corner as they turn. The improvement would be evident for formations, but would also be noticeable for rams and cavalry. I'm not sure where's the code for that.
- I can keep making improvements if you like, my goal is to make formations good looking, and also reasonable even for competitive games, and I'd like my edits to go in the main game. (edit/clarification/license: I renounce to all rights on my work on the mod and agree to the legal disclaimer)
Formation formation-mod-proposal.pyromod