Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CommunicationSoundComponent.c
Go to the documentation of this file.
1[EntityEditorProps(category: "GameScripted/ScriptWizard", description: "")]
5
6enum ECP_VehicleRoles
7{
14 PASSANGER // TODO: PASSENGER
15}
16
17enum ECP_Characters
18{
26 RADIO_MAN
27}
28
29enum ECP_VehicleTypes
30{
40}
41
42enum SCR_ECommunicationSoundEventPriority
43{
50}
51
52void OnSoundEventStartedDelegate(SCR_CommunicationSoundComponent component, string eventName, AudioHandle handle, int priority);
54typedef ScriptInvokerBase<OnSoundEventStartedDelegate> OnSoundEventStartedInvoker;
55
56void OnSoundEventFinishedDelegate(SCR_CommunicationSoundComponent component, string eventName, AudioHandle handle, int priority, bool terminated);
58typedef ScriptInvokerBase<OnSoundEventFinishedDelegate> OnSoundEventFinishedInvoker;
59
61{
63 private static const int SUBTITLES_MAX_DISTANCE = 20;
64 static const int DEFAULT_EVENT_PRIORITY_DELAY = 100;
65 private static const string DAMAGE_TYPE_SIGNAL_NAME = "DamageType";
66 private static const string HIT_SCREAM_INTENSITY_SIGNAL_NAME = "HitScreamIntensity";
67
68 protected string m_sDelayedSoundEvent;
69 protected SCR_ECommunicationSoundEventPriority m_eDelayedSoundEventPriority;
71 protected int m_iHitScreamIntensity;
74
77
78 protected static bool m_bShowSubtitles;
79
80 //------------------------------------------------------------------------------------------------
83 void ShowSubtitles(array<string> metadata)
84 {
85 int size = metadata.Count();
86
87 if (size > 10)
88 {
89 Print("Too many metadata. Metadata size = " + size.ToString(), LogLevel.ERROR);
90 return;
91 }
92
93 // Get text
94 int textIdx = -1;
95
96 for (int i = size - 1; i >= 0; i--)
97 {
98 if (!metadata[i].IsEmpty())
99 {
100 textIdx = i;
101 break;
102 }
103 }
104
105 // Do not show subtitles if metadata is empty
106 if (textIdx == -1)
107 return;
108
109 // Get parameters
110 string param[9];
111 int paramIndex;
112
113 for (int i = 0; i < textIdx; i++)
114 {
115 if (!metadata[i].IsEmpty())
116 {
117 param[paramIndex] = metadata[i];
118 paramIndex++;
119 }
120 }
121
122 // Show subtitles
123 // Subtitles printed to the chat - old way
124 string localizedText = WidgetManager.Translate(metadata[textIdx], param[0], param[1], param[2], param[3], param[4], param[5], param[6], param[7], param[8]);
125
126 SCR_ChatComponent.RadioProtocolMessage(localizedText);
127 }
128
129 //------------------------------------------------------------------------------------------------
130 // Inserted to OnUserSettingsChangedInvoker() on SCR_UISoundEntity
131 static void SetSubtitiles()
132 {
133 BaseContainer settings = GetGame().GetGameUserSettings().GetModule("SCR_GameplaySettings");
134 if (settings)
135 settings.Get("m_bShowRadioProtocolText", m_bShowSubtitles);
136 }
137
138 //------------------------------------------------------------------------------------------------
144 void SetCallsignSignals(int company, int platoon, int squad, int character, int characterRole)
145 {
147 return;
148
149 m_SignalsManagerComponent.SetSignalValue(m_SignalsManagerComponent.AddOrFindSignal("CompanyCaller"), company);
150 m_SignalsManagerComponent.SetSignalValue(m_SignalsManagerComponent.AddOrFindSignal("PlattonCaller"), platoon);
151 m_SignalsManagerComponent.SetSignalValue(m_SignalsManagerComponent.AddOrFindSignal("SquadCaller"), squad);
152 m_SignalsManagerComponent.SetSignalValue(m_SignalsManagerComponent.AddOrFindSignal("SoldierCaller"), character -1);
153 }
154
155 //------------------------------------------------------------------------------------------------
159 void SoundEventHit(bool critical, EDamageType damageType)
160 {
161 if (critical)
163
164 SCR_ECommunicationSoundEventPriority priority = SCR_ECommunicationSoundEventPriority.SOUND_HIT + m_iHitScreamIntensity;
165 if (priority >= SCR_ECommunicationSoundEventPriority.SOUND_DEATH)
166 priority = SCR_ECommunicationSoundEventPriority.SOUND_DEATH - 1;
167
168 DelayedSoundEventPriority(SCR_SoundEvent.SOUND_HIT, priority, DEFAULT_EVENT_PRIORITY_DELAY, damageType);
169 }
170
171 //------------------------------------------------------------------------------------------------
177 void DelayedSoundEventPriority(string eventName, SCR_ECommunicationSoundEventPriority priority, int delayMS, EDamageType damageType = EDamageType.TRUE)
178 {
179 if (priority < m_eDelayedSoundEventPriority)
180 return;
181
182 m_sDelayedSoundEvent = eventName;
184 m_eEDamageType = damageType;
185
186 ScriptCallQueue queue = GetGame().GetCallqueue();
187
188 int remainingTime = queue.GetRemainingTime(PlayDelayedSoundEventPriority);
189
190 if (delayMS < remainingTime)
191 {
192 queue.Remove(PlayDelayedSoundEventPriority);
193 remainingTime = 0;
194 }
195
196 if (remainingTime <= 0)
197 queue.CallLater(PlayDelayedSoundEventPriority, delayMS);
198 }
199
200 //------------------------------------------------------------------------------------------------
204 {
206 {
209 }
210
211 SoundEventPriority(m_sDelayedSoundEvent, m_eDelayedSoundEventPriority, true);
212
213 m_sDelayedSoundEvent = string.Empty;
214 m_eDelayedSoundEventPriority = SCR_ECommunicationSoundEventPriority.SOUND_NONE;
216
217 // Also reset hit scream intensity
219 }
220
221 //------------------------------------------------------------------------------------------------
225 void SoundEventDeath(bool silent)
226 {
227 GetGame().GetCallqueue().Remove(DelayedSoundEventPriority);
228
229 if (silent)
230 SoundEvent(SCR_SoundEvent.SOUND_KNOCKOUT);
231 else
232 SoundEvent(SCR_SoundEvent.SOUND_DEATH);
233 }
234
235 //------------------------------------------------------------------------------------------------
243
244 //------------------------------------------------------------------------------------------------
252
253 //------------------------------------------------------------------------------------------------
254 override void OnPostInit(IEntity owner)
255 {
257 if (callsignBaseComponent)
258 callsignBaseComponent.GetOnCallsignChanged().Insert(SetCallsignSignals);
259
262 {
263 m_iDamageTypeSignalIdx = m_SignalsManagerComponent.AddOrFindSignal(DAMAGE_TYPE_SIGNAL_NAME);
264 m_iHitScreamIntensitySignalIdx = m_SignalsManagerComponent.AddOrFindSignal(HIT_SCREAM_INTENSITY_SIGNAL_NAME);
265 }
266 }
267
268 //------------------------------------------------------------------------------------------------
269 override void OnSoundEventStarted(string eventName, AudioHandle handle, int priority)
270 {
272 m_OnSoundEventStarted.Invoke(this, eventName, handle, priority);
273 }
274
275 //------------------------------------------------------------------------------------------------
276 override void OnSoundEventFinished(string eventName, AudioHandle handle, int priority, bool terminated)
277 {
279 m_OnSoundEventFinished.Invoke(this, eventName, handle, priority, terminated);
280 }
281
282 //------------------------------------------------------------------------------------------------
283 // constructor
288 {
289 SetScriptedMethodsCall(true);
290 }
291
292 //------------------------------------------------------------------------------------------------
293 // destructor
295 {
296 SCR_CallsignBaseComponent callsignBaseComponent = SCR_CallsignBaseComponent.Cast(GetOwner().FindComponent(SCR_CallsignBaseComponent));
297 if (callsignBaseComponent)
298 callsignBaseComponent.GetOnCallsignChanged().Remove(SetCallsignSignals);
299 }
300}
ArmaReforgerScripted GetGame()
Definition game.c:1398
int size
SCR_AIInfoComponentClass SNIPER
ScriptInvokerBase< OnSoundEventStartedDelegate > OnSoundEventStartedInvoker
SCR_CommunicationSoundComponentClass GUNNER
SCR_CommunicationSoundComponentClass RECON
func OnSoundEventFinishedDelegate
SCR_CommunicationSoundComponentClass COMM_TRUCK
SCR_CommunicationSoundComponentClass DRIVER
SCR_CommunicationSoundComponentClass APC
SCR_CommunicationSoundComponentClass FUEL_TRUCK
SCR_CommunicationSoundComponentClass SOUND_BREATH
SCR_CommunicationSoundComponentClass AT_SOLDIER
SCR_CommunicationSoundComponentClass MACHINE_GUNNER
SCR_CommunicationSoundComponentClass TRUCK
SCR_CommunicationSoundComponentClass CAR
SCR_CommunicationSoundComponentClass OFFICER
func OnSoundEventStartedDelegate
SCR_CommunicationSoundComponentClass SOUND_KNOCKOUT
SCR_CommunicationSoundComponentClass SOLDIER
SCR_CommunicationSoundComponentClass SOUND_NONE
ScriptInvokerBase< OnSoundEventFinishedDelegate > OnSoundEventFinishedInvoker
SCR_CommunicationSoundComponentClass SOUND_HIT
SCR_CommunicationSoundComponentClass MORTAR
SCR_CommunicationSoundComponentClass SUPPLY_TRUCK
SCR_CommunicationSoundComponentClass OPERATOR
SCR_CommunicationSoundComponentClass MAN
SCR_CommunicationSoundComponentClass SOUND_PAIN_RELIEVE
SCR_CommunicationSoundComponentClass COPILOT
SCR_CommunicationSoundComponentClass PILOT
SCR_CommunicationSoundComponentClass COMMANDER
SCR_CommunicationSoundComponentClass SOUND_DEATH
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
proto external Managed FindComponent(typename typeName)
Component of assigning and storing squad names.
ScriptInvokerBase< SCR_CallsignBaseComponent_OnCallsignChanged > GetOnCallsignChanged()
void ShowSubtitles(array< string > metadata)
override void OnSoundEventStarted(string eventName, AudioHandle handle, int priority)
override void OnSoundEventFinished(string eventName, AudioHandle handle, int priority, bool terminated)
ref OnSoundEventStartedInvoker m_OnSoundEventStarted
SCR_ECommunicationSoundEventPriority m_eDelayedSoundEventPriority
void SetCallsignSignals(int company, int platoon, int squad, int character, int characterRole)
OnSoundEventFinishedInvoker GetOnSoundEventFinished()
void SCR_CommunicationSoundComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
ref OnSoundEventFinishedInvoker m_OnSoundEventFinished
void SoundEventHit(bool critical, EDamageType damageType)
OnSoundEventStartedInvoker GetOnSoundEventStarted()
void DelayedSoundEventPriority(string eventName, SCR_ECommunicationSoundEventPriority priority, int delayMS, EDamageType damageType=EDamageType.TRUE)
ScriptCallQueue Class provide "lazy" calls - when we don't want to execute function immediately but l...
Definition tools.c:53
IEntity GetOwner()
Owner entity of the fuel tank.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
EDamageType
Definition EDamageType.c:13
proto native bool IsEmpty()