Skip to main content

FB2AggroManager

Overview

  • Aggro system. A single Source can hold multiple Target aggro entries simultaneously (multi-target). Summary: AddAggro finds (or creates) the (Source, Target) entry and accumulates the Reason bucket; among a Source's entries, the one with the largest total each tick is picked as the chase target; per-entry OffsetDistance / arrival fire / one-shot (bArrivalFired) guard; the Source's autonomy toggle is blocked only while a Chase-active entry exists (one flag, restored on end).

Metadata

FieldValue
Kindsystem
EnvironmentB2 - Simulation
Categorysystems
ExtendsFB2ManagerBase
Requirerequire('Systems.B2AggroManager')

Properties (1)

NameTypeDescription
ActiveAggrostable<FB1EntityId, FB2AggroSourceState>

Functions (18)

FunctionParametersReturnsDescription
AddAggroInSourceEntityId: FB1EntityId, InTargetEntityId: FB1EntityId, InAggroValue: integer, InAggroReason: stringbooleanExternal call interface. Takes (SourceId, TargetId, Value, Reason).
DecreaseAggroByReasonInSourceEntityId: FB1EntityId, InAggroReason: string, InValue: integer-Iterates all of the Source's entries and decreases matching Reason buckets by InValue. Called by external systems such as scripts (e.g. reduce anger-reason aggro on emotion release). Buckets that drop to <=0 are auto-removed; the Source itself is cleaned up when all entries are empty.
DecreaseAggroByTargetReasonInSourceEntityId: FB1EntityId, InTargetEntityId: FB1EntityId, InAggroReason: string, InValue: integer-Decreases the matching Reason bucket by InValue, limited to the Source-Target entry (narrowest scope). Buckets at <=0 are auto-removed; empty entries and then the Source are cleaned up.
GetEntriesInSourceEntityId: FB1EntityIdFB2AggroEntry[]Returns all of the Source's entries (for debugging/statistics).
GetSetting-UB1AggroDataAssetCommon chase settings. Fetched via DA_GET on every call (not cached, to allow DA hot-reload).
GetTopEntryInSourceEntityId: FB1EntityIdFB2AggroEntryReturns the Source's largest-total entry. Recomputes when the cache is invalid (hence non-const). Returns nullptr if none. Use this for single-shot calls.
GetTopReasonInSourceEntityId: FB1EntityIdstringReturns the TopReason of the current chase-target entry. NAME_None if none. Since a Source can have multiple Targets, the single TopReason means the TopReason within the chase-target entry.
GetTopTargetInSourceEntityId: FB1EntityIdFB1EntityIdReturns the current chase target (= GetTopEntry().TargetEntityId). Invalid if none.
HasActiveAggroInSourceEntityId: FB1EntityIdbooleanReturns whether the Source holds at least one aggro entry (any Reason). Used for debug/statistics.
HasActiveChaseAggroInSourceEntityId: FB1EntityIdbooleanReturns whether the Source holds at least one entry whose TopReason is a chase-type (bAutoChase=true) Reason. Used by autonomy queries; entries with only instant-type (bAutoChase=false) Reasons do not block autonomy.
HasHostileAggroTargetInSourceEntityId: FB1EntityId, InTargetEntityId: FB1EntityIdbooleanReturns whether the Source has at least one Hostile-disposition Reason bucket toward this Target. Since aggro also includes friendly reasons (e.g. calling someone to eat), use this (not IsAggroTargetOf) to decide whether they are currently fighting. Reason disposition is defined by EB1AggroDisposition in the Aggro table.
IsAggroTargetOfInSourceEntityId: FB1EntityId, InTargetEntityId: FB1EntityIdbooleanReturns whether a specific Source has this Target as an aggro entry (self->target relation only). Used as a filter, e.g. 'do not tell the target I am chasing to move over' in MoveOver.
NotifyChaseAbortedByUserInSourceEntityId: FB1EntityId-Called when a Chase Action is canceled by user intent (B2InteractionHelper::IsUserCancelReason). Marks bUserAborted=true on all of that Source's entries so it will not restart chasing even if the aggro entry survives. Automatically reset to false when an entry is updated via AddAggro.
NotifyChaseArrivedInSourceEntityId: FB1EntityId, InTargetEntityId: FB1EntityId-Called when a Chase Action ends via OnFinish (normal arrival). Fires FireArrival on the (Source, Target) entry + marks bArrivalFired + clears the progress flag. Idempotent: ignored if re-called on an already-fired entry. OnCanceled/OnPaused paths are not arrivals, so they call only NotifyChaseFinished and skip the fire.
NotifyChaseFinishedInSourceEntityId: FB1EntityId-Notification called when a Chase Action ends/cancels. Lowers the Source's chase-in-progress flag so it can re-chase on the next tick.
OnEntityRemovedInEntityId: FB1EntityId-On entity removal, cleans up both Source and Target directions (invoked by the EntityManager callback).
RemoveAggroInSourceEntityId: FB1EntityId-Force-clears all of the Source's Target aggro. Cleans up the Chase Action and restores autonomy.
RemoveAggroForTargetInSourceEntityId: FB1EntityId, InTargetEntityId: FB1EntityId-Clears only the Source's aggro toward a specific Target.

