Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ScenarioFrameworkAIActionSplitGroup.c
Go to the documentation of this file.
3{
4 [Attribute(desc: "SlotAI for new group")];
6
7 [Attribute(defvalue: "0", desc: "Determines, how much AI's should split to new group", params: "0 inf")]
8 int m_iSplitCount;
9
10 [Attribute(defvalue: "", desc: "Prefabs to transfer (optional)")]
11 ref array<ResourceName> m_aPrefabFilter;
12
13 [Attribute(defvalue: "{000CD338713F2B5A}Prefabs/AI/Groups/Group_Base.et")]
14 ResourceName m_sGroupPrefab;
15
16 //------------------------------------------------------------------------------------------------
17 override void OnActivate()
18 {
20 if (!slotAI)
21 {
22 Print(string.Format("ScenarioFramework Action: No SlotAI found on for %1.", this), LogLevel.ERROR);
23 return;
24 }
25
26 array<AIAgent> agents = {};
27 m_AIGroup.GetAgents(agents);
28 if (agents.IsEmpty())
29 return;
30
31 int ageitnCount = agents.Count();
32
33 //filter out unallowed prefabs
34 if (!m_aPrefabFilter)
35 {
36 IEntity controlledEntity;
37 for (int i = agents.Count()-1; i >= 0; i--)
38 {
39 controlledEntity = agents[i].GetControlledEntity();
40 if (!controlledEntity)
41 continue;
42
43 if (!m_aPrefabFilter.Contains(controlledEntity.GetPrefabData().GetPrefabName()))
44 agents.Remove(i);
45 }
46 }
47
48 ageitnCount = agents.Count();
49 if (agents.Count() <= m_iSplitCount)
50 {
51 Print("SCR_ScenarioFrameworkAIActionSplitGroup: Original group doesn't have enough AI's", LogLevel.ERROR);
52 return;
53 }
54
55 agents.Resize(m_iSplitCount);
56
57 AIGroup group = AIGroup.Cast(GetGame().SpawnEntityPrefab(Resource.Load(m_sGroupPrefab)));
58 if (!group)
59 return;
60
61 foreach (AIAgent agent : agents)
62 {
63 group.AddAgent(agent);
64 }
65
66 slotAI.m_Entity = group;
67 slotAI.m_AIGroup = SCR_AIGroup.Cast(group);
68 }
69
70 //------------------------------------------------------------------------------------------------
72 {
73 if (!m_Getter)
74 return null;
75
76 SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Getter.Get());
77 if (!entityWrapper)
78 {
79 Print(string.Format("ScenarioFramework Action: Issue with Getter detected for Action %1.", this), LogLevel.ERROR);
80 return null;
81 }
82
83 IEntity entity = entityWrapper.GetValue();
84 if (!entity)
85 {
86 Print(string.Format("ScenarioFramework Action: Entity not found for Action %1.", this), LogLevel.ERROR);
87 return null;
88 }
89
91 }
92}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
override void OnActivate()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external Managed FindComponent(typename typeName)
proto external EntityPrefabData GetPrefabData()
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute