Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_HealSupportStationComponent.c
Go to the documentation of this file.
1[ComponentEditorProps(category: "GameScripted/SupportStation", description: "")]
3{
4 [Attribute("SOUND_HEAL_SELF", desc: "Sound effect played when heal is updated and not done. Broadcast to players. Leave empty if no sfx", category: "Heal/Repair Support Station")]
6
7 protected ref SCR_AudioSourceConfiguration m_OnHealBloodUpdateAudioSourceConfiguration;
8
9 //------------------------------------------------------------------------------------------------
19}
20
21class SCR_HealSupportStationComponent : SCR_BaseDamageHealSupportStationComponent
22{
23 [Attribute("1000", desc: "Max blood amount healed each execute. If you hold the action it will heal each time the action ends", category: "Heal/Repair Support Station")]
24 protected float m_iBloodHealedEachExecute;
26 [Attribute("100", desc: "Supply cost for ever 'm_iBloodHealedEachExecute' damage healed. If the left over blood amount is less then it will of course be cheaper with a min value of 1", category: "Heal/Repair Support Station")]
27 protected int m_iSupplyCostBloodHealed;
28
29 [Attribute("1", desc: "The max blood scaled that this support station can heal. 1 == 100%", params: "0.01 1", category: "Heal/Repair Support Station")]
30 protected float m_fMaxBloodScaled;
32 //------------------------------------------------------------------------------------------------
34 {
35 return ESupportStationType.HEAL;
36 }
37
38 //------------------------------------------------------------------------------------------------
39 protected override float GetDamageOrStateToHeal(IEntity actionOwner, IEntity actionUser, notnull SCR_BaseDamageHealSupportStationAction action, out EDamageType activeDoT, out notnull array<HitZone> hitZones)
40 {
41 float damageToHeal = super.GetDamageOrStateToHeal(actionOwner, actionUser, action, activeDoT, hitZones);
42 if (damageToHeal > 0)
43 return damageToHeal;
44
46 if (!healAction)
47 return damageToHeal;
48
49 HitZone bloodHitZone = healAction.GetBloodHitZoneToHeal();
50 if (!bloodHitZone)
51 return damageToHeal;
52
53 hitZones.Clear();
54 hitZones.Insert(bloodHitZone);
55
56 return Math.Clamp(action.GetActionDamageManager().GetHitZonesDamage(m_fMaxBloodScaled, hitZones), 0, m_iBloodHealedEachExecute);
57 }
58
59 //------------------------------------------------------------------------------------------------
60 protected override int GetSupplyAmountAction(IEntity actionOwner, IEntity actionUser, SCR_BaseUseSupportStationAction action)
61 {
62 if (!AreSuppliesEnabled())
63 return 0;
64
66
67 array<HitZone> hitZones = {};
68 EDamageType activeDoT;
69 float damageToHeal = GetDamageOrStateToHeal(actionOwner, actionUser, damageHealAction, activeDoT, hitZones);
70 if (activeDoT != -1)
71 return super.GetSupplyAmountAction(actionOwner, actionUser, action);
72
73 //~ Not a character
75 if (!characterDamageManager)
76 return super.GetSupplyAmountAction(actionOwner, actionUser, action);
77
78 HitZone bloodHitZone = characterDamageManager.GetBloodHitZone();
79
80 //~ No blood hitZone or bloodhitZone full health, use default logic
81 if (hitZones.Count() != 1 || hitZones[0] != bloodHitZone)
82 return super.GetSupplyAmountAction(actionOwner, actionUser, action);
83
84 //~ Calculate the supply cost
85 float bloodHealCost = (damageToHeal / m_iBloodHealedEachExecute) * m_iSupplyCostBloodHealed;
86
87 return Math.Ceil(bloodHealCost + m_iBaseSupplyCostOnUse);
88 }
89
90 //------------------------------------------------------------------------------------------------
91 override void OnExecutedServer(notnull IEntity actionOwner, notnull IEntity actionUser, notnull SCR_BaseUseSupportStationAction action)
92 {
94 array<HitZone> hitZones = {};
95 EDamageType activeDoT;
96 float damageToHeal = GetDamageOrStateToHeal(actionOwner, actionUser, damageHealAction, activeDoT, hitZones);
97 if (activeDoT != -1)
98 {
99 super.OnExecutedServer(actionOwner, actionUser, action);
100 return;
101 }
102
103 //~ Not a character
105 if (!characterDamageManager)
106 {
107 super.OnExecutedServer(actionOwner, actionUser, action);
108 return;
109 }
110 HitZone bloodHitZone = characterDamageManager.GetBloodHitZone();
111
112 //~ No blood hitZone or bloodhitZone full health, use default logic
113 if (hitZones.Count() != 1 || hitZones[0] != bloodHitZone)
114 {
115 super.OnExecutedServer(actionOwner, actionUser, action);
116 return;
117 }
118
119 //~ Consume supplies
120 if (AreSuppliesEnabled())
121 {
122 //~ Failed to consume supplies, meaning there weren't enough supplies for the action
123 if (!OnConsumeSuppliesServer(GetSupplyAmountAction(actionOwner, actionUser, action)))
124 return;
125 }
126
127 //~ Heal the blood hitZone
128 characterDamageManager.HealHitZones(damageToHeal, true, m_fMaxBloodScaled, hitZones);
129
130 //~ Get healstate
132 if (bloodHitZone.GetHealthScaled() < m_fMaxBloodScaled)
133 healState = SCR_EDamageSupportStationHealState.BLOOD_UPDATE;
134 else if (m_fMaxBloodScaled < 1 && bloodHitZone.GetHealthScaled() == m_fMaxBloodScaled)
135 healState = SCR_EDamageSupportStationHealState.BLOOD_DONE_NOT_FULL_HEAL;
136 else
137 healState = SCR_EDamageSupportStationHealState.BLOOD_DONE;
138
139 RplId ownerId;
140 RplId userId;
141 int playerId;
142 FindEntityIds(actionOwner, actionUser, ownerId, userId, playerId);
143
144 OnExecuteDamageSystem(actionOwner, actionUser, healState, SCR_BaseDamageHealSupportStationAction.Cast(action), bloodHitZone.GetHealthScaled());
145 Rpc(OnExecuteDamageSystemBroadcast, ownerId, userId, healState, action.GetActionID(), bloodHitZone.GetHealthScaled());
146 }
147
148 //------------------------------------------------------------------------------------------------
149 protected override void OnExecuteDamageSystem(IEntity actionOwner, IEntity actionUser, SCR_EDamageSupportStationHealState healState, SCR_BaseDamageHealSupportStationAction action, float healthScaled)
150 {
151 //~ Could not send notification as unknown owner or user
152 if (!actionOwner || !actionUser)
153 {
154 //~ Action was still succesfully executed
155 OnSuccessfullyExecuted(actionOwner, actionUser, action);
156 return;
157 }
158
159 bool isBloodHealState = false;
160
161 //~ Play sound effect
163 if (classData)
164 {
165 switch (healState)
166 {
167 case SCR_EDamageSupportStationHealState.BLOOD_UPDATE :
168 {
169 isBloodHealState = true;
170 PlaySoundEffect(classData.GetOnHealBloodUpdateAudioConfig(), actionOwner, action);
171 break;
172 }
173 case SCR_EDamageSupportStationHealState.BLOOD_DONE_NOT_FULL_HEAL :
174 {
175 isBloodHealState = true;
176 PlaySoundEffect(GetOnUseAudioConfig(), actionOwner, action);
177 break;
178 }
179 case SCR_EDamageSupportStationHealState.BLOOD_DONE :
180 {
181 isBloodHealState = true;
182 PlaySoundEffect(GetOnUseAudioConfig(), actionOwner, action);
183
184 //~ Play done voice event (if any)
185 PlayCharacterVoiceEvent(actionUser);
186 break;
187 }
188 }
189 }
190
191 //~ Blood not healed, use default logic
192 if (!isBloodHealState)
193 {
194 super.OnExecuteDamageSystem(actionOwner, actionUser, healState, action, healthScaled);
195 return;
196 }
197
198 //~ On succesfully executed
199 OnSuccessfullyExecuted(actionOwner, actionUser, action);
200
201 //~ Do not send notification
203 return;
204
205 SendDamageSupportStationNotification(actionOwner, actionUser, action, healState, healthScaled);
206 }
207
208 //------------------------------------------------------------------------------------------------
209 protected override void SendDamageSupportStationNotification(IEntity actionOwner, IEntity actionUser, SCR_BaseUseSupportStationAction action, SCR_EDamageSupportStationHealState healState, float healthScaled)
210 {
211 //~ Editable entity not found
213 if (!userEditableEntity)
214 return;
215
216 int ownerPlayerID;
217
218 SCR_PossessingManagerComponent possesionManager = SCR_PossessingManagerComponent.GetInstance();
219 if (possesionManager)
220 {
221 ownerPlayerID = possesionManager.GetPlayerIdFromControlledEntity(actionOwner);
222 }
223 else
224 {
226
227 if (ownerEditableEntity)
228 ownerPlayerID = ownerEditableEntity.GetPlayerID();
229 }
230
231 //~ If owner is AI do not send notification
232 if (ownerPlayerID <= 0)
233 return;
234
235 RplId userRplId = Replication.FindItemId(userEditableEntity);
236
237 ECharacterHitZoneGroup notificationHitZoneGroup = ECharacterHitZoneGroup.VIRTUAL;
239 if (healAction)
240 notificationHitZoneGroup = healAction.GetHitZoneGroup();
241
242 //~ Send correct notification
243 switch (healState)
244 {
245 case SCR_EDamageSupportStationHealState.HEAL_UPDATE :
246 {
247 if (SCR_PlayerController.GetLocalPlayerId() == ownerPlayerID)
248 SCR_NotificationsComponent.SendLocal(ENotification.SUPPORTSTATION_HEALED_BY_OTHER_UPDATE, userRplId, notificationHitZoneGroup, healthScaled * 1000);
249 return;
250 }
251 case SCR_EDamageSupportStationHealState.HEAL_DONE_NOT_FULL_HEAL :
252 {
253 if (SCR_PlayerController.GetLocalPlayerId() == ownerPlayerID)
254 SCR_NotificationsComponent.SendLocal(ENotification.SUPPORTSTATION_HEALED_BY_OTHER_DONE_NOT_FULL, userRplId, notificationHitZoneGroup, healthScaled * 1000);
255 return;
256 }
258 {
259 if (SCR_PlayerController.GetLocalPlayerId() == ownerPlayerID)
260 SCR_NotificationsComponent.SendLocal(ENotification.SUPPORTSTATION_HEALED_BY_OTHER_DONE, userRplId, notificationHitZoneGroup, 1);
261
262 return;
263 }
264 }
265 }
266}
ENotification
ESupportStationType
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
override int GetSupplyAmountAction(IEntity actionOwner, IEntity actionUser, SCR_BaseUseSupportStationAction action)
float GetDamageOrStateToHeal(IEntity actionOwner, IEntity actionUser, notnull SCR_BaseDamageHealSupportStationAction action, out EDamageType activeDoT, out notnull array< HitZone > hitZones)
void OnExecuteDamageSystemBroadcast(RplId ownerId, RplId userId, SCR_EDamageSupportStationHealState healState, int actionId, float healthScaled)
void OnExecuteDamageSystem(IEntity actionOwner, IEntity actionUser, SCR_EDamageSupportStationHealState healState, SCR_BaseDamageHealSupportStationAction action, float healthScaled)
void SendDamageSupportStationNotification(IEntity actionOwner, IEntity actionUser, SCR_BaseUseSupportStationAction action, SCR_EDamageSupportStationHealState healState, float healthScaled)
override void OnExecutedServer(notnull IEntity actionOwner, notnull IEntity actionUser, notnull SCR_BaseUseSupportStationAction action)
bool GetSendNotificationOnUse()
void PlayCharacterVoiceEvent(IEntity character)
ESupportStationType GetSupportStationType()
bool OnConsumeSuppliesServer(int amount)
void FindEntityIds(IEntity owner, IEntity user, out RplId ownerId, out RplId userId, out int playerId)
void OnSuccessfullyExecuted(IEntity actionOwner, IEntity actionUser, SCR_BaseUseSupportStationAction action)
void PlaySoundEffect(SCR_AudioSourceConfiguration audioConfig, notnull IEntity soundOwner, SCR_BaseUseSupportStationAction action)
SCR_AudioSourceConfiguration GetOnUseAudioConfig()
SCR_CharacterSoundComponentClass GetComponentData()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external Managed FindComponent(typename typeName)
Definition Math.c:13
Main replication API.
Definition Replication.c:14
Replication item identifier.
Definition RplId.c:14
SCR_AudioSourceConfiguration CreateSoundAudioConfig(string soundEventName)
HitZone GetBloodHitZoneToHeal()
return Return the Blood hitzone to heal if any is set
SCR_AudioSourceConfiguration GetOnHealBloodUpdateAudioConfig()
ref SCR_AudioSourceConfiguration m_OnHealBloodUpdateAudioSourceConfiguration
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
IEntity GetOwner()
Owner entity of the fuel tank.
SCR_FieldOfViewSettings Attribute
EDamageType
Definition EDamageType.c:13