Override points (11)

Implement these in Lua as FB2AggroManager.Override_Name = function(...) end.

FunctionParametersReturnsDescription
Override_AddAggroInSourceEntityId: FB1EntityId, InTargetEntityId: FB1EntityId, InAggroValue: integer, InAggroReason: stringbooleanExternal call interface. Takes (SourceId, TargetId, Value, Reason).
Override_DecreaseAggroByReasonInSourceEntityId: FB1EntityId, InAggroReason: string, InValue: integer-Iterates all of the Source's entries and decreases matching Reason buckets by InValue. Called by external systems such as scripts. Buckets that drop to <=0 are auto-removed; the Source is cleaned up when all entries are empty.
Override_DecreaseAggroByTargetReasonInSourceEntityId: FB1EntityId, InTargetEntityId: FB1EntityId, InAggroReason: string, InValue: integer-Decreases the matching Reason bucket by InValue, limited to the Source-Target entry. Buckets at <=0 are auto-removed; empty entries and then the Source are cleaned up.
Override_HasActiveAggroInSourceEntityId: FB1EntityIdbooleanReturns whether the Source holds at least one aggro entry (any Reason). Used for debug/statistics.
Override_HasActiveChaseAggroInSourceEntityId: FB1EntityIdbooleanReturns whether the Source holds at least one entry whose TopReason is a chase-type (bAutoChase=true) Reason. Used by autonomy queries.
Override_NotifyChaseAbortedByUserInSourceEntityId: FB1EntityId-Called when a Chase Action is canceled by user intent. Marks bUserAborted=true on all of that Source's entries so it will not restart chasing even if the aggro entry survives.
Override_NotifyChaseArrivedInSourceEntityId: FB1EntityId, InTargetEntityId: FB1EntityId-Called when a Chase Action ends via OnFinish (normal arrival). Fires FireArrival + marks bArrivalFired + clears the progress flag. Idempotent.
Override_NotifyChaseFinishedInSourceEntityId: FB1EntityId-Notification called when a Chase Action ends/cancels. Lowers the chase-in-progress flag so the Source can re-chase next tick.
Override_OnEntityRemovedInEntityId: FB1EntityId-On entity removal, cleans up both Source and Target directions (invoked by the EntityManager callback).
Override_RemoveAggroInSourceEntityId: FB1EntityId-Force-clears all of the Source's Target aggro. Cleans up the Chase Action and restores autonomy.
Override_RemoveAggroForTargetInSourceEntityId: FB1EntityId, InTargetEntityId: FB1EntityId-Clears only the Source's aggro toward a specific Target.