Skip to content

Faction Sources

Faction Sources are a simple abstraction in the framework. They are defined by an interface, to be implemented by any Object type, including but not limited to Actors and Pawns.

In the context of single player or more lenient co-op games, the Faction Source is more of an utilitary interface to help you integrate other parts of your code with the Faction System, without these other parts having to know anything about the Faction Domain.

The Faction System does not care if the reputation comes from an Enemy, a Quest or an Item. It only cares that it comes from a FactionSourceInterface that is able to provide reputation rewards to the FactionMemberComponent.

However, in the context of more strict online games, this interface also validates any RPCs made to the server, ensuring that Faction Membership or Reputation Gains are indeed valid.

Faction Source Actor reference

The project provides a reference implementation of the FactionSourceInterface. It's an Actor that implements the interface's methods in a simple yet useful way. It's meant to do two things:

  1. Only allow events represented by the framework, via the FactionEventType enumeration and only allow Reputation gains up to the amount of reputation supported by the actor.

  2. Always provide the set amount of Reputation Worth to the requester's Main Faction.

Even though you are absolutely free to use this actor as a base for your sources, it's mostly meant to function as an implementation reference so you can replicate similar behaviors in your own actors, pawns and characters.

Things to Keep in Mind

There are some important implementation details to keep in mind, while creating your own Faction Sources.

First, they can be virtually anything. The Faction Source is only used by the Faction Member Component and it expects any Object to be a valid implementation. This means that your Faction Source could be any class in the Object hierarchy.

Second, you will notice that there's an uint8 reference to an Event Type. This is an open way to allow you to only allow certain events to be supported by certain Sources. This is mostly meant to be used from a validation perspective, if you are working on online games that must ensure that Server RPCs are valid. Some examples of this in the next topic.

The Faction System provides an Enumeration that may help you track common expected events. You can choose to create your own Enumeration (or any other uint8-based solution) or use the provided FactionEventType, with its thorough collection os values.

As usual, Faction Sources can be implemented in Blueprints or C++, since it's only defined by the blueprintable FactionSourceInterface.

Examples of Faction Sources

The following table provides some examples of Faction Sources to help you further consolidate the concept.

Source Description Notes
Enemy Character Grants Reputation when killed by players. Provides itself as source in the death event, with the SourceKilled event.
Quest Giver Grants Reputation once a quest is completed. Provides itself as source when quest is completed, with the SourceHelped event.
Item Pickup Grants Reputation when picked up. Provides itself as source when gathered, with the SourceCollected event.
Zone Grants a new Faction when players enter it. Provides itself as source on collision, with the ZoneEntered event.
Intial Faction Granted by the member who's also a source. Provides itself as source on begin play, with the Default event.