17 bool m_bSpawnAIOnWPPos;
19 [
Attribute(
desc:
"Default waypoint if any WP group is defined",
"{93291E72AC23930F}Prefabs/AI/Waypoints/AIWaypoint_Defend.et",
category:
"Waypoints")]
22 [
Attribute(defvalue:
"0",
desc:
"Balancing group sizes based on number of players",
category:
"Balance")]
23 bool m_bBalanceOnPlayersCount;
25 [
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")]
26 int m_iMinUnitsInGroup;
28 [
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")]
29 bool m_bExcludeFromDynamicDespawnOnVehicleEntered;
31 [
Attribute(defvalue: SCR_EAIGroupFormation.Wedge.ToString(),
UIWidgets.ComboBox,
"AI group formation",
"", ParamEnumArray.FromEnum(SCR_EAIGroupFormation),
category:
"Common")]
32 SCR_EAIGroupFormation m_eAIGroupFormation;
34 [
Attribute(defvalue: EAISkill.REGULAR.ToString(),
UIWidgets.ComboBox,
"AI skill in combat",
"", ParamEnumArray.FromEnum(EAISkill),
category:
"Common")]
37 [
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")]
38 float m_fPerceptionFactor;
40 [
Attribute(defvalue:
"{000CD338713F2B5A}Prefabs/AI/Groups/Group_Base.et",
category:
"Common")]
43 ref array<AIWaypoint> m_aWaypoints = {};
45 ref array<ResourceName> m_aAIPrefabsForRemoval = {};
47 ref array<SCR_ScenarioFrameworkSlotWaypoint> m_aSlotWaypoints = {};
48 int m_iCurrentlySpawnedWaypoints;
51 bool m_bWaypointsInitialized;
56 void SetAIPrefabsForRemoval(array<ResourceName> arrayForRemoval)
58 m_aAIPrefabsForRemoval = arrayForRemoval;
65 return m_aAIPrefabsForRemoval;
73 override void RestoreToDefault(
bool includeChildren =
false,
bool reinitAfterRestoration =
false,
bool affectRandomization =
true,
bool deleteSpawnedEntities =
true)
77 m_aAIPrefabsForRemoval.Clear();
78 m_aSlotWaypoints.Clear();
79 m_iCurrentlySpawnedWaypoints = 0;
80 m_bWaypointsInitialized =
false;
82 super.RestoreToDefault(includeChildren, reinitAfterRestoration, affectRandomization, deleteSpawnedEntities);
121 m_aWaypoints.Clear();
130 if (!agent || !
Vehicle.Cast(targetEntity))
142 if (!agent || !
Vehicle.Cast(targetEntity))
145 array<AIAgent> agents = {};
146 m_AIGroup.GetAgents(agents);
149 foreach (AIAgent groupAgent : agents)
152 if (character && character.IsInVehicle())
170 if (!m_bWaypointsInitialized &&
173 !m_WaypointSet.m_aLayerName.IsEmpty())
178 return super.InitOtherThings();
219 if (!m_bWaypointsInitialized)
235 m_bGroupWasNull =
false;
238 m_bGroupWasNull =
true;
246 if (!m_aAIPrefabsForRemoval.IsEmpty())
248 foreach (
ResourceName prefabToRemove : m_aAIPrefabsForRemoval)
250 for (
int i = m_AIGroup.m_aUnitPrefabSlots.Count() - 1; i >= 0; i--)
252 if (m_AIGroup.m_aUnitPrefabSlots[i] != prefabToRemove)
255 m_AIGroup.m_aUnitPrefabSlots.Remove(i);
260 else if (m_bBalanceOnPlayersCount)
262 int iMaxUnitsInGroup = m_AIGroup.m_aUnitPrefabSlots.Count();
265 if (iUnitsToSpawn < m_iMinUnitsInGroup)
266 iUnitsToSpawn = m_iMinUnitsInGroup;
268 m_AIGroup.SetMaxUnitsToSpawn(iUnitsToSpawn);
275 m_AIGroup.SetNumberOfMembersToSpawn(1);
280 m_AIGroup.SetMemberSpawnDelay(200);
282 m_AIGroup.SpawnUnits();
295 if (m_AIGroup.GetNumberOfMembersToSpawn() != m_AIGroup.GetAgentsCount())
302 if (m_aSlotWaypoints.IsEmpty())
312 array<AIAgent> agents = {};
313 m_AIGroup.GetAgents(agents);
318 formComp.SetFormation(
SCR_Enum.GetEnumName(SCR_EAIGroupFormation, m_eAIGroupFormation));
323 foreach (
int i, AIAgent agent : agents)
325 IEntity agentEntity = agent.GetControlledEntity();
330 if (basePosition ==
vector.Zero)
332 basePosition = m_AIGroup.GetOrigin();
336 vector formationPosition = basePosition + formDef.GetOffsetPosition(i);
341 float surfaceY = world.GetSurfaceY(formationPosition[0], formationPosition[2]);
342 float oceanY = world.GetOceanHeight(formationPosition[0], formationPosition[2]);
343 formationPosition[1] =
Math.Max(
Math.Max(oceanY, surfaceY), formationPosition[1]);
346 formationPosition = floorPosition;
348 agentEntity.
SetOrigin(formationPosition);
351 SCR_AICombatComponent combatComponent = SCR_AICombatComponent.Cast(agentEntity.
FindComponent(SCR_AICombatComponent));
354 combatComponent.SetAISkill(m_eAISkill);
355 combatComponent.SetPerceptionFactor(m_fPerceptionFactor);
358 if (!m_bExcludeFromDynamicDespawnOnVehicleEntered)
376 foreach (AIAgent agent : agents)
378 IEntity agentEntity = agent.GetControlledEntity();
382 SCR_AICombatComponent combatComponent = SCR_AICombatComponent.Cast(agentEntity.
FindComponent(SCR_AICombatComponent));
385 combatComponent.SetAISkill(m_eAISkill);
386 combatComponent.SetPerceptionFactor(m_fPerceptionFactor);
389 if (!m_bExcludeFromDynamicDespawnOnVehicleEntered)
410 array<string> WaypointSetLayers = {};
411 WaypointSetLayers = m_WaypointSet.m_aLayerName;
412 array<SCR_ScenarioFrameworkLayerBase> layerBases = {};
413 array<SCR_ScenarioFrameworkLayerBase> layerChildren = {};
421 foreach (
string waypointSetLayer : WaypointSetLayers)
423 IEntity layerEntity = world.FindEntityByName(waypointSetLayer);
430 if (layerBases.Contains(layerBase))
433 layerChildren = layerBase.GetChildrenEntities();
437 if (slotWaypoint && !m_aSlotWaypoints.Contains(slotWaypoint))
438 m_aSlotWaypoints.Insert(slotWaypoint);
444 if (slotWaypoint && !m_aSlotWaypoints.Contains(slotWaypoint))
445 m_aSlotWaypoints.Insert(slotWaypoint);
449 int waypointCount = m_aSlotWaypoints.Count();
452 if (waypoint.GetIsInitiated())
453 m_iCurrentlySpawnedWaypoints++;
457 if (waypointCount == m_iCurrentlySpawnedWaypoints)
473 if (!cycleWP.m_bInitiated)
478 else if (cycleWP.m_OnAllWaypointsSpawned)
485 m_iCurrentlySpawnedWaypoints++;
486 if (m_iCurrentlySpawnedWaypoints == m_aSlotWaypoints.Count())
499 else if (!m_bGroupWasNull)
508 m_bWaypointsInitialized =
true;
512 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);
517 if (m_aSlotWaypoints.IsEmpty())
526 waypoint = AIWaypoint.Cast(waypointSlot.GetSpawnedEntity());
528 m_aWaypoints.Insert(waypoint);
539 m_bWaypointsInitialized =
true;
544 m_aWaypoints.RemoveItemOrdered(null);
546 foreach (AIWaypoint waypoint : m_aWaypoints)
548 m_AIGroup.AddWaypoint(waypoint);
551 if (m_aWaypoints.IsEmpty())
553 m_bWaypointsInitialized =
false;
560 AIWaypoint waypoint = m_aWaypoints[0];
561 AIWaypointCycle cycleWaypoint = AIWaypointCycle.Cast(waypoint);
564 array<AIWaypoint> cycleWaypoints = {};
565 cycleWaypoint.GetWaypoints(cycleWaypoints);
566 if (!cycleWaypoints.IsEmpty() && cycleWaypoints[0] != null)
568 waypoint = cycleWaypoints[0];
572 m_bWaypointsInitialized =
false;
585 array<AIAgent> agents = {};
586 m_AIGroup.GetAgents(agents);
588 foreach (
int i, AIAgent agent : agents)
590 IEntity agentEntity = agent.GetControlledEntity();
594 agentEntity.
SetOrigin(waypoint.GetOrigin() + formDef.GetOffsetPosition(i));
607 spawnParams.TransformMode = ETransformMode.WORLD;
608 spawnParams.Transform[3] =
m_Entity.GetOrigin();
611 if (!resWP || !resWP.IsValid())
614 AIWaypoint waypoint = AIWaypoint.Cast(
GetGame().SpawnEntityPrefab(resWP,
GetGame().GetWorld(), spawnParams));
618 m_aWaypoints.Insert(waypoint);
628 if (group.GetAgentsCount() == 0)
641 IEntity agentEntity = agent.GetControlledEntity();
644 Print(
"ScenarioFramework: Decreasing AI member count failed due to not getting AI entity!",
LogLevel.ERROR);
651 Print(
"ScenarioFramework: Decreasing AI member count failed due to not getting entity prefab data",
LogLevel.ERROR);
657 m_aAIPrefabsForRemoval.Insert(resource);
666 paramsPatrol.TransformMode = ETransformMode.WORLD;
668 paramsPatrol.Transform[3] =
m_Entity.GetOrigin();
670 if (!groupResource.IsValid())
677 FactionAffiliationComponent facComp = FactionAffiliationComponent.Cast(
m_Entity.FindComponent(FactionAffiliationComponent));
681 m_AIGroup.
SetFaction(facComp.GetAffiliatedFaction());
682 m_AIGroup.AddAIEntityToGroup(
m_Entity);
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 SCR_ScenarioFrameworkLayerBase(IEntityComponentSource src, IEntity ent, IEntity parent)
ref array< ref SCR_ScenarioFrameworkPlugin > m_aPlugins
int GetMaxPlayersForGameMode(FactionKey factionName="")
bool m_bDynamicallyDespawned
ScriptInvokerBase< ScriptInvokerScenarioFrameworkSlotAIMethod > ScriptInvokerScenarioFrameworkSlotAI
func ScriptInvokerScenarioFrameworkSlotAIMethod
void SCR_ScenarioFrameworkSlotBase(IEntityComponentSource src, IEntity ent, IEntity parent)
array< ResourceName > GetAIPrefabsForRemoval()
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.
ScriptInvoker GetOnAgentRemoved()
static void IgnoreSpawning(bool ignore)
bool SetFaction(Faction faction)
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)
void OnAgentCompartmentLeft(AIAgent agent, IEntity targetEntity, BaseCompartmentManagerComponent manager, int mgrID, int slotID, bool move)
void CheckWaypointsAfterInit(SCR_ScenarioFrameworkLayerBase layer)
override void AfterAllChildrenSpawned(SCR_ScenarioFrameworkLayerBase layer)
void SetWaypointToAI(SCR_ScenarioFrameworkLayerBase layer)
override bool InitOtherThings()
void ActivateAI()
Activates AI group, removes unwanted prefabs, balances units count, sets on agent remove and add even...
void AfterAllAgentsSpawned()
Initializes plugins, actions, and checks for parent layer spawn completion, then sets waypoints for A...
void OnAgentCompartmentEntered(AIAgent agent, IEntity targetEntity, BaseCompartmentManagerComponent manager, int mgrID, int slotID, bool move)
AIWaypoint CreateDefaultWaypoint()
void DecreaseAIGroupMemberCount(SCR_AIGroup group, AIAgent agent)
void InitWaypoints()
Initializes waypoints by finding them in specified layers, adding them to list, and processing them a...
void ProcessWaypoints(SCR_ScenarioFrameworkLayerBase layer)
void OnAgentAdded(AIAgent child)
void SCR_ScenarioFrameworkSlotAI(IEntityComponentSource src, IEntity ent, IEntity parent)
void InitGroupComponents()
Initializes AI group components, sets formation, and combat parameters for agents in the group.
static void InvokeSlotAISpawned(SCR_ScenarioFrameworkLayerBase layer, IEntity entity)
ScriptInvokerScenarioFrameworkLayer GetOnAllWaypointsSpawned()
static bool IsEmptyOrWhiteSpace(string input)
enum EPhysicsLayerPresets Vehicle
IEntity GetOwner()
Owner entity of the fuel tank.
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
proto int ARGB(int a, int r, int g, int b)