6 class SCR_ScenarioFrameworkSlotTaskAI : SCR_ScenarioFrameworkSlotTask
11 [
Attribute(
desc:
"(OBSOLETE - use Waypoint Set instead) Waypoint Groups if applicable",
category:
"Waypoints")]
12 ref array<ref SCR_WaypointSet> m_aWaypointGroupNames;
15 bool m_bSpawnAIOnWPPos;
17 [
Attribute(
desc:
"Default waypoint if any WP group is defined",
"{93291E72AC23930F}Prefabs/AI/Waypoints/AIWaypoint_Defend.et",
category:
"Waypoints")]
18 ResourceName m_sWPToSpawn;
20 [
Attribute(defvalue:
"0",
desc:
"Balancing group sizes based on number of players",
category:
"Balance")]
23 [
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")]
35 [
Attribute(defvalue: EAISkill.REGULAR.ToString(), UIWidgets.ComboBox,
"AI skill in combat",
"", ParamEnumArray.FromEnum(EAISkill),
category:
"Common")]
38 [
Attribute(defvalue: EAICombatType.NORMAL.ToString(), UIWidgets.ComboBox,
"AI combat type",
"", ParamEnumArray.FromEnum(EAICombatType),
category:
"Common")]
41 [
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")]
44 [
Attribute(defvalue:
"{000CD338713F2B5A}Prefabs/AI/Groups/Group_Base.et",
category:
"Common")]
73 override void RestoreToDefault(
bool includeChildren =
false,
bool reinitAfterRestoration =
false)
82 super.RestoreToDefault(includeChildren, reinitAfterRestoration);
123 override void Init(
SCR_ScenarioFrameworkArea area =
null, SCR_ScenarioFrameworkEActivationType activation = SCR_ScenarioFrameworkEActivationType.SAME_AS_PARENT)
145 if (!activationCondition.Init(
GetOwner()))
155 if (
m_eActivationType == SCR_ScenarioFrameworkEActivationType.SAME_AS_PARENT && m_WaypointSet && !m_WaypointSet.m_aLayerName.IsEmpty())
158 super.Init(area, activation);
162 super.Init(area, activation);
220 for (
int i =
m_AIGroup.m_aUnitPrefabSlots.Count() - 1; i >= 0; i--)
222 if (
m_AIGroup.m_aUnitPrefabSlots[i] != prefabToRemove)
232 int iMaxUnitsInGroup =
m_AIGroup.m_aUnitPrefabSlots.Count();
238 m_AIGroup.SetMaxUnitsToSpawn(iUnitsToSpawn);
276 array<AIAgent> agents = {};
279 AIFormationComponent formComp = AIFormationComponent.Cast(
m_AIGroup.FindComponent(AIFormationComponent));
284 AIFormationDefinition formDef = formComp.GetFormation();
287 foreach (
int i, AIAgent agent : agents)
289 IEntity agentEntity = agent.GetControlledEntity();
293 agentEntity.SetOrigin(
m_vPosition + formDef.GetOffsetPosition(i));
295 SCR_AICombatComponent combatComponent = SCR_AICombatComponent.Cast(agentEntity.FindComponent(SCR_AICombatComponent));
307 foreach (AIAgent agent : agents)
309 IEntity agentEntity = agent.GetControlledEntity();
313 SCR_AICombatComponent combatComponent = SCR_AICombatComponent.Cast(agentEntity.FindComponent(SCR_AICombatComponent));
328 array<string> WaypointSetLayers = {};
329 WaypointSetLayers = m_WaypointSet.m_aLayerName;
330 array<SCR_ScenarioFrameworkLayerBase> layerBases = {};
331 array<SCR_ScenarioFrameworkLayerBase> layerChildren = {};
335 foreach (
string waypointSetLayer : WaypointSetLayers)
337 IEntity layerEntity =
GetGame().GetWorld().FindEntityByName(waypointSetLayer);
344 if (layerBases.Contains(layerBase))
347 layerChildren = layerBase.GetChildrenEntities();
366 if (waypoint.GetIsInitiated())
386 if (!cycleWP.m_bInitiated)
391 else if (cycleWP.m_OnAllWaypointsSpawned)
424 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);
438 waypoint = AIWaypoint.Cast(waypointSlot.GetSpawnedEntity());
468 EntitySpawnParams spawnParams =
new EntitySpawnParams();
469 spawnParams.TransformMode = ETransformMode.WORLD;
470 spawnParams.Transform[3] =
m_Entity.GetOrigin();
472 Resource resWP = Resource.Load(m_sWPToSpawn);
473 if (!resWP || !resWP.IsValid())
476 AIWaypoint waypoint = AIWaypoint.Cast(
GetGame().SpawnEntityPrefab(resWP,
GetGame().GetWorld(), spawnParams));
490 if (group.GetAgentsCount() == 0)
493 IEntity agentEntity = agent.GetControlledEntity();
496 Print(
"ScenarioFramework: Decreasing AI member count failed due to not getting AI entity!", LogLevel.ERROR);
500 EntityPrefabData prefabData = agentEntity.GetPrefabData();
503 Print(
"ScenarioFramework: Decreasing AI member count failed due to not getting entity prefab data", LogLevel.ERROR);
507 ResourceName resource = prefabData.GetPrefabName();
516 EntitySpawnParams paramsPatrol =
new EntitySpawnParams();
517 paramsPatrol.TransformMode = ETransformMode.WORLD;
519 paramsPatrol.Transform[3] =
m_Entity.GetOrigin();
521 if (!groupResource.IsValid())
528 FactionAffiliationComponent facComp = FactionAffiliationComponent.Cast(
m_Entity.FindComponent(FactionAffiliationComponent));
532 m_AIGroup.SetFaction(facComp.GetAffiliatedFaction());