Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_TransportTask.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/Tasks", description: "Transport task.")]
3 {
4 };
5 
6 //------------------------------------------------------------------------------------------------
8 {
9  [Attribute("")]
10  protected LocalizedString m_sAssigneeMetText;
11 
12  [Attribute("")]
13  protected LocalizedString m_sRequesterMetText;
14 
15  protected vector m_vTargetPosition = vector.Zero;
16  protected bool m_bVolunteerMet = false;
17 
18  //------------------------------------------------------------------------------------------------
19  bool GetVolunteerMet()
20  {
21  return m_bVolunteerMet;
22  }
23 
24  //------------------------------------------------------------------------------------------------
25  void SetVolunteerMet(bool volunteerMet)
26  {
27  m_bVolunteerMet = volunteerMet;
28 
29  if (volunteerMet)
30  {
31  if (IsAssignedToLocalPlayer())
32  SCR_PopUpNotification.GetInstance().PopupMsg(m_sRequesterMetText, prio: SCR_ECampaignPopupPriority.TASK_DONE);
33  if (IsLocallyRequestedTask())
34  SCR_PopUpNotification.GetInstance().PopupMsg(m_sAssigneeMetText, prio: SCR_ECampaignPopupPriority.TASK_DONE);
35  }
36  }
37 
38  //------------------------------------------------------------------------------------------------
39  void SetTargetPosition(vector targetPosition)
40  {
41  m_vTargetPosition = targetPosition;
42  }
43 
44  //------------------------------------------------------------------------------------------------
45  vector GetTargetPosition()
46  {
47  return m_vTargetPosition;
48  }
49 
50  //------------------------------------------------------------------------------------------------
51  override void OnAssigneeKilled()
52  {
54  return;
55 
57  if (!supportEntity)
58  return;
59 
60  if (GetVolunteerMet())
61  supportEntity.FailTask(this);
62  }
63 
64  //------------------------------------------------------------------------------------------------
65  void PeriodicalCheck()
66  {
67  if (!GetTaskManager())
68  return;
69 
70  SCR_BaseTaskExecutor assignee = GetAssignee();
71  if (!assignee)
72  return;
73 
74  IEntity assigneeEntity = assignee.GetControlledEntity();
75  IEntity requesterEntity = m_Requester.GetControlledEntity();
76 
78  if (!supportEntity)
79  return;
80 
81  if (!GetVolunteerMet())
82  {
83  if (vector.DistanceSq(assigneeEntity.GetOrigin(), requesterEntity.GetOrigin()) > supportEntity.GetMaxDistanceAssigneeSq())
84  return;
85 
86  supportEntity.TransportTaskNextPhase(this);
87  return;
88  }
89  else if (vector.DistanceSq(requesterEntity.GetOrigin(), GetOrigin()) > supportEntity.GetMaxDistanceDestinationSq())
90  return;
91 
92  supportEntity.FinishTask(this);
93  }
94 
95  //------------------------------------------------------------------------------------------------
96  override void Deserialize(ScriptBitReader reader)
97  {
98  super.Deserialize(reader);
99 
100  reader.ReadVector(m_vTargetPosition);
101 
102  bool volunteerMet;
103  reader.ReadBool(volunteerMet);
104  SetVolunteerMet(volunteerMet);
105  }
106 
107  //------------------------------------------------------------------------------------------------
108  override void Serialize(ScriptBitWriter writer)
109  {
110  super.Serialize(writer);
111 
112  vector targetPosition = GetTargetPosition();
113  writer.WriteVector(targetPosition);
114  writer.WriteBool(m_bVolunteerMet);
115  }
116 
117  //------------------------------------------------------------------------------------------------
118  override void EOnInit(IEntity owner)
119  {
120  super.EOnInit(owner);
121 
122  SCR_BaseTaskManager taskManager = GetTaskManager();
123  if (taskManager && taskManager.IsProxy())
124  return;
125 
126  SCR_BaseTaskManager.s_OnPeriodicalCheck2Second.Insert(PeriodicalCheck);
127  }
128 
129  //------------------------------------------------------------------------------------------------
130  void SCR_TransportTask(IEntitySource src, IEntity parent)
131  {
132  SetEventMask(EntityEvent.INIT);
133  }
134 
135  //------------------------------------------------------------------------------------------------
136  void ~SCR_TransportTask()
137  {
138  }
139 
140 };
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
SCR_TransportTaskSupportEntity
Definition: SCR_TransportTaskSupportEntity.c:8
SCR_PopUpNotification
Takes care of dynamic and static onscreen popups.
Definition: SCR_PopupNotification.c:24
GetOrigin
vector GetOrigin()
Definition: SCR_AIUtilityComponent.c:279
IsProxy
protected bool IsProxy()
Definition: SCR_CampaignBuildingCompositionComponent.c:456
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_RequestedTaskClass
Definition: SCR_RequestedTask.c:2
GetTaskManager
SCR_BaseTaskManager GetTaskManager()
Definition: SCR_BaseTaskManager.c:7
SCR_TransportTask
Definition: SCR_TransportTask.c:7
SCR_ECampaignPopupPriority
SCR_ECampaignPopupPriority
Popup message priorities sorted from lowest to highest.
Definition: SCR_CampaignFeedbackComponent.c:1419
SCR_BaseTaskManager
Definition: SCR_BaseTaskManager.c:25
SCR_BaseTaskSupportEntity
Definition: SCR_BaseTaskSupportEntity.c:8
SCR_BaseTaskExecutor
Definition: SCR_BaseTaskExecutor.c:7
SCR_TransportTaskClass
Definition: SCR_TransportTask.c:2
SCR_RequestedTask
Definition: SCR_RequestedTask.c:8
LocalizedString
Definition: LocalizedString.c:21
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180