EQS query never finishes above certain number of AI

Hi all,

I have a really strange problem which I cannot figure out at all.

I have created an EQS query which projects a cone of test locations from an enemy position towards the AI, and then runs a series of tests. The aim is to choose a good position to deploy a company of soldiers so they can pour fire down from a strategic location.

I am running this EQS query inside a service, which I am running like so:

When I run 6 AI, this works just fine. The EQS completes and the AI forms up nicely. However if I run a test with 8 AI, suddenly the EQS query never completes. It runs forever. I tested this by adding a print screen message saying “Start Query” right after the Run EQS Query node, and a “Finish Query” right at the start of the “Company Position Finished” node. I just see “Start Query” being spammed by each AI and never see “Finish Query” appear.

Here are the performance metrics for my EQS queries (the problem query is highlighted):

I am so confused, because this was all working fine before. I haven’t made any changes to that service or even to the EQS query. The only reason I realised there is a problem is that my AI suddenly stopped taking up positions and just kind of milled about in the centre of the map. I had been testing with 8 AI successfully for weeks before hand.

Things I have tried initially:

  • Reducing all the complexity of “FindOpenCompanyPosition” by cutting the number of points tested down to 1/4 of what they were, and adding a single test to score them by distance to the querier, removing all the other tests I was doing
  • Deleted by binaries, intermediate and saved folders and rebuilding the game module from scratch (re-enabling EQS after!)
  • Swapping the EQS query for a different one
  • Deleting the OnQueryFinished bind and re-appying it to a new custom event

No matter what I try, the problem persists: the EQS query will not complete unless there are no more than 6 AI in the map.

I am on 4.24. Any help much appreciated!

Ok I figured out my problem.

The answer was in the profiling screenshot. The query “DetermineBestEnemyLineMelee” was insanely expensive, and being run very frequently, and I have to assume that this was blocking the other queries from completing within a reasonable timeframe.

This EQS query is used to determine which enemy is the most appropriate target to engage in melee (not necessarily the closest!). It generates a list of characters, and then was running some tests, including a pathfinding query to ensure the AI doesn’t try to charge an opponent that is unreachable. The pathfinding test was INSANELY expensive, being more expensive by itself than the ENTIRE EQS query to find a good place to deploy its soldiers. I have no idea why this was, but removing it resolved the problem.

Does anyone know how this test works? Is it just using synchronous, non-hierarchical queries? If so then that would explain why it’s so expensive…