Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CampaignStruct.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
4 {
5  protected int m_iHours = -1;
6  protected int m_iMinutes = -1;
7  protected int m_iSeconds = -1;
8  protected vector m_vMHQLocationBLUFOR;
9  protected vector m_vMHQRotationBLUFOR;
10  protected vector m_vMHQLocationOPFOR;
11  protected vector m_vMHQRotationOPFOR;
12  protected ref array<ref SCR_CampaignBaseStruct> m_aBasesStructs = {};
13  protected ref array<ref SCR_CampaignRemnantInfoStruct> m_aRemnantsStructs = {};
14  protected ref array<ref SCR_CampaignPlayerStruct> m_aPlayerStructs = {};
15  protected int m_iTutorialStage = -1;
16  protected bool m_bMatchOver;
17  protected string m_sWeatherState;
18  protected int m_iCallsignOffset = SCR_MilitaryBaseComponent.INVALID_BASE_CALLSIGN;
19 
20  //------------------------------------------------------------------------------------------------
21  int GetHours()
22  {
23  return m_iHours;
24  }
25 
26  //------------------------------------------------------------------------------------------------
27  int GetMinutes()
28  {
29  return m_iMinutes;
30  }
31 
32  //------------------------------------------------------------------------------------------------
33  int GetSeconds()
34  {
35  return m_iSeconds;
36  }
37 
38  //------------------------------------------------------------------------------------------------
39  vector GetMHQLocationBLUFOR()
40  {
41  return m_vMHQLocationBLUFOR;
42  }
43 
44  //------------------------------------------------------------------------------------------------
45  vector GetMHQRotationBLUFOR()
46  {
47  return m_vMHQRotationBLUFOR;
48  }
49 
50  //------------------------------------------------------------------------------------------------
51  vector GetMHQLocationOPFOR()
52  {
53  return m_vMHQLocationOPFOR;
54  }
55 
56  //------------------------------------------------------------------------------------------------
57  vector GetMHQRotationOPFOR()
58  {
59  return m_vMHQRotationOPFOR;
60  }
61 
62  //------------------------------------------------------------------------------------------------
63  array <ref SCR_CampaignBaseStruct>GetBasesStructs()
64  {
65  return m_aBasesStructs;
66  }
67 
68  //------------------------------------------------------------------------------------------------
69  array <ref SCR_CampaignRemnantInfoStruct>GetRemnantsStructs()
70  {
71  return m_aRemnantsStructs;
72  }
73 
74  //------------------------------------------------------------------------------------------------
75  array <ref SCR_CampaignPlayerStruct>GetPlayersStructs()
76  {
77  return m_aPlayerStructs;
78  }
79 
80  //------------------------------------------------------------------------------------------------
81  int GetTutorialStage()
82  {
83  return m_iTutorialStage;
84  }
85 
86  //------------------------------------------------------------------------------------------------
87  bool IsMatchOver()
88  {
89  return m_bMatchOver;
90  }
91 
92  //------------------------------------------------------------------------------------------------
93  string GetWeatherState()
94  {
95  return m_sWeatherState;
96  }
97 
98  //------------------------------------------------------------------------------------------------
99  int GetCallsignOffset()
100  {
101  return m_iCallsignOffset;
102  }
103 
104  //------------------------------------------------------------------------------------------------
105  override bool Serialize()
106  {
107  SCR_GameModeCampaign campaign = SCR_GameModeCampaign.GetInstance();
108 
109  if (!campaign)
110  return false;
111 
112  m_bMatchOver = campaign.GetIsMatchOver();
113 
114  Clear();
115 
116  ChimeraWorld world = campaign.GetWorld();
117  TimeAndWeatherManagerEntity timeManager = world.GetTimeAndWeatherManager();
118 
119  if (timeManager)
120  {
121  timeManager.GetHoursMinutesSeconds(m_iHours, m_iMinutes, m_iSeconds);
122  WeatherStateTransitionManager transitionManager = timeManager.GetTransitionManager();
123 
124  if (transitionManager)
125  m_sWeatherState = transitionManager.GetCurrentState().GetStateName();
126  }
127 
128  campaign.GetBaseManager().StoreBasesStates(m_aBasesStructs);
129 
130  SCR_CampaignTutorialArlandComponent tutorial = SCR_CampaignTutorialArlandComponent.Cast(campaign.FindComponent(SCR_CampaignTutorialArlandComponent));
131 
132  if (tutorial)
133  {
134  m_iTutorialStage = tutorial.GetStage();
135  return true;
136  }
137 
138  campaign.StoreRemnantsStates(m_aRemnantsStructs);
139 
140  SCR_CampaignFaction factionBLUFOR = campaign.GetFactionByEnum(SCR_ECampaignFaction.BLUFOR);
141  SCR_CampaignFaction factionOPFOR = campaign.GetFactionByEnum(SCR_ECampaignFaction.OPFOR);
142  IEntity mobileHQ;
143 
144  if (factionBLUFOR && factionBLUFOR.GetMobileAssembly())
145  {
146  mobileHQ = factionBLUFOR.GetMobileAssembly().GetVehicle();
147 
148  if (mobileHQ)
149  {
150  m_vMHQLocationBLUFOR = mobileHQ.GetOrigin();
151  m_vMHQRotationBLUFOR = mobileHQ.GetYawPitchRoll();
152  }
153  }
154 
155  if (factionOPFOR && factionOPFOR.GetMobileAssembly())
156  {
157  mobileHQ = factionOPFOR.GetMobileAssembly().GetVehicle();
158 
159  if (mobileHQ)
160  {
161  m_vMHQLocationOPFOR = mobileHQ.GetOrigin();
162  m_vMHQRotationOPFOR = mobileHQ.GetYawPitchRoll();
163  }
164  }
165 
166  campaign.WriteAllClientsData();
167  array<ref SCR_CampaignClientData> clients = {};
168  campaign.GetClientsData(clients);
169 
170  foreach (SCR_CampaignClientData data : clients)
171  {
173  struct.SetID(data.GetID());
174  struct.SetXP(data.GetXP());
175  struct.SetFactionIndex(data.GetFactionIndex());
176 
177  m_aPlayerStructs.Insert(struct);
178  }
179 
180  m_iCallsignOffset = campaign.GetCallsignOffset();
181 
182  return true;
183  }
184 
185  //------------------------------------------------------------------------------------------------
186  override bool Deserialize()
187  {
188  SCR_GameModeCampaign campaign = SCR_GameModeCampaign.GetInstance();
189 
190  if (!campaign)
191  return false;
192 
193  campaign.StoreLoadedData(this);
194 
195  return true;
196  }
197 
198  //------------------------------------------------------------------------------------------------
199  void Clear()
200  {
201  m_aBasesStructs.Clear();
202  m_aRemnantsStructs.Clear();
203  m_aPlayerStructs.Clear();
204  m_vMHQLocationBLUFOR = vector.Zero;
205  m_vMHQRotationBLUFOR = vector.Zero;
206  m_vMHQLocationOPFOR = vector.Zero;
207  m_vMHQRotationOPFOR = vector.Zero;
208  }
209 
210  //------------------------------------------------------------------------------------------------
214  static string GetResourceId(string resourceName)
215  {
216  int i = resourceName.IndexOf("}");
217 
218  if (i <= 0)
219  return string.Empty;
220 
221  return resourceName.Substring(0, resourceName.IndexOf("}") + 1);
222  }
223 
224  //------------------------------------------------------------------------------------------------
225  void SCR_CampaignStruct()
226  {
227  RegV("m_iHours");
228  RegV("m_iMinutes");
229  RegV("m_iSeconds");
230  RegV("m_vMHQLocationBLUFOR");
231  RegV("m_vMHQRotationBLUFOR");
232  RegV("m_vMHQLocationOPFOR");
233  RegV("m_vMHQRotationOPFOR");
234  RegV("m_aBasesStructs");
235  RegV("m_aRemnantsStructs");
236  RegV("m_aPlayerStructs");
237  RegV("m_iTutorialStage");
238  RegV("m_bMatchOver");
239  RegV("m_sWeatherState");
240  RegV("m_iCallsignOffset");
241  }
242 };
243 
244 //------------------------------------------------------------------------------------------------
246 {
247  // We need to keep these short so save file size is manageable
248  protected bool m_bIsHQ;
249  protected int m_iCSI;
250  protected vector m_vPos;
251  protected int m_iF;
252  protected int m_iS;
253  /*protected string m_sHQP;
254  protected vector m_vHQPos;
255  protected vector m_vHQRot;
256  protected string m_sVDP;
257  protected vector m_vVDPos;
258  protected vector m_vVDRot;
259  protected string m_sArmP;
260  protected vector m_vArmPos;
261  protected vector m_vArmRot;
262  protected string m_sHVDP;
263  protected vector m_vHVDPos;
264  protected vector m_vHVDRot;
265  protected string m_sSDP;
266  protected vector m_vSDPos;
267  protected vector m_vSDRot;
268  protected string m_sAP;
269  protected vector m_vAPos;
270  protected vector m_vARot;
271  protected string m_sFHP;
272  protected vector m_vFHPos;
273  protected vector m_vFHRot;
274  protected string m_sBP;
275  protected vector m_vBPos;
276  protected vector m_vBRot;*/
277 
278  //------------------------------------------------------------------------------------------------
279  bool IsHQ()
280  {
281  return m_bIsHQ;
282  }
283 
284  //------------------------------------------------------------------------------------------------
285  int GetCallsignIndex()
286  {
287  return m_iCSI;
288  }
289 
290  vector GetPosition()
291  {
292  return m_vPos;
293  }
294 
295  //------------------------------------------------------------------------------------------------
296  int GetSupplies()
297  {
298  return m_iS;
299  }
300 
301  //------------------------------------------------------------------------------------------------
302  int GetFaction()
303  {
304  return m_iF;
305  }
306 
307  //------------------------------------------------------------------------------------------------
308  /*string GetHQPrefab()
309  {
310  return m_sHQP;
311  }
312 
313  //------------------------------------------------------------------------------------------------
314  vector GetHQPosition()
315  {
316  return m_vHQPos;
317  }
318 
319  //------------------------------------------------------------------------------------------------
320  vector GetHQRotation()
321  {
322  return m_vHQRot;
323  }
324 
325  //------------------------------------------------------------------------------------------------
326  string GetServicePrefab(SCR_EServicePointType type)
327  {
328  switch (type)
329  {
330  case SCR_EServicePointType.LIGHT_VEHICLE_DEPOT: {return m_sVDP;};
331  case SCR_EServicePointType.ARMORY: {return m_sArmP;};
332  case SCR_EServicePointType.HEAVY_VEHICLE_DEPOT: {return m_sHVDP;};
333  case SCR_EServicePointType.SUPPLY_DEPOT: {return m_sSDP;};
334  case SCR_EServicePointType.RADIO_ANTENNA: {return m_sAP;};
335  case SCR_EServicePointType.FIELD_HOSPITAL: {return m_sFHP;};
336  case SCR_EServicePointType.BARRACKS: {return m_sBP;};
337  }
338 
339  return string.Empty;
340  }
341 
342  //------------------------------------------------------------------------------------------------
343  vector GetServicePosition(SCR_EServicePointType type)
344  {
345  switch (type)
346  {
347  case SCR_EServicePointType.LIGHT_VEHICLE_DEPOT: {return m_vVDPos;};
348  case SCR_EServicePointType.ARMORY: {return m_vArmPos;};
349  case SCR_EServicePointType.HEAVY_VEHICLE_DEPOT: {return m_vHVDPos;};
350  case SCR_EServicePointType.SUPPLY_DEPOT: {return m_vSDPos;};
351  case SCR_EServicePointType.RADIO_ANTENNA: {return m_vAPos;};
352  case SCR_EServicePointType.FIELD_HOSPITAL: {return m_vFHPos;};
353  case SCR_EServicePointType.BARRACKS: {return m_vBPos;};
354  }
355 
356  return vector.Zero;
357  }
358 
359  //------------------------------------------------------------------------------------------------
360  vector GetServiceRotation(SCR_EServicePointType type)
361  {
362  switch (type)
363  {
364  case SCR_EServicePointType.LIGHT_VEHICLE_DEPOT: {return m_vVDRot;};
365  case SCR_EServicePointType.ARMORY: {return m_vArmRot;};
366  case SCR_EServicePointType.HEAVY_VEHICLE_DEPOT: {return m_vHVDRot;};
367  case SCR_EServicePointType.SUPPLY_DEPOT: {return m_vSDRot;};
368  case SCR_EServicePointType.RADIO_ANTENNA: {return m_vARot;};
369  case SCR_EServicePointType.FIELD_HOSPITAL: {return m_vFHRot;};
370  case SCR_EServicePointType.BARRACKS: {return m_vBRot;};
371  }
372 
373  return vector.Zero;
374  }*/
375 
376  //------------------------------------------------------------------------------------------------
377  void SetIsHQ(bool hq)
378  {
379  m_bIsHQ = hq;
380  }
381 
382  //------------------------------------------------------------------------------------------------
383  void SetCallsignIndex(int callsign)
384  {
385  m_iCSI = callsign;
386  }
387 
388  //------------------------------------------------------------------------------------------------
389  void SetPosition(vector position)
390  {
391  m_vPos = position;
392  }
393 
394  //------------------------------------------------------------------------------------------------
395  void SetSupplies(int supplies)
396  {
397  m_iS = supplies;
398  }
399 
400  //------------------------------------------------------------------------------------------------
401  void SetOwningFaction(int owningFaction)
402  {
403  m_iF = owningFaction;
404  }
405 
406  //------------------------------------------------------------------------------------------------
407  /*void SetBuildingsData(notnull SCR_CampaignMilitaryBaseComponent base)
408  {
409  array<SCR_ServicePointComponent> services = {};
410  base.GetServices(services);
411 
412  IEntity composition = SCR_EntityHelper.GetMainParent(base.GetHQRadio());
413  EntityPrefabData data;
414  ResourceName prefab;
415 
416  if (composition)
417  {
418  data = composition.GetPrefabData();
419 
420  if (data)
421  {
422  prefab = data.GetPrefabName();
423 
424  if (!prefab.IsEmpty())
425  {
426  m_sHQP = SCR_CampaignStruct.GetResourceId(prefab);
427  m_vHQPos = composition.GetOrigin();
428  m_vHQRot = composition.GetYawPitchRoll();
429  }
430  }
431  }
432 
433  foreach (SCR_ServicePointComponent service : services)
434  {
435  composition = SCR_EntityHelper.GetMainParent(service.GetOwner(), true);
436 
437  if (!composition)
438  continue;
439 
440  data = composition.GetPrefabData();
441 
442  if (!data)
443  continue;
444 
445  prefab = data.GetPrefabName();
446 
447  if (prefab.IsEmpty())
448  continue;
449 
450  switch (service.GetType())
451  {
452  case SCR_EServicePointType.LIGHT_VEHICLE_DEPOT:
453  {
454  m_sVDP = SCR_CampaignStruct.GetResourceId(prefab);
455  m_vVDPos = composition.GetOrigin();
456  m_vVDRot = composition.GetYawPitchRoll();
457  break;
458  }
459 
460  case SCR_EServicePointType.ARMORY:
461  {
462  m_sArmP = SCR_CampaignStruct.GetResourceId(prefab);
463  m_vArmPos = composition.GetOrigin();
464  m_vArmRot = composition.GetYawPitchRoll();
465  break;
466  }
467 
468  case SCR_EServicePointType.HEAVY_VEHICLE_DEPOT:
469  {
470  m_sHVDP = SCR_CampaignStruct.GetResourceId(prefab);
471  m_vHVDPos = composition.GetOrigin();
472  m_vHVDRot = composition.GetYawPitchRoll();
473  break;
474  }
475 
476  case SCR_EServicePointType.SUPPLY_DEPOT:
477  {
478  m_sSDP = SCR_CampaignStruct.GetResourceId(prefab);
479  m_vSDPos = composition.GetOrigin();
480  m_vSDRot = composition.GetYawPitchRoll();
481  break;
482  }
483 
484  case SCR_EServicePointType.RADIO_ANTENNA:
485  {
486  m_sAP = SCR_CampaignStruct.GetResourceId(prefab);
487  m_vAPos = composition.GetOrigin();
488  m_vARot = composition.GetYawPitchRoll();
489  break;
490  }
491 
492  case SCR_EServicePointType.FIELD_HOSPITAL:
493  {
494  m_sFHP = SCR_CampaignStruct.GetResourceId(prefab);
495  m_vFHPos = composition.GetOrigin();
496  m_vFHRot = composition.GetYawPitchRoll();
497  break;
498  }
499 
500  case SCR_EServicePointType.BARRACKS:
501  {
502  m_sBP = SCR_CampaignStruct.GetResourceId(prefab);
503  m_vBPos = composition.GetOrigin();
504  m_vBRot = composition.GetYawPitchRoll();
505  break;
506  }
507  }
508  }
509  }*/
510 
511  //------------------------------------------------------------------------------------------------
512  override void OnExpand()
513  {
514  Print("OnExpand()");
515  }
516 
517  //------------------------------------------------------------------------------------------------
518  override void OnItemObject(int index, string name)
519  {
520  }
521 
522  //------------------------------------------------------------------------------------------------
523  override void OnPack()
524  {
525  }
526 
527  //------------------------------------------------------------------------------------------------
528  override void OnObject( string name )
529  {
530  }
531 
532  //------------------------------------------------------------------------------------------------
533  override void OnError(int errorCode)
534  {
535  Print("OnError: " + errorCode);
536  }
537 
538  //------------------------------------------------------------------------------------------------
539  override void OnSuccess( int errorCode )
540  {
541  Print("OnSuccess: " + errorCode );
542  }
543 
544  //------------------------------------------------------------------------------------------------
546  {
547  RegV("m_bIsHQ");
548  RegV("m_iCSI");
549  RegV("m_vPos");
550  RegV("m_iF");
551  RegV("m_iS");
552  /*RegV("m_sHQP");
553  RegV("m_vHQPos");
554  RegV("m_vHQRot");
555  RegV("m_sVDP");
556  RegV("m_vVDPos");
557  RegV("m_vVDRot");
558  RegV("m_sArmP");
559  RegV("m_vArmPos");
560  RegV("m_vArmRot");
561  RegV("m_sHVDP");
562  RegV("m_vHVDPos");
563  RegV("m_vHVDRot");
564  RegV("m_sSDP");
565  RegV("m_vSDPos");
566  RegV("m_vSDRot");
567  RegV("m_sAP");
568  RegV("m_vAPos");
569  RegV("m_vARot");
570  RegV("m_sFHP");
571  RegV("m_vFHPos");
572  RegV("m_vFHRot");
573  RegV("m_sBP");
574  RegV("m_vBPos");
575  RegV("m_vBRot");*/
576  }
577 };
578 
579 //------------------------------------------------------------------------------------------------
581 {
582  protected int m_iID;
583  protected int m_iSize;
584  protected float m_fR;
585 
586  //------------------------------------------------------------------------------------------------
587  int GetID()
588  {
589  return m_iID;
590  }
591 
592  //------------------------------------------------------------------------------------------------
593  int GetMembersAlive()
594  {
595  return m_iSize;
596  }
597 
598  //------------------------------------------------------------------------------------------------
599  float GetRespawnTimer()
600  {
601  return m_fR;
602  }
603 
604  //------------------------------------------------------------------------------------------------
605  void SetID(int ID)
606  {
607  m_iID = ID;
608  }
609 
610  //------------------------------------------------------------------------------------------------
611  void SetMembersAlive(int count)
612  {
613  m_iSize = count;
614  }
615 
616  //------------------------------------------------------------------------------------------------
617  void SetRespawnTimer(float timer)
618  {
619  m_fR = timer;
620  }
621 
622  //------------------------------------------------------------------------------------------------
624  {
625  RegV("m_iID");
626  RegV("m_iSize");
627  RegV("m_fR");
628  }
629 };
630 
631 //------------------------------------------------------------------------------------------------
633 {
634  static const string LOCAL_PLAYER_IDENTITY_ID = "identitySP";
635 
636  protected string m_sID;
637  protected int m_iF = -1;
638  protected int m_iXP;
639 
640  //------------------------------------------------------------------------------------------------
641  string GetID()
642  {
643  return m_sID;
644  }
645 
646  //------------------------------------------------------------------------------------------------
647  int GetFactionIndex()
648  {
649  return m_iF;
650  }
651 
652  //------------------------------------------------------------------------------------------------
653  int GetXP()
654  {
655  return m_iXP;
656  }
657 
658  //------------------------------------------------------------------------------------------------
659  void SetID(string ID)
660  {
661  m_sID = ID;
662  }
663 
664  //------------------------------------------------------------------------------------------------
665  void SetFactionIndex(int index)
666  {
667  m_iF = index;
668  }
669 
670  //------------------------------------------------------------------------------------------------
671  void SetXP(int xp)
672  {
673  m_iXP = xp;
674  }
675 
676  //------------------------------------------------------------------------------------------------
677  static string GetPlayerIdentity(int playerId)
678  {
679  if (playerId <= 0)
680  return string.Empty;
681 
682  if (RplSession.Mode() == RplMode.None)
683  return LOCAL_PLAYER_IDENTITY_ID;
684 
685  BackendApi api = GetGame().GetBackendApi();
686 
687  if (!api)
688  return string.Empty;
689 
690  return api.GetPlayerIdentityId(playerId);
691  }
692 
693  //------------------------------------------------------------------------------------------------
695  {
696  RegV("m_sID");
697  RegV("m_iF");
698  RegV("m_iXP");
699  }
700 };
WeatherStateTransitionManager
Definition: WeatherStateTransitionManager.c:7
ChimeraWorld
Definition: ChimeraWorld.c:12
SCR_ECampaignFaction
SCR_ECampaignFaction
Definition: SCR_CampaignFactionManager.c:130
m_iHours
protected int m_iHours
Definition: SCR_WristwatchComponent.c:51
Clear
void Clear(GenericEntity entity)
Definition: SCR_GadgetManagerComponent.c:105
SCR_CampaignClientData
Used for storing client data to be reapplied for reconnecting clients.
Definition: SCR_CampaignClientData.c:3
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_iID
protected int m_iID
Definition: SCR_AmbientPatrolSpawnPointComponent.c:42
m_iCallsignOffset
protected int m_iCallsignOffset
Definition: SCR_GameModeCampaign.c:124
SCR_GameModeCampaign
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
Definition: SCR_GameModeCampaign.c:1927
m_bMatchOver
protected bool m_bMatchOver
Definition: SCR_GameModeCampaign.c:102
m_iSeconds
SCR_WristwatchComponentClass m_iSeconds
SCR_CampaignBaseStruct
Definition: SCR_CampaignStruct.c:245
m_bIsHQ
protected bool m_bIsHQ
Definition: SCR_CampaignMilitaryBaseComponent.c:119
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
SCR_CampaignPlayerStruct
Definition: SCR_CampaignStruct.c:632
m_iMinutes
protected int m_iMinutes
Definition: SCR_WristwatchComponent.c:50
SCR_CampaignFaction
Definition: SCR_CampaignFaction.c:2
data
Get all prefabs that have the spawner data
Definition: SCR_EntityCatalogManagerComponent.c:305
SCR_JsonApiStruct
Definition: SCR_JsonApiStruct.c:5
position
vector position
Definition: SCR_DestructibleTreeV2.c:30
SCR_CampaignRemnantInfoStruct
Definition: SCR_CampaignStruct.c:580
SCR_CampaignStruct
Definition: SCR_CampaignStruct.c:3
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468
Deserialize
override void Deserialize(SCR_EditableEntityComponent target, int targetValue)
Definition: SCR_EditableCharacterComponent.c:758