Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_TutorialLogic_Commanding.c
Go to the documentation of this file.
3{
4 protected const ResourceName GROUP_PREFAB = "{3BF36BDEEB33AEC9}Prefabs/Groups/BLUFOR/Group_US_SentryTeam.et";
5
6 //------------------------------------------------------------------------------------------------
7 protected void OnEntitySpawned(IEntity ent)
8 {
9 if (!ent || ent.GetPrefabData().GetPrefabName() != GROUP_PREFAB)
10 return;
11
12 ent.SetName("REQUESTING_GROUP");
13 SCR_AIGroup group = SCR_AIGroup.Cast(ent);
14 if (group)
15 group.RemoveWaypoint(group.GetCurrentWaypoint());
16 }
17
18 //------------------------------------------------------------------------------------------------
19 override void OnCourseStart()
20 {
21 SCR_TutorialGamemodeComponent tutorial = SCR_TutorialGamemodeComponent.GetInstance();
22 IEntity playerVeh = GetGame().GetWorld().FindEntityByName("PlayerVehicle");
23 if (tutorial && playerVeh)
24 {
25 tutorial.ChangeVehicleLockState(playerVeh, true);
26 tutorial.GetOnEntitySpawned().Insert(OnEntitySpawned);
27 }
28
29 IEntity ent = GetGame().GetWorld().FindEntityByName("UNIT_REQUESTING_SUPPLIES");
30 if (!ent)
31 return;
32
33 SCR_ResourceComponent resComp = SCR_ResourceComponent.FindResourceComponent(ent);
34 if (!resComp)
35 return;
36
37 SCR_ResourceContainer resourceContainer = resComp.GetContainer(EResourceType.SUPPLIES);
38 if (resourceContainer)
39 resourceContainer.IncreaseResourceValue(150);
40
41 HandleRemnantGroup("OldGroup");
42
43 SCR_CommandingManagerComponent commandingManager = SCR_CommandingManagerComponent.GetInstance();
44 if (commandingManager)
45 commandingManager.SetMaxAIPerGroup(2);
46 }
47
48 //------------------------------------------------------------------------------------------------
49 void HandleRemnantGroup(string groupName)
50 {
51 IEntity oldGroupEnt = GetGame().GetWorld().FindEntityByName(groupName);
52
53 SCR_AIGroup group = SCR_AIGroup.Cast(oldGroupEnt);
54 if (!group)
55 return;
56
57 array <AIAgent> agents = {};
58 group.GetAgents(agents);
59
60 if (!agents || agents.IsEmpty())
61 return;
62
63 for (int i = agents.Count()-1; i >= 0; i--)
64 {
65 SCR_EntityHelper.DeleteEntityAndChildren(agents[i].GetControlledEntity());
66 }
67 }
68
69 //------------------------------------------------------------------------------------------------
70 override void OnCourseEnd()
71 {
72 SCR_ResourceComponent resComp = SCR_ResourceComponent.FindResourceComponent(GetGame().GetWorld().FindEntityByName("UNIT_REQUESTING_SUPPLIES"));
73 if (resComp)
74 {
75 SCR_ResourceContainer resourceContainer = resComp.GetContainer(EResourceType.SUPPLIES);
76 if (resourceContainer)
77 resourceContainer.DecreaseResourceValue(resourceContainer.GetResourceValue());
78 }
79
80 HandleRemnantGroup("REQUESTING_GROUP");
81
82 SCR_CommandingManagerComponent commandingManager = SCR_CommandingManagerComponent.GetInstance();
83 if (commandingManager)
84 commandingManager.SetMaxAIPerGroup(0);
85
86 SCR_TutorialGamemodeComponent tutorial = SCR_TutorialGamemodeComponent.GetInstance();
87 IEntity playerVeh = GetGame().GetWorld().FindEntityByName("PlayerVehicle");
88 if (tutorial && playerVeh)
89 {
90 tutorial.ChangeVehicleLockState(playerVeh, false);
91 tutorial.GetOnEntitySpawned().Remove(OnEntitySpawned);
92 }
93
94 //TODO: GIVE group name and use HandleRemnantGroup, to get rid of redundant code
96 if (!playerController)
97 return;
98
99 SCR_PlayerControllerGroupComponent playerGroupComp = SCR_PlayerControllerGroupComponent.Cast(playerController.FindComponent(SCR_PlayerControllerGroupComponent));
100 if (!playerGroupComp)
101 return;
102
103 SCR_GroupsManagerComponent groupsManager = SCR_GroupsManagerComponent.GetInstance();
104 if (!groupsManager)
105 return;
106
107 SCR_AIGroup group = groupsManager.FindGroup(playerGroupComp.GetGroupID());
108 if (!group)
109 return;
110
111 group = group.GetSlave();
112 if (!group)
113 return;
114
115 group.RemoveWaypoint(group.GetCurrentWaypoint());
116
117 array <AIAgent> agents = {};
118 group.GetAgents(agents);
119
120 if (!agents || agents.IsEmpty())
121 return;
122
123 for (int i = agents.Count()-1; i >= 0; i--)
124 {
125 SCR_EntityHelper.DeleteEntityAndChildren(agents[i].GetControlledEntity());
126 }
127 }
128}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
void SCR_CommandingManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
proto external BaseWorld GetWorld()
proto external void SetName(string name)
proto external EntityPrefabData GetPrefabData()
SCR_AIGroup GetSlave()
bool DecreaseResourceValue(float value, bool notifyChange=true)
bool IncreaseResourceValue(float value, bool notifyChange=true)
SCR_EditableEntityComponent GetControlledEntity()
proto external PlayerController GetPlayerController()