6class SCR_ScenarioFrameworkSlotTaskAI : SCR_ScenarioFrameworkSlotTask
12 bool m_bSpawnAIOnWPPos;
14 [
Attribute(
desc:
"Default waypoint if any WP group is defined",
"{93291E72AC23930F}Prefabs/AI/Waypoints/AIWaypoint_Defend.et",
category:
"Waypoints")]
17 [
Attribute(defvalue:
"0",
desc:
"Balancing group sizes based on number of players",
category:
"Balance")]
20 [
Attribute(defvalue:
"1",
desc:
"Least amount of AIs in the group after balancing occurs. Will not exceed maximum number of units defined in the group prefab.",
category:
"Balance")]
23 [
Attribute(defvalue:
"1",
desc:
"When enabled and AI enters a vehicle, whole AI group won't be despawned by the Dynamic Despawn feature until the whole group is outside the vehicle",
category:
"Activation")]
26 [
Attribute(defvalue: SCR_EAIGroupFormation.Wedge.ToString(),
UIWidgets.ComboBox,
"AI group formation",
"", ParamEnumArray.FromEnum(SCR_EAIGroupFormation),
category:
"Common")]
29 [
Attribute(defvalue: EAISkill.REGULAR.ToString(),
UIWidgets.ComboBox,
"AI skill in combat",
"", ParamEnumArray.FromEnum(EAISkill),
category:
"Common")]
32 [
Attribute(defvalue:
"1", uiwidget:
UIWidgets.EditBox,
desc:
"Sets perception ability. Affects speed at which perception detects targets. Bigger value means proportionally faster detection.",
params:
"0 100 0.001",
category:
"Common")]
35 [
Attribute(defvalue:
"{000CD338713F2B5A}Prefabs/AI/Groups/Group_Base.et",
category:
"Common")]
68 override void RestoreToDefault(
bool includeChildren =
false,
bool reinitAfterRestoration =
false,
bool affectRandomization =
true,
bool deleteSpawnedEntities =
true)
77 super.RestoreToDefault(includeChildren, reinitAfterRestoration, affectRandomization, deleteSpawnedEntities);
125 if (!agent || !
Vehicle.Cast(targetEntity))
137 if (!agent || !
Vehicle.Cast(targetEntity))
140 array<AIAgent> agents = {};
144 foreach (AIAgent groupAgent : agents)
147 if (character && character.IsInVehicle())
172 return super.InitOtherThings();
232 for (
int i =
m_AIGroup.m_aUnitPrefabSlots.Count() - 1; i >= 0; i--)
234 if (
m_AIGroup.m_aUnitPrefabSlots[i] != prefabToRemove)
244 int iMaxUnitsInGroup =
m_AIGroup.m_aUnitPrefabSlots.Count();
250 m_AIGroup.SetMaxUnitsToSpawn(iUnitsToSpawn);
294 array<AIAgent> agents = {};
305 foreach (
int i, AIAgent agent : agents)
307 IEntity agentEntity = agent.GetControlledEntity();
312 if (basePosition ==
vector.Zero)
318 vector formationPosition = basePosition + formDef.GetOffsetPosition(i);
323 float surfaceY = world.GetSurfaceY(formationPosition[0], formationPosition[2]);
324 float oceanY = world.GetOceanHeight(formationPosition[0], formationPosition[2]);
325 formationPosition[1] =
Math.Max(
Math.Max(oceanY, surfaceY), formationPosition[1]);
328 formationPosition = floorPosition;
330 agentEntity.
SetOrigin(formationPosition);
333 SCR_AICombatComponent combatComponent = SCR_AICombatComponent.Cast(agentEntity.
FindComponent(SCR_AICombatComponent));
358 foreach (AIAgent agent : agents)
360 IEntity agentEntity = agent.GetControlledEntity();
364 SCR_AICombatComponent combatComponent = SCR_AICombatComponent.Cast(agentEntity.
FindComponent(SCR_AICombatComponent));
392 array<string> WaypointSetLayers = {};
393 WaypointSetLayers = m_WaypointSet.m_aLayerName;
394 array<SCR_ScenarioFrameworkLayerBase> layerBases = {};
395 array<SCR_ScenarioFrameworkLayerBase> layerChildren = {};
403 foreach (
string waypointSetLayer : WaypointSetLayers)
405 IEntity layerEntity = world.FindEntityByName(waypointSetLayer);
412 if (layerBases.Contains(layerBase))
415 layerChildren = layerBase.GetChildrenEntities();
434 if (waypoint.GetIsInitiated())
455 if (!cycleWP.m_bInitiated)
460 else if (cycleWP.m_OnAllWaypointsSpawned)
494 Print(
string.Format(
"ScenarioFramework: Trying to add waypoints to non existing entity! Did you select the object to spawn for %1?",
GetOwner().
GetName()),
LogLevel.ERROR);
508 waypoint = AIWaypoint.Cast(waypointSlot.GetSpawnedEntity());
543 AIWaypointCycle cycleWaypoint = AIWaypointCycle.Cast(waypoint);
546 array<AIWaypoint> cycleWaypoints = {};
547 cycleWaypoint.GetWaypoints(cycleWaypoints);
548 if (!cycleWaypoints.IsEmpty() && cycleWaypoints[0] != null)
550 waypoint = cycleWaypoints[0];
567 array<AIAgent> agents = {};
570 foreach (
int i, AIAgent agent : agents)
572 IEntity agentEntity = agent.GetControlledEntity();
576 agentEntity.
SetOrigin(waypoint.GetOrigin() + formDef.GetOffsetPosition(i));
589 spawnParams.TransformMode = ETransformMode.WORLD;
590 spawnParams.Transform[3] =
m_Entity.GetOrigin();
593 if (!resWP || !resWP.IsValid())
596 AIWaypoint waypoint = AIWaypoint.Cast(
GetGame().SpawnEntityPrefab(resWP,
GetGame().GetWorld(), spawnParams));
610 if (group.GetAgentsCount() == 0)
623 IEntity agentEntity = agent.GetControlledEntity();
626 Print(
"ScenarioFramework: Decreasing AI member count failed due to not getting AI entity!",
LogLevel.ERROR);
633 Print(
"ScenarioFramework: Decreasing AI member count failed due to not getting entity prefab data",
LogLevel.ERROR);
648 paramsPatrol.TransformMode = ETransformMode.WORLD;
650 paramsPatrol.Transform[3] =
m_Entity.GetOrigin();
652 if (!groupResource.IsValid())
659 FactionAffiliationComponent facComp = FactionAffiliationComponent.Cast(
m_Entity.FindComponent(FactionAffiliationComponent));
663 m_AIGroup.SetFaction(facComp.GetAffiliatedFaction());
ArmaReforgerScripted GetGame()
enum EAITargetInfoCategory m_Entity
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
SCR_ScenarioFrameworkEActivationType
ref array< IEntity > m_aSpawnedEntities
SCR_ScenarioFrameworkEActivationType m_eActivationType
bool m_bEnableRepeatedSpawn
int m_iRepeatedSpawnNumber
SCR_ScenarioFrameworkLayerBase m_ParentLayer
ScriptInvokerScenarioFrameworkLayer GetOnAllChildrenSpawned()
bool m_bExcludeFromDynamicDespawn
void SetIsTerminated(bool state)
void InitActivationActions()
void AfterAllChildrenSpawned(SCR_ScenarioFrameworkLayerBase layer)
void SCR_ScenarioFrameworkLayerBase(IEntityComponentSource src, IEntity ent, IEntity parent)
ref array< ref SCR_ScenarioFrameworkPlugin > m_aPlugins
int GetMaxPlayersForGameMode(FactionKey factionName="")
void DynamicDespawn(SCR_ScenarioFrameworkLayerBase layer)
bool m_bDynamicallyDespawned
bool InitOtherThings()
For situations where some other logic is to be appended in these checks and is to be performed before...
override void SetWaypointToAI(SCR_ScenarioFrameworkLayerBase layer)
void OnAgentCompartmentLeft(AIAgent agent, IEntity targetEntity, BaseCompartmentManagerComponent manager, int mgrID, int slotID, bool move)
ref array< SCR_ScenarioFrameworkSlotWaypoint > m_aSlotWaypoints
void OnAgentCompartmentEntered(AIAgent agent, IEntity targetEntity, BaseCompartmentManagerComponent manager, int mgrID, int slotID, bool move)
void AfterAllAgentsSpawned()
Initializes plugins, actions, and checks for parent layer spawn completion, then sets waypoints for A...
void ProcessWaypoints(SCR_ScenarioFrameworkLayerBase layer)
void InitWaypoints()
Initializes waypoints by finding them in specified layers, adding them to list, and processing them a...
ref array< AIWaypoint > m_aWaypoints
ResourceName m_sGroupPrefab
void InitGroupComponents()
Initializes AI group components, sets formation, and combat parameters for agents in the group.
void CheckWaypointsAfterInit(SCR_ScenarioFrameworkLayerBase layer)
bool m_bBalanceOnPlayersCount
ref array< ResourceName > m_aAIPrefabsForRemoval
void DecreaseAIGroupMemberCount(SCR_AIGroup group, AIAgent agent)
bool m_bExcludeFromDynamicDespawnOnVehicleEntered
SCR_EAIGroupFormation m_eAIGroupFormation
bool m_bWaypointsInitialized
array< ResourceName > GetAIPrefabsForRemoval()
AIWaypoint CreateDefaultWaypoint()
float m_fPerceptionFactor
int m_iCurrentlySpawnedWaypoints
void SetAIPrefabsForRemoval(array< ResourceName > arrayForRemoval)
void SCR_ScenarioFrameworkSlotWaypoint(IEntityComponentSource src, IEntity ent, IEntity parent)
proto external Managed FindComponent(typename typeName)
proto external void SetOrigin(vector orig)
proto external vector GetOrigin()
proto external int Update()
proto external BaseWorld GetWorld()
proto external EntityPrefabData GetPrefabData()
Object holding reference to resource. In destructor release the resource.
static void IgnoreSpawning(bool ignore)
ref ScriptInvokerBase< SCR_AIOnCompartmentLeft > m_OnCompartmentLeft
ref ScriptInvokerBase< SCR_AIOnCompartmentEntered > m_OnCompartmentEntered
static bool TryFindNearbyFloorPositionForEntity(BaseWorld world, IEntity entity, vector position=vector.Zero, out vector floorPos=vector.Zero)
static void InvokeSlotAISpawned(SCR_ScenarioFrameworkLayerBase layer, IEntity entity)
ScriptInvokerScenarioFrameworkLayer GetOnAllWaypointsSpawned()
static bool IsEmptyOrWhiteSpace(string input)
enum EPhysicsLayerPresets Vehicle
void OnAgentAdded(AIAgent agent)
IEntity GetOwner()
Owner entity of the fuel tank.
proto external void ActivateAI()
Activates AI group, removes unwanted prefabs, balances units count, sets on agent remove and add even...
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
SCR_FieldOfViewSettings Attribute