Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ScenarioFrameworkActionVoiceOverPlayLine.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 line as defined in Voice Over Data Config")]
8 string m_sLineName;
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 Line should play right now or wait for the current voice lines 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
25 //------------------------------------------------------------------------------------------------
26 override void OnActivate(IEntity object)
27 {
28 if (!m_sVoiceOverDataConfig || m_sVoiceOverDataConfig.IsEmpty())
29 {
31 if (!scenarioFrameworkSystem)
32 return;
33
34 m_sVoiceOverDataConfig = scenarioFrameworkSystem.m_sVoiceOverDataConfig;
35
36 if (!m_sVoiceOverDataConfig || m_sVoiceOverDataConfig.IsEmpty())
37 return;
38 }
39
40 if (!CanActivate())
41 return;
42
44 if (!gamemode || (!m_bAllowPlayingInGameOver && !gamemode.IsRunning()))
45 return;
46
47 PlayerManager playerManager = GetGame().GetPlayerManager();
48 if (!playerManager)
49 return;
50
51 IEntity entity;
52 array<IEntity> entities = {};
53 if (m_PlayerGetter)
54 {
55 SCR_ScenarioFrameworkParam<array<IEntity>> entityArrayWrapper = SCR_ScenarioFrameworkParam<array<IEntity>>.Cast(m_PlayerGetter.Get());
56 if (entityArrayWrapper)
57 {
58 entities = entityArrayWrapper.GetValue();
59 if (!entities || entities.IsEmpty())
60 return;
61 }
62 else
63 {
64 SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_PlayerGetter.Get());
65 if (!entityWrapper)
66 {
67 if (object)
68 Print(string.Format("ScenarioFramework Action: Issue with Getter detected for Action %1 attached on %2.", this, object.GetName()), LogLevel.ERROR);
69 else
70 Print(string.Format("ScenarioFramework Action: Issue with Getter detected for Action %1.", this), LogLevel.ERROR);
71
72 return;
73 }
74
75 IEntity playerEntity = entityWrapper.GetValue();
76
77 entities.Insert(playerEntity);
78 }
79 }
80
81 if (!ValidateInputEntity(object, m_ActorGetter, entity))
82 return;
83
84 array<int> playerIDs = {};
85 foreach(IEntity possiblePlayerEntity : entities)
86 {
87 if (EntityUtils.IsPlayer(possiblePlayerEntity))
88 playerIDs.Insert(playerManager.GetPlayerIdFromControlledEntity(possiblePlayerEntity))
89 }
90
92 if (!voiceoverSystem)
93 return;
94
95 voiceoverSystem.SetData(m_sVoiceOverDataConfig);
96 voiceoverSystem.GetOnFinished().Insert(OnFinished);
97
98 if (RplSession.Mode() == RplMode.None)
99 {
100 voiceoverSystem.PlayLine(m_sLineName, entity, m_bPlayImmediately);
101 }
102 else
103 {
104 if (!Replication.FindItemId(entity))
105 PrintFormat("ScenarioFramework Action %1 detected %2 without RplComponent thus VO won't work!", object, entity);
106
107 voiceoverSystem.PlayLineFor(m_sLineName, entity, playerIDs, m_bPlayImmediately);
108 }
109 }
110
111 //------------------------------------------------------------------------------------------------
112 void OnFinished()
113 {
115 if (voiceoverSystem)
116 voiceoverSystem.GetOnFinished().Remove(OnFinished);
117
118 foreach (SCR_ScenarioFrameworkActionBase actions : m_aActions)
119 {
120 actions.OnActivate(m_Entity);
121 }
122 }
123
124 //------------------------------------------------------------------------------------------------
125 override array<ref SCR_ScenarioFrameworkActionBase> GetSubActions()
126 {
127 return m_aActions;
128 }
129}
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()
override void OnActivate()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Main replication API.
Definition Replication.c:14
static SCR_ScenarioFrameworkSystem GetInstance()
ScriptInvokerVoid GetOnFinished()
Triggered when a line or sequence finishes playing.
static SCR_VoiceoverSystem GetInstance()
void PlayLine(string lineName, IEntity actor=null, bool playImmediately=true)
Plays a voiceover line defined in loaded config (see SetData).
void PlayLineFor(string lineName, notnull IEntity actor, notnull array< int > targetPlayerIds, bool playImmediately=true)
Same as PlayLineGlobal but plays the VO for clients defined by player IDs.
void SetData(ResourceName config)
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