Jump to content

[patch] faction depending reputation reward at quest complete


Guest FunkyBit
 Share

Recommended Posts

What bug does the patch fix? What features does the patch add?

The patch adds core support for quests that give different reputation to characters of each faction. Till now each quest can only do up to 5 reputation changes to the completing characters but can not sense the faction the character belongs to.

There are some quests in outland that give different reputation to characters of alliance and horde.

For example: Wanted: Nazan's Riding Crop http://www.wowhead.com/?quest=11354

And also all other daily quests you can do inside the hellfire citadel instances.

For which repository revision was the patch created?

This patch was created for mangos-0.12 branch, revision 8158.

I don't use any 0.13 realm installation so don't ask for a master branch patch.

Is there a thread in the bug report section or at lighthouse?

Never seen one.

Who has been writing this patch?

only me

diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index 652c103..d601454 100644
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
@@ -2815,17 +2815,17 @@ void ObjectMgr::LoadQuests()
        "RewChoiceItemCount1, RewChoiceItemCount2, RewChoiceItemCount3, RewChoiceItemCount4, RewChoiceItemCount5, RewChoiceItemCount6,"
    //   81          82          83          84          85             86             87             88
        "RewItemId1, RewItemId2, RewItemId3, RewItemId4, RewItemCount1, RewItemCount2, RewItemCount3, RewItemCount4,"
-    //   89              90              91              92              93              94            95            96            97            98
-        "RewRepFaction1, RewRepFaction2, RewRepFaction3, RewRepFaction4, RewRepFaction5, RewRepValue1, RewRepValue2, RewRepValue3, RewRepValue4, RewRepValue5,"
-    //   99                 100            101               102       103           104                105               106         107     108     109
+    //   89              90              91              92              93              94                     95                  96            97            98            99            100           101                  102
+        "RewRepFaction1, RewRepFaction2, RewRepFaction3, RewRepFaction4, RewRepFaction5, RewRepFactionAlliance, RewRepFactionHorde, RewRepValue1, RewRepValue2, RewRepValue3, RewRepValue4, RewRepValue5, RewRepValueAlliance, RewRepValueHorde, "
+    //   103                104            105               106       107           108                109               110         111     112     113
        "RewHonorableKills, RewOrReqMoney, RewMoneyMaxLevel, RewSpell, RewSpellCast, RewMailTemplateId, RewMailDelaySecs, PointMapId, PointX, PointY, PointOpt,"
-    //   110            111            112            113            114                 115                 116                 117
+    //   114            115            116            117            118                 119                 120                 121
        "DetailsEmote1, DetailsEmote2, DetailsEmote3, DetailsEmote4, DetailsEmoteDelay1, DetailsEmoteDelay2, DetailsEmoteDelay3, DetailsEmoteDelay4,"
-    //   118              119            120                121                122                123
+    //   122              123            124                125                126                127
        "IncompleteEmote, CompleteEmote, OfferRewardEmote1, OfferRewardEmote2, OfferRewardEmote3, OfferRewardEmote4,"
-    //   124                     125                     126                     127
+    //   128                     129                     130                     131
        "OfferRewardEmoteDelay1, OfferRewardEmoteDelay2, OfferRewardEmoteDelay3, OfferRewardEmoteDelay4,"
-    //   128          129
+    //   132          133
        "StartScript, CompleteScript"
        " FROM quest_template");
    if(result == NULL)
@@ -3344,6 +3344,52 @@ void ObjectMgr::LoadQuests()
            }
        }

