Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CampaignTask.c
Go to the documentation of this file.
1//------------------------------------------------------------------------------------------------
2//class SCR_CampaignTaskClass: SCR_CampaignBaseTaskClass
3//{
4//};
5
6//------------------------------------------------------------------------------------------------
7//class SCR_CampaignTask : SCR_CampaignBaseTask
8//{
9// static const string CAMPAIGN_TASK_RECONFIGURED_TEXT = "#AR-CampaignTasks_Reconfigured-UC";
10// static const string CAMPAIGN_TASK_RECONFIGURED_BY_TEXT = "#AR-CampaignTasks_ReconfiguredBy-UC";
11//
12// //*****************//
13// //MEMBER ATTRIBUTES//
14// //*****************//
15//
16// [Attribute(defvalue: "Task title for reconfigure.", desc: "The task title visible to the player.")]
17// protected string m_sNameReconfigure;
18// [Attribute(defvalue: "Task description.", desc: "The task description visible to the player.")]
19// protected string m_sDescriptionReconfigure;
20//
21// protected string m_sAffix;
22//
23// //**************************//
24// //PROTECTED MEMBER VARIABLES//
25// //**************************//
26//
27// protected SCR_CampaignTaskType m_eType;
28//
29// //*********************************//
30// //PROTECTED OVERRIDE MEMBER METHODS//
31// //*********************************//
32//
33// //------------------------------------------------------------------------------------------------
34// protected override bool DoneByAssignee()
35// {
36// SCR_BaseTaskExecutor assignee = GetAssignee();
37// if (assignee && m_TargetBase)
38// {
39// int assigneeID = SCR_BaseTaskExecutor.GetTaskExecutorID(assignee);
40// int reconfigurerID = m_TargetBase.GetReconfiguredByID();
41// if (assigneeID == reconfigurerID)
42// return true;
43// }
44//
45// return false;
46// }
47//
48// //------------------------------------------------------------------------------------------------
49// //! Shows a message about this task being available again
50// protected override void ShowAvailableTask(bool afterAssigneeRemoved = false)
51// {
52// SCR_ECannotAssignReasons reason;
53// if (CanBeAssigned(reason))
54// {
55// SCR_GameModeCampaign campaign = SCR_GameModeCampaign.GetInstance();
56// if (campaign)
57// {
58// string text = TASK_AVAILABLE_TEXT + " " + GetTitle();
59// string baseName;
60//
61// if (m_TargetBase)
62// baseName = GetBaseNameWithCallsign();
63//
64// SCR_PopUpNotification.GetInstance().PopupMsg(text, prio: SCR_ECampaignPopupPriority.TASK_AVAILABLE, param1: baseName, text2: TASK_HINT_TEXT, text2param1: SCR_PopUpNotification.TASKS_KEY_IMAGE_FORMAT, sound: SCR_SoundEvent.TASK_CREATED);
65// }
66// }
67// }
68//
69// //------------------------------------------------------------------------------------------------
70// override protected void ShowTaskProgress(bool showMsg = true)
71// {
72// SCR_GameModeCampaign campaign = SCR_GameModeCampaign.GetInstance();
73// if (campaign && showMsg)
74// {
75// string baseName;
76//
77// if (m_TargetBase)
78// baseName = GetBaseNameWithCallsign();
79//
80// SCR_PopUpNotification.GetInstance().PopupMsg(TASK_PROGRESS_TEXT + " " + GetTitle() + " " + TASK_AMOUNT_COMPLETED_TEXT, prio: SCR_ECampaignPopupPriority.TASK_PROGRESS, param1: baseName);
81// }
82// }
83//
84// //******************************//
85// //PUBLIC OVERRIDE MEMBER METHODS//
86// //******************************//
87//
88// //------------------------------------------------------------------------------------------------
89// override string GetIconSuffix()
90// {
91// if (m_TargetBase && m_TargetBase.GetType() == SCR_ECampaignBaseType.RELAY)
92// return "_Relay";
93//
94// return "";
95// }
96//
97// //------------------------------------------------------------------------------------------------
98// override void DoNotifyAssignment(int assigneeID)
99// {
100// if (m_TargetBase.GetType() != SCR_ECampaignBaseType.BASE)
101// return;
102//
103// SCR_CampaignNetworkComponent assigneeNetworkComponent = SCR_CampaignNetworkComponent.GetCampaignNetworkComponent(assigneeID);
104// if (!assigneeNetworkComponent)
105// return;
106//
107// assigneeNetworkComponent.SendPlayerMessage(GetAssignMessage(), m_TargetBase.GetCallsign(), public: false);
108// }
109//
110// //------------------------------------------------------------------------------------------------
111// //! Return the title of this task.
112// override string GetTitle()
113// {
114// if (m_TargetBase && m_TargetBase.GetType() == SCR_ECampaignBaseType.RELAY)
115// return m_sNameReconfigure;
116//
117// return m_sName;
118// }
119//
120// //------------------------------------------------------------------------------------------------
121// override void SetIsPriority(bool isPrio)
122// {
123// super.SetIsPriority(isPrio);
124//
125// if (isPrio)
126// m_sAffix = "<br/><br/>#AR-Campaign_PriorityTaskInfo";
127// else
128// m_sAffix = string.Empty;
129//
130// RegisterTaskUpdate(SCR_ETaskEventMask.TASK_PROPERTY_CHANGED);
131// }
132//
133// //------------------------------------------------------------------------------------------------
134// //! Return the description of this task.
135// override string GetDescription()
136// {
137// if (m_TargetBase && m_TargetBase.GetType() == SCR_ECampaignBaseType.RELAY)
138// return m_sDescriptionReconfigure + m_sAffix;
139//
140// return m_sDescription + m_sAffix;
141// }
142//
143// //------------------------------------------------------------------------------------------------
144// override void Finish(bool showMsg = true)
145// {
146// SCR_MilitaryBaseSystem system = SCR_MilitaryBaseSystem.GetInstance();
147//
148// if (system)
149// system.GetOnBaseFactionChanged().Remove(OnTargetBaseCaptured);
150//
151// showMsg = SCR_FactionManager.SGetLocalPlayerFaction() == m_TargetFaction;
152// super.Finish(showMsg);
153//
154// SCR_XPHandlerComponent comp = SCR_XPHandlerComponent.Cast(GetGame().GetGameMode().FindComponent(SCR_XPHandlerComponent));
155//
156// // Reward XP for seizing a base or reconfiguring a relay
157// if (comp && !GetTaskManager().IsProxy() && GetType() == SCR_CampaignTaskType.CAPTURE)
158// {
159// PlayerManager playerManager = GetGame().GetPlayerManager();
160// array<int> players = {};
161// playerManager.GetPlayers(players);
162// array<SCR_BaseTaskExecutor> assignees = {};
163// GetAssignees(assignees);
164// vector baseOrigin = m_TargetBase.GetOwner().GetOrigin();
165// int radius = m_TargetBase.GetRadius();
166// int radiusSq;
167// Faction playerFaction;
168// IEntity playerEntity;
169// bool isAssignee;
170// int assigneeID;
171// SCR_EXPRewards rewardID;
172//
173// if (m_TargetBase.GetType() == SCR_ECampaignBaseType.RELAY)
174// rewardID = SCR_EXPRewards.RELAY_RECONFIGURED;
175// else
176// rewardID = SCR_EXPRewards.BASE_SEIZED;
177//
178// if (m_TargetBase.GetType() == SCR_ECampaignBaseType.RELAY)
179// radiusSq = 50 * 50;
180// else
181// radiusSq = radius * radius;
182//
183// foreach (int playerId : players)
184// {
185// playerEntity = playerManager.GetPlayerControlledEntity(playerId);
186//
187// if (!playerEntity)
188// continue;
189//
190// playerFaction = SCR_CampaignReconfigureRelayUserAction.GetPlayerFaction(playerEntity);
191//
192// if (playerFaction != m_TargetFaction)
193// continue;
194//
195// if (vector.DistanceSq(playerEntity.GetOrigin(), baseOrigin) < radiusSq)
196// {
197// isAssignee = false;
198//
199// foreach (SCR_BaseTaskExecutor assignee : assignees)
200// {
201// assigneeID = SCR_BaseTaskExecutor.GetTaskExecutorID(assignee);
202//
203// if (assigneeID == playerId)
204// {
205// isAssignee = true;
206// break;
207// }
208// }
209//
210// float multiplier = 1.0;
211//
212// if (m_bIsPriority)
213// multiplier = 1.5;
214//
215// comp.AwardXP(playerId, rewardID, multiplier, isAssignee);
216// }
217// }
218// }
219//
220// string baseName;
221//
222// if (m_TargetBase)
223// baseName = GetBaseNameWithCallsign();
224//
225// if (showMsg)
226// {
227// // TODO make this nicer
228// if (m_bIndividualTask)
229// {
230// if (IsAssignedToLocalPlayer())
231// {
232// if (DoneByAssignee())
233// {
234// SCR_PopUpNotification.GetInstance().PopupMsg(TASK_COMPLETED_TEXT + " " + GetTitle(), prio: SCR_ECampaignPopupPriority.TASK_DONE, param1: baseName, sound: SCR_SoundEvent.TASK_SUCCEED, text2: SCR_BaseTask.TASK_HINT_TEXT, text2param1: SCR_PopUpNotification.TASKS_KEY_IMAGE_FORMAT);
235// }
236// else
237// {
238// SCR_PopUpNotification.GetInstance().PopupMsg(TASK_FAILED_TEXT + " " + GetTitle(), prio: SCR_ECampaignPopupPriority.TASK_DONE, param1: baseName, sound: SCR_SoundEvent.TASK_FAILED);
239// }
240// }
241// else
242// {
243// if (m_aAssignees && m_aAssignees.Count() > 0)
244// {
245// string text;
246// string par1;
247// string par2;
248// string par3;
249// string par4;
250// string par5;
251// GetFinishTextData(text, par1, par2, par3, par4, par5);
252// SCR_PopUpNotification.GetInstance().PopupMsg(text, prio: SCR_ECampaignPopupPriority.TASK_DONE, param1: par1, param2: par2, param3: par3, param4: par4, sound: SCR_SoundEvent.TASK_SUCCEED);
253// }
254// else
255// SCR_PopUpNotification.GetInstance().PopupMsg(TASK_COMPLETED_TEXT + " " + GetTitle(), prio: SCR_ECampaignPopupPriority.TASK_DONE, param1: baseName, sound: SCR_SoundEvent.TASK_SUCCEED, text2: SCR_BaseTask.TASK_HINT_TEXT, text2param1: SCR_PopUpNotification.TASKS_KEY_IMAGE_FORMAT);
256// }
257// }
258// else
259// SCR_PopUpNotification.GetInstance().PopupMsg(TASK_COMPLETED_TEXT + " " + GetTitle(), prio: SCR_ECampaignPopupPriority.TASK_DONE, param1: baseName, sound: SCR_SoundEvent.TASK_SUCCEED, text2: SCR_BaseTask.TASK_HINT_TEXT, text2param1: SCR_PopUpNotification.TASKS_KEY_IMAGE_FORMAT);
260// }
261// }
262//
263// //------------------------------------------------------------------------------------------------
264// //! Fails the task.
265// override void Fail(bool showMsg = true)
266// {
267// showMsg = SCR_FactionManager.SGetLocalPlayerFaction() == m_TargetFaction;
268// super.Fail(showMsg);
269//
270// /*SCR_GameModeCampaign campaign = SCR_GameModeCampaign.GetInstance();
271// if (campaign && showMsg)
272// {
273// string baseName;
274//
275// if (m_TargetBase)
276// baseName = GetBaseNameWithCallsign();
277//
278// SCR_PopUpNotification.GetInstance().PopupMsg(TASK_FAILED_TEXT + " " + GetTitle(), prio: SCR_ECampaignPopupPriority.TASK_DONE, param1: baseName, sound: SCR_SoundEvent.TASK_FAILED);
279// }*/
280// }
281//
282// //------------------------------------------------------------------------------------------------
283// //! Returns a text informing about the task being finished
284// override string GetFinishText()
285// {
286// // TODO Add other types of tasks here once needed...
287// string text = "";
288//
289// switch (m_eType)
290// {
291// case SCR_CampaignTaskType.CAPTURE:
292// {
293// if (m_TargetBase)
294// {
295// //if (m_bIndividualTask && DoneByAssignee())
296// if (false)
297// text = string.Format(CAMPAIGN_TASK_RECONFIGURED_BY_TEXT, GetBaseNameWithCallsign(), GetAllAssigneeNamesString());
298// else
299// text = string.Format(CAMPAIGN_TASK_RECONFIGURED_TEXT, GetBaseNameWithCallsign());
300// }
301// break;
302// };
303// }
304//
305// return text;
306// }
307//
308// //------------------------------------------------------------------------------------------------
309// //! Returns text data informing about the task being finished
310// void GetFinishTextData(out string text = "", out string param1 = "", out string param2 = "", out string param3 = "", out string param4 = "", out string param5 = "")
311// {
312// switch (m_eType)
313// {
314// case SCR_CampaignTaskType.CAPTURE:
315// {
316// if (m_TargetBase)
317// {
318// //if (m_bIndividualTask && DoneByAssignee())
319// if (false)
320// {
321// text = CAMPAIGN_TASK_RECONFIGURED_BY_TEXT;
322// param1 = GetBaseNameWithCallsign();
323// param2 = GetAllAssigneeNamesString();
324// }
325// else
326// {
327// text = CAMPAIGN_TASK_RECONFIGURED_TEXT;
328// param1 = GetBaseNameWithCallsign();
329// }
330// }
331//
332// break;
333// };
334// }
335// }
336//
337// //------------------------------------------------------------------------------------------------
338// override string GetMapDescriptorText()
339// {
340// return GetTaskListTaskText();
341// }
342//
343// //*********************//
344// //PUBLIC MEMBER METHODS//
345// //*********************//
346//
347// //------------------------------------------------------------------------------------------------
348// override void SetTitleWidgetText(notnull TextWidget textWidget, string taskText)
349// {
350// string baseName;
351//
352// if (m_TargetBase)
353// {
354// baseName = GetBaseNameWithCallsign();
355// textWidget.SetTextFormat(taskText, baseName);
356// }
357// else
358// {
359// // m_TargetBase has not been set in time, delay another call
360// GetGame().GetCallqueue().CallLater(SetTitleWidgetText, SCR_GameModeCampaign.UI_UPDATE_DELAY, false, textWidget, taskText);
361// }
362// }
363//
364// //------------------------------------------------------------------------------------------------
365// override string GetTitleText()
366// {
367// string baseName;
368//
369// if (m_TargetBase)
370// baseName = GetBaseNameWithCallsign();
371//
372// return string.Format("%1 %2", m_sName, baseName);
373// }
374//
375// //------------------------------------------------------------------------------------------------
376// override void SetDescriptionWidgetText(notnull TextWidget textWidget, string taskText)
377// {
378// string baseName;
379//
380// if (m_TargetBase)
381// baseName = GetBaseNameWithCallsign();
382//
383// textWidget.SetTextFormat(taskText, baseName);
384// }
385//
386// //------------------------------------------------------------------------------------------------
387// //! Returns the type of this task.
388// SCR_CampaignTaskType GetType()
389// {
390// return m_eType;
391// }
392//
393// //------------------------------------------------------------------------------------------------
394// //! Sets the type of this task.
395// void SetType(SCR_CampaignTaskType type)
396// {
397// m_eType = type;
398// }
399//
400// //***************************//
401// //PUBLIC MEMBER EVENT METHODS//
402// //***************************//
403//
404// //------------------------------------------------------------------------------------------------
405// override void Deserialize(ScriptBitReader reader)
406// {
407// super.Deserialize(reader);
408//
409// SCR_CampaignTaskType type;
410// reader.ReadIntRange(type, 0, SCR_CampaignTaskType.LAST-1);
411// SetType(type);
412// }
413//
414// //------------------------------------------------------------------------------------------------
415// override void Serialize(ScriptBitWriter writer)
416// {
417// super.Serialize(writer);
418//
419// writer.WriteIntRange(GetType(), 0, SCR_CampaignTaskType.LAST-1);
420// }
421//
422// //------------------------------------------------------------------------------------------------
423// override void SetTargetBase(notnull SCR_CampaignMilitaryBaseComponent targetBase)
424// {
425// super.SetTargetBase(targetBase);
426// SCR_MilitaryBaseSystem.GetInstance().GetOnBaseFactionChanged().Insert(OnTargetBaseCaptured);
427// }
428//
429// //------------------------------------------------------------------------------------------------
430// void OnTargetBaseCaptured(SCR_MilitaryBaseComponent base, Faction faction)
431// {
432// if (base != m_TargetBase || !m_TargetFaction || m_eType != SCR_CampaignTaskType.CAPTURE || faction != m_TargetFaction)
433// return;
434//
435// if (!GetTaskManager())
436// return;
437//
438// SCR_BaseTaskSupportEntity supportEntity = GetTaskManager().FindSupportEntity(SCR_BaseTaskSupportEntity);
439//
440// if (!supportEntity)
441// return;
442//
443// supportEntity.FinishTask(this);
444// }
445//
446// //------------------------------------------------------------------------------------------------
447// void OnCampaignBaseSignalChanged(SCR_CampaignMilitaryBaseComponent base)
448// {
449// if (!m_TargetBase || !base || !m_TargetFaction || m_eType != SCR_CampaignTaskType.CAPTURE || base != m_TargetBase)
450// return;
451//
452// SCR_CampaignFaction castFaction = SCR_CampaignFaction.Cast(m_TargetFaction);
453//
454// if (!castFaction)
455// return;
456//
457// if (!GetTaskManager())
458// return;
459//
460// SCR_BaseTaskSupportEntity supportEntity = GetTaskManager().FindSupportEntity(SCR_BaseTaskSupportEntity);
461//
462// if (!supportEntity)
463// return;
464//
465// if (!m_TargetBase.IsHQRadioTrafficPossible(castFaction))
466// supportEntity.FailTask(this);
467// }
468//
469// //------------------------------------------------------------------------------------------------
470// void SCR_CampaignTask(IEntitySource src, IEntity parent)
471// {
472// if (SCR_Global.IsEditMode(this))
473// return;
474//
475// if (!GetTaskManager().IsProxy())
476// {
477// SCR_GameModeCampaign.GetInstance().GetBaseManager().GetOnSignalChanged().Insert(OnCampaignBaseSignalChanged);
478// }
479// }
480//
481// //------------------------------------------------------------------------------------------------
482// void ~SCR_CampaignTask()
483// {
484// if (SCR_Global.IsEditMode(this) || !GetGame().GetGameMode())
485// return;
486//
487// if (!GetTaskManager().IsProxy())
488// {
489// if (m_TargetBase)
490// {
491// SCR_MilitaryBaseSystem system = SCR_MilitaryBaseSystem.GetInstance();
492//
493// if (system)
494// system.GetOnBaseFactionChanged().Remove(OnTargetBaseCaptured);
495// }
496//
497// SCR_GameModeCampaign campaign = SCR_GameModeCampaign.GetInstance();
498//
499// if (campaign)
500// campaign.GetBaseManager().GetOnSignalChanged().Remove(OnCampaignBaseSignalChanged);
501// }
502// }
503//};