Core/Conversation: Implemented OnConversationStart and OnConversationUpdate hooks (#29086)

This commit is contained in:
ModoX
2023-06-28 01:30:23 +02:00
committed by GitHub
parent a983db9457
commit 7f14b64e09
3 changed files with 35 additions and 0 deletions
@@ -64,6 +64,8 @@ void Conversation::RemoveFromWorld()
void Conversation::Update(uint32 diff)
{
sScriptMgr->OnConversationUpdate(this, diff);
if (GetDuration() > Milliseconds(diff))
{
_duration -= Milliseconds(diff);
@@ -239,6 +241,7 @@ bool Conversation::Start()
if (!GetMap()->AddToMap(this))
return false;
sScriptMgr->OnConversationStart(this);
return true;
}
+24
View File
@@ -2259,6 +2259,14 @@ void ScriptMgr::OnConversationCreate(Conversation* conversation, Unit* creator)
tmpscript->OnConversationCreate(conversation, creator);
}
void ScriptMgr::OnConversationStart(Conversation* conversation)
{
ASSERT(conversation);
GET_SCRIPT(ConversationScript, conversation->GetScriptId(), tmpscript);
tmpscript->OnConversationStart(conversation);
}
void ScriptMgr::OnConversationLineStarted(Conversation* conversation, uint32 lineId, Player* sender)
{
ASSERT(conversation);
@@ -2268,6 +2276,14 @@ void ScriptMgr::OnConversationLineStarted(Conversation* conversation, uint32 lin
tmpscript->OnConversationLineStarted(conversation, lineId, sender);
}
void ScriptMgr::OnConversationUpdate(Conversation* conversation, uint32 diff)
{
ASSERT(conversation);
GET_SCRIPT(ConversationScript, conversation->GetScriptId(), tmpscript);
tmpscript->OnConversationUpdate(conversation, diff);
}
// Scene
void ScriptMgr::OnSceneStart(Player* player, uint32 sceneInstanceID, SceneTemplate const* sceneTemplate)
{
@@ -3125,10 +3141,18 @@ void ConversationScript::OnConversationCreate(Conversation* /*conversation*/, Un
{
}
void ConversationScript::OnConversationStart(Conversation* /*conversation*/ )
{
}
void ConversationScript::OnConversationLineStarted(Conversation* /*conversation*/, uint32 /*lineId*/, Player* /*sender*/)
{
}
void ConversationScript::OnConversationUpdate(Conversation* /*conversation*/, uint32 /*diff*/)
{
}
SceneScript::SceneScript(char const* name)
: ScriptObject(name)
{
+8
View File
@@ -923,8 +923,14 @@ class TC_GAME_API ConversationScript : public ScriptObject
// Called when Conversation is created but not added to Map yet.
virtual void OnConversationCreate(Conversation* conversation, Unit* creator);
// Called when Conversation is started
virtual void OnConversationStart(Conversation* conversation);
// Called when player sends CMSG_CONVERSATION_LINE_STARTED with valid conversation guid
virtual void OnConversationLineStarted(Conversation* conversation, uint32 lineId, Player* sender);
// Called for each update tick
virtual void OnConversationUpdate(Conversation* conversation, uint32 diff);
};
class TC_GAME_API SceneScript : public ScriptObject
@@ -1269,7 +1275,9 @@ class TC_GAME_API ScriptMgr
public: /* ConversationScript */
void OnConversationCreate(Conversation* conversation, Unit* creator);
void OnConversationStart(Conversation* conversation);
void OnConversationLineStarted(Conversation* conversation, uint32 lineId, Player* sender);
void OnConversationUpdate(Conversation* conversation, uint32 diff);
public: /* SceneScript */