+        if(qinfo->RewRepFactionAlliance)
+        {
+            if(!qinfo->RewRepValueAlliance)
+            {
+                sLog.outErrorDb("Quest %u has `RewRepFactionAlliance` = %u but `RewRepValueAlliance` = 0, quest will not reward this reputation.",
+                    qinfo->GetQuestId(),qinfo->RewRepValueAlliance);
+                // no changes
+            }
+
+            if(!sFactionStore.LookupEntry(qinfo->RewRepFactionAlliance))
+            {
+                sLog.outErrorDb("Quest %u has `RewRepFactionAlliance` = %u but raw faction (faction.dbc) %u does not exist, quest will not reward reputation for this faction.",
+                    qinfo->GetQuestId(),qinfo->RewRepFactionAlliance ,qinfo->RewRepFactionAlliance );
+                qinfo->RewRepFactionAlliance = 0;            // quest will not reward this
+            }
+        }
+        else if(qinfo->RewRepValueAlliance!=0)
+        {
+            sLog.outErrorDb("Quest %u has `RewRepFactionAlliance` = 0 but `RewRepValueAlliance` = %u.",
+                qinfo->GetQuestId(),qinfo->RewRepValueAlliance);
+            // no changes, quest ignore this data
+        }
+
+        if(qinfo->RewRepFactionHorde)
+        {
+            if(!qinfo->RewRepValueHorde)
+            {
+                sLog.outErrorDb("Quest %u has `RewRepFactionHorde` = %u but `RewRepValueHorde` = 0, quest will not reward this reputation.",
+                    qinfo->GetQuestId(),qinfo->RewRepValueHorde);
+                // no changes
+            }
+
+            if(!sFactionStore.LookupEntry(qinfo->RewRepFactionHorde))
+            {
+                sLog.outErrorDb("Quest %u has `RewRepFactionHorde` = %u but raw faction (faction.dbc) %u does not exist, quest will not reward reputation for this faction.",
+                    qinfo->GetQuestId(),qinfo->RewRepFactionHorde ,qinfo->RewRepFactionHorde );
+                qinfo->RewRepFactionHorde = 0;            // quest will not reward this
+            }
+        }
+        else if(qinfo->RewRepValueHorde)
+        {
+            sLog.outErrorDb("Quest %u has `RewRepFactionHorde` = 0 but `RewRepValueHorde` = %u.",
+                qinfo->GetQuestId(),qinfo->RewRepValueHorde);
+            // no changes, quest ignore this data
+        }
+
        if(qinfo->RewSpell)
        {
            SpellEntry const* spellInfo = sSpellStore.LookupEntry(qinfo->RewSpell);
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 1e796cb..86205b9 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -5579,6 +5579,21 @@ void Player::RewardReputation(Quest const *pQuest)
        }
    }

+    if(pQuest->RewRepFactionAlliance && GetTeam()==ALLIANCE && pQuest->RewRepValueAlliance)
+    {
+        int32 rep = CalculateReputationGain(GetQuestLevel(pQuest), pQuest->RewRepValueAlliance, pQuest->RewRepFactionAlliance, true);
+        FactionEntry const* factionEntry = sFactionStore.LookupEntry(pQuest->RewRepFactionAlliance);
+        if(factionEntry)
+            GetReputationMgr().ModifyReputation(factionEntry, rep);
+    }
+    else if(pQuest->RewRepFactionHorde && GetTeam()==HORDE && pQuest->RewRepValueHorde)
+    {
+        int32 rep = CalculateReputationGain(GetQuestLevel(pQuest), pQuest->RewRepValueHorde, pQuest->RewRepFactionHorde, true);
+        FactionEntry const* factionEntry = sFactionStore.LookupEntry(pQuest->RewRepFactionHorde);
+        if(factionEntry)
+            GetReputationMgr().ModifyReputation(factionEntry, rep);
+    }
+
    // TODO: implement reputation spillover
}

diff --git a/src/game/QuestDef.cpp b/src/game/QuestDef.cpp
index 53f3381..d59d6a3 100644
--- a/src/game/QuestDef.cpp
+++ b/src/game/QuestDef.cpp
@@ -98,38 +98,44 @@ Quest::Quest(Field * questRecord)
    for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
        RewRepFaction[i] = questRecord[89+i].GetUInt32();

+    RewRepFactionAlliance = questRecord[94].GetUInt32();
+    RewRepFactionHorde = questRecord[95].GetUInt32();
+
    for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
