Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CampaignTaskNetworkComponent.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/ScriptWizard", description: "Handles client > server communication in Campaign tasks. Should be attached to PlayerController.", color: "0 0 255 255")]
3 {
4 }
5 
7 {
8 
9  //------------------------------------------------------------------------------------------------
12  {
13  int playerID = GetPlayerId();
14  if (playerID == -1)
15  return;
16 
17  Rpc(RPC_RequestReinforcements, playerID);
18  }
19 
20  //------------------------------------------------------------------------------------------------
24  void RequestTransport(vector positionFrom, vector positionTo)
25  {
26  int playerID = GetPlayerId();
27  if (playerID == -1)
28  return;
29 
30  Rpc(RPC_RequestTransport, playerID, positionFrom, positionTo);
31  }
32 
33  //------------------------------------------------------------------------------------------------
36  void RequestRefuel(vector position)
37  {
38  int playerID = GetPlayerId();
39  if (playerID == -1)
40  return;
41 
42  Rpc(RPC_RequestRefuel, playerID, position);
43  }
44 
45  //------------------------------------------------------------------------------------------------
48  {
49  int playerID = GetPlayerId();
50  if (playerID == -1)
51  return;
52 
53  Rpc(RPC_RequestEvacuation, playerID, position);
54  }
55 
56  //------------------------------------------------------------------------------------------------
58  [RplRpc(RplChannel.Reliable, RplRcver.Server)]
59  protected void RPC_RequestReinforcements(int requesterID)
60  {
62  if (!SCR_CampaignDefendTask.CheckDefendRequestConditions(m_PlayerController, base))
63  return;
64 
65  if (!base)
66  return;
67 
68  SCR_CampaignNetworkComponent networkComponent = SCR_CampaignNetworkComponent.Cast(m_PlayerController.FindComponent(SCR_CampaignNetworkComponent));
69  if (!networkComponent)
70  return;
71 
72  networkComponent.SendPlayerMessage(SCR_ERadioMsg.REQUEST_REINFORCEMENTS, base.GetCallsign(), checkHQReached: true);
73 
74  SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(m_PlayerController.GetMainEntity());
75  if (!character)
76  return;
77 
78  SCR_CampaignFaction requesterFaction = SCR_CampaignFaction.Cast(character.GetFaction());
79  if (!requesterFaction)
80  return;
81 
82  BaseRadioComponent radioComp = GetRadioComponent(m_PlayerController, character);
83  if (!radioComp)
84  return;
85 
86  BaseTransceiver transmitter = radioComp.GetTransceiver(0);
87  if (!transmitter)
88  return;
89 
90  // send message with requester faction and his ID
92  msg.SetTargetFaction(requesterFaction);
93  msg.SetTargetBase(base);
94  //msg.SetRequesterID(requesterID);
95  transmitter.BeginTransmission(msg);
96  }
97 
98  //------------------------------------------------------------------------------------------------
99  [RplRpc(RplChannel.Reliable, RplRcver.Server)]
100  protected void RPC_RequestTransport(int requesterID, vector positionFrom, vector positionTo)
101  {
102  if (GetTaskManager() && GetTaskManager().HasRequestedTask(requesterID))
103  return;
104 
105  SCR_CampaignNetworkComponent networkComponent = SCR_CampaignNetworkComponent.Cast(m_PlayerController.FindComponent(SCR_CampaignNetworkComponent));
106  if (!networkComponent)
107  return;
108 
109  networkComponent.SendPlayerMessage(SCR_ERadioMsg.REQUEST_TRANSPORT, checkHQReached: true);
110 
111  SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(m_PlayerController.GetMainEntity());
112  if (!character)
113  return;
114 
115  SCR_CampaignFaction requesterFaction = SCR_CampaignFaction.Cast(character.GetFaction());
116  if (!requesterFaction)
117  return;
118 
119  BaseRadioComponent radioComp = GetRadioComponent(m_PlayerController, character);
120  if (!radioComp)
121  return;
122 
123  BaseTransceiver transmitter = radioComp.GetTransceiver(0);
124  if (!transmitter)
125  return;
126 
127  // send message with requester faction and his ID
129  msg.SetRequesterMainBase(requesterFaction);
130  msg.SetRequesterID(requesterID);
131  msg.SetPosition(positionFrom);
132  msg.SetTargetPosition(positionTo);
133  transmitter.BeginTransmission(msg);
134  }
135 
136  //------------------------------------------------------------------------------------------------
140  [RplRpc(RplChannel.Reliable, RplRcver.Server)]
141  protected void RPC_RequestRefuel(int requesterID, vector position)
142  {
143  if (GetTaskManager() && GetTaskManager().HasRequestedTask(requesterID))
144  return;
145 
146  SCR_CampaignNetworkComponent networkComponent = SCR_CampaignNetworkComponent.Cast(m_PlayerController.FindComponent(SCR_CampaignNetworkComponent));
147  if (!networkComponent)
148  return;
149 
150  networkComponent.SendPlayerMessage(SCR_ERadioMsg.REQUEST_FUEL, checkHQReached: true);
151 
152  SCR_BaseTaskExecutor taskExecutor = SCR_BaseTaskExecutor.GetTaskExecutorByID(requesterID);
153  if (!taskExecutor)
154  return;
155 
156  Vehicle vehicle = SCR_RefuelTask.GetVehicleExecutorIsIn(taskExecutor);
157  if (!vehicle)
158  return;
159 
160  if (!SCR_RefuelTask.CheckRefuelRequestConditions(taskExecutor))
161  return;
162 
163  SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(m_PlayerController.GetMainEntity());
164  if (!character)
165  return;
166 
167  SCR_CampaignFaction requesterFaction = SCR_CampaignFaction.Cast(character.GetFaction());
168  if (!requesterFaction)
169  return;
170 
171  BaseRadioComponent radioComp = GetRadioComponent(m_PlayerController, character);
172  if (!radioComp)
173  return;
174 
175  BaseTransceiver transmitter = radioComp.GetTransceiver(0);
176  if (!transmitter)
177  return;
178 
179  // send message with requester faction and his ID
181  msg.SetRequesterMainBase(requesterFaction);
182  msg.SetRequesterID(requesterID);
183  msg.SetPosition(position);
184  msg.SetRequesterVehicle(vehicle);
185  transmitter.BeginTransmission(msg);
186  }
187 
188  //------------------------------------------------------------------------------------------------
192  [RplRpc(RplChannel.Reliable, RplRcver.Server)]
193  protected void RPC_RequestEvacuation(int requesterID, vector position)
194  {
195  if (GetTaskManager() && GetTaskManager().HasRequestedTask(requesterID))
196  return;
197 
198  SCR_CampaignNetworkComponent networkComponent = SCR_CampaignNetworkComponent.Cast(m_PlayerController.FindComponent(SCR_CampaignNetworkComponent));
199  if (!networkComponent)
200  return;
201 
202  SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(m_PlayerController.GetMainEntity());
203  if (!character)
204  return;
205 
206  SCR_CampaignMilitaryBaseComponent closestBase = SCR_GameModeCampaign.GetInstance().GetBaseManager().FindClosestBase(character.GetOrigin());
207  if (closestBase)
208  networkComponent.SendPlayerMessage(SCR_ERadioMsg.REQUEST_EVAC, closestBase.GetCallsign(), checkHQReached: true);
209 
210  SCR_CampaignFaction requesterFaction = SCR_CampaignFaction.Cast(character.GetFaction());
211  if (!requesterFaction)
212  return;
213 
214  BaseRadioComponent radioComp = GetRadioComponent(m_PlayerController, character);
215  if (!radioComp)
216  return;
217 
218  BaseTransceiver transmitter = radioComp.GetTransceiver(0);
219  if (!transmitter)
220  return;
221 
222  // send message with requester faction and his ID
224  msg.SetRequesterMainBase(requesterFaction);
225  msg.SetRequesterID(requesterID);
226  msg.SetPosition(position);
227  transmitter.BeginTransmission(msg);
228  }
229 
230  //------------------------------------------------------------------------------------------------
234  BaseRadioComponent GetRadioComponent(PlayerController playerController, ChimeraCharacter character)
235  {
236  SCR_GadgetManagerComponent gadgetManager = SCR_GadgetManagerComponent.Cast(character.FindComponent(SCR_GadgetManagerComponent));
237  if (!gadgetManager)
238  return null;
239 
240  GenericEntity radio = GenericEntity.Cast(gadgetManager.GetGadgetByType(EGadgetType.RADIO));
241  if (!radio)
242  return null;
243 
244  BaseRadioComponent radioComp = BaseRadioComponent.Cast(radio.FindComponent(BaseRadioComponent));
245  if (!radioComp)
246  return null;
247 
248  return radioComp;
249  }
250 
251  //------------------------------------------------------------------------------------------------
254  {
255  int playerID = m_PlayerController.GetPlayerId();
256  return playerID;
257  }
258 
259  //------------------------------------------------------------------------------------------------
260  // constructor
264  void SCR_CampaignTaskNetworkComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
265  {
266  }
267 }
SCR_RefuelTask
Definition: SCR_RefuelTask.c:7
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
SCR_CampaignTaskNetworkComponent
void SCR_CampaignTaskNetworkComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_CampaignTaskNetworkComponent.c:264
SCR_GadgetManagerComponent
Definition: SCR_GadgetManagerComponent.c:138
RPC_RequestRefuel
protected void RPC_RequestRefuel(int requesterID, vector position)
Definition: SCR_CampaignTaskNetworkComponent.c:141
SCR_ERadioMsg
SCR_ERadioMsg
Definition: SCR_CampaignRadioMsg.c:138
RequestRefuel
void RequestRefuel(vector position)
Definition: SCR_CampaignTaskNetworkComponent.c:36
RplRpc
SCR_AchievementsHandlerClass ScriptComponentClass RplRpc(RplChannel.Reliable, RplRcver.Owner)] void UnlockOnClient(AchievementId achievement)
Definition: SCR_AchievementsHandler.c:11
GenericEntity
SCR_GenericBoxEntityClass GenericEntity
SCR_CampaignTaskNetworkComponentClass
Definition: SCR_CampaignTaskNetworkComponent.c:2
SCR_TaskNetworkComponent
void SCR_TaskNetworkComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_TaskNetworkComponent.c:207
SCR_RequestTransportMessage
Definition: SCR_RequestTransportMessage.c:2
SCR_GameModeCampaign
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
Definition: SCR_GameModeCampaign.c:1927
GetRadioComponent
BaseRadioComponent GetRadioComponent(PlayerController playerController, ChimeraCharacter character)
Definition: SCR_CampaignTaskNetworkComponent.c:234
GetTaskManager
SCR_BaseTaskManager GetTaskManager()
Definition: SCR_BaseTaskManager.c:7
RequestTransport
void RequestTransport(vector positionFrom, vector positionTo)
Definition: SCR_CampaignTaskNetworkComponent.c:24
BaseTransceiver
Definition: BaseTransceiver.c:12
RequestReinforcements
SCR_CampaignTaskNetworkComponentClass SCR_TaskNetworkComponentClass RequestReinforcements()
Definition: SCR_CampaignTaskNetworkComponent.c:11
RequestEvacuation
void RequestEvacuation(vector position)
Allows the local player to request evacuation.
Definition: SCR_CampaignTaskNetworkComponent.c:47
SCR_BaseTaskExecutor
Definition: SCR_BaseTaskExecutor.c:7
RPC_RequestEvacuation
protected void RPC_RequestEvacuation(int requesterID, vector position)
Definition: SCR_CampaignTaskNetworkComponent.c:193
m_PlayerController
SCR_CampaignNetworkComponentClass m_PlayerController
Takes care of Campaign-specific server <> client communication and requests.
SCR_CampaignFaction
Definition: SCR_CampaignFaction.c:2
SCR_RequestRefuelMessage
Definition: SCR_RequestRefuelMessage.c:2
SCR_RequestReinforcementsMessage
Definition: SCR_RequestReinforcementsMessage.c:3
SCR_CampaignDefendTask
Definition: SCR_CampaignDefendTask.c:7
SCR_TaskNetworkComponentClass
Definition: SCR_TaskNetworkComponent.c:2
RPC_RequestReinforcements
protected void RPC_RequestReinforcements(int requesterID)
Requests refuel for the vehicle local player is currently in.
Definition: SCR_CampaignTaskNetworkComponent.c:59
position
vector position
Definition: SCR_DestructibleTreeV2.c:30
SCR_RequestEvacuationMessage
Definition: SCR_RequestEvacuationMessage.c:2
GetPlayerId
int GetPlayerId()
Definition: SCR_CampaignTaskNetworkComponent.c:253
SCR_CampaignMilitaryBaseComponent
Definition: SCR_CampaignMilitaryBaseComponent.c:38
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180
RPC_RequestTransport
protected void RPC_RequestTransport(int requesterID, vector positionFrom, vector positionTo)
Definition: SCR_CampaignTaskNetworkComponent.c:100