Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CampaignFaction.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
3 {
4  [Attribute("", UIWidgets.ResourceNamePicker, "Defenders group prefab", "et")]
5  private ResourceName m_DefendersGroupPrefab;
6 
7  [Attribute("", params: "et")]
8  protected ref array<ResourceName> m_aStartingVehicles;
9 
10  [Attribute("", UIWidgets.ResourceNamePicker, "", "et")]
11  private ResourceName m_MobileHQPrefab;
12 
13  [Attribute("", UIWidgets.ResourceNamePicker, "For radio operators", "et")]
14  private ResourceName m_RadioPrefab;
15 
16  [Attribute("", UIWidgets.ResourceNamePicker, "HQ composition in small bases", "et")]
17  private ResourceName m_BaseBuildingHQ;
18 
19  [Attribute("", UIWidgets.ResourceNamePicker, "Supply stash composition", "et")]
20  private ResourceName m_BaseBuildingSupplyDepot;
21 
22  protected SCR_CampaignMilitaryBaseComponent m_MainBase;
23  protected SCR_CampaignMilitaryBaseComponent m_PrimaryTarget;
24 
25  protected SCR_CampaignMobileAssemblyStandaloneComponent m_MobileAssembly;
26 
27  protected WorldTimestamp m_fVictoryTimestamp;
28  protected WorldTimestamp m_fPauseByBlockTimestamp;
29 
30  protected int m_iControlPointsHeld;
31 
32  //------------------------------------------------------------------------------------------------
33  void GetStartingVehiclePrefabs(out notnull array<ResourceName> prefabs)
34  {
35  prefabs.Copy(m_aStartingVehicles);
36  }
37 
38  //------------------------------------------------------------------------------------------------
39  void SendHQMessage(SCR_ERadioMsg msgType, int baseCallsign = SCR_MilitaryBaseComponent.INVALID_BASE_CALLSIGN, int calledID = SCR_CampaignMilitaryBaseComponent.INVALID_PLAYER_INDEX, bool public = true, int param = SCR_CampaignRadioMsg.INVALID_RADIO_MSG_PARAM)
40  {
41  if (msgType == SCR_ERadioMsg.NONE)
42  return;
43 
44  SCR_CampaignMilitaryBaseComponent HQ = GetMainBase();
45 
46  if (!HQ)
47  return;
48 
49  BaseRadioComponent radio = BaseRadioComponent.Cast(HQ.GetOwner().FindComponent(BaseRadioComponent));
50 
51  if (!radio || !radio.IsPowered())
52  return;
53 
54  BaseTransceiver transmitter = radio.GetTransceiver(0);
55 
56  if (!transmitter)
57  return;
58 
59  SCR_GameModeCampaign campaign = SCR_GameModeCampaign.GetInstance();
60 
61  if (!campaign)
62  return;
63 
64  SCR_CallsignManagerComponent callsignManager = SCR_CallsignManagerComponent.Cast(campaign.FindComponent(SCR_CallsignManagerComponent));
65 
66  if (!callsignManager)
67  return;
68 
69  IEntity called = GetGame().GetPlayerManager().GetPlayerControlledEntity(calledID);
70  int companyCallsignIndex, platoonCallsignIndex, squadCallsignIndex, characterCallsignIndex;
71 
72  if (called && !callsignManager.GetEntityCallsignIndexes(called, companyCallsignIndex, platoonCallsignIndex, squadCallsignIndex, characterCallsignIndex))
73  return;
74 
76  msg.SetRadioMsg(msgType);
77  msg.SetFactionId(GetGame().GetFactionManager().GetFactionIndex(this));
78  msg.SetBaseCallsign(baseCallsign);
79  msg.SetCalledCallsign(companyCallsignIndex, platoonCallsignIndex, squadCallsignIndex);
80  msg.SetIsPublic(public);
81  msg.SetParam(param);
82  msg.SetPlayerID(calledID);
83  msg.SetEncryptionKey(radio.GetEncryptionKey());
84 
85  transmitter.BeginTransmission(msg);
86  }
87 
88  //------------------------------------------------------------------------------------------------
89  void SetControlPointsHeld(int count)
90  {
91  m_iControlPointsHeld = count;
92  }
93 
94  //------------------------------------------------------------------------------------------------
95  int GetControlPointsHeld()
96  {
97  return m_iControlPointsHeld;
98  }
99 
100  //------------------------------------------------------------------------------------------------
101  void SetMainBase(SCR_CampaignMilitaryBaseComponent mainBase)
102  {
103  m_MainBase = mainBase;
104  }
105 
106  //------------------------------------------------------------------------------------------------
107  void SetPrimaryTarget(SCR_CampaignMilitaryBaseComponent target)
108  {
109  m_PrimaryTarget = target;
110 
111  // Give tasks time to get created before refreshing the priorities
112  GetGame().GetCallqueue().CallLater(RefreshTaskPriorities, SCR_GameModeCampaign.DEFAULT_DELAY);
113  }
114 
115  //------------------------------------------------------------------------------------------------
116  void RefreshTaskPriorities()
117  {
118  SCR_BaseTaskManager taskManager = GetTaskManager();
119 
120  if (!taskManager)
121  return;
122 
123  SCR_CampaignMilitaryBaseManager baseManager = SCR_GameModeCampaign.GetInstance().GetBaseManager();
124 
125  if (!baseManager)
126  return;
127 
128  array<SCR_BaseTask> tasks = {};
129  taskManager.GetFilteredTasks(tasks, this);
130 
131  foreach (SCR_BaseTask task : tasks)
132  {
133  SCR_CampaignTask conflictTask = SCR_CampaignTask.Cast(task);
134 
135  if (!conflictTask)
136  continue;
137 
138  SCR_CampaignMilitaryBaseComponent base = conflictTask.GetTargetBase();
139 
140  if (!base || base.GetFaction() == conflictTask.GetTargetFaction())
141  continue;
142 
143  conflictTask.SetIsPriority(m_PrimaryTarget == base);
144  }
145  }
146 
147  //------------------------------------------------------------------------------------------------
148  SCR_CampaignMilitaryBaseComponent GetPrimaryTarget()
149  {
150  return m_PrimaryTarget;
151  }
152 
153  //------------------------------------------------------------------------------------------------
154  void SetMobileAssembly(SCR_CampaignMobileAssemblyStandaloneComponent mobileAssembly)
155  {
156  m_MobileAssembly = mobileAssembly;
157  }
158 
159  //------------------------------------------------------------------------------------------------
160  ResourceName GetRadioPrefab()
161  {
162  return m_RadioPrefab;
163  }
164 
165  //------------------------------------------------------------------------------------------------
166  ResourceName GetDefendersGroupPrefab()
167  {
168  return m_DefendersGroupPrefab;
169  }
170 
171  //------------------------------------------------------------------------------------------------
172  ResourceName GetMobileHQPrefab()
173  {
174  return m_MobileHQPrefab;
175  }
176 
177  //------------------------------------------------------------------------------------------------
178  ResourceName GetBuildingPrefab(EEditableEntityLabel type)
179  {
180  switch (type)
181  {
182  case EEditableEntityLabel.SERVICE_HQ: {return m_BaseBuildingHQ;};
183  case EEditableEntityLabel.SERVICE_SUPPLY_STORAGE: {return m_BaseBuildingSupplyDepot;};
184  }
185 
186  return ResourceName.Empty;
187  }
188 
189  //------------------------------------------------------------------------------------------------
190  string GetFactionNameUpperCase()
191  {
193 
194  if (UI)
195  return UI.GetFactionNameUpperCase();
196  else
197  return "";
198  }
199 
200  //------------------------------------------------------------------------------------------------
202  {
203  return m_MainBase;
204  }
205 
206  //------------------------------------------------------------------------------------------------
207  SCR_CampaignMobileAssemblyStandaloneComponent GetMobileAssembly()
208  {
209  return m_MobileAssembly;
210  }
211 
212  //------------------------------------------------------------------------------------------------
213  void SetVictoryTimestamp(WorldTimestamp timestamp)
214  {
215  m_fVictoryTimestamp = timestamp;
216  }
217 
218  //------------------------------------------------------------------------------------------------
219  WorldTimestamp GetVictoryTimestamp()
220  {
221  return m_fVictoryTimestamp;
222  }
223 
224  //------------------------------------------------------------------------------------------------
225  void SetPauseByBlockTimestamp(WorldTimestamp timestamp)
226  {
227  m_fPauseByBlockTimestamp = timestamp;
228  }
229 
230  //------------------------------------------------------------------------------------------------
231  WorldTimestamp GetPauseByBlockTimestamp()
232  {
233  return m_fPauseByBlockTimestamp;
234  }
235 };
EEditableEntityLabel
EEditableEntityLabel
Definition: EEditableEntityLabel.c:1
SCR_FactionUIInfo
Definition: SCR_FactionUIInfo.c:3
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
GetFactionIndex
int GetFactionIndex()
Definition: SCR_EditableFactionComponent.c:57
SCR_ERadioMsg
SCR_ERadioMsg
Definition: SCR_CampaignRadioMsg.c:138
SCR_BaseTask
A base class for tasks.
Definition: SCR_BaseTask.c:8
m_aStartingVehicles
protected ref array< IEntity > m_aStartingVehicles
Definition: SCR_CampaignMilitaryBaseComponent.c:88
SCR_GameModeCampaign
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
Definition: SCR_GameModeCampaign.c:1927
SCR_CampaignTask
Definition: SCR_CampaignTask.c:7
GetUIInfo
SCR_UIInfo GetUIInfo()
Definition: SCR_EditableEntityCampaignBuildingModeLabelSetting.c:27
Attribute
typedef Attribute
Post-process effect of scripted camera.
GetTaskManager
SCR_BaseTaskManager GetTaskManager()
Definition: SCR_BaseTaskManager.c:7
SCR_BaseTaskManager
Definition: SCR_BaseTaskManager.c:25
BaseTransceiver
Definition: BaseTransceiver.c:12
UI
@ UI
Definition: EStringTableLabels.c:10
SCR_CampaignMilitaryBaseManager
Created in SCR_GameModeCampaign.
Definition: SCR_CampaignMilitaryBaseManager.c:21
SCR_CampaignFaction
Definition: SCR_CampaignFaction.c:2
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
SCR_CampaignRadioMsg
Definition: SCR_CampaignRadioMsg.c:2
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
SCR_CallsignManagerComponent
Definition: SCR_CallsignManagerComponent.c:12
m_fVictoryTimestamp
protected WorldTimestamp m_fVictoryTimestamp
Definition: SCR_GameModeCampaign.c:115
SCR_Faction
Definition: SCR_Faction.c:6
SCR_CampaignMilitaryBaseComponent
Definition: SCR_CampaignMilitaryBaseComponent.c:38