-        RewRepValue[i] = questRecord[94+i].GetInt32();
-
-    RewHonorableKills = questRecord[99].GetUInt32();
-    RewOrReqMoney = questRecord[100].GetInt32();
-    RewMoneyMaxLevel = questRecord[101].GetUInt32();
-    RewSpell = questRecord[102].GetUInt32();
-    RewSpellCast = questRecord[103].GetUInt32();
-    RewMailTemplateId = questRecord[104].GetUInt32();
-    RewMailDelaySecs = questRecord[105].GetUInt32();
-    PointMapId = questRecord[106].GetUInt32();
-    PointX = questRecord[107].GetFloat();
-    PointY = questRecord[108].GetFloat();
-    PointOpt = questRecord[109].GetUInt32();
+        RewRepValue[i] = questRecord[96+i].GetInt32();
+
+    RewRepValueAlliance = questRecord[101].GetInt32();
+    RewRepValueHorde = questRecord[102].GetInt32();
+
+    RewHonorableKills = questRecord[103].GetUInt32();
+    RewOrReqMoney = questRecord[104].GetInt32();
+    RewMoneyMaxLevel = questRecord[105].GetUInt32();
+    RewSpell = questRecord[106].GetUInt32();
+    RewSpellCast = questRecord[107].GetUInt32();
+    RewMailTemplateId = questRecord[108].GetUInt32();
+    RewMailDelaySecs = questRecord[109].GetUInt32();
+    PointMapId = questRecord[110].GetUInt32();
+    PointX = questRecord[111].GetFloat();
+    PointY = questRecord[112].GetFloat();
+    PointOpt = questRecord[113].GetUInt32();

    for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
-        DetailsEmote[i] = questRecord[110+i].GetUInt32();
+        DetailsEmote[i] = questRecord[114+i].GetUInt32();

    for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
-        DetailsEmoteDelay[i] = questRecord[114+i].GetUInt32();
+        DetailsEmoteDelay[i] = questRecord[118+i].GetUInt32();

-    IncompleteEmote = questRecord[118].GetUInt32();
-    CompleteEmote = questRecord[119].GetUInt32();
+    IncompleteEmote = questRecord[122].GetUInt32();
+    CompleteEmote = questRecord[123].GetUInt32();

    for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
-        OfferRewardEmote[i] = questRecord[120+i].GetInt32();
+        OfferRewardEmote[i] = questRecord[124+i].GetInt32();

    for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
-        OfferRewardEmoteDelay[i] = questRecord[124+i].GetInt32();
+        OfferRewardEmoteDelay[i] = questRecord[128+i].GetInt32();

-    QuestStartScript = questRecord[128].GetUInt32();
-    QuestCompleteScript = questRecord[129].GetUInt32();
+    QuestStartScript = questRecord[132].GetUInt32();
+    QuestCompleteScript = questRecord[133].GetUInt32();

    QuestFlags |= SpecialFlags << 16;

diff --git a/src/game/QuestDef.h b/src/game/QuestDef.h
index 7c77e5f..1ec2453 100644
--- a/src/game/QuestDef.h
+++ b/src/game/QuestDef.h
@@ -239,6 +239,11 @@ class Quest
        uint32 OfferRewardEmote[QUEST_EMOTE_COUNT];
        uint32 OfferRewardEmoteDelay[QUEST_EMOTE_COUNT];

+        uint32 RewRepFactionAlliance;
+        uint32 RewRepFactionHorde;
+        int32  RewRepValueAlliance;
+        int32  RewRepValueHorde;
+
        uint32 GetReqItemsCount() const { return m_reqitemscount; }
        uint32 GetReqCreatureOrGOcount() const { return m_reqCreatureOrGOcount; }
        uint32 GetRewChoiceItemsCount() const { return m_rewchoiceitemscount; }

ALTER TABLE quest_template
 ADD COLUMN RewRepFactionAlliance smallint(5) unsigned NOT NULL default '0' COMMENT 'faction id from Faction.dbc in this case' AFTER RewRepFaction5,
 ADD COLUMN RewRepFactionHorde smallint(5) unsigned NOT NULL default '0' COMMENT 'faction id from Faction.dbc in this case' AFTER RewRepFactionAlliance,
 ADD COLUMN RewRepValueAlliance smallint(9) NOT NULL default '0' AFTER RewRepValue5,
 ADD COLUMN RewRepValueHorde smallint(9) NOT NULL default '0' AFTER RewRepValueAlliance;

Patch code at pastebin: http://pastebin.com/f59b5cf82

SQL query at pastebin: http://pastebin.com/f71e1dc1d

If interested in already done db content:

Heroic daily quests: http://pastebin.com/f156ec389

Non-heroic daily quests: http://pastebin.com/f49daf4ea

(this will, if accepted, also be posted at db developers forum)

With best regards

Funkybit

Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...
  • 1 month later...
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use