Topic: Attacking soldiers
xorx![]() Topic Opener |
Posted at:
2021-01-01, 23:44 UTC+1.0
Hi, I've a question about attacking soldiers. Once you chose a military building to attack, a pop-up windows appears where you can chose the soldiers you want to use on that attack (very nice feature, by the way). But many times this pop-up lets me wondering from which military building these soldiers will come from. Is there a smart way to guess that? Is the given list sorted in some way (closest first) or is it completely randomized? Thanks! ![]() ![]() |
Nordfriese![]() |
Posted at:
2021-01-02, 11:37 UTC+1.0
This was partly discussed in the merge request (https://code.launchpad.net/~widelands-dev/widelands/choose-attack-soldiers/+merge/367041):
Soldiers from the same building will be shown directly after each other, but there is no way to tell which building which soldier corresponds to, not is this possible without messing up the UI as stated above I think that the soldiers are searched for by making a hexagonal "circle" with the (fixed) maximum attack radius around the enemy milsite, then iterating every row of the circle left-to-right, all rows being iterated top-to-bottom, and appending the soldiers of every own milsite found in the same order as in the milsite's window to the back of the list of soldiers. Not 100% sure about this though. ![]() ![]() |
xorx![]() Topic Opener |
Posted at:
2021-01-02, 14:37 UTC+1.0
Hi Nordfriese, thanks for the information. Does that mean that if I have a scenario like the following:
where x, y, z and k are military building I own and e is an enemy military building, I will get the soldiers from x, then y, then z and finally k? ![]() ![]() |
Nordfriese![]() |
Posted at:
2021-01-02, 15:32 UTC+1.0
I had another look at the code and actually it's more complicated than I thought because the code also ensures at the same time that the soldiers can actually reach the target building. The algorithm works like this:
(code: So the exact order is not entirely intuitive (basically from the center outwards in clockwise circles); but if there are obstacles or non-walkable ground it can get almost impossible to predict without following the algorithm with pen and paper… ![]() ![]() |