UnofficialCrusaderPatch / UnofficialCrusaderPatch2

Unofficial balancing patch installer for Stronghold Crusader 1
MIT License
430 stars 59 forks source link

Changing the form of building and moving the enemy army #920

Open Russianstory opened 3 years ago

Russianstory commented 3 years ago

Is it possible to do? So that the enemy soldiers go at the player not in a long line, but in a crowd in the shape of a square (diamond). And yet they gathered at the gathering point of the army not near the player and his towers, but a little further away so that the player could not get the AI soldiers. image

Monsterfisch commented 3 years ago

that would require rewriting the pathfinding for the game which is on par with increasing the map size which also is based on the pathfinding so no it's not possible any time soon

gynt commented 3 years ago

Although I have never tested it, but the mechanical reason for this big line being formed is two things:

  1. The crowd of units form a line probably to make the path finding algorithm simpler. They probably designed it this way to make computation easier.
  2. Units move a tiny bit slower if the unit shares the tile he is standing on with more units. This causes the line of units to become longer.

We can fix number 2, but number 1 is way more difficult. I am afraid knowledge is currently limited to do that.

GRhin commented 3 years ago

Actually I am fairly certain the mechanics of the line is due to the gatehouse or turning corners. As from the gatehouse exit tile the calculated path is the same for every unit. If they started outside the castle, and there were no obstacles to go around, I believe there would not be a line. The main solution I can think of is to make AIs move in stages, for example from inside castle to outside, then to middle of map, then to seige rally point, waiting for everyone to arrive before starting the next stage, but this is very easy to abuse.

On Mon, 16 Aug 2021, 17:43 gynt, @.***> wrote:

Although I have never tested it, but the mechanical reason for this big line being formed is two things:

  1. The crowd of units form a line probably to make the path finding algorithm simpler. They probably designed it this way to make computation easier.
  2. Units move a tiny bit slower if the unit shares the tile he is standing on with more units. This causes the line of units to become longer.

We can fix number 2, but number 1 is way more difficult. I am afraid knowledge is currently limited to do that.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/UnofficialCrusaderPatch/UnofficialCrusaderPatch/issues/920#issuecomment-899295791, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALGGWTXUU77XEHMCDQK3QDLT5C6TBANCNFSM5CE3GZRQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

gynt commented 3 years ago

Ah yes of course, the gate house is the ultimate cause for the line forming in the first place. I wrote an elaborate answer first, and then removed a lot of it.

But what I meant is that there is no continuous path finding going on, like, after exiting the gatehouse, the units do not try to find a better way. Even if their route is a tiny bit sub optimal (and more sub optimal because of the slowdown). They only stick to the line when leaving the castle and moving horizontally or vertically (example-1), but not when moving diagonally (example-2). So, when exiting the gatehouse to take a diagonal path, they immediately spread out. (I am referring to the map editor files from the zip file for a visual illustration).

The opposite is true when entering a castle through a gatehouse, or moving through any narrow point I believe (a gap in the wall, a gap between rocks), they form a line when moving diagonally to the gatehouse, but walk spread out when moving horizontally/vertically to a gatehouse (until the very last moment).

I guess this is caused by a preference to only create paths that have one diagonal line, and one vertical/horizontal line or something.

What I am trying to explain is, that, indeed your suggestions would improve the situation greatly. But the caveat will be that when the AI moves their armies horizontally/vertically towards your castle opening, they will happily form a line again :)

units-pathfinding-ex-1-2-3.zip

LeSpec commented 3 years ago

Example 3: seems like every 5th unit is walking vertical first instead of diagonal, i wonder why.