6class SCR_AIUtilityComponent : SCR_AIBaseUtilityComponent
34 protected static const float DISTANCE_HYSTERESIS_FACTOR = 0.45;
35 protected static const float NEARBY_DISTANCE_SQ = 2500;
36 protected static const float REACTION_TO_SAME_UNKNOWN_TARGET_INTERVAL_MS = 2500;
48 AddDebugMessage(
"EvaluateBehavior START");
49 if (m_bEvaluationBreakpoint)
51 Print(
"EvaluateBehavior breakpoint triggered",
LogLevel.NORMAL);
53 m_bEvaluationBreakpoint =
false;
80 AddDebugMessage(
string.Format(
"PerformGoalReaction: %1, from BT: %2", msgGoal, msgGoal.m_sSentFromBt));
97 AddDebugMessage(
string.Format(
"InfoMessage consumed by action: %1, from BT: %2", msgInfo, msgInfo.m_sSentFromBt));
102 if (!overrideReaction)
105 AddDebugMessage(
string.Format(
"PerformInfoReaction: %1, from BT: %2", msgInfo, msgInfo.m_sSentFromBt));
113 bool reactToUnknownTarget =
false;
119 reactToUnknownTarget =
true;
123 reactToUnknownTarget =
true;
129 AddDebugMessage(
string.Format(
"PerformReaction: Unknown Target: %1", unknownTarget));
141 bool selectedTargetChanged;
142 bool retreatTargetChanged;
143 bool compartmentChanged;
147 prevTarget, selectedTarget, retreatTargetChanged, compartmentChanged);
152 AddDebugMessage(
string.Format(
"PerformReaction: Selected Target Changed: %1", selectedTarget));
155 m_ConfigComponent.m_Reaction_SelectedTargetChanged.PerformReaction(
this, prevTarget, selectedTarget);
160 (compartmentChanged ||
161 (selectedTargetChanged && !selectedTarget && retreatTarget) ||
162 (!selectedTarget && retreatTargetChanged)))
167 AddDebugMessage(
string.Format(
"PerformReaction: Retreat From Target: %1", retreatTarget));
183 DebugLogActionsPriority();
206 AddDebugMessage(
"EvaluateBehavior END\n");
229 return leaderAgent.m_UtilityComponent.m_MovementDetector.GetMoving();
238 if (!subformationLeaderAgent)
241 IEntity subformationLeaderEntity = subformationLeaderAgent.GetControlledEntity();
243 if (!subformationLeaderEntity)
255 AIAgent myAgent = GetAIAgent();
263 AIGroupMovementComponent movementComp = AIGroupMovementComponent.Cast(myGroup.GetMovementComponent());
264 int moveHandlerId = movementComp.GetAgentMoveHandlerId(myAgent);
265 bool formationDisplaced = movementComp.IsFormationDisplaced(moveHandlerId);
269 if (formationDisplaced && masterGroup)
274 IEntity leaderEntity =
GetGame().GetPlayerManager().GetPlayerControlledEntity(leaderId);
278 AIControlComponent controlComp = AIControlComponent.Cast(leaderEntity.
FindComponent(AIControlComponent));
283 return controlComp.GetAIAgent();
288 return myGroup.GetLeaderAgent();
295 AIAgent myAgent = GetAIAgent();
301 AIGroupMovementComponent movementComp = AIGroupMovementComponent.Cast(myGroup.GetMovementComponent());
306 int moveHandlerId = movementComp.GetAgentMoveHandlerId(myAgent);
308 bool formationDisplaced = movementComp.IsFormationDisplaced(moveHandlerId);
311 if (formationDisplaced)
315 array<AIAgent> agentsInHandler = {};
316 movementComp.GetAgentsInHandler(agentsInHandler, moveHandlerId);
317 int myIndexInHandler = agentsInHandler.Find(myAgent);
319 return myIndexInHandler == 0;
351 array<ref AIActionBase> actions = {};
358 if (relatedGroupActivity && relatedGroupActivity.m_Utility == groupUtility)
369 CompartmentAccessComponent compartmentAccess = CompartmentAccessComponent.Cast(
m_OwnerEntity.FindComponent(CompartmentAccessComponent));
370 if (!compartmentAccess)
373 if (!compartmentAccess.IsInCompartment())
381 float priority = action.GetPriority();
382 float priorityLevel = action.EvaluatePriorityLevel();
383 IEntity vehicle = compartmentAccess.GetCompartment().GetOwner();
386 AddAction(
new SCR_AIGetInVehicle(
this, relatedActivity, vehicle, compartmentAccess.GetCompartment(), roleInVehicle: compartmentType, priority: priority, priorityLevel: priorityLevel));
392 super.EOnInit(owner);
397 m_ConfigComponent = SCR_AIConfigComponent.Cast(agent.FindComponent(SCR_AIConfigComponent));
ArmaReforgerScripted GetGame()
void SCR_AIActivityBase(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint)
void DiagIncreaseCounter()
void SCR_AIBehaviorBase(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity)
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
SCR_AIUtilityComponentClass m_OwnerEntity
ref SCR_AILookAction m_LookAction
PerceptionComponent m_PerceptionComponent
ref SCR_AISectorThreatFilter m_SectorThreatFilter
ref SCR_AIThreatSystem m_ThreatSystem
void OnCompartmentEntered(AIAgent agent, IEntity targetEntity, BaseCompartmentManagerComponent manager, int mgrID, int slotID, bool move)
SCR_AIInfoComponent m_AIInfo
SCR_AICharacterSettingsComponent m_SettingsComponent
void OnCompartmentLeft(AIAgent agent, IEntity targetEntity, BaseCompartmentManagerComponent manager, int mgrID, int slotID, bool move)
bool IsMilitary()
Are we a military AI or not?
ref SCR_AICommsHandler m_CommsHandler
ref SCR_AIBehaviorBase m_CurrentBehavior
Used for avoiding constant casting, outside of this class use GetCurrentBehavior().
bool GetSubformationLeaderMoving()
bool CanIndependentlyMove()
SCR_CharacterControllerComponent GetCharacterController()
SCR_AIBehaviorBase GetCurrentBehavior()
ref BaseTarget m_UnknownTarget
float m_fReactionUnknownTargetTime_ms
WorldTime timestamp.
ref SCR_AICombatMoveState m_CombatMoveState
SCR_MailboxComponent m_Mailbox
AIAgent GetSubformationLeaderAgent()
Returns leader agent of subformation of this agent.
bool ShouldKeepFormation()
Returns true if we should be mindful about our formation overall.
ref SCR_AIMovementDetector m_MovementDetector
bool IsSubformationLeader()
Returns true if this agent is leader of its subformation.
FactionAffiliationComponent m_FactionComponent
ref ScriptCallQueue m_Callqueue
void LookAt(vector pos, float duration=2)
bool GetNearSubformationLeader()
SCR_AICombatComponent m_CombatComponent
void CancelAllGroupActivityBehaviors(notnull SCR_AIGroupUtilityComponent groupUtility)
SCR_CharacterControllerComponent m_OwnerController
SCR_AIBehaviorBase EvaluateBehavior(BaseTarget unknownTarget)
SCR_AIConfigComponent m_ConfigComponent
void WrapBehaviorOutsideOfVehicle(SCR_AIActionBase action)
ScriptCallQueue GetCallqueue()
Returns CallQueue of this AI. It gets updated from EvaluateBehavior, so that it's synchronous with ot...
void ~SCR_AIUtilityComponent()
Base class for all messages related to AI.
proto external Managed FindComponent(typename typeName)
proto external vector GetOrigin()
Game core which persists through whole game and stores various data for AI debugging.
static string GetBehaviorName(SCR_AIBehaviorBase behavior)
static void VisualizeMessage(IEntity entity, string message, EAIDebugCategory category, float showTime, Color color=Color.White, float fontSize=16, bool ignoreCategory=false)
ScriptCallQueue Class provide "lazy" calls - when we don't want to execute function immediately but l...
proto external bool CallActionsOnMessage(AIMessage msg)
IEntity GetOwner()
Owner entity of the fuel tank.
override void EOnDiag(IEntity owner, float timeSlice)
proto external bool HasActionOfType(typename actionType)
Returns true when there is an action of exactly this type.
AIBaseUtilityComponentClass AIComponentClass EvaluateActions()
Evaluate all actions and return the highest evaluated action which is not suspended....
proto external void AddAction(AIActionBase action)
Adds an action.
override void EOnInit(IEntity owner)
proto external bool RemoveObsoleteActions()
Removes actions which are failed or completed.
proto external void SetCurrentAction(AIActionBase executed)
proto external AIActionBase FindActionOfType(typename actionType)
Finds action of exactly this type.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.