Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CampaignSeizingComponent.c
Go to the documentation of this file.
2 {
3 }
4 
5 class SCR_CampaignSeizingComponent : SCR_SeizingComponent
6 {
7  [Attribute("60", params: "0 inf 0.1", category: "Campaign")]
8  protected float m_fExtraTimePerService;
9 
11 
12  //------------------------------------------------------------------------------------------------
13  protected override SCR_Faction EvaluateEntityFaction(IEntity ent)
14  {
15  if (!m_Base || m_Base.IsHQ() || !m_Base.IsInitialized())
16  return null;
17 
18  SCR_Faction faction = super.EvaluateEntityFaction(ent);
19 
20  if (!faction)
21  return null;
22 
23  // Players of faction not covering this base with radio signal should not be able to capture or prevent capture
24  SCR_CampaignFaction cFaction = SCR_CampaignFaction.Cast(faction);
25 
26  if (!cFaction)
27  return null;
28 
29  if (faction.IsPlayable() && !m_Base.IsHQRadioTrafficPossible(cFaction))
30  return null;
31 
32  return faction;
33  }
34 
35  //------------------------------------------------------------------------------------------------
36  override void RefreshSeizingTimer()
37  {
38  if (!m_fSeizingStartTimestamp)
39  return;
40 
41  int servicesCount;
42 
43  if (m_Base)
44  {
45  array<SCR_EServicePointType> checkedTypes = {
46  SCR_EServicePointType.ARMORY,
47  SCR_EServicePointType.HELIPAD,
48  SCR_EServicePointType.BARRACKS,
49  SCR_EServicePointType.RADIO_ANTENNA,
50  SCR_EServicePointType.FIELD_HOSPITAL,
51  SCR_EServicePointType.LIGHT_VEHICLE_DEPOT,
52  SCR_EServicePointType.HEAVY_VEHICLE_DEPOT
53  };
54 
55  foreach (SCR_EServicePointType type : checkedTypes)
56  {
57  if (m_Base.GetServiceByType(type))
58  servicesCount++;
59  }
60  }
61 
62  float seizingTimeVar = m_fMaximumSeizingTime - m_fMinimumSeizingTime;
63  float deduct;
64 
65  if (m_iMaximumSeizingCharacters > 1) // Avoid division by 0
66  {
67  float deductPerPlayer = seizingTimeVar / (m_iMaximumSeizingCharacters - 1);
68  deduct = deductPerPlayer * (m_iSeizingCharacters - 1);
69  }
70 
71  float servicesMultiplier = 1;
72 
73  if ((m_fMaximumSeizingTime - m_fMinimumSeizingTime) > 0)
74  servicesMultiplier = 1 + (servicesCount * (m_fExtraTimePerService / (m_fMaximumSeizingTime - m_fMinimumSeizingTime)));
75 
76  m_fSeizingEndTimestamp = m_fSeizingStartTimestamp.PlusSeconds(servicesMultiplier * (m_fMaximumSeizingTime - deduct));
77 
78  ChimeraWorld world = GetGame().GetWorld();
79  WorldTimestamp currentTime = world.GetServerTimestamp();
80 
81  // Add a tiny delay if removing a service would cause immediate capture
82  if (m_fSeizingEndTimestamp.LessEqual(currentTime))
83  m_fSeizingEndTimestamp = currentTime.PlusMilliseconds(SCR_GameModeCampaign.DEFAULT_DELAY);
84 
85  if (m_bGradualTimerReset && m_fInterruptedCaptureDuration != 0)
86  HandleGradualReset();
87 
88  Replication.BumpMe();
89  OnSeizingTimestampChanged();
90  }
91 
92 // //------------------------------------------------------------------------------------------------
93 // //!
94 // //! \param[in] maxSeizingTime
95 // //! \param[in] minSeizingTime
96 // //! \param[in] extraTime
97 // //! \param[in] players
98 // //! \param[in] services
99 // static void TestValues(float maxSeizingTime, float minSeizingTime, float extraTime, int players, int services)
100 // {
101 // float seizingTimeVar = maxSeizingTime - minSeizingTime;
102 // float deductPerPlayer = seizingTimeVar / 11;
103 // float deduct = deductPerPlayer * (players - 1);
104 // float servicesMultiplier = 1 + (services * (extraTime / (maxSeizingTime - minSeizingTime)));
105 // Print(servicesMultiplier * (maxSeizingTime - deduct));
106 // }
107 
108  //------------------------------------------------------------------------------------------------
109  override void OnBaseRegistered(notnull SCR_MilitaryBaseComponent base)
110  {
111  super.OnBaseRegistered(base);
112 
114 
115  if (!campaignBase)
116  {
117  UnregisterBase(base);
118  base.UnregisterLogicComponent(this);
119  }
120 
121  if (!campaignBase || campaignBase.IsHQ())
122  return;
123 
124  m_Base = campaignBase;
125  }
126 }
ChimeraWorld
Definition: ChimeraWorld.c:12
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_CampaignSeizingComponentClass
Definition: SCR_CampaignSeizingComponent.c:1
OnBaseRegistered
override void OnBaseRegistered(notnull SCR_MilitaryBaseComponent base)
Definition: SCR_CampaignSeizingComponent.c:109
SCR_GameModeCampaign
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
Definition: SCR_GameModeCampaign.c:1927
m_Base
protected SCR_CampaignMilitaryBaseComponent m_Base
Definition: SCR_CampaignServiceCompositionComponent.c:19
SCR_SeizingComponentClass
Definition: SCR_SeizingComponent.c:1
SCR_SeizingComponent
Definition: SCR_SeizingComponent.c:18
RefreshSeizingTimer
override void RefreshSeizingTimer()
Definition: SCR_CampaignSeizingComponent.c:36
SCR_CampaignFaction
Definition: SCR_CampaignFaction.c:2
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
UnregisterBase
void UnregisterBase(notnull SCR_MilitaryBaseComponent base)
Definition: SCR_MilitaryBaseLogicComponent.c:35
SCR_EServicePointType
SCR_EServicePointType
Definition: SCR_ServicePointComponent.c:180
SCR_Faction
Definition: SCR_Faction.c:6
Attribute
SCR_CampaignSeizingComponentClass SCR_SeizingComponentClass Attribute("60", params:"0 inf 0.1", category:"Campaign")
Definition: SCR_CampaignSeizingComponent.c:7
SCR_CampaignMilitaryBaseComponent
Definition: SCR_CampaignMilitaryBaseComponent.c:38
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180