2010-10-07 15:35:36 +02:00
/*
2020-01-02 06:44:10 +01:00
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
2010-10-07 15:35:36 +02:00
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
2008-10-11 14:16:25 -05:00
*/
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
#include "QuestDef.h"
2020-11-05 19:37:35 +01:00
#include "ConditionMgr.h"
2017-06-04 01:00:45 +02:00
#include "DB2Stores.h"
2017-05-18 23:52:58 +02:00
#include "Field.h"
2016-06-24 23:12:03 +02:00
#include "GameTables.h"
2017-05-12 18:49:51 +02:00
#include "Log.h"
2017-12-04 17:35:37 +01:00
#include "ObjectMgr.h"
2008-10-11 14:16:25 -05:00
#include "Player.h"
2025-04-25 20:07:53 +02:00
#include "QueryResult.h"
#include "QueryResultStructured.h"
2014-12-28 22:55:53 +02:00
#include "QuestPackets.h"
2019-08-04 12:22:57 +02:00
#include "QuestPools.h"
2020-11-05 19:37:35 +01:00
#include "SpellMgr.h"
2017-06-04 01:00:45 +02:00
#include "World.h"
2020-12-01 21:08:06 +01:00
#include "WorldSession.h"
2009-10-17 15:51:44 -07:00
2025-04-25 20:07:53 +02:00
#define QUEST_TEMPLATE_FIELDS (ID)(QuestType)(QuestPackageID)(ContentTuningID)(QuestSortID)(QuestInfoID)(SuggestedGroupNum)(RewardNextQuest)(RewardXPDifficulty)\
(RewardXPMultiplier)(RewardMoneyDifficulty)(RewardMoneyMultiplier)(RewardBonusMoney)(RewardSpell)(RewardHonor)(RewardKillHonor)(StartItem)\
2025-04-25 22:50:11 +02:00
(RewardArtifactXPDifficulty)(RewardArtifactXPMultiplier)(RewardArtifactCategoryID)(Flags)(FlagsEx)(FlagsEx2)(FlagsEx3)\
2025-04-25 20:07:53 +02:00
(RewardItem1)(RewardAmount1)(ItemDrop1)(ItemDropQuantity1)(RewardItem2)(RewardAmount2)(ItemDrop2)(ItemDropQuantity2)\
(RewardItem3)(RewardAmount3)(ItemDrop3)(ItemDropQuantity3)(RewardItem4)(RewardAmount4)(ItemDrop4)(ItemDropQuantity4)\
(RewardChoiceItemID1)(RewardChoiceItemQuantity1)(RewardChoiceItemDisplayID1)(RewardChoiceItemID2)(RewardChoiceItemQuantity2)(RewardChoiceItemDisplayID2)\
(RewardChoiceItemID3)(RewardChoiceItemQuantity3)(RewardChoiceItemDisplayID3)(RewardChoiceItemID4)(RewardChoiceItemQuantity4)(RewardChoiceItemDisplayID4)\
(RewardChoiceItemID5)(RewardChoiceItemQuantity5)(RewardChoiceItemDisplayID5)(RewardChoiceItemID6)(RewardChoiceItemQuantity6)(RewardChoiceItemDisplayID6)\
(POIContinent)(POIx)(POIy)(POIPriority)(RewardTitle)(RewardArenaPoints)(RewardSkillLineID)(RewardNumSkillUps)\
(PortraitGiver)(PortraitGiverMount)(PortraitGiverModelSceneID)(PortraitTurnIn)(RewardFactionID1)(RewardFactionValue1)(RewardFactionOverride1)(RewardFactionCapIn1)\
(RewardFactionID2)(RewardFactionValue2)(RewardFactionOverride2)(RewardFactionCapIn2)(RewardFactionID3)(RewardFactionValue3)(RewardFactionOverride3)(RewardFactionCapIn3)\
(RewardFactionID4)(RewardFactionValue4)(RewardFactionOverride4)(RewardFactionCapIn4)(RewardFactionID5)(RewardFactionValue5)(RewardFactionOverride5)(RewardFactionCapIn5)\
(RewardFactionFlags)(RewardCurrencyID1)(RewardCurrencyQty1)(RewardCurrencyID2)(RewardCurrencyQty2)(RewardCurrencyID3)(RewardCurrencyQty3)\
(RewardCurrencyID4)(RewardCurrencyQty4)(AcceptedSoundKitID)(CompleteSoundKitID)(AreaGroupID)(TimeAllowed)(AllowableRaces)(ResetByScheduler)(Expansion)\
(ManagedWorldStateID)(QuestSessionBonus)(LogTitle)(LogDescription)(QuestDescription)(AreaDescription)(PortraitGiverText)(PortraitGiverName)\
(PortraitTurnInText)(PortraitTurnInName)(QuestCompletionLog)
DEFINE_FIELD_ACCESSOR_CACHE ( Quest :: QuestTemplateQueryResult , ResultSet , QUEST_TEMPLATE_FIELDS );
Quest :: Quest ( QueryResult const & questRecord ) : Quest ( QuestTemplateQueryResult { . Result = * questRecord })
2008-10-11 14:16:25 -05:00
{
2025-04-25 20:07:53 +02:00
}
2022-01-18 21:22:41 +01:00
2025-04-25 20:07:53 +02:00
Quest :: Quest ( QuestTemplateQueryResult const & questRecord ) :
RewardItemId ({ questRecord . RewardItem1 (). GetUInt32 (), questRecord . RewardItem2 (). GetUInt32 (),
questRecord . RewardItem3 (). GetUInt32 (), questRecord . RewardItem4 (). GetUInt32 () }),
RewardItemCount ({ questRecord . RewardAmount1 (). GetUInt32 (), questRecord . RewardAmount2 (). GetUInt32 (),
questRecord . RewardAmount3 (). GetUInt32 (), questRecord . RewardAmount4 (). GetUInt32 () }),
ItemDrop ({ questRecord . ItemDrop1 (). GetUInt32 (), questRecord . ItemDrop2 (). GetUInt32 (),
questRecord . ItemDrop3 (). GetUInt32 (), questRecord . ItemDrop4 (). GetUInt32 () }),
ItemDropQuantity ({ questRecord . ItemDropQuantity1 (). GetUInt32 (), questRecord . ItemDropQuantity2 (). GetUInt32 (),
questRecord . ItemDropQuantity3 (). GetUInt32 (), questRecord . ItemDropQuantity4 (). GetUInt32 () }),
RewardChoiceItemId ({ questRecord . RewardChoiceItemID1 (). GetUInt32 (), questRecord . RewardChoiceItemID2 (). GetUInt32 (),
questRecord . RewardChoiceItemID3 (). GetUInt32 (), questRecord . RewardChoiceItemID4 (). GetUInt32 (),
questRecord . RewardChoiceItemID5 (). GetUInt32 (), questRecord . RewardChoiceItemID6 (). GetUInt32 () }),
RewardChoiceItemCount ({ questRecord . RewardChoiceItemQuantity1 (). GetUInt32 (), questRecord . RewardChoiceItemQuantity2 (). GetUInt32 (),
questRecord . RewardChoiceItemQuantity3 (). GetUInt32 (), questRecord . RewardChoiceItemQuantity4 (). GetUInt32 (),
questRecord . RewardChoiceItemQuantity5 (). GetUInt32 (), questRecord . RewardChoiceItemQuantity6 (). GetUInt32 () }),
RewardChoiceItemDisplayId ({ questRecord . RewardChoiceItemDisplayID1 (). GetUInt32 (), questRecord . RewardChoiceItemDisplayID2 (). GetUInt32 (),
questRecord . RewardChoiceItemDisplayID3 (). GetUInt32 (), questRecord . RewardChoiceItemDisplayID4 (). GetUInt32 (),
questRecord . RewardChoiceItemDisplayID5 (). GetUInt32 (), questRecord . RewardChoiceItemDisplayID6 (). GetUInt32 () }),
RewardFactionId ({ questRecord . RewardFactionID1 (). GetUInt32 (), questRecord . RewardFactionID2 (). GetUInt32 (),
questRecord . RewardFactionID3 (). GetUInt32 (), questRecord . RewardFactionID4 (). GetUInt32 (), questRecord . RewardFactionID5 (). GetUInt32 () }),
RewardFactionValue ({ questRecord . RewardFactionValue1 (). GetInt32 (), questRecord . RewardFactionValue2 (). GetInt32 (),
questRecord . RewardFactionValue3 (). GetInt32 (), questRecord . RewardFactionValue4 (). GetInt32 (), questRecord . RewardFactionValue5 (). GetInt32 () }),
RewardFactionOverride ({ questRecord . RewardFactionOverride1 (). GetInt32 (), questRecord . RewardFactionOverride2 (). GetInt32 (),
questRecord . RewardFactionOverride3 (). GetInt32 (), questRecord . RewardFactionOverride4 (). GetInt32 (), questRecord . RewardFactionOverride5 (). GetInt32 () }),
RewardFactionCapIn ({ questRecord . RewardFactionCapIn1 (). GetInt32 (), questRecord . RewardFactionCapIn2 (). GetInt32 (),
questRecord . RewardFactionCapIn3 (). GetInt32 (), questRecord . RewardFactionCapIn4 (). GetInt32 (), questRecord . RewardFactionCapIn5 (). GetInt32 () }),
RewardCurrencyId ({ questRecord . RewardCurrencyID1 (). GetUInt32 (), questRecord . RewardCurrencyID2 (). GetUInt32 (),
questRecord . RewardCurrencyID3 (). GetUInt32 (), questRecord . RewardCurrencyID4 (). GetUInt32 () }),
RewardCurrencyCount ({ questRecord . RewardCurrencyQty1 (). GetUInt32 (), questRecord . RewardCurrencyQty2 (). GetUInt32 (),
questRecord . RewardCurrencyQty3 (). GetUInt32 (), questRecord . RewardCurrencyQty4 (). GetUInt32 () }),
_rewItemsCount ( std :: ranges :: count_if ( RewardItemId , []( uint32 itemId ) { return itemId != 0 ; })),
_rewChoiceItemsCount ( std :: ranges :: count_if ( RewardChoiceItemId , []( uint32 itemId ) { return itemId != 0 ; })),
_id ( questRecord . ID (). GetUInt32 ()),
_type ( questRecord . QuestType (). GetUInt8 ()),
_packageID ( questRecord . QuestPackageID (). GetUInt32 ()),
_contentTuningID ( questRecord . ContentTuningID (). GetInt32 ()),
_questSortID ( questRecord . QuestSortID (). GetInt16 ()),
_questInfoID ( questRecord . QuestInfoID (). GetUInt16 ()),
_suggestedPlayers ( questRecord . SuggestedGroupNum (). GetUInt8 ()),
_nextQuestInChain ( questRecord . RewardNextQuest (). GetUInt32 ()),
_rewardXPDifficulty ( questRecord . RewardXPDifficulty (). GetUInt32 ()),
_rewardXPMultiplier ( questRecord . RewardXPMultiplier (). GetFloat ()),
_rewardMoneyDifficulty ( questRecord . RewardMoneyDifficulty (). GetUInt32 ()),
_rewardMoneyMultiplier ( questRecord . RewardMoneyMultiplier (). GetFloat ()),
_rewardBonusMoney ( questRecord . RewardBonusMoney (). GetUInt32 ()),
_rewardSpell ( questRecord . RewardSpell (). GetUInt32 ()),
_rewardHonor ( questRecord . RewardHonor (). GetUInt32 ()),
_rewardKillHonor ( questRecord . RewardKillHonor (). GetUInt32 ()),
_rewardArtifactXPDifficulty ( questRecord . RewardArtifactXPDifficulty (). GetUInt32 ()),
_rewardArtifactXPMultiplier ( questRecord . RewardArtifactXPMultiplier (). GetFloat ()),
_rewardArtifactCategoryID ( questRecord . RewardArtifactCategoryID (). GetUInt32 ()),
_sourceItemId ( questRecord . StartItem (). GetUInt32 ()),
_flags ( questRecord . Flags (). GetUInt32 ()),
_flagsEx ( questRecord . FlagsEx (). GetUInt32 ()),
_flagsEx2 ( questRecord . FlagsEx2 (). GetUInt32 ()),
2025-04-25 22:50:11 +02:00
_flagsEx3 ( questRecord . FlagsEx3 (). GetUInt32 ()),
2025-04-25 20:07:53 +02:00
_poiContinent ( questRecord . POIContinent (). GetUInt32 ()),
_poix ( questRecord . POIx (). GetFloat ()),
_poiy ( questRecord . POIy (). GetFloat ()),
_poiPriority ( questRecord . POIPriority (). GetUInt32 ()),
_rewardTitleId ( questRecord . RewardTitle (). GetUInt32 ()),
_rewardArenaPoints ( questRecord . RewardArenaPoints (). GetUInt32 ()),
_rewardSkillId ( questRecord . RewardSkillLineID (). GetUInt32 ()),
_rewardSkillPoints ( questRecord . RewardNumSkillUps (). GetUInt32 ()),
_questGiverPortrait ( questRecord . PortraitGiver (). GetUInt32 ()),
_questGiverPortraitMount ( questRecord . PortraitGiverMount (). GetUInt32 ()),
_questGiverPortraitModelSceneId ( questRecord . PortraitGiverModelSceneID (). GetInt32 ()),
_questTurnInPortrait ( questRecord . PortraitTurnIn (). GetUInt32 ()),
_rewardReputationMask ( questRecord . RewardFactionFlags (). GetUInt32 ()),
_soundAccept ( questRecord . AcceptedSoundKitID (). GetUInt32 ()),
_soundTurnIn ( questRecord . CompleteSoundKitID (). GetUInt32 ()),
_areaGroupID ( questRecord . AreaGroupID (). GetUInt32 ()),
_limitTime ( questRecord . TimeAllowed (). GetInt64 ()),
_allowableRaces ({ . RawValue = questRecord . AllowableRaces (). GetUInt64 () }),
_expansion ( questRecord . Expansion (). GetInt32 ()),
_managedWorldStateID ( questRecord . ManagedWorldStateID (). GetInt32 ()),
_questSessionBonus ( questRecord . QuestSessionBonus (). GetInt32 ()),
_logTitle ( questRecord . LogTitle (). GetStringView ()),
_logDescription ( questRecord . LogDescription (). GetStringView ()),
_questDescription ( questRecord . QuestDescription (). GetStringView ()),
_areaDescription ( questRecord . AreaDescription (). GetStringView ()),
_portraitGiverText ( questRecord . PortraitGiverText (). GetStringView ()),
_portraitGiverName ( questRecord . PortraitGiverName (). GetStringView ()),
_portraitTurnInText ( questRecord . PortraitTurnInText (). GetStringView ()),
_portraitTurnInName ( questRecord . PortraitTurnInName (). GetStringView ()),
_questCompletionLog ( questRecord . QuestCompletionLog (). GetStringView ()),
_resetByScheduler ( questRecord . ResetByScheduler (). GetBool ())
{
2020-11-05 19:37:35 +01:00
}
2023-06-02 00:50:30 +02:00
Quest ::~ Quest ()
{
for ( QuestObjective & objective : Objectives )
delete objective . CompletionEffect ;
}
2020-11-05 19:37:35 +01:00
void Quest :: LoadRewardDisplaySpell ( Field * fields )
{
uint32 spellId = fields [ 1 ]. GetUInt32 ();
uint32 playerConditionId = fields [ 2 ]. GetUInt32 ();
2023-05-05 14:34:27 +02:00
uint32 type = fields [ 3 ]. GetUInt32 ();
2020-11-05 19:37:35 +01:00
if ( ! sSpellMgr -> GetSpellInfo ( spellId , DIFFICULTY_NONE ))
{
2023-01-08 21:16:53 +01:00
TC_LOG_ERROR ( "sql.sql" , "Table `quest_reward_display_spell` has non-existing Spell ({}) set for quest {}. Skipped." , spellId , fields [ 0 ]. GetUInt32 ());
2020-11-05 19:37:35 +01:00
return ;
}
if ( playerConditionId && ! sPlayerConditionStore . LookupEntry ( playerConditionId ))
{
2024-03-27 21:38:08 +01:00
if ( ! sConditionMgr -> HasConditionsForNotGroupedEntry ( CONDITION_SOURCE_TYPE_PLAYER_CONDITION , playerConditionId ))
{
TC_LOG_ERROR ( "sql.sql" , "Table `quest_reward_display_spell` has serverside PlayerCondition ({}) set for quest {} and spell {} without conditions. Set to 0." , playerConditionId , fields [ 0 ]. GetUInt32 (), spellId );
playerConditionId = 0 ;
}
2020-11-05 19:37:35 +01:00
}
2023-05-05 14:34:27 +02:00
if ( type >= AsUnderlyingType ( QuestCompleteSpellType :: Max ))
{
TC_LOG_ERROR ( "sql.sql" , "Table `quest_reward_display_spell` invalid type value ({}) set for quest {} and spell {}. Set to 0." , type , fields [ 0 ]. GetUInt32 (), spellId );
type = AsUnderlyingType ( QuestCompleteSpellType :: LegacyBehavior );
}
RewardDisplaySpell . emplace_back ( spellId , playerConditionId , QuestCompleteSpellType ( type ));
2020-11-05 19:37:35 +01:00
}
void Quest :: LoadRewardChoiceItems ( Field * fields )
{
for ( uint32 i = 0 ; i < QUEST_REWARD_CHOICES_COUNT ; ++ i )
RewardChoiceItemType [ i ] = LootItemType ( fields [ 1 + i ]. GetUInt8 ());
2014-12-28 22:55:53 +02:00
}
2010-04-07 18:09:10 +02:00
2014-12-28 22:55:53 +02:00
void Quest :: LoadQuestDetails ( Field * fields )
{
2016-06-24 23:12:03 +02:00
for ( uint32 i = 0 ; i < QUEST_EMOTE_COUNT ; ++ i )
2016-06-28 18:01:03 +02:00
{
if ( ! sEmotesStore . LookupEntry ( fields [ 1 + i ]. GetUInt16 ()))
{
2023-01-08 21:16:53 +01:00
TC_LOG_ERROR ( "sql.sql" , "Table `quest_details` has non-existing Emote{} ({}) set for quest {}. Skipped." , 1 + i , fields [ 1 + i ]. GetUInt16 (), fields [ 0 ]. GetUInt32 ());
2016-06-28 18:01:03 +02:00
continue ;
}
2016-06-24 23:12:03 +02:00
DetailsEmote [ i ] = fields [ 1 + i ]. GetUInt16 ();
2016-06-28 18:01:03 +02:00
}
2010-04-07 18:09:10 +02:00
2016-06-24 23:12:03 +02:00
for ( uint32 i = 0 ; i < QUEST_EMOTE_COUNT ; ++ i )
DetailsEmoteDelay [ i ] = fields [ 5 + i ]. GetUInt32 ();
2014-12-28 22:55:53 +02:00
}
void Quest :: LoadQuestRequestItems ( Field * fields )
{
2017-03-16 00:24:52 -03:00
_emoteOnComplete = fields [ 1 ]. GetUInt16 ();
_emoteOnIncomplete = fields [ 2 ]. GetUInt16 ();
2016-06-28 18:01:03 +02:00
2017-03-16 00:24:52 -03:00
if ( ! sEmotesStore . LookupEntry ( _emoteOnComplete ))
2023-01-08 21:16:53 +01:00
TC_LOG_ERROR ( "sql.sql" , "Table `quest_request_items` has non-existing EmoteOnComplete ({}) set for quest {}." , _emoteOnComplete , fields [ 0 ]. GetUInt32 ());
2016-06-28 18:01:03 +02:00
2017-03-16 00:24:52 -03:00
if ( ! sEmotesStore . LookupEntry ( _emoteOnIncomplete ))
2023-01-08 21:16:53 +01:00
TC_LOG_ERROR ( "sql.sql" , "Table `quest_request_items` has non-existing EmoteOnIncomplete ({}) set for quest {}." , _emoteOnIncomplete , fields [ 0 ]. GetUInt32 ());
2016-06-28 18:01:03 +02:00
2017-03-16 00:24:52 -03:00
_emoteOnCompleteDelay = fields [ 3 ]. GetUInt32 ();
_emoteOnIncompleteDelay = fields [ 4 ]. GetUInt32 ();
2025-04-25 20:07:53 +02:00
_requestItemsText = fields [ 5 ]. GetStringView ();
2014-12-28 22:55:53 +02:00
}
2010-04-07 18:09:10 +02:00
2014-12-28 22:55:53 +02:00
void Quest :: LoadQuestOfferReward ( Field * fields )
{
2016-06-24 23:12:03 +02:00
for ( uint32 i = 0 ; i < QUEST_EMOTE_COUNT ; ++ i )
2016-06-28 18:01:03 +02:00
{
if ( ! sEmotesStore . LookupEntry ( fields [ 1 + i ]. GetUInt16 ()))
{
2023-01-08 21:16:53 +01:00
TC_LOG_ERROR ( "sql.sql" , "Table `quest_offer_reward` has non-existing Emote{} ({}) set for quest {}. Skipped." , 1 + i , fields [ 1 + i ]. GetUInt16 (), fields [ 0 ]. GetUInt32 ());
2016-06-28 18:01:03 +02:00
continue ;
}
2022-07-19 06:25:23 +02:00
OfferRewardEmote [ i ] = fields [ 1 + i ]. GetInt16 ();
2016-06-28 18:01:03 +02:00
}
2010-04-07 18:09:10 +02:00
2016-06-24 23:12:03 +02:00
for ( uint32 i = 0 ; i < QUEST_EMOTE_COUNT ; ++ i )
OfferRewardEmoteDelay [ i ] = fields [ 5 + i ]. GetUInt32 ();
2011-11-26 03:00:06 +00:00
2025-04-25 20:07:53 +02:00
_offerRewardText = fields [ 9 ]. GetStringView ();
2014-12-28 22:55:53 +02:00
}
void Quest :: LoadQuestTemplateAddon ( Field * fields )
{
2017-03-16 00:24:52 -03:00
_maxLevel = fields [ 1 ]. GetUInt8 ();
_allowableClasses = fields [ 2 ]. GetUInt32 ();
_sourceSpellID = fields [ 3 ]. GetUInt32 ();
_prevQuestID = fields [ 4 ]. GetInt32 ();
2017-03-16 01:27:13 -03:00
_nextQuestID = fields [ 5 ]. GetUInt32 ();
2017-03-16 00:24:52 -03:00
_exclusiveGroup = fields [ 6 ]. GetInt32 ();
2019-04-10 12:58:40 +02:00
_breadcrumbForQuestId = fields [ 7 ]. GetInt32 ();
_rewardMailTemplateId = fields [ 8 ]. GetUInt32 ();
_rewardMailDelay = fields [ 9 ]. GetUInt32 ();
_requiredSkillId = fields [ 10 ]. GetUInt16 ();
_requiredSkillPoints = fields [ 11 ]. GetUInt16 ();
_requiredMinRepFaction = fields [ 12 ]. GetUInt16 ();
_requiredMaxRepFaction = fields [ 13 ]. GetUInt16 ();
_requiredMinRepValue = fields [ 14 ]. GetInt32 ();
_requiredMaxRepValue = fields [ 15 ]. GetInt32 ();
_sourceItemIdCount = fields [ 16 ]. GetUInt8 ();
_specialFlags = fields [ 17 ]. GetUInt8 ();
_scriptId = sObjectMgr -> GetScriptId ( fields [ 18 ]. GetString ());
2017-03-16 00:24:52 -03:00
if ( _specialFlags & QUEST_SPECIAL_FLAGS_AUTO_ACCEPT )
_flags |= QUEST_FLAGS_AUTO_ACCEPT ;
2014-12-28 22:55:53 +02:00
}
2014-07-10 13:22:15 -05:00
2017-03-16 00:40:27 -03:00
void Quest :: LoadQuestMailSender ( Field * fields )
{
_rewardMailSenderEntry = fields [ 1 ]. GetUInt32 ();
}
2014-12-28 22:55:53 +02:00
void Quest :: LoadQuestObjective ( Field * fields )
{
2023-06-02 00:50:30 +02:00
QuestObjective & obj = Objectives . emplace_back ();
2017-03-16 00:40:27 -03:00
obj . QuestID = fields [ 0 ]. GetUInt32 ();
obj . ID = fields [ 1 ]. GetUInt32 ();
2014-12-28 22:55:53 +02:00
obj . Type = fields [ 2 ]. GetUInt8 ();
2014-12-29 20:48:40 +02:00
obj . StorageIndex = fields [ 3 ]. GetInt8 ();
2014-12-28 22:55:53 +02:00
obj . ObjectID = fields [ 4 ]. GetInt32 ();
obj . Amount = fields [ 5 ]. GetInt32 ();
obj . Flags = fields [ 6 ]. GetUInt32 ();
2016-10-25 19:13:32 +02:00
obj . Flags2 = fields [ 7 ]. GetUInt32 ();
obj . ProgressBarWeight = fields [ 8 ]. GetFloat ();
2025-04-25 20:07:53 +02:00
obj . Description = fields [ 9 ]. GetStringView ();
2014-12-29 20:48:40 +02:00
2023-06-02 00:50:30 +02:00
bool hasCompletionEffect = std :: any_of ( fields + 10 , fields + 15 , []( Field const & f ) { return ! f . IsNull (); });
if ( hasCompletionEffect )
{
obj . CompletionEffect = new QuestObjectiveAction ();
if ( ! fields [ 10 ]. IsNull ())
obj . CompletionEffect -> GameEventId = fields [ 10 ]. GetUInt32 ();
if ( ! fields [ 11 ]. IsNull ())
obj . CompletionEffect -> SpellId = fields [ 11 ]. GetUInt32 ();
if ( ! fields [ 12 ]. IsNull ())
obj . CompletionEffect -> ConversationId = fields [ 12 ]. GetUInt32 ();
if ( ! fields [ 13 ]. IsNull ())
obj . CompletionEffect -> UpdatePhaseShift = fields [ 13 ]. GetBool ();
if ( ! fields [ 14 ]. IsNull ())
obj . CompletionEffect -> UpdateZoneAuras = fields [ 14 ]. GetBool ();
}
2021-05-09 15:45:29 +02:00
_usedQuestObjectiveTypes [ obj . Type ] = true ;
2014-12-28 22:55:53 +02:00
}
2009-10-17 15:51:44 -07:00
2014-12-28 22:55:53 +02:00
void Quest :: LoadQuestObjectiveVisualEffect ( Field * fields )
{
2015-04-10 18:10:52 +02:00
uint32 objID = fields [ 1 ]. GetUInt32 ();
2009-10-17 15:51:44 -07:00
2014-12-29 20:48:40 +02:00
for ( QuestObjective & obj : Objectives )
{
if ( obj . ID == objID )
{
uint8 effectIndex = fields [ 3 ]. GetUInt8 ();
if ( effectIndex >= obj . VisualEffects . size ())
2017-03-16 00:24:52 -03:00
obj . VisualEffects . resize ( effectIndex + 1 , 0 );
2011-11-26 14:49:15 +00:00
2014-12-29 20:48:40 +02:00
obj . VisualEffects [ effectIndex ] = fields [ 4 ]. GetInt32 ();
break ;
}
}
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2022-12-04 15:13:20 +01:00
void Quest :: LoadConditionalConditionalQuestDescription ( Field * fields )
{
LocaleConstant locale = GetLocaleByName ( fields [ 4 ]. GetStringView ());
2024-06-03 19:44:22 -03:00
if ( ! sWorld -> getBoolConfig ( CONFIG_LOAD_LOCALES ) && locale != DEFAULT_LOCALE )
return ;
2022-12-04 15:13:20 +01:00
if ( locale >= TOTAL_LOCALES )
{
2023-01-08 21:16:53 +01:00
TC_LOG_ERROR ( "sql.sql" , "Table `quest_description_conditional` has invalid locale {} set for quest {}. Skipped." , fields [ 4 ]. GetCString (), fields [ 0 ]. GetUInt32 ());
2022-12-04 15:13:20 +01:00
return ;
}
auto itr = std :: find_if ( _conditionalQuestDescription . begin (), _conditionalQuestDescription . end (), [ fields ]( QuestConditionalText const & text )
{
return text . PlayerConditionId == fields [ 1 ]. GetInt32 () && text . QuestgiverCreatureId == fields [ 2 ]. GetInt32 ();
});
QuestConditionalText & text = itr != _conditionalQuestDescription . end () ? * itr : _conditionalQuestDescription . emplace_back ();
text . PlayerConditionId = fields [ 1 ]. GetInt32 ();
text . QuestgiverCreatureId = fields [ 2 ]. GetInt32 ();
2023-04-30 14:04:28 +02:00
ObjectMgr :: AddLocaleString ( fields [ 3 ]. GetStringView (), locale , text . Text );
2022-12-04 15:13:20 +01:00
}
void Quest :: LoadConditionalConditionalRequestItemsText ( Field * fields )
{
LocaleConstant locale = GetLocaleByName ( fields [ 4 ]. GetStringView ());
2024-06-03 19:44:22 -03:00
if ( ! sWorld -> getBoolConfig ( CONFIG_LOAD_LOCALES ) && locale != DEFAULT_LOCALE )
return ;
2022-12-04 15:13:20 +01:00
if ( locale >= TOTAL_LOCALES )
{
2023-01-08 21:16:53 +01:00
TC_LOG_ERROR ( "sql.sql" , "Table `quest_request_items_conditional` has invalid locale {} set for quest {}. Skipped." , fields [ 4 ]. GetCString (), fields [ 0 ]. GetUInt32 ());
2022-12-04 15:13:20 +01:00
return ;
}
auto itr = std :: find_if ( _conditionalRequestItemsText . begin (), _conditionalRequestItemsText . end (), [ fields ]( QuestConditionalText const & text )
{
return text . PlayerConditionId == fields [ 1 ]. GetInt32 () && text . QuestgiverCreatureId == fields [ 2 ]. GetInt32 ();
});
QuestConditionalText & text = itr != _conditionalRequestItemsText . end () ? * itr : _conditionalRequestItemsText . emplace_back ();
text . PlayerConditionId = fields [ 1 ]. GetInt32 ();
text . QuestgiverCreatureId = fields [ 2 ]. GetInt32 ();
2023-04-30 14:04:28 +02:00
ObjectMgr :: AddLocaleString ( fields [ 3 ]. GetStringView (), locale , text . Text );
2022-12-04 15:13:20 +01:00
}
void Quest :: LoadConditionalConditionalOfferRewardText ( Field * fields )
{
LocaleConstant locale = GetLocaleByName ( fields [ 4 ]. GetStringView ());
2024-06-03 19:44:22 -03:00
if ( ! sWorld -> getBoolConfig ( CONFIG_LOAD_LOCALES ) && locale != DEFAULT_LOCALE )
return ;
2022-12-04 15:13:20 +01:00
if ( locale >= TOTAL_LOCALES )
{
2023-01-08 21:16:53 +01:00
TC_LOG_ERROR ( "sql.sql" , "Table `quest_offer_reward_conditional` has invalid locale {} set for quest {}. Skipped." , fields [ 4 ]. GetCString (), fields [ 0 ]. GetUInt32 ());
2022-12-04 15:13:20 +01:00
return ;
}
auto itr = std :: find_if ( _conditionalOfferRewardText . begin (), _conditionalOfferRewardText . end (), [ fields ]( QuestConditionalText const & text )
{
return text . PlayerConditionId == fields [ 1 ]. GetInt32 () && text . QuestgiverCreatureId == fields [ 2 ]. GetInt32 ();
});
QuestConditionalText & text = itr != _conditionalOfferRewardText . end () ? * itr : _conditionalOfferRewardText . emplace_back ();
text . PlayerConditionId = fields [ 1 ]. GetInt32 ();
text . QuestgiverCreatureId = fields [ 2 ]. GetInt32 ();
2023-04-30 14:04:28 +02:00
ObjectMgr :: AddLocaleString ( fields [ 3 ]. GetStringView (), locale , text . Text );
2022-12-04 15:13:20 +01:00
}
void Quest :: LoadConditionalConditionalQuestCompletionLog ( Field * fields )
{
LocaleConstant locale = GetLocaleByName ( fields [ 4 ]. GetStringView ());
2024-06-03 19:44:22 -03:00
if ( ! sWorld -> getBoolConfig ( CONFIG_LOAD_LOCALES ) && locale != DEFAULT_LOCALE )
return ;
2022-12-04 15:13:20 +01:00
if ( locale >= TOTAL_LOCALES )
{
2023-01-08 21:16:53 +01:00
TC_LOG_ERROR ( "sql.sql" , "Table `quest_completion_log_conditional` has invalid locale {} set for quest {}. Skipped." , fields [ 4 ]. GetCString (), fields [ 0 ]. GetUInt32 ());
2022-12-04 15:13:20 +01:00
return ;
}
auto itr = std :: find_if ( _conditionalQuestCompletionLog . begin (), _conditionalQuestCompletionLog . end (), [ fields ]( QuestConditionalText const & text )
{
return text . PlayerConditionId == fields [ 1 ]. GetInt32 () && text . QuestgiverCreatureId == fields [ 2 ]. GetInt32 ();
});
QuestConditionalText & text = itr != _conditionalQuestCompletionLog . end () ? * itr : _conditionalQuestCompletionLog . emplace_back ();
text . PlayerConditionId = fields [ 1 ]. GetInt32 ();
text . QuestgiverCreatureId = fields [ 2 ]. GetInt32 ();
2023-04-30 14:04:28 +02:00
ObjectMgr :: AddLocaleString ( fields [ 3 ]. GetStringView (), locale , text . Text );
2022-12-04 15:13:20 +01:00
}
2024-08-02 13:25:41 +02:00
void Quest :: LoadTreasurePickers ( Field * fields )
{
_treasurePickerID . push_back ( fields [ 1 ]. GetInt32 ());
}
2018-10-04 18:50:21 +02:00
uint32 Quest :: XPValue ( Player const * player ) const
2022-12-29 16:57:35 +01:00
{
return XPValue ( player , GetContentTuningId (), _rewardXPDifficulty , _rewardXPMultiplier , _expansion );
}
uint32 Quest :: XPValue ( Player const * player , uint32 contentTuningId , uint32 xpDifficulty , float xpMultiplier /*= 1.0f*/ , int32 expansion /*= -1*/ )
2008-10-11 14:16:25 -05:00
{
2018-10-04 18:50:21 +02:00
if ( player )
2008-10-11 14:16:25 -05:00
{
2022-12-29 16:57:35 +01:00
uint32 questLevel = player -> GetQuestLevel ( contentTuningId );
2016-06-24 23:12:03 +02:00
QuestXPEntry const * questXp = sQuestXPStore . LookupEntry ( questLevel );
2022-12-29 16:57:35 +01:00
if ( ! questXp || xpDifficulty >= 10 )
2010-05-23 14:40:23 +02:00
return 0 ;
2023-05-04 17:00:52 +02:00
uint32 xp = questXp -> Difficulty [ xpDifficulty ];
if ( ContentTuningEntry const * contentTuning = sContentTuningStore . LookupEntry ( contentTuningId ))
xp = xp * contentTuning -> QuestXpMultiplier ;
2019-07-01 21:36:32 +02:00
int32 diffFactor = 2 * ( questLevel - player -> GetLevel ()) + 12 ;
2010-05-23 14:40:23 +02:00
if ( diffFactor < 1 )
diffFactor = 1 ;
else if ( diffFactor > 10 )
diffFactor = 10 ;
2023-05-04 17:00:52 +02:00
xp = diffFactor * xp * xpMultiplier / 10 ;
2022-12-29 16:57:35 +01:00
if ( player -> GetLevel () >= GetMaxLevelForExpansion ( CURRENT_EXPANSION - 1 ) && player -> GetSession () -> GetExpansion () == CURRENT_EXPANSION && expansion >= 0 && expansion < CURRENT_EXPANSION )
2020-12-01 21:08:06 +01:00
xp = uint32 ( xp / 9.0f );
2017-11-03 19:25:14 -05:00
xp = RoundXPValue ( xp );
if ( sWorld -> getIntConfig ( CONFIG_MIN_QUEST_SCALED_XP_RATIO ))
{
2022-12-29 16:57:35 +01:00
uint32 minScaledXP = RoundXPValue ( questXp -> Difficulty [ xpDifficulty ] * xpMultiplier ) * sWorld -> getIntConfig ( CONFIG_MIN_QUEST_SCALED_XP_RATIO ) / 100 ;
2017-11-03 19:25:14 -05:00
xp = std :: max ( minScaledXP , xp );
}
2010-05-23 14:40:23 +02:00
return xp ;
2008-10-11 14:16:25 -05:00
}
2010-05-23 14:40:23 +02:00
2008-10-11 14:16:25 -05:00
return 0 ;
}
2009-10-17 15:51:44 -07:00
2019-08-04 12:22:57 +02:00
/*static*/ bool Quest :: IsTakingQuestEnabled ( uint32 questId )
{
if ( ! sQuestPoolMgr -> IsQuestActive ( questId ))
return false ;
return true ;
}
2018-10-04 18:50:21 +02:00
uint32 Quest :: MoneyValue ( Player const * player ) const
2008-10-11 14:16:25 -05:00
{
2018-10-04 18:50:21 +02:00
if ( QuestMoneyRewardEntry const * money = sQuestMoneyRewardStore . LookupEntry ( player -> GetQuestLevel ( this )))
2018-03-12 18:20:26 +01:00
return money -> Difficulty [ GetRewMoneyDifficulty ()] * GetMoneyMultiplier ();
2014-12-29 20:48:40 +02:00
else
return 0 ;
2008-10-11 14:16:25 -05:00
}
2010-07-12 14:38:24 +02:00
2022-01-18 21:22:41 +01:00
uint32 Quest :: MaxMoneyValue () const
{
uint32 value = 0 ;
if ( Optional < ContentTuningLevels > questLevels = sDB2Manager . GetContentTuningData ( GetContentTuningId (), 0 ))
if ( QuestMoneyRewardEntry const * money = sQuestMoneyRewardStore . LookupEntry ( questLevels -> MaxLevel ))
value = money -> Difficulty [ GetRewMoneyDifficulty ()] * GetMoneyMultiplier ();
return value ;
}
uint32 Quest :: GetMaxMoneyReward () const
{
return MaxMoneyValue () * sWorld -> getRate ( RATE_MONEY_QUEST );
}
2020-12-11 22:19:19 +01:00
Optional < QuestTagType > Quest :: GetQuestTag () const
{
if ( QuestInfoEntry const * questInfo = sQuestInfoStore . LookupEntry ( GetQuestInfoID ()))
return static_cast < QuestTagType > ( questInfo -> Type );
return {};
}
2023-07-12 16:29:00 +02:00
bool Quest :: IsImportant () const
{
if ( QuestInfoEntry const * questInfo = sQuestInfoStore . LookupEntry ( GetQuestInfoID ()))
return ( questInfo -> Modifiers & 0x400 ) != 0 ;
return false ;
}
2024-08-02 13:25:41 +02:00
bool Quest :: IsMeta () const
{
if ( QuestInfoEntry const * questInfo = sQuestInfoStore . LookupEntry ( GetQuestInfoID ()))
return ( questInfo -> Modifiers & 0x800 ) != 0 ;
return false ;
}
2014-12-28 22:55:53 +02:00
void Quest :: BuildQuestRewards ( WorldPackets :: Quest :: QuestRewards & rewards , Player * player ) const
{
rewards . ChoiceItemCount = GetRewChoiceItemsCount ();
rewards . ItemCount = GetRewItemsCount ();
2015-07-01 17:57:09 -04:00
rewards . Money = player -> GetQuestMoneyReward ( this );
2014-12-28 22:55:53 +02:00
rewards . XP = player -> GetQuestXPReward ( this );
2016-06-28 20:23:09 +02:00
rewards . ArtifactCategoryID = GetArtifactCategoryId ();
2014-12-28 22:55:53 +02:00
rewards . Title = GetRewTitle ();
rewards . FactionFlags = GetRewardReputationMask ();
2020-11-05 19:37:35 +01:00
auto displaySpellItr = rewards . SpellCompletionDisplayID . begin ();
for ( QuestRewardDisplaySpell displaySpell : RewardDisplaySpell )
{
2024-03-27 21:38:08 +01:00
if ( ! ConditionMgr :: IsPlayerMeetingCondition ( player , displaySpell . PlayerConditionId ))
continue ;
2020-11-05 19:37:35 +01:00
* displaySpellItr = displaySpell . SpellId ;
if ( ++ displaySpellItr == rewards . SpellCompletionDisplayID . end ())
break ;
}
2016-06-24 23:12:03 +02:00
2014-12-28 22:55:53 +02:00
rewards . SpellCompletionID = GetRewSpell ();
rewards . SkillLineID = GetRewardSkillId ();
rewards . NumSkillUps = GetRewardSkillPoints ();
2018-10-04 18:50:21 +02:00
rewards . TreasurePickerID = GetTreasurePickerId ();
2014-12-28 22:55:53 +02:00
for ( uint32 i = 0 ; i < QUEST_REWARD_CHOICES_COUNT ; ++ i )
{
2020-11-05 19:37:35 +01:00
rewards . ChoiceItems [ i ]. LootItemType = RewardChoiceItemType [ i ];
2018-10-04 18:50:21 +02:00
rewards . ChoiceItems [ i ]. Item . ItemID = RewardChoiceItemId [ i ];
2014-12-28 22:55:53 +02:00
rewards . ChoiceItems [ i ]. Quantity = RewardChoiceItemCount [ i ];
}
for ( uint32 i = 0 ; i < QUEST_REWARD_ITEM_COUNT ; ++ i )
{
2024-08-02 13:25:41 +02:00
rewards . Items [ i ]. ItemID = RewardItemId [ i ];
rewards . Items [ i ]. ItemQty = RewardItemCount [ i ];
2014-12-28 22:55:53 +02:00
}
for ( uint32 i = 0 ; i < QUEST_REWARD_REPUTATIONS_COUNT ; ++ i )
{
rewards . FactionID [ i ] = RewardFactionId [ i ];
rewards . FactionValue [ i ] = RewardFactionValue [ i ];
rewards . FactionOverride [ i ] = RewardFactionOverride [ i ];
2016-06-24 23:12:03 +02:00
rewards . FactionCapIn [ i ] = RewardFactionCapIn [ i ];
2014-12-28 22:55:53 +02:00
}
for ( uint32 i = 0 ; i < QUEST_REWARD_CURRENCY_COUNT ; ++ i )
{
2024-08-02 13:25:41 +02:00
rewards . Currencies [ i ]. CurrencyID = RewardCurrencyId [ i ];
rewards . Currencies [ i ]. CurrencyQty = RewardCurrencyCount [ i ];
2014-12-28 22:55:53 +02:00
}
}
2013-02-26 16:57:11 +01:00
uint32 Quest :: GetRewMoneyMaxLevel () const
{
2014-08-20 23:43:56 +02:00
// If Quest has flag to not give money on max level, it's 0
2023-06-10 20:31:33 +02:00
if ( HasFlag ( QUEST_FLAGS_NO_MONEY_FOR_XP ))
2013-02-26 16:57:11 +01:00
return 0 ;
2014-08-20 23:43:56 +02:00
// Else, return the rewarded copper sum modified by the rate
2017-03-16 00:24:52 -03:00
return uint32 ( _rewardBonusMoney * sWorld -> getRate ( RATE_MONEY_MAX_LEVEL_QUEST ));
2013-02-26 16:57:11 +01:00
}
2012-02-08 20:01:38 -06:00
bool Quest :: IsAutoAccept () const
{
2014-07-17 15:42:57 +02:00
return ! sWorld -> getBoolConfig ( CONFIG_QUEST_IGNORE_AUTO_ACCEPT ) && HasFlag ( QUEST_FLAGS_AUTO_ACCEPT );
2012-02-08 20:01:38 -06:00
}
2023-06-10 20:31:33 +02:00
bool Quest :: IsTurnIn () const
2011-10-20 17:53:46 +01:00
{
2023-06-10 20:31:33 +02:00
return ! sWorld -> getBoolConfig ( CONFIG_QUEST_IGNORE_AUTO_COMPLETE ) && _type == QUEST_TYPE_TURNIN ;
2011-10-20 17:53:46 +01:00
}
2012-12-24 19:53:28 +01:00
bool Quest :: IsRaidQuest ( Difficulty difficulty ) const
2010-07-12 14:38:24 +02:00
{
2017-03-16 00:24:52 -03:00
switch ( _questInfoID )
2012-12-24 19:53:28 +01:00
{
2014-12-29 20:48:40 +02:00
case QUEST_INFO_RAID :
2012-12-24 19:53:28 +01:00
return true ;
2014-12-29 20:48:40 +02:00
case QUEST_INFO_RAID_10 :
2015-01-10 01:35:47 +01:00
return difficulty == DIFFICULTY_10_N || difficulty == DIFFICULTY_10_HC ;
2014-12-29 20:48:40 +02:00
case QUEST_INFO_RAID_25 :
2015-01-10 01:35:47 +01:00
return difficulty == DIFFICULTY_25_N || difficulty == DIFFICULTY_25_HC ;
2012-12-24 19:53:28 +01:00
default :
break ;
}
2023-06-10 20:31:33 +02:00
if (( _flags & QUEST_FLAGS_RAID_GROUP_OK ) != 0 )
2016-07-11 10:15:51 +02:00
return true ;
2012-12-24 19:53:28 +01:00
return false ;
}
bool Quest :: IsAllowedInRaid ( Difficulty difficulty ) const
{
if ( IsRaidQuest ( difficulty ))
2010-07-12 14:38:24 +02:00
return true ;
2010-12-23 23:25:44 +01:00
return sWorld -> getBoolConfig ( CONFIG_QUEST_IGNORE_RAID );
2010-07-12 14:38:24 +02:00
}
2011-01-31 16:27:23 +01:00
2015-03-22 13:47:55 +01:00
uint32 Quest :: CalculateHonorGain ( uint8 /*level*/ ) const
2011-01-31 16:27:23 +01:00
{
uint32 honor = 0 ;
2011-11-23 13:16:45 +01:00
/*if (GetRewHonorAddition() > 0 || GetRewHonorMultiplier() > 0.0f)
2011-01-31 16:27:23 +01:00
{
// values stored from 0.. for 1...
2012-08-28 12:03:39 +02:00
TeamContributionPointsEntry const* tc = sTeamContributionPointsStore.LookupEntry(level);
2011-01-31 16:27:23 +01:00
if (!tc)
return 0;
2012-08-28 12:03:39 +02:00
2020-07-12 15:36:55 +02:00
honor = uint32(tc->Data * GetRewHonorMultiplier() * 0.1f);
2011-01-31 16:27:23 +01:00
honor += GetRewHonorAddition();
2011-11-23 13:16:45 +01:00
}*/
2011-01-31 16:27:23 +01:00
return honor ;
}
2016-07-05 09:53:08 +02:00
bool Quest :: CanIncreaseRewardedQuestCounters () const
{
// Dungeon Finder/Daily/Repeatable (if not weekly, monthly or seasonal) quests are never considered rewarded serverside.
// This affects counters and client requests for completed quests.
return ( ! IsDFQuest () && ! IsDaily () && ( ! IsRepeatable () || IsWeekly () || IsMonthly () || IsSeasonal ()));
}
2019-07-27 02:52:13 +02:00
void Quest :: InitializeQueryData ()
{
for ( uint8 loc = LOCALE_enUS ; loc < TOTAL_LOCALES ; ++ loc )
2024-06-03 19:44:22 -03:00
{
if ( ! sWorld -> getBoolConfig ( CONFIG_LOAD_LOCALES ) && loc != DEFAULT_LOCALE )
continue ;
2022-01-18 21:22:41 +01:00
QueryData [ loc ] = BuildQueryData ( static_cast < LocaleConstant > ( loc ), nullptr );
2024-06-03 19:44:22 -03:00
}
2019-07-27 02:52:13 +02:00
}
2022-01-18 21:22:41 +01:00
WorldPacket Quest :: BuildQueryData ( LocaleConstant loc , Player * player ) const
2019-07-27 02:52:13 +02:00
{
WorldPackets :: Quest :: QueryQuestInfoResponse response ;
response . Allow = true ;
response . QuestID = GetQuestId ();
response . Info . LogTitle = GetLogTitle ();
response . Info . LogDescription = GetLogDescription ();
response . Info . QuestDescription = GetQuestDescription ();
response . Info . AreaDescription = GetAreaDescription ();
response . Info . QuestCompletionLog = GetQuestCompletionLog ();
response . Info . PortraitGiverText = GetPortraitGiverText ();
response . Info . PortraitGiverName = GetPortraitGiverName ();
response . Info . PortraitTurnInText = GetPortraitTurnInText ();
response . Info . PortraitTurnInName = GetPortraitTurnInName ();
2022-12-04 15:13:20 +01:00
std :: transform ( GetConditionalQuestDescription (). begin (), GetConditionalQuestDescription (). end (), std :: back_inserter ( response . Info . ConditionalQuestDescription ), [ loc ]( QuestConditionalText const & text )
{
std :: string_view content = text . Text [ LOCALE_enUS ];
ObjectMgr :: GetLocaleString ( text . Text , loc , content );
return WorldPackets :: Quest :: ConditionalQuestText { text . PlayerConditionId , text . QuestgiverCreatureId , content };
});
std :: transform ( GetConditionalQuestCompletionLog (). begin (), GetConditionalQuestCompletionLog (). end (), std :: back_inserter ( response . Info . ConditionalQuestCompletionLog ), [ loc ]( QuestConditionalText const & text )
{
std :: string_view content = text . Text [ LOCALE_enUS ];
ObjectMgr :: GetLocaleString ( text . Text , loc , content );
return WorldPackets :: Quest :: ConditionalQuestText { text . PlayerConditionId , text . QuestgiverCreatureId , content };
});
2019-07-27 02:52:13 +02:00
if ( loc != LOCALE_enUS )
{
if ( QuestTemplateLocale const * questTemplateLocale = sObjectMgr -> GetQuestLocale ( GetQuestId ()))
{
ObjectMgr :: GetLocaleString ( questTemplateLocale -> LogTitle , loc , response . Info . LogTitle );
ObjectMgr :: GetLocaleString ( questTemplateLocale -> LogDescription , loc , response . Info . LogDescription );
ObjectMgr :: GetLocaleString ( questTemplateLocale -> QuestDescription , loc , response . Info . QuestDescription );
ObjectMgr :: GetLocaleString ( questTemplateLocale -> AreaDescription , loc , response . Info . AreaDescription );
ObjectMgr :: GetLocaleString ( questTemplateLocale -> QuestCompletionLog , loc , response . Info . QuestCompletionLog );
ObjectMgr :: GetLocaleString ( questTemplateLocale -> PortraitGiverText , loc , response . Info . PortraitGiverText );
ObjectMgr :: GetLocaleString ( questTemplateLocale -> PortraitGiverName , loc , response . Info . PortraitGiverName );
ObjectMgr :: GetLocaleString ( questTemplateLocale -> PortraitTurnInText , loc , response . Info . PortraitTurnInText );
ObjectMgr :: GetLocaleString ( questTemplateLocale -> PortraitTurnInName , loc , response . Info . PortraitTurnInName );
}
}
response . Info . QuestID = GetQuestId ();
response . Info . QuestType = GetQuestType ();
2020-11-05 19:37:35 +01:00
response . Info . ContentTuningID = GetContentTuningId ();
2019-07-27 02:52:13 +02:00
response . Info . QuestPackageID = GetQuestPackageID ();
response . Info . QuestSortID = GetZoneOrSort ();
response . Info . QuestInfoID = GetQuestInfoID ();
response . Info . SuggestedGroupNum = GetSuggestedPlayers ();
response . Info . RewardNextQuest = GetNextQuestInChain ();
response . Info . RewardXPDifficulty = GetXPDifficulty ();
response . Info . RewardXPMultiplier = GetXPMultiplier ();
2023-06-10 20:31:33 +02:00
if ( ! HasFlag ( QUEST_FLAGS_HIDE_REWARD ))
2022-01-18 21:22:41 +01:00
response . Info . RewardMoney = player ? player -> GetQuestMoneyReward ( this ) : GetMaxMoneyReward ();
2019-07-27 02:52:13 +02:00
response . Info . RewardMoneyDifficulty = GetRewMoneyDifficulty ();
response . Info . RewardMoneyMultiplier = GetMoneyMultiplier ();
response . Info . RewardBonusMoney = GetRewMoneyMaxLevel ();
2020-11-05 19:37:35 +01:00
for ( QuestRewardDisplaySpell displaySpell : RewardDisplaySpell )
2023-05-05 14:34:27 +02:00
{
WorldPackets :: Quest :: QuestCompleteDisplaySpell & rewardDisplaySpell = response . Info . RewardDisplaySpell . emplace_back ();
rewardDisplaySpell . SpellID = displaySpell . SpellId ;
rewardDisplaySpell . PlayerConditionID = displaySpell . PlayerConditionId ;
rewardDisplaySpell . Type = int32 ( displaySpell . Type );
}
2019-07-27 02:52:13 +02:00
response . Info . RewardSpell = GetRewSpell ();
response . Info . RewardHonor = GetRewHonor ();
response . Info . RewardKillHonor = GetRewKillHonor ();
response . Info . RewardArtifactXPDifficulty = GetArtifactXPDifficulty ();
response . Info . RewardArtifactXPMultiplier = GetArtifactXPMultiplier ();
response . Info . RewardArtifactCategoryID = GetArtifactCategoryId ();
response . Info . StartItem = GetSrcItemId ();
response . Info . Flags = GetFlags ();
response . Info . FlagsEx = GetFlagsEx ();
response . Info . FlagsEx2 = GetFlagsEx2 ();
2025-04-25 22:50:11 +02:00
response . Info . FlagsEx3 = GetFlagsEx3 ();
2019-07-27 02:52:13 +02:00
response . Info . RewardTitle = GetRewTitle ();
response . Info . RewardArenaPoints = GetRewArenaPoints ();
response . Info . RewardSkillLineID = GetRewardSkillId ();
response . Info . RewardNumSkillUps = GetRewardSkillPoints ();
response . Info . RewardFactionFlags = GetRewardReputationMask ();
response . Info . PortraitGiver = GetQuestGiverPortrait ();
response . Info . PortraitGiverMount = GetQuestGiverPortraitMount ();
2021-08-05 19:37:53 +02:00
response . Info . PortraitGiverModelSceneID = GetQuestGiverPortraitModelSceneId ();
2019-07-27 02:52:13 +02:00
response . Info . PortraitTurnIn = GetQuestTurnInPortrait ();
for ( uint8 i = 0 ; i < QUEST_ITEM_DROP_COUNT ; ++ i )
{
response . Info . ItemDrop [ i ] = ItemDrop [ i ];
response . Info . ItemDropQuantity [ i ] = ItemDropQuantity [ i ];
}
2023-06-10 20:31:33 +02:00
if ( ! HasFlag ( QUEST_FLAGS_HIDE_REWARD ))
2019-07-27 02:52:13 +02:00
{
for ( uint8 i = 0 ; i < QUEST_REWARD_ITEM_COUNT ; ++ i )
{
response . Info . RewardItems [ i ] = RewardItemId [ i ];
response . Info . RewardAmount [ i ] = RewardItemCount [ i ];
}
for ( uint8 i = 0 ; i < QUEST_REWARD_CHOICES_COUNT ; ++ i )
{
response . Info . UnfilteredChoiceItems [ i ]. ItemID = RewardChoiceItemId [ i ];
response . Info . UnfilteredChoiceItems [ i ]. Quantity = RewardChoiceItemCount [ i ];
}
}
for ( uint8 i = 0 ; i < QUEST_REWARD_REPUTATIONS_COUNT ; ++ i )
{
response . Info . RewardFactionID [ i ] = RewardFactionId [ i ];
response . Info . RewardFactionValue [ i ] = RewardFactionValue [ i ];
response . Info . RewardFactionOverride [ i ] = RewardFactionOverride [ i ];
response . Info . RewardFactionCapIn [ i ] = RewardFactionCapIn [ i ];
}
response . Info . POIContinent = GetPOIContinent ();
response . Info . POIx = GetPOIx ();
response . Info . POIy = GetPOIy ();
response . Info . POIPriority = GetPOIPriority ();
response . Info . AllowableRaces = GetAllowableRaces ();
response . Info . TreasurePickerID = GetTreasurePickerId ();
response . Info . Expansion = GetExpansion ();
2019-10-26 11:17:33 +02:00
response . Info . ManagedWorldStateID = GetManagedWorldStateId ();
response . Info . QuestSessionBonus = 0 ; //GetQuestSessionBonus(); // this is only sent while quest session is active
2022-12-04 15:13:20 +01:00
response . Info . QuestGiverCreatureID = 0 ; // only sent during npc interaction
2019-07-27 02:52:13 +02:00
for ( QuestObjective const & questObjective : GetObjectives ())
{
response . Info . Objectives . push_back ( questObjective );
if ( loc != LOCALE_enUS )
{
if ( QuestObjectivesLocale const * questObjectivesLocale = sObjectMgr -> GetQuestObjectivesLocale ( questObjective . ID ))
ObjectMgr :: GetLocaleString ( questObjectivesLocale -> Description , loc , response . Info . Objectives . back (). Description );
}
}
for ( uint32 i = 0 ; i < QUEST_REWARD_CURRENCY_COUNT ; ++ i )
{
response . Info . RewardCurrencyID [ i ] = RewardCurrencyId [ i ];
response . Info . RewardCurrencyQty [ i ] = RewardCurrencyCount [ i ];
}
response . Info . AcceptedSoundKitID = GetSoundAccept ();
response . Info . CompleteSoundKitID = GetSoundTurnIn ();
response . Info . AreaGroupID = GetAreaGroupID ();
response . Info . TimeAllowed = GetLimitTime ();
2024-08-02 13:25:41 +02:00
response . Info . ResetByScheduler = IsResetByScheduler ();
2019-07-27 02:52:13 +02:00
2018-04-19 17:35:57 +02:00
response . Write ();
2018-08-22 19:44:21 +02:00
response . ShrinkToFit ();
2018-04-19 17:35:57 +02:00
return response . Move ();
2019-07-27 02:52:13 +02:00
}
2017-11-03 19:25:14 -05:00
uint32 Quest :: RoundXPValue ( uint32 xp )
{
if ( xp <= 100 )
return 5 * (( xp + 2 ) / 5 );
else if ( xp <= 500 )
return 10 * (( xp + 5 ) / 10 );
else if ( xp <= 1000 )
return 25 * (( xp + 12 ) / 25 );
else
return 50 * (( xp + 25 ) / 50 );
}