Jump to content

UnitAI - Formation Controller Improvements


Recommended Posts

Hi,

we explored the task "Units stop the attack after changing formation" and therefore jumped into the UnitAI.

The issue is that when doing an attack with a group of soldiers in some formation and changing the formation while they approach the target, the group will stop attacking and just take the new formation.

Responsable for the bug are the not yet implemented parts in the formation cotnroller (orders "atack" , "heal", "gather", "gatherNearPosition", "retournResource" and "garrison") marked with TODOs. What is missing is always the approaching part. Adding this fixes the issue. Anyway, we have to make shure that the current order is finished (e.g. "atack": kill unit, then process next order), so we thought of adding a new state for this in the formation controller (e.g. "attacking"), where we then can finish the order if the target was killed.

Hence, we would end up with 6 more states. Do you think it's possible to abstract from these 6 states to decrease complexity?

Before implementing stuff we wanted to make shure that this approach is reasonable to the developers of this project that have contributed to it for a longer time.

Yannick & Simon

Link to comment
Share on other sites

Argh. (because I added a patch for review by another dev for most of those TODOs today)

See ticket #1716 for the patch and some thoughts.

Formations are pretty much in need of a nearly complete overhaul, as units should go into a column formation automatically when moving and formations like testudo or phalanx should have some bonuses. In the new formation system units shouldn't execute tasks on their own if they are in a formation (like the Total War games).

#1624 could still be fixed now, if I haven't discouraged you. I believe the best starting place for this ticket would be helpers/Commands.js in the "formation" case. Adding a statement (to continue the execution of the order prior to changing the formation) after

cmpFormation.MoveMembersIntoFormation(true);

seems reasonable.

If you want to do something else you could give #997 a try (just using domestic animals as a start).

Also if you have got any questions join #0ad-dev on QuakeNet.

Link to comment
Share on other sites

We had a look at your patch and actually this is exactly how we would have done it and how we suggested to do it. This patch fixes the issue we described.

However, unfortunately when testing the patch, we discovered that there are still issues when changing the formation more often during an attack. After changing it two or three times the units are just standing still and won't attack on their own anymore (usual aggressive behavior). They are not even defending their selves when being attacked.

We had a detailed look at your changes and the UnitAI, but could not figure out why this happens. Maybe you have an idea?!

Link to comment
Share on other sites

As I said above the formation change order isn't covered by that patch. I assume the best place to start fixing this is still Commands.js (see above).

I assume (and I'm pretty sure that assumption is true as I don't believe that anyone has changed that code a lot since I last fixed at smaller problem with that a while back) that the issue with changing the formation is that the units get stuck in the MoveIntoFormation state (the actual name may differ) and they don't leave that state.

You can check the current UnitAI state of a unit with the "Display selection state" option in the developer overlay ingame (Alt-D)

Link to comment
Share on other sites

As I said above the formation change order isn't covered by that patch. I assume the best place to start fixing this is still Commands.js (see above).

ok sorry. checked it and it looks you are right. when the units are in the INDIVIDUAL.COMBAT.ATTACKING state and then get a command to move into formation they never leave this state again.

we will try to fix this small issue. thanks for your help so far.

Link to comment
Share on other sites

Finally, we fixed the bug we initially wanted to fix (#1624). Based on your patch (leper) we introduced a new function in UnitAI to move into formation. Also we added a new order "MoveIntoFormationOrder"to the formation controller to apply a new formation. We did this for conceptual reasons, as changing the formation is now also treated as an order. We think that this is more consistent. We adapted the function MoveIntoFormation in Formation, which actually applies the formation, so it's possible now to get in formation without replacing all individual orders of the formation units. This is the actual fix for the bug #1624.

We now would like to submit the patch as an update to leper's patch attaching it to #1716.

Unfortunately we can not do so, since registering for the Trac was not yet successful, because we never get a confirmation email to verify our account (tried two different mail addresses).

Link to comment
Share on other sites

Ah I thought it could have been bad luck with trying to register while trac ate the credential file. (Nice to know though)

It might have been one of the time, but GMX really doesn't like them, so we might even want to add that to the register page so people are aware of it before registering.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...