Core/PacketIO: Implemented CMSG_CONVERSATION_LINE_STARTED (#27036)

* Added OnConversationLineStarted hook to ConversationScripts
* Added example for Defender of Azeroth conversation
This commit is contained in:
ModoX
2021-10-12 00:16:20 +02:00
committed by GitHub
parent 9b036b8fe0
commit 6d9ce8e8ba
10 changed files with 94 additions and 2 deletions

View File

@@ -15,6 +15,41 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "Conversation.h"
#include "ObjectAccessor.h"
#include "Player.h"
class conversation_allied_race_dk_defender_of_azeroth : public ConversationScript
{
public:
enum DefenderOfAzerothIds : uint32
{
NPC_TALK_TO_YOUR_COMMANDER_CREDIT = 161709,
NPC_LISTEN_TO_YOUR_COMMANDER_CREDIT = 163027,
CONVERSATION_LINE_PLAYER = 32926
};
conversation_allied_race_dk_defender_of_azeroth() : ConversationScript("conversation_allied_race_dk_defender_of_azeroth") { }
void OnConversationCreate(Conversation* conversation, Unit* creator) override
{
conversation->AddActor(ObjectGuid::Create<HighGuid::Player>(0xFFFFFFFFFFFFFFFF), 1);
if (Player* player = creator->ToPlayer())
player->KilledMonsterCredit(NPC_TALK_TO_YOUR_COMMANDER_CREDIT);
}
void OnConversationLineStarted(Conversation* /*conversation*/, uint32 lineId, Player* sender) override
{
if (lineId != CONVERSATION_LINE_PLAYER)
return;
sender->KilledMonsterCredit(NPC_LISTEN_TO_YOUR_COMMANDER_CREDIT);
}
};
void AddSC_conversation_scripts()
{
new conversation_allied_race_dk_defender_of_azeroth();
}