Faction API

Set Faction Level

Changes the relation of the given faction. Note: The faction must be available in the AI's faction list.

EmeraldAPI.Faction.SetFactionLevel(EmeraldSystem EmeraldComponent, string Faction, RelationTypes RelationType)
//Example - It is recomended that EmeraldComponent is cached somewhere
EmeraldSystem EmeraldComponent = GetComponent<EmeraldSystem>();
EmeraldAPI.Faction.SetFactionLevel(EmeraldComponent, "Undead", RelationTypes.Enemy);

Add Faction Relation

Adds the Faction and Faction Relation to the AI's Faction Relations List. Note: The faction must exist within the Emerald Faction Manager's Faction List.

EmeraldAPI.Faction.AddFactionRelation(EmeraldSystem EmeraldComponent, string Faction, RelationTypes RelationType)
//Example - It is recomended that EmeraldComponent is cached somewhere
EmeraldSystem EmeraldComponent = GetComponent<EmeraldSystem>();
EmeraldAPI.Faction.AddFactionRelation(EmeraldComponent, "Undead", RelationTypes.Enemy);

Get Target Faction Relation

Gets the relation of the passed target and this AI in the form of a string (Enemy, Neutral, or Friendly). If a faction cannot be found, or if it is not a valid target, you will receive a value of Invalid Target.

EmeraldAPI.Faction.GetTargetFactionRelation(EmeraldSystem EmeraldComponent, Transform Target)
//Example - It is recomended that EmeraldComponent is cached somewhere
EmeraldSystem EmeraldComponent = GetComponent<EmeraldSystem>();
EmeraldAPI.Faction.GetTargetFactionRelation(EmeraldComponent, YourTargetTransform);

Get Target Faction Name

Gets the faction name of the passed AI target. The AI's own transform can also be passed to get its own faction name.

EmeraldAPI.Faction.GetTargetFactionName(Transform Target)
//Example
EmeraldAPI.Faction.GetTargetFactionName(YourTargetTransform);

Change Faction

Changes the AI's faction (Note: The FactionName must exists within the Faction Manager's Current Faction list).

EmeraldAPI.Faction.ChangeFaction(EmeraldSystem EmeraldComponent, string FactionName)
//Example - It is recomended that EmeraldComponent is cached somewhere
EmeraldSystem EmeraldComponent = GetComponent<EmeraldSystem>();
EmeraldAPI.Faction.ChangeFaction(EmeraldComponent, "Undead");

Copy Faction Data

Copies all faction data from the FactionDataToCopy and applies it to the EmeraldComponent. This is the AI Faction Relations List (within the Faction Settings foldout of the Detection Component).

Note: The AI's EmeraldComponent is the one who will receive the FactionDataToCopy AI's faction data.

EmeraldAPI.Faction.CopyFactionData(EmeraldSystem EmeraldComponent, EmeraldSystem FactionDataToCopy)
//Example - It is recomended that EmeraldComponent is cached somewhere
EmeraldSystem EmeraldComponent = GetComponent<EmeraldSystem>();
EmeraldAPI.Faction.CopyFactionData(EmeraldComponent, TheEmeraldComponentToCopy);

Last updated