Skip to content

Commit

Permalink
Added reputation spillover to quest_template
Browse files Browse the repository at this point in the history
I have added per quest reputation spillover data, and changed the code to utilize that data.

Current changes are made to perfectly mimic previous behavior.
The purpose of this commit is only to create basis for future changes of quest's reputation spillover.
  • Loading branch information
JJBcku committed Aug 1, 2024
1 parent dd034ee commit 6b13f68
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 17 deletions.
3 changes: 3 additions & 0 deletions sql/updates/mangos/z2825_01_mangos_reputation_spillover.sql
Original file line number Diff line number Diff line change
@@ -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';
2 changes: 1 addition & 1 deletion src/game/Entities/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/game/Globals/ObjectMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions src/game/Quests/QuestDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ Quest::Quest(Field* questRecord)
QuestCompleteScript = questRecord[127].GetUInt32();

RequiredCondition = questRecord[128].GetUInt32();
ReputationSpillover = questRecord[130].GetUInt32();

m_isActive = true;

Expand Down
2 changes: 2 additions & 0 deletions src/game/Quests/QuestDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -346,6 +347,7 @@ class Quest
uint32 CompleteEmoteDelay;
uint32 QuestStartScript;
uint32 QuestCompleteScript;
uint32 ReputationSpillover;
};

enum QuestUpdateState
Expand Down
21 changes: 12 additions & 9 deletions src/game/Reputation/ReputationMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/game/Reputation/ReputationMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 6b13f68

Please sign in to comment.