9 [
Attribute(defvalue:
"", uiwidget:
UIWidgets.EditBox,
desc:
"Don't use, it's here for backwards compatibility, not guaranteed to work in all classes",
params:
"bt")]
10 string m_OverrideBehaviorTree;
15 void PerformReaction(notnull SCR_AIUtilityComponent utility,
SCR_AIMessageBase message) {}
27 override void PerformReaction(notnull SCR_AIUtilityComponent utility,
SCR_AIMessageBase message)
33 utility.m_CombatComponent.UpdateLastSeenPosition(msg.m_TargetInfo.m_Entity, msg.m_TargetInfo);
34 utility.m_CombatComponent.SetAssignedTargets({msg.m_TargetInfo.m_Entity}, null);
42 const float INVESTIGATION_DURATION_S = 120.0;
44 override void PerformReaction(notnull SCR_AIUtilityComponent utility,
SCR_AIMessageBase message)
51 if (!msg.m_TargetClusterState || !msg.m_TargetClusterState.m_Cluster)
55 utility.m_CombatComponent.SetAssignedTargets(null, msg.m_TargetClusterState);
61 if (msg.m_bAllowInvestigate)
63 bool targetIdentified =
false;
64 foreach (
IEntity targetEntity : msg.m_TargetClusterState.m_Cluster.m_aEntities)
66 if (utility.m_PerceptionComponent.GetTargetPerceptionObject(targetEntity,
ETargetCategory.ENEMY))
68 targetIdentified =
true;
76 if (!targetIdentified && msg.m_bAllowInvestigate)
82 float investigateRadius;
86 investigatePos, radius: investigateRadius,
87 priorityLevel: msg.m_fPriorityLevel, isDangerous:
true,
88 duration: INVESTIGATION_DURATION_S);
89 utility.AddAction(investigateBehavior);
108 override void PerformReaction(notnull SCR_AIUtilityComponent utility,
SCR_AIMessageBase message)
114 utility.m_CombatComponent.ResetAssignedTargets();
121 override void PerformReaction(notnull SCR_AIUtilityComponent utility, SCR_AIMessageBase
message)
125 SCR_AICommsHandler commsHandler = utility.m_CommsHandler;
137 override void PerformReaction(notnull SCR_AIUtilityComponent utility, SCR_AIMessageBase
message)
139 auto msg = SCR_AIMessage_Move.Cast(
message);
143 auto behavior =
new SCR_AIMoveIndividuallyBehavior(utility, msg.m_RelatedGroupActivity,
144 msg.m_MovePosition, SCR_AIActionBase.PRIORITY_BEHAVIOR_MOVE_INDIVIDUALLY, msg.m_fPriorityLevel, msg.m_FollowEntity);
146 utility.WrapBehaviorOutsideOfVehicle(behavior);
147 utility.AddAction(behavior);
150 override void PerformReaction(notnull SCR_AIGroupUtilityComponent utility, SCR_AIMessageBase
message)
152 auto msg = SCR_AIMessage_Move.Cast(
message);
156 auto activity =
new SCR_AIMoveActivity(utility, msg.m_RelatedWaypoint, msg.m_MovePosition,
157 msg.m_FollowEntity, msg.m_eMovementType, msg.m_bUseVehicles, SCR_AIActionBase.PRIORITY_ACTIVITY_MOVE, priorityLevel: msg.m_fPriorityLevel);
159 utility.SetStateAllActionsOfType(SCR_AISearchAndDestroyActivity,
EAIActionState.FAILED);
160 utility.AddAction(activity);
170 if (!msg || !msg.m_FollowEntity)
174 msg.m_eMovementType,
false, SCR_AIActionBase.PRIORITY_ACTIVITY_FOLLOW, priorityLevel: msg.m_fPriorityLevel,
distance: msg.m_fDistance);
176 utility.AddAction(activity);
183 override void PerformReaction(notnull SCR_AIUtilityComponent utility,
SCR_AIMessageBase message)
193 SCR_AIActionBase.PRIORITY_BEHAVIOR_MOVE_AND_INVESTIGATE, msg.m_fPriorityLevel, isDangerous: msg.m_bIsDangerous, radius: msg.m_fRadius, targetUnitType: msg.m_eTargetUnitType, duration: msg.m_fDuration);
194 utility.AddAction(behavior);
201 override void PerformReaction(notnull SCR_AIUtilityComponent utility,
SCR_AIMessageBase message)
207 utility.AddAction(behavior);
214 override void PerformReaction(notnull SCR_AIUtilityComponent utility,
SCR_AIMessageBase message)
224 if (msg.m_CompartmentSlot)
226 compartmentSlot = msg.m_CompartmentSlot;
234 array<BaseCompartmentSlot> compartments = {};
235 compMan.GetCompartments(compartments);
244 IEntity occupant = comp.GetOccupant();
245 if (occupant && occupant == utility.m_OwnerEntity)
248 else if (occupant && SCR_AIDamageHandling.IsConscious(occupant))
250 comp.SetReserved(utility.m_OwnerEntity);
251 compartmentSlot = comp;
255 if (!compartmentSlot)
258 PrintFormat(
"Warning: unit %1 got to get in %2 but there is no room for it in comp type %3!", utility.m_OwnerEntity, msg.m_Vehicle, msg.m_eRoleInVehicle);
262 auto behavior =
new SCR_AIGetInVehicle(utility, msg.m_RelatedGroupActivity, msg.m_Vehicle, compartmentSlot, wantedCompartmentType, SCR_AIActionBase.PRIORITY_BEHAVIOR_GET_IN_VEHICLE, msg.m_fPriorityLevel);
263 if (m_OverrideBehaviorTree !=
string.Empty)
264 behavior.m_sBehaviorTree = m_OverrideBehaviorTree;
266 utility.AddAction(behavior);
275 auto activity =
new SCR_AIGetInActivity(utility, msg.m_RelatedWaypoint, msg.m_Vehicle, msg.m_BoardingParams, msg.m_eRoleInVehicle, priorityLevel: msg.m_fPriorityLevel);
276 utility.AddAction(activity);
283 override void PerformReaction(notnull SCR_AIUtilityComponent utility,
SCR_AIMessageBase message)
289 auto behavior =
new SCR_AIGetOutVehicle(utility, msg.m_RelatedGroupActivity, msg.m_Vehicle, delay_s: msg.m_fDelay_s, priority: SCR_AIActionBase.PRIORITY_BEHAVIOR_GET_OUT_VEHICLE, priorityLevel: msg.m_fPriorityLevel);
290 if (m_OverrideBehaviorTree !=
string.Empty)
291 behavior.m_sBehaviorTree = m_OverrideBehaviorTree;
293 utility.AddAction(behavior);
303 float customPriorityLevel;
306 customPriorityLevel = SCR_AIActionBase.PRIORITY_LEVEL_GAMEMASTER;
308 customPriorityLevel = msg.m_fPriorityLevel;
310 auto activity =
new SCR_AIGetOutActivity(utility, msg.m_RelatedWaypoint, msg.m_Vehicle, msg.m_BoardingParams, priorityLevel: customPriorityLevel);
312 utility.AddAction(activity);
325 auto activity =
new SCR_AISearchAndDestroyActivity(utility, msg.m_RelatedWaypoint, msg.m_MovePosition, ent: msg.m_FollowEntity, useVehicles: msg.m_bUseVehicles, priorityLevel: msg.m_fPriorityLevel);
328 utility.AddAction(activity);
335 override void PerformReaction(notnull SCR_AIUtilityComponent utility,
SCR_AIMessageBase message)
341 auto behavior =
new SCR_AIMedicHealBehavior(utility, msg.m_RelatedGroupActivity, msg.m_EntityToHeal,
false, priorityLevel: msg.m_fPriorityLevel);
342 if (m_OverrideBehaviorTree !=
string.Empty)
343 behavior.m_sBehaviorTree = m_OverrideBehaviorTree;
345 utility.WrapBehaviorOutsideOfVehicle(behavior);
346 utility.AddAction(behavior);
355 SCR_AIActionBase currentAction = SCR_AIActionBase.Cast(utility.GetCurrentAction());
359 float priorityLevelClamped = currentAction.GetRestrictedPriorityLevel(msg.m_fPriorityLevel);
362 array <ref AIActionBase> actions = {};
369 if (healActivity.m_EntityToHeal.m_Value == msg.m_EntityToHeal)
371 healActivity.SetPriorityLevel(priorityLevelClamped);
377 auto activity =
new SCR_AIHealActivity(utility, msg.m_RelatedWaypoint, msg.m_EntityToHeal, priorityLevel: priorityLevelClamped);
379 utility.AddAction(activity);
386 override void PerformReaction(notnull SCR_AIUtilityComponent utility,
SCR_AIMessageBase message)
392 auto behavior =
new SCR_AIHealWaitBehavior(utility, msg.m_RelatedGroupActivity, msg.m_HealProvider, msg.m_fPriorityLevel);
394 utility.AddAction(behavior);
401 override void PerformReaction(notnull SCR_AIUtilityComponent utility,
SCR_AIMessageBase message)
404 if (!msg || !msg.m_RelatedWaypoint)
407 auto behavior =
new SCR_AIDefendBehavior(utility, msg.m_RelatedGroupActivity, msg.m_RelatedWaypoint,
408 msg.m_vDefendDirection, msg.m_fDefendAngularRange, priorityLevel: msg.m_fPriorityLevel);
409 if (m_OverrideBehaviorTree !=
string.Empty)
410 behavior.m_sBehaviorTree = m_OverrideBehaviorTree;
412 utility.AddAction(behavior);
418 if (!msg || !msg.m_RelatedWaypoint)
421 auto activity =
new SCR_AIDefendActivity(utility, msg.m_RelatedWaypoint, msg.m_vDefendDirection,
422 priorityLevel: msg.m_fPriorityLevel);
423 if (m_OverrideBehaviorTree !=
string.Empty)
424 activity.m_sBehaviorTree = m_OverrideBehaviorTree;
426 utility.AddAction(activity);
433 override void PerformReaction(notnull SCR_AIUtilityComponent utility,
SCR_AIMessageBase message)
439 auto behavior =
new SCR_AIPerformActionBehavior(utility, msg.m_RelatedGroupActivity, msg.m_SmartActionComponent, priorityLevel: msg.m_fPriorityLevel);
440 if (m_OverrideBehaviorTree !=
string.Empty)
441 behavior.m_sBehaviorTree = m_OverrideBehaviorTree;
443 utility.AddAction(behavior);
452 auto activity =
new SCR_AIPerformActionActivity(utility, msg.m_RelatedWaypoint, msg.m_SmartActionEntity, msg.m_SmartActionTag, priorityLevel: msg.m_fPriorityLevel);
453 if (m_OverrideBehaviorTree !=
string.Empty)
454 activity.m_sBehaviorTree = m_OverrideBehaviorTree;
456 utility.AddAction(activity);
463 static const string SMART_ACTION_TAG =
"OpenGate";
465 override void PerformReaction(notnull SCR_AIUtilityComponent utility,
SCR_AIMessageBase message)
471 if (!msg.m_DoorEntity)
476 if (!smartActionComp)
480 msg.m_RelatedGroupActivity, smartActionComp,
481 priority: SCR_AIActionBase.PRIORITY_BEHAVIOR_OPEN_NAVLINK_DOOR,
482 priorityLevel: msg.m_fPriorityLevel);
484 utility.WrapBehaviorOutsideOfVehicle(performActionBehavior);
485 utility.AddAction(performActionBehavior);
492 override void PerformReaction(notnull SCR_AIUtilityComponent utility,
SCR_AIMessageBase message)
495 if (!msg || !msg.m_RelatedGroupActivity)
498 array<ref AIActionBase> actions = {};
499 utility.GetActions(actions);
500 foreach(AIActionBase action: actions)
502 if (action.GetRelatedGroupActivity() == msg.m_RelatedGroupActivity)
504 SCR_AIActionBase actionBase = SCR_AIActionBase.Cast(action);
516 override void PerformReaction(notnull SCR_AIUtilityComponent utility,
SCR_AIMessageBase message)
523 utility.AddAction(behavior);
530 override void PerformReaction(notnull SCR_AIUtilityComponent utility,
SCR_AIMessageBase message)
545 utility.AddAction(behavior);
552 override void PerformReaction(notnull SCR_AIUtilityComponent utility,
SCR_AIMessageBase message)
559 msg.m_AmmoConsumer, msg.m_MagazineWell, msg.m_fPriorityLevel);
561 utility.AddAction(behavior);
568 override void PerformReaction(notnull SCR_AIUtilityComponent utility,
SCR_AIMessageBase message)
575 msg.m_vPickupPosition, msg.m_MagazineWellType, msg.m_fPriorityLevel);
577 utility.AddAction(behavior);
584 override void PerformReaction(notnull SCR_AIUtilityComponent utility, SCR_AIMessageBase
message)
586 SCR_AIMessage_Suppress msg = SCR_AIMessage_Suppress.Cast(
message);
587 if (!msg || !msg.m_Volume)
590 SCR_AISuppressBehavior behavior =
new SCR_AISuppressBehavior(utility, msg.m_RelatedGroupActivity, msg.m_Volume, msg.m_fDuration_s, fireRate: msg.m_fFireRate, priorityLevel: msg.m_fPriorityLevel);
591 utility.AddAction(behavior);
598 override void PerformReaction(notnull SCR_AIUtilityComponent utility,
SCR_AIMessageBase message)
601 if (!msg || !msg.m_RootEntity)
604 auto behavior =
new SCR_AIAnimateBehavior(utility, msg.m_RelatedGroupActivity, rootEntity: msg.m_RootEntity, priorityLevel: msg.m_fPriorityLevel, scriptForAgent: msg.m_AgentScript, relatedInvoker: msg.m_RelatedInvoker);
605 if (m_OverrideBehaviorTree !=
string.Empty)
606 behavior.m_sBehaviorTree = m_OverrideBehaviorTree;
608 utility.AddAction(behavior);
614 if (!msg || !msg.m_RelatedWaypoint)
617 auto activity =
new SCR_AIAnimateActivity(utility, msg.m_RelatedWaypoint, priorityLevel: msg.m_fPriorityLevel);
618 if (m_OverrideBehaviorTree !=
string.Empty)
619 activity.m_sBehaviorTree = m_OverrideBehaviorTree;
621 utility.AddAction(activity);
628 override void PerformReaction(notnull SCR_AIUtilityComponent utility,
SCR_AIMessageBase message)
634 array<ref AIActionBase> actions = {};
636 foreach (
auto a : actions)
640 utility.AddAction(b);
EAIActionFailReason
Fail reasons of actions. They can be generic or specific to some behavior.
SCR_AIGoalReaction_Follow BaseContainerProps
void SCR_AIMessage_PickupInventoryItems()
SCR_AIMessage_AttackCluster SCR_AIMessageGoal SCR_AIMessage_AttackClusterDone()
void SCR_AIMessage_ArtillerySupport()
void SCR_AITalkRequest(ECommunicationType type, IEntity entity, vector pos, int enumSignal, bool transmitIfNoReceivers, bool transmitIfPassenger, SCR_EAITalkRequestPreset preset)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
void AddRequest(SCR_AITalkRequest request)
bool CanBypass(SCR_AITalkRequest request=null)
static void CalculateInvestigationArea(notnull SCR_AITargetClusterState s, out vector outCenterPos, out float outRadius)
Calculates position and radius of investigation area.
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
SCR_FieldOfViewSettings Attribute