FactionsAttitude Solver
Last modified: 15 September 2024Attitude Solvers are used to determine the Attitude between an AI Agent and a given target.
The Faction System does not expose these directly to designers. Instead, these objects are used internally by the Faction Subsystem to determine the attitude between factions.
Available Solvers
There are two Attitude Solvers provided by the Faction System. Faction Solvers can be set in the Faction Settings page.
Solver | Description |
---|---|
Simple Attitude Check | Determines attitude based on the Main Faction configuration for both actors. |
Target Reputation | Determines attitude based on the Reputation between the source's Main Faction and the target's tier. |
Creating Solvers
Projects can use create their own Attitude Solver by extending NinjaFactionAttitudeSolver
. This can be done in Blueprints or C++.
In this example, a "Chaotic Solver" will be created, where the attitude is always random.
#pragma once
#include "CoreMinimal.h"
#include "NinjaFactionAttitudeSolver.h"
#include "FactionSolver_ChaoticSolver.generated.h"
UCLASS(DisplayName = "Faction Database: Chaotic Solver")
class PLUGINLABS_API UFactionSolver_ChaoticSolver : public UNinjaFactionAttitudeSolver
{
GENERATED_BODY()
public:
// -- Begin Faction Attitude Solver implementation
virtual ETeamAttitude::Type SolveAttitude_Implementation(const AActor* Source, const AActor* Target) const override;
// -- End Faction Attitude Solver implementation
};
#include "FactionSolver_ChaoticSolver.h"
ETeamAttitude::Type UFactionSolver_ChaoticSolver::SolveAttitude_Implementation(const AActor* Source, const AActor* Target) const
{
// Yikes! o.O
return FMath::RandBool() ? ETeamAttitude::Friendly : ETeamAttitude::Hostile;
}