Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CampaignDeployMobileAssemblyUserAction.c
Go to the documentation of this file.
2{
3 protected IEntity m_TruckBed;
4 protected SCR_CampaignMobileAssemblyComponent m_AssemblyComponent;
6
7 static const float MAX_TERRAIN_HEIGHT = 0.5;
8 static const float TERRAIN_SLOPE_THRESHOLD = 0.9;
9
10 //------------------------------------------------------------------------------------------------
11 override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
12 {
13 m_TruckBed = pOwnerEntity;
14
15 if (!m_TruckBed)
16 return;
17
18 m_AssemblyComponent = SCR_CampaignMobileAssemblyComponent.Cast(m_TruckBed.FindComponent(SCR_CampaignMobileAssemblyComponent));
19 }
20
21 //------------------------------------------------------------------------------------------------
23 {
26
27 if (!m_TruckBed)
28 return null;
29
30 IEntity truck = m_TruckBed.GetParent();
31
32 if (!truck)
33 return null;
34
36
38 }
39
40 //------------------------------------------------------------------------------------------------
41 override bool CanBeShownScript(IEntity user)
42 {
43 float depth;
44 if (SCR_WorldTools.IsObjectUnderwater(GetOwner(), vector.Zero, -1, depth) && depth > SCR_CampaignMobileAssemblyComponent.MAX_WATER_DEPTH)
45 return false;
46
48 return false;
49
50 Faction f = SCR_FactionManager.SGetLocalPlayerFaction();
51
52 if (!f)
53 return false;
54
55 if (f != m_AssemblyComponent.GetAffiliatedFaction())
56 return false;
57
59 return false;
60
61 if (m_TruckBed)
62 {
63 IEntity truck = m_TruckBed.GetParent();
64
65 if (truck)
66 {
67 Physics physicsComponent = truck.GetPhysics();
68 vector vel = physicsComponent.GetVelocity();
69 vel[1] = 0; // Ignore Y velocity
70
71 if (physicsComponent && vel.LengthSq() > 0.01)
72 return false;
73 }
74 }
75
76 return !m_AssemblyComponent.IsDeployed();
77 }
78
79 //------------------------------------------------------------------------------------------------
80 override bool CanBePerformedScript(IEntity user)
81 {
83 return false;
84
85 SCR_GameModeCampaign campaign = SCR_GameModeCampaign.GetInstance();
86
87 if (!campaign)
88 return false;
89
90 SCR_CampaignFaction f = m_AssemblyComponent.GetAffiliatedFaction();
91
92 if (!f)
93 return false;
94
95 if (f.GetMobileAssembly())
96 {
97 SetCannotPerformReason("#AR-Campaign_Action_AnotherAssemblyActive-UC");
98 return false;
99 }
100
101 const int playerId = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(user);
102 if (playerId == 0)
103 return false;
104
105 const IEntity playerController = GetGame().GetPlayerManager().GetPlayerController(playerId);
106 if (!playerController)
107 return false;
108
109 SCR_CampaignFeedbackComponent feedbackComponent = SCR_CampaignFeedbackComponent.Cast(playerController.FindComponent(SCR_CampaignFeedbackComponent));
110 if (!feedbackComponent)
111 return false;
112
113 if (feedbackComponent.GetBaseWithPlayer())
114 {
115 SetCannotPerformReason("#AR-Campaign_Action_AnotherHQNearby-UC");
116 return false;
117 }
118
119 bool isInRange = m_AssemblyComponent.IsInRadioRange();
120
121 if (!isInRange)
122 SetCannotPerformReason("#AR-Campaign_Action_NoSignal");
123
124 IEntity truck = m_TruckBed.GetParent();
125
126 if (truck)
127 {
128 vector pos = truck.GetOrigin();
129
131 {
132 SetCannotPerformReason("#AR-Campaign_Action_UnevenTerrain-UC");
133 return false;
134 }
135
136 /*if (SCR_TerrainHelper.GetTerrainNormal(pos)[1] < TERRAIN_SLOPE_THRESHOLD)
137 {
138 SetCannotPerformReason("#AR-Campaign_Action_UnevenTerrain-UC");
139 return false;
140 }*/
141 }
142
143 return isInRange;
144 }
145
146 //------------------------------------------------------------------------------------------------
147 override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
148 {
150 return;
151
152 if (!CanBePerformed(pUserEntity))
153 return;
154
155 int playerId = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(pUserEntity);
156 m_AssemblyComponent.Deploy(SCR_EMobileAssemblyStatus.DEPLOYED, playerId);
157 }
158
159 //------------------------------------------------------------------------------------------------
160 override bool CanBroadcastScript()
161 {
162 return false;
163 }
164}
ArmaReforgerScripted GetGame()
Definition game.c:1398
void SCR_FactionManager(IEntitySource src, IEntity parent)
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
void SetCannotPerformReason(string reason)
proto external IEntity GetOwner()
Returns the parent entity of this action.
proto external bool CanBePerformed(IEntity user)
Can this action be performed by the user?
proto external Managed FindComponent(typename typeName)
proto external vector GetOrigin()
proto external Physics GetPhysics()
override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
SCR_CampaignMobileAssemblyStandaloneComponent GetMobileAssembly()
static float GetHeightAboveTerrain(vector pos, BaseWorld world=null, bool noUnderwater=false, TraceParam trace=null)
EDamageState
proto external EParticleEffectState GetState()