Where to begin with having NPCs behave friendly or aggresively when seeing other NPCs belonging to a different faction?
Two wizards from opposing magic guilds, if these NPCs see each other they should fight. If they are the same or have a certain reputation with, then they will greet each other and pass friendly -y.
Hi, if you used some C++ or want to do so (and especially if you also use the AI perception system since you can then use friendly, neutral and hostile there as well) then I suggest you make use of the build in team system (you will need some C++ to set this up though). Otherwise you can implement your own system from scratch in BP.
Hi thanks for responding. Yeah I was looking for a way to do it in Blueprints but all signs point to at least some c++.
Time for a new avenue on the road of game development it seems!
In the end there are two important things there. One is for the system to retrieve the team id (FGenericTeamId which in the end is just a uint8, so you can have up to 255 teams) from an actor and the other is to take two team ids as input and return an affiliation between them (friendly, neutral or hostile).
In order to retrieve the team id the actor needs to implement the IGenericTeamAgentInterface (which you need to do in C++). So your NPCs should implement this. AI controller has it implemented by default (so you don’t need to implement it in your own AI controller, you can just use SetGenericTeamId to change it). The NPC and its AI controller should have the same team id.
Now if the system checks the affiliation between two actors, it will first check whether both of them implement the IGenericTeamAgentInterface (which for AI perception the perceived actor, which will be e. g. your NPC, will not by default) and if one of them does not implement it, it will return neutral as affiliation (therefore by default everything in AI perception is perceived as neutral). Now if both actors do implement the IGenericTeamAgentInterface it will use it to grab the FGenericTeamId from them and put those two team ids into the attitude solver function. By default this function will return friendly if both team ids are the same and hostile otherwise.
And you can use the FGenericTeamId::SetAttitudeSolver function to use your own attitude solver function. You may want to use your own attitude solver function, since you may want to have things differently than only those belonging to the same guild are friendly and everyone else is hostile.
And it also would make sense to have some blueprint callable function that takes in two actors and returns an affiliation between them (so that you can also use that in blueprint).