diff --git a/sql/updates/mangos/z2825_01_mangos_reputation_spillover.sql b/sql/updates/mangos/z2825_01_mangos_reputation_spillover.sql new file mode 100644 index 0000000000..7a7600f025 --- /dev/null +++ b/sql/updates/mangos/z2825_01_mangos_reputation_spillover.sql @@ -0,0 +1,3 @@ +ALTER TABLE db_version CHANGE COLUMN required_z2824_01_mangos_model_unification required_z2825_01_mangos_reputation_spillover bit; + +ALTER TABLE quest_template ADD COLUMN ReputationSpillover tinyint unsigned NOT NULL DEFAULT '1'; diff --git a/src/game/Entities/Player.cpp b/src/game/Entities/Player.cpp index c02b06108d..b93115c13e 100644 --- a/src/game/Entities/Player.cpp +++ b/src/game/Entities/Player.cpp @@ -6395,7 +6395,7 @@ void Player::RewardReputation(Quest const* pQuest) int32 rep = CalculateReputationGain(REPUTATION_SOURCE_QUEST, pQuest->RewRepValue[i], pQuest->RewRepFaction[i], GetQuestLevelForPlayer(pQuest)); if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(pQuest->RewRepFaction[i])) - GetReputationMgr().ModifyReputation(factionEntry, rep); + GetReputationMgr().ModifyReputation(factionEntry, rep, pQuest->GetReputationSpillover() == 1); } } diff --git a/src/game/Globals/ObjectMgr.cpp b/src/game/Globals/ObjectMgr.cpp index d46e86d88d..cbb1151ef5 100644 --- a/src/game/Globals/ObjectMgr.cpp +++ b/src/game/Globals/ObjectMgr.cpp @@ -4138,8 +4138,8 @@ void ObjectMgr::LoadQuests() "IncompleteEmote, IncompleteEmoteDelay, CompleteEmote, CompleteEmoteDelay, OfferRewardEmote1, OfferRewardEmote2, OfferRewardEmote3, OfferRewardEmote4," // 122 123 124 125 "OfferRewardEmoteDelay1, OfferRewardEmoteDelay2, OfferRewardEmoteDelay3, OfferRewardEmoteDelay4," - // 126 127 128 129 - "StartScript, CompleteScript, RequiredCondition, BreadcrumbForQuestId" + // 126 127 128 129 130 + "StartScript, CompleteScript, RequiredCondition, BreadcrumbForQuestId, ReputationSpillover" " FROM quest_template"); if (!queryResult) { diff --git a/src/game/Quests/QuestDef.cpp b/src/game/Quests/QuestDef.cpp index cf470f9a3a..3ba27bfd29 100644 --- a/src/game/Quests/QuestDef.cpp +++ b/src/game/Quests/QuestDef.cpp @@ -137,6 +137,7 @@ Quest::Quest(Field* questRecord) QuestCompleteScript = questRecord[127].GetUInt32(); RequiredCondition = questRecord[128].GetUInt32(); + ReputationSpillover = questRecord[130].GetUInt32(); m_isActive = true; diff --git a/src/game/Quests/QuestDef.h b/src/game/Quests/QuestDef.h index 4374ad53a3..0972a15124 100644 --- a/src/game/Quests/QuestDef.h +++ b/src/game/Quests/QuestDef.h @@ -241,6 +241,7 @@ class Quest uint32 GetDetailsEmoteCount() const { return m_detailsemotecount; } uint32 GetQuestStartScript() const { return QuestStartScript; } uint32 GetQuestCompleteScript() const { return QuestCompleteScript; } + uint32 GetReputationSpillover() const { return ReputationSpillover; } bool IsRepeatable() const { return (m_SpecialFlags & QUEST_SPECIAL_FLAG_REPEATABLE) != 0; } bool IsAutoComplete() const { return !QuestMethod; } @@ -346,6 +347,7 @@ class Quest uint32 CompleteEmoteDelay; uint32 QuestStartScript; uint32 QuestCompleteScript; + uint32 ReputationSpillover; }; enum QuestUpdateState diff --git a/src/game/Reputation/ReputationMgr.cpp b/src/game/Reputation/ReputationMgr.cpp index d49fdcdb4c..36cf56b321 100644 --- a/src/game/Reputation/ReputationMgr.cpp +++ b/src/game/Reputation/ReputationMgr.cpp @@ -263,24 +263,27 @@ void ReputationMgr::Initialize() } } -bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental) +bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental, bool reputationSpillover) { if (!factionEntry) return false; bool res = false; - // if spillover definition exists in DB - if (const RepSpilloverTemplate* repTemplate = sObjectMgr.GetRepSpilloverTemplate(factionEntry->ID)) + if (reputationSpillover) { - for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i) + // if spillover definition exists in DB + if (const RepSpilloverTemplate* repTemplate = sObjectMgr.GetRepSpilloverTemplate(factionEntry->ID)) { - if (repTemplate->faction[i]) + for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i) { - if (m_player->GetReputationRank(repTemplate->faction[i]) <= ReputationRank(repTemplate->faction_rank[i])) + if (repTemplate->faction[i]) { - // bonuses are already given, so just modify standing by rate - int32 spilloverRep = standing * repTemplate->faction_rate[i]; - SetOneFactionReputation(sFactionStore.LookupEntry(repTemplate->faction[i]), spilloverRep, incremental); + if (m_player->GetReputationRank(repTemplate->faction[i]) <= ReputationRank(repTemplate->faction_rank[i])) + { + // bonuses are already given, so just modify standing by rate + int32 spilloverRep = standing * repTemplate->faction_rate[i]; + SetOneFactionReputation(sFactionStore.LookupEntry(repTemplate->faction[i]), spilloverRep, incremental); + } } } } diff --git a/src/game/Reputation/ReputationMgr.h b/src/game/Reputation/ReputationMgr.h index 30be71da04..5afccadeb3 100644 --- a/src/game/Reputation/ReputationMgr.h +++ b/src/game/Reputation/ReputationMgr.h @@ -87,13 +87,13 @@ class ReputationMgr ReputationRank const* GetForcedRankIfAny(FactionTemplateEntry const* factionTemplateEntry) const; public: // modifiers - bool SetReputation(FactionEntry const* factionEntry, int32 standing) + bool SetReputation(FactionEntry const* factionEntry, int32 standing, bool reputationSpillover = true) { - return SetReputation(factionEntry, standing, false); + return SetReputation(factionEntry, standing, false, reputationSpillover); } - bool ModifyReputation(FactionEntry const* factionEntry, int32 standing) + bool ModifyReputation(FactionEntry const* factionEntry, int32 standing, bool reputationSpillover = true) { - return SetReputation(factionEntry, standing, true); + return SetReputation(factionEntry, standing, true, reputationSpillover); } void SetVisible(FactionTemplateEntry const* factionTemplateEntry); @@ -111,7 +111,7 @@ class ReputationMgr private: // internal helper functions void Initialize(); uint32 GetDefaultStateFlags(const FactionEntry* factionEntry) const; - bool SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental); + bool SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental, bool reputationSpillover); bool SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing, bool incremental); void SetVisible(FactionState* faction); void SetAtWar(FactionState* faction, bool atWar);