[HOWTO] How To: Get Faction Members That Dislike Player
Posted: Tue Oct 03, 2023 11:39 am
The code below gets a list of all FactionMembers whose affinity to the player is negative. It assumes the player's faction is named "Player".
Code: Select all
var enemies = new List<FactionMember>();
foreach (var kvp in FactionManager.instance.members)
{
var faction = kvp.Key;
var members = kvp.Value;
if (FactionManager.instance.GetAffinity(faction.name, "Player") < 0)
{
enemies.AddRange(members);
}
}