aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp8
-rw-r--r--src/server/game/Handlers/NPCHandler.cpp9
-rw-r--r--src/server/game/Server/WorldSession.h4
-rw-r--r--src/server/scripts/World/npc_professions.cpp89
4 files changed, 102 insertions, 8 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index dacbc519e13..a0077de693e 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -8464,7 +8464,7 @@ void ObjectMgr::LoadMailLevelRewards()
TC_LOG_INFO("server.loading", ">> Loaded %u level dependent mail rewards in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
-void ObjectMgr::AddSpellToTrainer(uint32 ID, uint32 SpellID, uint32 MoneyCost, uint32 ReqSkillLine, uint32 ReqSkillRank, uint32 ReqLevel)
+void ObjectMgr::AddSpellToTrainer(uint32 ID, uint32 SpellID, uint32 MoneyCost, uint32 ReqSkillLine, uint32 ReqSkillRank, uint32 ReqLevel, uint32 Index)
{
if (ID >= TRINITY_TRAINER_START_REF)
return;
@@ -8503,6 +8503,7 @@ void ObjectMgr::AddSpellToTrainer(uint32 ID, uint32 SpellID, uint32 MoneyCost, u
trainerSpell.ReqSkillLine = ReqSkillLine;
trainerSpell.ReqSkillRank = ReqSkillRank;
trainerSpell.ReqLevel = ReqLevel;
+ trainerSpell.Index = Index;
if (!trainerSpell.ReqLevel)
trainerSpell.ReqLevel = spellinfo->SpellLevel;
@@ -8543,7 +8544,7 @@ void ObjectMgr::LoadTrainerSpell()
// For reload case
_cacheTrainerSpellStore.clear();
- QueryResult result = WorldDatabase.Query("SELECT b.ID, a.SpellID, a.MoneyCost, a.ReqSkillLine, a.ReqSkillRank, a.Reqlevel FROM npc_trainer AS a "
+ QueryResult result = WorldDatabase.Query("SELECT b.ID, a.SpellID, a.MoneyCost, a.ReqSkillLine, a.ReqSkillRank, a.Reqlevel, a.Index FROM npc_trainer AS a "
"INNER JOIN npc_trainer AS b ON a.ID = -(b.SpellID) "
"UNION SELECT * FROM npc_trainer WHERE SpellID > 0");
@@ -8566,8 +8567,9 @@ void ObjectMgr::LoadTrainerSpell()
uint32 ReqSkillLine = fields[3].GetUInt16();
uint32 ReqSkillRank = fields[4].GetUInt16();
uint32 ReqLevel = fields[5].GetUInt8();
+ uint32 Index = fields[6].GetUInt8();
- AddSpellToTrainer(ID, SpellID, MoneyCost, ReqSkillLine, ReqSkillRank, ReqLevel);
+ AddSpellToTrainer(ID, SpellID, MoneyCost, ReqSkillLine, ReqSkillRank, ReqLevel, Index);
++count;
}
diff --git a/src/server/game/Handlers/NPCHandler.cpp b/src/server/game/Handlers/NPCHandler.cpp
index 53578310324..3b257f238a4 100644
--- a/src/server/game/Handlers/NPCHandler.cpp
+++ b/src/server/game/Handlers/NPCHandler.cpp
@@ -88,13 +88,13 @@ void WorldSession::HandleTrainerListOpcode(WorldPackets::NPC::Hello& packet)
SendTrainerList(packet.Unit);
}
-void WorldSession::SendTrainerList(ObjectGuid guid)
+void WorldSession::SendTrainerList(ObjectGuid guid, uint32 index)
{
std::string str = GetTrinityString(LANG_NPC_TAINER_HELLO);
- SendTrainerList(guid, str);
+ SendTrainerList(guid, str, index);
}
-void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle)
+void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle, uint32 index)
{
Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TRAINER);
if (!unit)
@@ -127,6 +127,9 @@ void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle)
{
TrainerSpell const* tSpell = &itr->second;
++ if (index && tSpell->Index != index)
++ continue;
+
bool valid = true;
for (uint8 i = 0; i < MAX_TRAINERSPELL_ABILITY_REQS; ++i)
{
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index ed91e8ca38e..2438bb2a426 100644
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -994,8 +994,8 @@ class TC_GAME_API WorldSession
void SendNameQueryOpcode(ObjectGuid guid);
- void SendTrainerList(ObjectGuid guid);
- void SendTrainerList(ObjectGuid guid, std::string const& strTitle);
+ void SendTrainerList(ObjectGuid guid, uint32 index = 0);
+ void SendTrainerList(ObjectGuid guid, std::string const& strTitle, uint32 index = 0);
void SendListInventory(ObjectGuid guid);
void SendShowBank(ObjectGuid guid);
bool CanOpenMailBox(ObjectGuid guid);
diff --git a/src/server/scripts/World/npc_professions.cpp b/src/server/scripts/World/npc_professions.cpp
index 16017d19b0b..bb174e3616f 100644
--- a/src/server/scripts/World/npc_professions.cpp
+++ b/src/server/scripts/World/npc_professions.cpp
@@ -1210,6 +1210,94 @@ public:
}
};
+/*###
+# start menu multi profession trainer
+###*/
+
+class npc_multi_profession_trainer : public CreatureScript
+{
+public:
+ npc_multi_profession_trainer() : CreatureScript("npc_multi_profession_trainer") { }
+
+ struct npc_multi_profession_trainerAI : public ScriptedAI
+ {
+ npc_multi_profession_trainerAI(Creature* creature) : ScriptedAI(creature) { }
+
+ void sGossipSelect(Player* player, uint32 menuId, uint32 gossipListId)
+ {
+ switch (gossipListId)
+ {
+ case GOSSIP_OPTION_ALCHEMY:
+ case GOSSIP_OPTION_BLACKSMITHING:
+ case GOSSIP_OPTION_ENCHANTING:
+ case GOSSIP_OPTION_ENGINEERING:
+ case GOSSIP_OPTION_HERBALISM:
+ case GOSSIP_OPTION_INSCRIPTION:
+ case GOSSIP_OPTION_JEWELCRAFTING:
+ case GOSSIP_OPTION_LEATHERWORKING:
+ case GOSSIP_OPTION_MINING:
+ case GOSSIP_OPTION_SKINNING:
+ case GOSSIP_OPTION_TAILORING:
+ SendTrainerList(player, gossipListId);
+ break;
+ case GOSSIP_OPTION_MULTI:
+ {
+ switch (menuId)
+ {
+ case GOSSIP_MENU_HERBALISM:
+ SendTrainerList(player, GOSSIP_OPTION_HERBALISM);
+ break;
+ case GOSSIP_MENU_MINING:
+ SendTrainerList(player, GOSSIP_OPTION_MINING);
+ break;
+ case GOSSIP_MENU_SKINNING:
+ SendTrainerList(player, GOSSIP_OPTION_SKINNING);
+ break;
+ case GOSSIP_MENU_ALCHEMY:
+ SendTrainerList(player, GOSSIP_OPTION_ALCHEMY);
+ break;
+ case GOSSIP_MENU_BLACKSMITHING:
+ SendTrainerList(player, GOSSIP_OPTION_BLACKSMITHING);
+ break;
+ case GOSSIP_MENU_ENCHANTING:
+ SendTrainerList(player, GOSSIP_OPTION_ENCHANTING);
+ break;
+ case GOSSIP_MENU_ENGINEERING:
+ SendTrainerList(player, GOSSIP_OPTION_ENGINEERING);
+ break;
+ case GOSSIP_MENU_INSCRIPTION:
+ SendTrainerList(player, GOSSIP_OPTION_INSCRIPTION);
+ break;
+ case GOSSIP_MENU_JEWELCRAFTING:
+ SendTrainerList(player, GOSSIP_OPTION_JEWELCRAFTING);
+ break;
+ case GOSSIP_MENU_LEATHERWORKING:
+ SendTrainerList(player, GOSSIP_OPTION_LEATHERWORKING);
+ break;
+ case GOSSIP_MENU_TAILORING:
+ SendTrainerList(player, GOSSIP_OPTION_TAILORING);
+ break;
+ default:
+ break;
+ }
+ }
+ default:
+ break;
+ }
+ }
+
+ void SendTrainerList(Player* player, uint32 Index)
+ {
+ player->GetSession()->SendTrainerList(me->GetGUID(), Index + 1);
+ }
+ };
+
+ CreatureAI* GetAI(Creature* creature) const override
+ {
+ return new npc_multi_profession_trainerAI(creature);
+ }
+};
+
void AddSC_npc_professions()
{
new npc_prof_alchemy();
@@ -1217,4 +1305,5 @@ void AddSC_npc_professions()
new npc_engineering_tele_trinket();
new npc_prof_leather();
new npc_prof_tailor();
+ new npc_multi_profession_trainer();
}