AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
DialogueHelper Class Reference
Inheritance diagram for DialogueHelper:
npc_ranshalla::npc_ranshallaAI

Public Member Functions

 DialogueHelper (DialogueEntry const *dialogueArray)
 
void StartNextDialogueText (int32 textEntry)
 
void DialogueUpdate (uint32 diff)
 

Protected Member Functions

virtual void JustDidDialogueStep (int32)
 Will be called when a dialogue step was done. More...
 
virtual CreatureGetSpeakerByEntry (int32)
 Will be called to get a speaker, MUST be implemented if not used in instances. More...
 

Private Member Functions

void DoNextDialogueStep ()
 

Private Attributes

DialogueEntry const * _dialogueArray
 
DialogueEntry const * _currentEntry
 
uint32 _actionTimer
 

Detailed Description

Constructor & Destructor Documentation

◆ DialogueHelper()

DialogueHelper::DialogueHelper ( DialogueEntry const *  dialogueArray)
inline
158 :
159 _dialogueArray(dialogueArray),
160 _currentEntry(nullptr),
161 _actionTimer(0)
162 { }
uint32 _actionTimer
Definition: zone_winterspring.cpp:238
DialogueEntry const * _dialogueArray
Definition: zone_winterspring.cpp:235
DialogueEntry const * _currentEntry
Definition: zone_winterspring.cpp:236

Member Function Documentation

◆ DialogueUpdate()

void DialogueHelper::DialogueUpdate ( uint32  diff)
inline
190 {
191 if (_actionTimer)
192 {
193 if (_actionTimer <= diff)
195 else
196 _actionTimer -= diff;
197 }
198 }
void DoNextDialogueStep()
Definition: zone_winterspring.cpp:207

References _actionTimer, and DoNextDialogueStep().

Referenced by npc_ranshalla::npc_ranshallaAI::UpdateEscortAI().

◆ DoNextDialogueStep()

void DialogueHelper::DoNextDialogueStep ( )
inlineprivate
208 {
209 // Last Dialogue Entry done?
211 {
212 _actionTimer = 0;
213 return;
214 }
215
216 // Get Text, SpeakerEntry and Timer
217 int32 textEntry = _currentEntry->TextEntry;
218 uint32 sayerEntry = _currentEntry->SayerEntry;
220
221 // Simulate Case
222 if (sayerEntry && textEntry >= 0)
223 {
224 // Use Speaker if directly provided
225 if (Creature* speaker = GetSpeakerByEntry(sayerEntry))
226 speaker->AI()->Talk(textEntry);
227 }
228
230
231 // Increment position
233 }
std::int32_t int32
Definition: Define.h:103
std::uint32_t uint32
Definition: Define.h:107
Definition: Creature.h:46
int32 TextEntry
To be said text entry.
Definition: zone_winterspring.cpp:149
int32 SayerEntry
Entry of the mob who should say.
Definition: zone_winterspring.cpp:150
uint32 SayTimer
Time delay until next text of array is said (0 stops)
Definition: zone_winterspring.cpp:151
virtual Creature * GetSpeakerByEntry(int32)
Will be called to get a speaker, MUST be implemented if not used in instances.
Definition: zone_winterspring.cpp:204
virtual void JustDidDialogueStep(int32)
Will be called when a dialogue step was done.
Definition: zone_winterspring.cpp:202

References _actionTimer, _currentEntry, GetSpeakerByEntry(), JustDidDialogueStep(), DialogueEntry::SayerEntry, DialogueEntry::SayTimer, and DialogueEntry::TextEntry.

Referenced by DialogueUpdate(), and StartNextDialogueText().

◆ GetSpeakerByEntry()

virtual Creature * DialogueHelper::GetSpeakerByEntry ( int32  )
inlineprotectedvirtual

Will be called to get a speaker, MUST be implemented if not used in instances.

Reimplemented in npc_ranshalla::npc_ranshallaAI.

204{ return nullptr; }

Referenced by DoNextDialogueStep().

◆ JustDidDialogueStep()

virtual void DialogueHelper::JustDidDialogueStep ( int32  )
inlineprotectedvirtual

Will be called when a dialogue step was done.

Reimplemented in npc_ranshalla::npc_ranshallaAI.

202{ }

Referenced by DoNextDialogueStep().

◆ StartNextDialogueText()

void DialogueHelper::StartNextDialogueText ( int32  textEntry)
inline

Function to initialize the dialogue helper for instances. If not used with instances, GetSpeakerByEntry MUST be overwritten to obtain the speakers Set if take first entries or second entries

169 {
170 // Find textEntry
171 bool found = false;
172
173 for (DialogueEntry const* entry = _dialogueArray; entry->TextEntry; ++entry)
174 {
175 if (entry->TextEntry == textEntry)
176 {
177 _currentEntry = entry;
178 found = true;
179 break;
180 }
181 }
182
183 if (!found)
184 return;
185
187 }
Definition: zone_winterspring.cpp:148

References _currentEntry, _dialogueArray, DoNextDialogueStep(), and DialogueEntry::TextEntry.

Referenced by npc_ranshalla::npc_ranshallaAI::SummonedMovementInform(), npc_ranshalla::npc_ranshallaAI::UpdateEscortAI(), and npc_ranshalla::npc_ranshallaAI::WaypointReached().

Member Data Documentation

◆ _actionTimer

uint32 DialogueHelper::_actionTimer
private

◆ _currentEntry

DialogueEntry const* DialogueHelper::_currentEntry
private

◆ _dialogueArray

DialogueEntry const* DialogueHelper::_dialogueArray
private

Referenced by StartNextDialogueText().