Page MenuHomeWildfire Games

Fixing a problem where the AI attacked bridges
ClosedPublic

Authored by Langbart on Oct 9 2021, 12:15 PM.

Details

Summary

The AI has attacked bridges, as reported in the referenced ticket and in the forum, see A26 Petra Bot is attacking Gaias Bridge in Via Augusta - 18/Jun/21.
Fixing the problem by following a suggestion from @Stan:

I think there is a template for that stone bridge while we should just use the actor.

Related IRC 0ad-dev conversation (9/Oct/21)

07:17 < Langbart> @tell Stan would I need to go in every map file and fix it one by one?
09:25 <@Stan> Langbart: You could grep/sed but yeah will have to be done in every map

Test Plan

Check a few random maps to see if everything works as before.

There is also a replay in the referenced ticket where the problem was observed. If you apply this patch and play the replay, the AI should no longer attack bridges and the entity state should look like in the 2nd image below.

If you run the following command in the console to check the state of the bridge

Engine.GuiInterfaceCall("GetEntityState", <entityID>);

it looked like this:


and now it should look like this:

Event Timeline

Langbart created this revision.Oct 9 2021, 12:15 PM
Owners added a subscriber: Restricted Owners Package.Oct 9 2021, 12:15 PM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/5048/display/redirect

Langbart edited the summary of this revision. (Show Details)Oct 9 2021, 12:23 PM
Langbart added a comment.EditedOct 9 2021, 6:27 PM

elexis joined in:

[...] if you just replace all bridge entities with bridge actors in all maps then it means the next one making a map or placing a bridge will reintroduce the same issue and no one will notice it for years. So a fix that would prevent that case is one that also removes health and resistance from the template OR make it so that the bridge is actually destroyed.

ok, i will try to remove the health from the template

that raises the question why there is health in there to begin with

  • The bridge_hele (20/Feb/11) was added with rP8954 and already included the Health tag.
  • The bridge_wooden (13/Jul/11) was added with rP9812 and also included the Health tag.

If I remove the Health tag from the file I get:

0 A.D. (0.0.26) Main log (warnings and errors only)
ERROR: RelaxNGValidator: Validation error: structures/bridge_hele:1: Expecting an element Max, got nothing

ERROR: RelaxNGValidator: Validation error: structures/bridge_hele:1: Invalid sequence in interleave

ERROR: RelaxNGValidator: Validation error: structures/bridge_hele:1: Element Health failed to validate content

ERROR: RelaxNGValidator: Validation failed for '(null)'

ERROR: Failed to validate entity template 'structures/bridge_hele'

ERROR: Failed to load entity template 'structures/bridge_hele'

ERROR: Failed to load entity template 'structures/bridge_hele'

Engine exited successfully on 2021-10-09 at 18:32:02 with 1124 message(s), 7 error(s) and 0 warning(s).
Langbart updated this revision to Diff 18786.EditedOct 9 2021, 7:14 PM

Deleting the bridge_hele.xml and bridge_wooden.xml files so that this entity can no longer be placed in the Atlas editor. This prevents the same problem from occurring again in the future. The actor file is still present and can be used.

Owners added a subscriber: Restricted Owners Package.Oct 9 2021, 7:14 PM
Vulcan added a comment.Oct 9 2021, 7:15 PM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/5054/display/redirect

bb published this revision for review.Oct 9 2021, 10:42 PM
bb added a subscriber: bb.

The question in need of answering here is: do bridges need to be entities or are actors enough?

If we just want the AI to stop attacking them, I suppose we could also remove the health component and be fine. This patch also removes the obstruction from bridges i.e., stuff can now be build on top of the bridge. Personally, I quite like the fact one can build outposts and stuff on bridges (large buildings won't fit anyhow).

Greps complete, reads correct, front doesn't fall.

bb accepted this revision.Oct 9 2021, 10:42 PM
This revision is now accepted and ready to land.Oct 9 2021, 10:42 PM
In D4297#183000, @bb wrote:

If we just want the AI to stop attacking them, I suppose we could also remove the health component and be fine.

If I remove the Health tag it throws errors at me, is there another way?

In D4297#183000, @bb wrote:

This patch also removes the obstruction from bridges i.e., stuff can now be build on top of the bridge. Personally, I quite like the fact one can build outposts and stuff on bridges (large buildings won't fit anyhow).

Yes, in the picture below the outpost can be built closer to the bridge, I tried to place it as near as possible in both cases.

Freagarach accepted this revision.Oct 10 2021, 8:08 AM
Freagarach added a subscriber: Freagarach.

The reason the bridge had health is because we couldn't have healthless entities earlier (refs. D341, D1268).

Removing the health can be done by disabling <Health disable=""/> and preventing to attack can be done by merely removing the resistance <Resistance disable=""/>. I don't care too much whether we use actors or actual entities, for I guess if we want bridges to be more interactable we also want that on a per map basis and with more changes to the template.
Instead of removing the templates, one could create a template_bridge with no health/resistance and let the two used templates inherit from that. But since the templates are wonky and don't add anything, deletion seems like the correct choice.

I didn't test.

Instead of removing the templates, one could create a template_bridge with no health/resistance and let the two used templates inherit from that. But since the templates are wonky and don't add anything, deletion seems like the correct choice.

This method also works, I just copied and renamed the template_structure.xml file into template_bridge.xml and replaced the Health & Resistance part with <Health disable=""/> & <Resistance replace=""/>. Additionaly adjusting the bridge_hele.xml & bridge_wooden.xml file. It worked see diff 18790.

@Stan how do you want it to be?

Silier added a subscriber: Silier.Oct 17 2021, 12:38 PM

They cannot be repaired, damaged, constructed, do not provide any resource or aura. There is curently no value letiting player to select the bridges. It can even make selecting/commanding units near these entities a bit complicated, so i would just keep it as is in this diff with only actors and not entities.

@Freagarach do you plan to commit this as it is right now?

Yes, as soon as I find the time. (But feel free, @bb or @Angen to do so.)

This revision was landed with ongoing or failed builds.Oct 26 2021, 6:37 PM
This revision was automatically updated to reflect the committed changes.