Faction integration (PulseAIFactionBridge)

The bridge PulseAIFactionBridge lets agents tell friend from foe by the factions of Pulse Faction: a guard attacks a player whose reputation with the guards fell to Hostile and leaves a player alone who is their ally; guards and bandits fight each other because their factions are enemies. Enable it next to PulseAI and PulseFaction. Everything runs on the server.

Setup

  1. Attitude solver Factions: Project Settings > Pulse > AI > Attitude Solver. The Pulse window does it for you (Workflow tab of AI or Faction, step “Use the attitude solver Factions”); the solver you had stays as its fallback.
  2. Give agents their factions: the profile extension Factions (below), or a Pulse Faction component on the pawn with Start Factions.
  3. Players need a reputation: the Pulse Faction component on the player state (setup step of Pulse Faction).

Attitude solver Factions

Who Attitude
An agent of a faction to a player The player’s rank with the agent’s factions (the worst of them); a player without faction component counts with the base reputation
An agent of a faction to an agent or NPC of a faction The relation of their factions (the worst pair)
Everything else (the agent or the other NPC belongs to no faction) The Fallback solver: Teams by default, Combat Teams of PulseAICombatBridge if you had it; empty: Neutral

Memberships of players do not count, only their reputation (the rule of Pulse Faction).

Alarms reach only friendly agents (UPulseAISubsystem::RaiseAlarm asks the solver): with Factions the agents of the same and of allied factions; a bandit that spots you does not alarm the guards.

When an attitude changes while the game runs, agents see it at once: the bridge listens to the faction messages (Pulse.Message.Faction.RankChanged, .Joined, .Left, .RelationChanged) and calls UPulseAISubsystem::RefreshAttitudes. Agents forget a player who became friendly and notice one who became hostile while in view.

Factions from the profile

The profile extension Factions makes the agent join Factions when it starts; its pawn gets a Pulse Faction component when it has none. The factions stay when the agent stops. With bLeaveOtherFactions the agent also leaves every other faction, for profiles that change sides (a bribed guard whose new profile is a bandit). Factions that are not known (Project Settings > Pulse > Faction or a Pulse Faction Level Settings actor) are logged.

StateTree conditions

Category Pulse AI Faction, for StateTrees with the Pulse AI schema.
Condition Passes when
Faction Attitude The agent stands to TargetActor (empty: the current target) by factions as Attitude, compared with Compare (Is, At Least, At Most; ordered Hostile, Neutral, Friendly). False without a target.
Faction Rank The rank of Player (empty: the current target) with Faction (empty: the agent’s first faction) compared with Rank (0 = the lowest rank of the faction). False without player or ranks.

A merchant that only trades with friends, for example: a state “Trade” entered with Faction Attitude At Least Friendly, a state “Refuse” otherwise.

Debugging

PulseAIFactionInfo (cheat, server) prints every agent with factions: its factions, how it stands to you by factions and by the attitude solver, and its target. With the cheats of Pulse Faction (PulseFactionReputation Guards -100, PulseFactionRelation Guards Bandits friendly) you change attitudes while you watch. PulseAIFactionJoin <faction> [radius] lets every agent near you join a faction (a Pulse Faction component is added where needed).

Guards at a capture point

A capture point of Pulse Faction Territory (the heart of an island) counts the guards of a faction while players are there: pawns of no player, possessed, alive, with a Pulse Faction component of their own. Give the guard profile the extension Factions (for the guards of Combat integration: a copy of DA_PulseAIProfile_CombatGuard with the extension; the guard example keeps extensions it does not make when it is built again), set the start owner of the territory to that faction, and use the attitude solver Factions with a base reputation that makes players hostile to the guards. In a test, PulseAICombatSpawnGuards and then PulseAIFactionJoin Guards put guards of the faction Guards at a point.


This site uses Just the Docs, a documentation theme for Jekyll.