Hey frens I wonder if someone could take a look at some.. interesting hacks and workarounds I had to do in order to get AI Commanding working in Overthrow (essentially recruiting civilian AI off the street into the player's group)
Maybe I'm missing something or have done it all completely wrong but here are the highlights:
It seems that even if I use SCR_PlayerFactionAffiliationComponent.RequestFaction in order to put the player in the CIV faction the client never updates the Player <-> Faction mapping in the faction manager (m_MappedPlayerFactionInfo), which is what the entire AI commanding UI relies on to even display, otherwise ~ just fails silently due to the player not being in the same faction as the AI. So I had to add an RPC call to the faction manager to force this to occur.
I then go about creating a playable group for the player automatically, making them leader, respawning any AI recruits they have saved in EPF and adding them to the group (also enabling their AI of course). This whole process, however, seems rife with race conditions unless I'm just doing it wrong.
its basically the majority of this file: https://github.com/ArmaOverthrow/Overthrow.Arma4/blob/v1.3.0/Scripts/Game/GameMode/Managers/OVT_RespawnSystemComponent.c
You can see me using CallLater a bunch of times in order to make sure the changes I'm doing are replicating to the client before doing the next thing. If I dont do this, I find that the AI just won't respond to commands. They are in the same group, the same faction, the player is leader, and the commands are definitely executed but they just stand there. Even adding brand new recruits to the group can be in this state.
As it stands now, with the code you can see on github in the v1.3.0 branch it works.. 98% of the time. I could maybe get it to 100% or close to that if I extend the delay times out even further, but I thought I'd get in touch to see if there are better options.
Thanking you kindly in advance for any guidance you can provide