Core/Quests: implement the option to cast spells upon abandoning quests (#434)

* Core/Quest: Implement a way to cast Spells on Quest Abandon.

* Core/Player: add a missing ;

* Core/Quest: moved the Abandon Spell away from a own table into quest_template_addon.
This commit is contained in:
sevi authored and GitHub committed 2023-12-01 16:07:39 +01:00
1 parent b4811b7a5d
commit 986c129bc0
5 files changed
+32 -2

No files matched your search

@@ -0,0 +1,6 @@
--
ALTER TABLE `quest_template_addon`
ADD COLUMN `AbandonSpellID` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `TimeAllowed`;
-- Example
UPDATE `quest_template_addon` SET `AbandonSpellID` = 74113 WHERE `ID` = 24958; -- Volcanoth!
@@ -14595,6 +14595,10 @@ void Player::AbandonQuest(uint32 questId)
if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->ItemDrop[i]))
if (quest->ItemDropQuantity[i] > 0 && itemTemplate->GetBonding() == BIND_QUEST)
DestroyItemCount(quest->ItemDrop[i], 9999, true);
// If Quest has a Abandon Spell cast it now
if (quest->GetQuestAbandonSpell() != 0)
CastSpell(this, quest->GetQuestAbandonSpell(), true);
}
}
+19 -2
View File
@@ -4092,8 +4092,8 @@ void ObjectMgr::LoadQuests()
// 0 1 2 3 4 5 6 7 8 9
{ "ID, MaxLevel, AllowableClasses, SourceSpellID, PrevQuestID, NextQuestID, ExclusiveGroup, BreadcrumbForQuestId, RewardMailTemplateID, RewardMailDelay,"
// 10 11 12 13 14 15 16 17 18 19
" RequiredSkillID, RequiredSkillPoints, RequiredMinRepFaction, RequiredMaxRepFaction, RequiredMinRepValue, RequiredMaxRepValue, ProvidedItemCount, SpecialFlags, AllowableRaces, TimeAllowed", "quest_template_addon", "template addons", &Quest::LoadQuestTemplateAddon },
// 10 11 12 13 14 15 16 17 18 19 20
" RequiredSkillID, RequiredSkillPoints, RequiredMinRepFaction, RequiredMaxRepFaction, RequiredMinRepValue, RequiredMaxRepValue, ProvidedItemCount, SpecialFlags, AllowableRaces, TimeAllowed, AbandonSpellID", "quest_template_addon", "template addons", &Quest::LoadQuestTemplateAddon },
// 0 1
{ "QuestId, RewardMailSenderEntry", "quest_mail_sender", "mail sender entries", &Quest::LoadQuestMailSender }
@@ -4757,6 +4757,23 @@ void ObjectMgr::LoadQuests()
}
}
if (qinfo->_questAbandonSpell)
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->_questAbandonSpell);
if (!spellInfo)
{
TC_LOG_ERROR("sql.sql", "Quest %u has `QuestAbandonSpell` = %u but spell %u doesn't exist, quest abandon Spell can't be work.",
qinfo->GetQuestId(), qinfo->_questAbandonSpell, qinfo->_questAbandonSpell);
qinfo->_questAbandonSpell = 0; // quest can't be done for this requirement
}
else if (!SpellMgr::IsSpellValid(spellInfo))
{
TC_LOG_ERROR("sql.sql", "Quest %u has `QuestAbandonSpell` = %u but spell %u is broken, quest abandon Spell can't be work",
qinfo->GetQuestId(), qinfo->_questAbandonSpell, qinfo->_questAbandonSpell);
qinfo->_questAbandonSpell = 0; // quest can't be done for this requirement
}
}
// fill additional data stores
if (uint32 prevQuestId = std::abs(qinfo->_prevQuestId))
{
+1
View File
@@ -232,6 +232,7 @@ void Quest::LoadQuestTemplateAddon(Field* fields)
_allowableRaces = fields[18].GetUInt32();
_timeAllowed = fields[19].GetInt32();
_questAbandonSpell = fields[20].GetUInt32();
}
void Quest::LoadQuestMailSender(Field* fields)
+2
View File
@@ -371,6 +371,7 @@ class TC_GAME_API Quest
uint32 GetRewItemsCount() const { return _rewItemsCount; }
uint32 GetRewCurrencyCount() const { return _rewCurrencyCount; }
uint32 GetReqCurrencyCount() const { return _reqCurrencyCount; }
uint32 GetQuestAbandonSpell() const { return _questAbandonSpell; }
void SetEventIdForQuest(uint16 eventId) { _eventIdForQuest = eventId; }
uint16 GetEventIdForQuest() const { return _eventIdForQuest; }
@@ -475,6 +476,7 @@ class TC_GAME_API Quest
uint32 _specialFlags = 0; // custom flags, not sniffed/WDB
uint32 _allowableRaces = 0;
uint32 _timeAllowed = 0;
uint32 _questAbandonSpell = 0;
};
struct QuestStatusData