Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ScenarioFrameworkActionVoiceOverPlaySequence.c
Go to the documentation of this file.
3{
4 [Attribute(desc: "Config with voice over data for this action.", params: "conf class=SCR_VoiceoverData")]
5 ResourceName m_sVoiceOverDataConfig;
6
7 [Attribute(desc: "Name of the sequence as defined in Voice Over Data Config")]
8 string m_sSequenceName;
9
10 [Attribute(desc: "Entity playing the voiceover. Order must be the same as the order of actor enums in Voice Over Data Config. Reminder: Related .acp needs to be present in the SCR_CommunicationSoundComponent of target entity.")]
11 ref SCR_ScenarioFrameworkGet m_ActorGetter;
12
13 [Attribute(desc: "Player entity or entities that the voice over will be played for. Reminder: Related .acp needs to be present in the SCR_CommunicationSoundComponent of target entity.")]
14 ref SCR_ScenarioFrameworkGet m_PlayerGetter;
15
16 [Attribute(defvalue: "1", desc: "If Voice Sequence should play right now or wait for the current voice sequence to finish and then play it")]
17 bool m_bPlayImmediately;
18
19 [Attribute(desc: "Allow VO Playing In Gameover and when game is stopped")]
20 bool m_bAllowPlayingInGameOver;
21
22 [Attribute(desc: "Actions that will be triggered once Sequence finishes playing")]
23 ref array<ref SCR_ScenarioFrameworkActionBase> m_aActions;
24
26
27 //------------------------------------------------------------------------------------------------
28 override void OnActivate(IEntity object)
29 {
30 if (!m_sVoiceOverDataConfig || m_sVoiceOverDataConfig.IsEmpty())
31 {
33 if (!scenarioFrameworkSystem)
34 return;
35
36 m_sVoiceOverDataConfig = scenarioFrameworkSystem.m_sVoiceOverDataConfig;
37
38 if (!m_sVoiceOverDataConfig || m_sVoiceOverDataConfig.IsEmpty())
39 return;
40 }
41
42 if (!CanActivate())
43 return;
44
46 if (!gamemode || (!m_bAllowPlayingInGameOver && !gamemode.IsRunning()))
47 return;
48
49 PlayerManager playerManager = GetGame().GetPlayerManager();
50 if (!playerManager)
51 return;
52
53 IEntity entity;
54 array<IEntity> entities = {};
55 if (m_PlayerGetter)
56 {
57 SCR_ScenarioFrameworkParam<array<IEntity>> entityArrayWrapper = SCR_ScenarioFrameworkParam<array<IEntity>>.Cast(m_PlayerGetter.Get());
58 if (entityArrayWrapper)
59 {
60 entities = entityArrayWrapper.GetValue();
61 if (!entities || entities.IsEmpty())
62 return;
63 }
64 else
65 {
66 SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_PlayerGetter.Get());
67 if (!entityWrapper)
68 {
69 if (object)
70 Print(string.Format("ScenarioFramework Action: Issue with Getter detected for Action %1 attached on %2.", this, object.GetName()), LogLevel.ERROR);
71 else
72 Print(string.Format("ScenarioFramework Action: Issue with Getter detected for Action %1.", this), LogLevel.ERROR);
73
74 return;
75 }
76
77 IEntity playerEntity = entityWrapper.GetValue();
78
79 entities.Insert(playerEntity);
80 }
81 }
82
83 array<IEntity> actorEntities = {};
84 if (m_ActorGetter)
85 {
86 SCR_ScenarioFrameworkParam<array<IEntity>> entityArrayWrapper = SCR_ScenarioFrameworkParam<array<IEntity>>.Cast(m_ActorGetter.Get());
87 if (entityArrayWrapper)
88 {
89 actorEntities = entityArrayWrapper.GetValue();
90 if (!actorEntities || actorEntities.IsEmpty())
91 return;
92 }
93 else
94 {
95 SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_ActorGetter.Get());
96 if (!entityWrapper)
97 {
98 if (object)
99 Print(string.Format("ScenarioFramework Action: Issue with Getter detected for Action %1 attached on %2.", this, object.GetName()), LogLevel.ERROR);
100 else
101 Print(string.Format("ScenarioFramework Action: Issue with Getter detected for Action %1.", this), LogLevel.ERROR);
102
103 return;
104 }
105
106 IEntity playerEntity = entityWrapper.GetValue();
107
108 actorEntities.Insert(playerEntity);
109 }
110 }
111
112 array<int> playerIDs = {};
113 foreach(IEntity possiblePlayerEntity : entities)
114 {
115 if (EntityUtils.IsPlayer(possiblePlayerEntity))
116 playerIDs.Insert(playerManager.GetPlayerIdFromControlledEntity(possiblePlayerEntity))
117 }
118
120 if (!voiceoverSystem)
121 return;
122
123 voiceoverSystem.SetData(m_sVoiceOverDataConfig);
124 voiceoverSystem.GetOnFinished().Insert(OnFinished);
125
126 if (RplSession.Mode() == RplMode.None)
127 {
128 voiceoverSystem.PlaySequenceActorsArray(m_sSequenceName, actorEntities, m_bPlayImmediately);
129 }
130 else
131 {
132 foreach (IEntity actor : actorEntities)
133 {
134 if (!Replication.FindItemId(actor))
135 PrintFormat("ScenarioFramework Action %1 detected %2 without RplComponent thus VO won't work!", object, actor);
136 }
137
138 voiceoverSystem.PlaySequenceFor(m_sSequenceName, actorEntities, playerIDs, m_bPlayImmediately);
139 }
140 }
141
142 //------------------------------------------------------------------------------------------------
144 {
146 if (voiceoverSystem)
147 voiceoverSystem.GetOnFinished().Remove(OnFinished);
148
149 foreach (SCR_ScenarioFrameworkActionBase actions : m_aActions)
150 {
151 actions.OnActivate(m_Entity);
152 }
153 }
154
155 //------------------------------------------------------------------------------------------------
156 override array<ref SCR_ScenarioFrameworkActionBase> GetSubActions()
157 {
158 return m_aActions;
159 }
160}
ArmaReforgerScripted GetGame()
Definition game.c:1398
RplMode
Mode of replication.
Definition RplMode.c:9
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
SCR_BaseGameMode GetGameMode()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Main replication API.
Definition Replication.c:14
override array< ref SCR_ScenarioFrameworkActionBase > GetSubActions()
static SCR_ScenarioFrameworkSystem GetInstance()
ScriptInvokerVoid GetOnFinished()
Triggered when a line or sequence finishes playing.
static SCR_VoiceoverSystem GetInstance()
void PlaySequenceActorsArray(string sequenceName, notnull array< IEntity > actors, bool playImmediately=true)
Same as PlaySequence but accepts an array of actors.
void PlaySequenceFor(string sequenceName, notnull array< IEntity > actors, notnull array< int > targetPlayerIds, bool playImmediately=true)
Same as PlaySequenceGlobal but plays the VO for clients defined by player IDs.
void SetData(ResourceName config)
Definition Types.c:486
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
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
SCR_FieldOfViewSettings Attribute