So what would be desirable is a Sub-AI that works exactly like a condition.
How to implement this so it feels like current AI programming in the game?
Simple: You can choose between either creating a (Sub)AI (as it is right now) or a new SubCondition.
- A SubCondition can not be selected as script to run for a bot.
- A SubCondition can not contain any action nodes except tagging.
- While when creating a normal AI, you get an empty file with just a root node, you actually get 2 nodes when creating a SubCondition.
- The root node, as normal, and a single freely movable RETURN node. The RETURN node is treated like an an action, thus you can link to it, but not from it.
Now when a SubCondition is encountered inside a script, the evaluation on it is launched like if it would be a normal SubAI. The moment the RETURN node is encountered you return from the SubCondition and consider the SubAI true and the evaluation continues to whatever is linked behind it. If the SubCondition evaluation is finished and the RETURN node is not reached the SubCondition is considered false.
Bonus candy points if it is possible to Invert a SubCondition like it can be done with normal conditions.
So all that is required is effectively one new node, which is preset in this new kind of SubCondition. Reach it -> true, Don't reach it -> false.
That would be a very simple system and not change the character of the game or its coding in any way. It would also not add any new possibilities to the game... all that can be done right now too, you just have to copy paste the conditions to every place massively cluttering the code.
And I even prepared a wonderful visual demo:
One of our Bots using it:
So the SubCondition is passed if the closest enemy is a shotgun moving to a res and we also see a res that someone moves to. If that's not the case, RETURN is never reached thus the SC is false.
If it was just one bot using it in one place, we wouldn't gain anything here. (except way more readable code... a benefit in it self)
But if we now had another bot, who would also want to act on the sneaky thief... But a different reaction, e.g. try to snatch the Res himself, shoot at any range or run to the closest enemy base, whatever you want... We could reuse it.
And if we later decide that this condition needs some changes, because, e.g., we want to also include Assaults as sneaky thieves, we only have to change one node. Instead of every occurrence scattered everywhere. And this is obviously a very simple example.
E.g. a SubCondition could als compare who has more Res in his half... Thats a decent number of nodes, potentially all bots could use it but react differently... Having to paste it everywhere is a massive annoyance.