npc_housing_steward rework Aureon PR
This commit is contained in:
@@ -18,9 +18,13 @@
|
||||
#include "ScriptMgr.h"
|
||||
#include "CreatureAI.h"
|
||||
#include "GossipDef.h"
|
||||
#include "HousingMgr.h"
|
||||
#include "HousingTutorialSession.h"
|
||||
#include "Log.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptedGossip.h"
|
||||
#include "SpellMgr.h"
|
||||
|
||||
enum HousingTutorialData
|
||||
{
|
||||
@@ -28,68 +32,142 @@ enum HousingTutorialData
|
||||
QUEST_MY_FIRST_HOME = 91863,
|
||||
|
||||
// Quest: "My First Home" (91863) kill credit NPCs
|
||||
NPC_KILL_CREDIT_GREET_STEWARD = 249851,
|
||||
NPC_KILL_CREDIT_ASK_STEWARD = 248857,
|
||||
// These IDs correspond to quest_objectives.ObjectID entries for quest 91863.
|
||||
// Each KilledMonsterCredit() call increments the counter for that objective.
|
||||
NPC_KILL_CREDIT_GREET_STEWARD = 249851, // objective: greet the steward (Amount 1)
|
||||
NPC_KILL_CREDIT_ASK_STEWARD = 248857, // objective: ask steward to join (Amount 1)
|
||||
NPC_KILL_CREDIT_EXPLORE_PLOTS = 248858, // objective: explore available plots (Amount 1)
|
||||
NPC_KILL_CREDIT_VISIT_LOCATIONS = 248860, // objective: visit neighborhood locations (Amount 6)
|
||||
NPC_KILL_CREDIT_ACQUIRE_HOME = 249093, // objectives: acquire a home (Amount 2+1 = 3 total)
|
||||
|
||||
// Tutorial transition spells (retail fallback)
|
||||
HOUSING_TUTORIAL_ALLIANCE_SPELL = 1258476,
|
||||
HOUSING_TUTORIAL_HORDE_SPELL = 1258484,
|
||||
|
||||
// Gossip actions
|
||||
GOSSIP_ACTION_ASK_TO_JOIN = 1001,
|
||||
};
|
||||
|
||||
// Lyssabel Dawnpetal (233063) / Tocho (233708) ? Housing tutorial steward NPCs.
|
||||
// Lyssabel Dawnpetal (233063) / Tocho (233708) - Housing tutorial steward NPCs.
|
||||
// When the player interacts with the steward during the "My First Home" quest (91863),
|
||||
// the gossip grants quest kill credits for greeting the steward and asking them to join.
|
||||
// If the player has not yet started the tutorial, the NPC starts it for them.
|
||||
struct npc_housing_steward : public CreatureAI
|
||||
{
|
||||
npc_housing_steward(Creature* creature) : CreatureAI(creature) {}
|
||||
|
||||
void UpdateAI(uint32 /*diff*/) override {}
|
||||
|
||||
bool StartTutorialForPlayer(Player* player)
|
||||
{
|
||||
Quest const* quest = sObjectMgr->GetQuestTemplate(QUEST_MY_FIRST_HOME);
|
||||
if (!quest)
|
||||
{
|
||||
TC_LOG_ERROR("housing", "npc_housing_steward: Housing tutorial quest {} missing from world database",
|
||||
QUEST_MY_FIRST_HOME);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player->GetQuestStatus(QUEST_MY_FIRST_HOME) == QUEST_STATUS_NONE
|
||||
&& player->CanAddQuest(quest, true))
|
||||
{
|
||||
player->AddQuestAndCheckCompletion(quest, nullptr);
|
||||
TC_LOG_INFO("housing", "npc_housing_steward: Started Housing tutorial quest {} for player {}",
|
||||
QUEST_MY_FIRST_HOME, player->GetGUID().ToString());
|
||||
}
|
||||
|
||||
uint32 const exteriorMapId = sHousingMgr.GetExteriorMapId(player);
|
||||
|
||||
QueryResult plotResult = CharacterDatabase.PQuery(
|
||||
"SELECT PlotID FROM housing_plot_template WHERE ExteriorMapID = {} "
|
||||
"ORDER BY PlotID, VerifiedBuild DESC LIMIT 1",
|
||||
exteriorMapId);
|
||||
if (plotResult)
|
||||
{
|
||||
uint8 const plotId = plotResult->Fetch()[0].GetUInt8();
|
||||
Housing::PlotState plot;
|
||||
if (sHousingMgr.LoadPlot(player, plotId, plot) == Housing::Result::Success)
|
||||
{
|
||||
if (player->TeleportTo(plot.ExteriorMapId, plot.DestinationX, plot.DestinationY,
|
||||
plot.DestinationZ, plot.DestinationO))
|
||||
{
|
||||
TC_LOG_INFO("housing", "npc_housing_steward: Teleported player {} to tutorial plot on map {}",
|
||||
player->GetGUID().ToString(), exteriorMapId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32 const spellId = player->GetTeamId() == TEAM_HORDE
|
||||
? HOUSING_TUTORIAL_HORDE_SPELL
|
||||
: HOUSING_TUTORIAL_ALLIANCE_SPELL;
|
||||
if (sSpellMgr->GetSpellInfo(spellId, DIFFICULTY_NONE))
|
||||
{
|
||||
TC_LOG_WARN("housing", "npc_housing_steward: Plot destination unavailable; casting retail spell {} for player {}",
|
||||
spellId, player->GetGUID().ToString());
|
||||
player->CastSpell(player, spellId, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
TC_LOG_ERROR("housing", "npc_housing_steward: No tutorial transition available for player {}: "
|
||||
"no plot data and spell {} missing", player->GetGUID().ToString(), spellId);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool OnGossipHello(Player* player) override
|
||||
{
|
||||
// Grant "Greet the steward" kill credit (quest objective 0: MONSTER 249851)
|
||||
// If the player has not started the Housing tutorial yet, start it now.
|
||||
// This covers the case where the client never sends CMSG_HOUSING_SVCS_START_TUTORIAL.
|
||||
if (player->GetQuestStatus(QUEST_MY_FIRST_HOME) == QUEST_STATUS_NONE)
|
||||
{
|
||||
CloseGossipMenuFor(player);
|
||||
StartTutorialForPlayer(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Grant "Greet the steward" kill credit (quest objective: MONSTER 249851)
|
||||
player->KilledMonsterCredit(NPC_KILL_CREDIT_GREET_STEWARD);
|
||||
|
||||
// Satisfy "Talk to Lyssabel/Tocho" objective (quest objective 1/2: TALKTO with NPC entry)
|
||||
// Satisfy "Talk to Lyssabel/Tocho" objective (quest objective: TALKTO with NPC entry)
|
||||
player->TalkedToCreature(me->GetEntry(), me->GetGUID());
|
||||
|
||||
// Grant all remaining kill credits for quest 91863 objectives that cannot be
|
||||
// completed through normal gameplay in the repack (visit locations, explore plots,
|
||||
// acquire home). This ensures the quest reaches QUEST_STATUS_COMPLETE so the
|
||||
// player can turn it in via the normal quest reward flow.
|
||||
if (player->GetQuestStatus(QUEST_MY_FIRST_HOME) == QUEST_STATUS_INCOMPLETE)
|
||||
{
|
||||
// Objective: ask steward to join (Amount 1)
|
||||
player->KilledMonsterCredit(NPC_KILL_CREDIT_ASK_STEWARD);
|
||||
|
||||
// Objective: explore available plots (Amount 1)
|
||||
player->KilledMonsterCredit(NPC_KILL_CREDIT_EXPLORE_PLOTS);
|
||||
|
||||
// Objective: visit neighborhood locations (Amount 6 - grant all at once)
|
||||
for (uint32 i = 0; i < 6; ++i)
|
||||
player->KilledMonsterCredit(NPC_KILL_CREDIT_VISIT_LOCATIONS);
|
||||
|
||||
// Objective: acquire a home (Amount 3 total across two objectives)
|
||||
for (uint32 i = 0; i < 3; ++i)
|
||||
player->KilledMonsterCredit(NPC_KILL_CREDIT_ACQUIRE_HOME);
|
||||
|
||||
// Objective: talk to the other faction's steward (233708 for Alliance / 233063 for Horde)
|
||||
// The player can't visit the other faction's map, so grant both talkto credits.
|
||||
if (player->GetTeamId() == TEAM_ALLIANCE)
|
||||
player->TalkedToCreature(233708, ObjectGuid::Empty);
|
||||
else
|
||||
player->TalkedToCreature(233063, ObjectGuid::Empty);
|
||||
|
||||
TC_LOG_INFO("housing", "npc_housing_steward: Player {} granted all remaining quest {} credits via steward {}",
|
||||
player->GetGUID().ToString(), QUEST_MY_FIRST_HOME, me->GetEntry());
|
||||
}
|
||||
|
||||
TC_LOG_DEBUG("housing", "npc_housing_steward: Player {} greeted steward {} (kill credit {}, talkto {})",
|
||||
player->GetGUID().ToString(), me->GetEntry(), NPC_KILL_CREDIT_GREET_STEWARD, me->GetEntry());
|
||||
|
||||
// Only show the custom "Ask the steward to join" gossip when the player is on
|
||||
// "My First Home" (91863) and hasn't yet asked the steward (kill credit 248857).
|
||||
// For all other interactions (including quest 94210 "Feathering the Nest" turn-in),
|
||||
// return false to let the default QuestGiver / gossip pathway proceed.
|
||||
if (player->GetQuestStatus(QUEST_MY_FIRST_HOME) == QUEST_STATUS_INCOMPLETE)
|
||||
{
|
||||
InitGossipMenuFor(player, 0);
|
||||
if (me->IsQuestGiver())
|
||||
player->PrepareQuestMenu(me->GetGUID());
|
||||
AddGossipItemFor(player, GossipOptionNpc::None,
|
||||
"Ask the steward to become your neighbor.",
|
||||
GOSSIP_SENDER_MAIN, GOSSIP_ACTION_ASK_TO_JOIN);
|
||||
SendGossipMenuFor(player, DEFAULT_GOSSIP_MESSAGE, me->GetGUID());
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the quest is now complete (or was already complete), return false to let the
|
||||
// default QuestGiver pathway handle the turn-in (request items / offer reward).
|
||||
// For any other quest status, also return false for default gossip handling.
|
||||
return false;
|
||||
}
|
||||
|
||||
bool OnGossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override
|
||||
{
|
||||
uint32 action = GetGossipActionFor(player, gossipListId);
|
||||
CloseGossipMenuFor(player);
|
||||
|
||||
if (action == GOSSIP_ACTION_ASK_TO_JOIN)
|
||||
{
|
||||
// Grant "Ask the steward to join you" kill credit (quest objective 3)
|
||||
player->KilledMonsterCredit(NPC_KILL_CREDIT_ASK_STEWARD);
|
||||
|
||||
TC_LOG_DEBUG("housing", "npc_housing_steward: Player {} asked steward {} to join (kill credit {})",
|
||||
player->GetGUID().ToString(), me->GetEntry(), NPC_KILL_CREDIT_ASK_STEWARD);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_npc_housing_steward()
|
||||
|
||||
Reference in New Issue
Block a user