Jump to content

[patch] WotLK Reputation Tabards


Auntie Mangos

Recommended Posts

  • Replies 56
  • Created
  • Last Reply

Top Posters In This Topic

I reworked the code of http://getmangos.eu/community/post/87422/#p87422

- original author=popovk

Already found issues: speedup for HasAura check - some other speedy things if possible

http://paste2.org/p/1353752

From looking around there is only one aura used with all tabards, so no use in storing this spell-id within the database for every npc.

Also I didn't see any information, that the "tabarded" reputation should be modified by a rate or depending on the map/mob.

So I think this version does work pretty correct.

The ugliest part is, where (on the long term)

we must code:

ItemLevel 85 => Expansion=3, ItemLevel 75=> Expansion=2, ItemLevel=1 => any

Observation:

I am not familar with this code, but I tested Keristrasza, which gave me:

250 rep for alliance (without tabard)

325 rep for kirin tor (with kirin tor tabard)

325 rep for ebon blade (ebon blade tabard) ..

Edit: I think this is not correct, but I don't know how the additional exp is created, and I also don't know if this is based on DB data created for different purposes)

Link to comment
Share on other sites

  • 39 years later...

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

This patch adds reputation tabard "championing" for WOTLK factions

For which repository revision was the patch created?

8001

Is there a thread in the bug report section or at lighthouse? If yes, please add a link to the thread.

Yes, this thread

Who has been writing this patch? Please include either forum user names or email addresses.

Me, Energy.

Patch code(insert it into textfile and rename it to .patch, then apply):

diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 8126abc..9acb0af 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -5731,6 +5731,7 @@ int32 Player::CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, in
//Calculates how many reputation points player gains in victim's enemy factions
void Player::RewardReputation(Unit *pVictim, float rate)
{
+    uint32  tabardFactionID = 0;
    if(!pVictim || pVictim->GetTypeId() == TYPEID_PLAYER)
        return;

@@ -5739,11 +5740,28 @@ void Player::RewardReputation(Unit *pVictim, float rate)
    if(!Rep)
        return;

+    // Northrend tabards reputation bonus
+    if(HasAura(57818) && (Rep->repfaction1 == 1037) && (Rep->repfaction2 == 1052))
+    {
+        Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_TABARD );
+        if(item)
+            tabardFactionID = pItem->GetProto()->RequiredReputationFaction;
+    }
+
    if(Rep->repfaction1 && (!Rep->team_dependent || GetTeam()==ALLIANCE))
    {
-        int32 donerep1 = CalculateReputationGain(pVictim->getLevel(), Rep->repvalue1, Rep->repfaction1, false);
+        int32 donerep1 = CalculateReputationGain(pVictim->getLevel(), Rep->repvalue1, tabardFactionID == 0 ? Rep->repfaction1 : tabardFactionID, false);
        donerep1 = int32(donerep1*rate);
-        FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(Rep->repfaction1);
+        FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(tabardFactionID == 0 ? Rep->repfaction1 : tabardFactionID);
        uint32 current_reputation_rank1 = GetReputationMgr().GetRank(factionEntry1);
        if (factionEntry1 && current_reputation_rank1 <= Rep->reputation_max_cap1)
            GetReputationMgr().ModifyReputation(factionEntry1, donerep1);
@@ -5759,9 +5777,9 @@ void Player::RewardReputation(Unit *pVictim, float rate)

    if(Rep->repfaction2 && (!Rep->team_dependent || GetTeam()==HORDE))
    {
-        int32 donerep2 = CalculateReputationGain(pVictim->getLevel(), Rep->repvalue2, Rep->repfaction2, false);
+        int32 donerep2 = CalculateReputationGain(pVictim->getLevel(), Rep->repvalue2, tabardFactionID == 0 ? Rep->repfaction2 : tabardFactionID, false);
        donerep2 = int32(donerep2*rate);
-        FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(Rep->repfaction2);
+        FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(tabardFactionID == 0 ? Rep->repfaction2 : tabardFactionID);
        uint32 current_reputation_rank2 = GetReputationMgr().GetRank(factionEntry2);
        if (factionEntry2 && current_reputation_rank2 <= Rep->reputation_max_cap2)
            GetReputationMgr().ModifyReputation(factionEntry2, donerep2);

If we have correct values in `creature_onkill_reputation` table(RewOnKillRepFaction1 == 1037(Alliance Vanguard), and RewOnKillRepFaction2 == 1052(Horde Expedition)), it looks for tabard auras on player, and changing faction id if needed(tabard equipped).

Example creature_onkill_reputation data:

-- Loken Heroic
INSERT INTO `creature_onkill_reputation` VALUES
(31538, 1037, 1052, 7, 0, 250, 7, 0, 250, 1);
-- Loken Normal
INSERT INTO `creature_onkill_reputation` VALUES
(28923, 1037, 1052, 7, 0, 50, 7, 0, 50, 1);
-- Keristrasza heroic
INSERT INTO `creature_onkill_reputation` VALUES
(30540, 1037, 1052, 7, 0, 250, 7, 0, 250, 1);
-- Keristrasza normal should not give any reputation
-- INSERT INTO `creature_onkill_reputation` VALUES
(26723, 1037, 1052, 7, 0, 50, 7, 0, 50, 1);

This worked as intended for me, but there is one bug with MaNGOS's reputation system(not this patch): if faction(that we trying to increase reputation with) have child factions (i.e. Alliance Vanguard has sub-factions:Explorers' League, The Frostborn, The Silver Covenant, Valiance Expedition), that faction doesn't receive any rep, but all of child factions' reputation is being increased by same amount(250 on heroic and 50 on normal in this case).

Link to comment
Share on other sites

As energy pointed out, child factions still don't work and it's kinda annoying, anyone figured out a fix for that? I remember mangos fixing something related to rep some weeks ago, seems it didn't fix this issue though.

Btw, is that all sql we need to make all tabard reps work? Thanks for the good job :)

Link to comment
Share on other sites

compile error fix:

 // Northrend tabards reputation bonus
   if(HasAura(57818) && (Rep->repfaction1 == 1037) && (Rep->repfaction2 == 1052))
   {
       Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_TABARD );
       if (pItem)
           tabardFactionID = pItem->GetProto()->RequiredReputationFaction;
   }

Link to comment
Share on other sites

As energy pointed out, child factions still don't work and it's kinda annoying, anyone figured out a fix for that? I remember mangos fixing something related to rep some weeks ago, seems it didn't fix this issue though.

I'll try to look at this problem. Seems like there is should be some faction flag, that tells us how to deliver reputation(to parent faction, or to all child factions)

Btw, is that all sql we need to make all tabard reps work? Thanks for the good job :)

Nope, this is test sql data(for 2 bosses only).

compile error fix:

 // Northrend tabards reputation bonus
   if(HasAura(57818) && (Rep->repfaction1 == 1037) && (Rep->repfaction2 == 1052))
   {
       Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_TABARD );
       if (pItem)
           tabardFactionID = pItem->GetProto()->RequiredReputationFaction;
   }

Thanks, first post updated.

Link to comment
Share on other sites

I've been thinking about this for a while and after looking to your patch and another posted in theses forums, I think that finally I've found a generic way to determine which instance is eligible for the championing system.

1. I check for the min_level == 80 from instance_template table and the data from DBCs to know if it's a WotLK instance and heroic.

2. I think that implementing the aura 57818 (HasTabard) is a better way to know if the player has it or not, checking a boolean value is much faster than iterating an array every time you gain a reputation. So I created a boolean var in Player class.

3. Needless to say, you need DB support for that to work (entries in creature_onkill_reputation for every trash / boss)

Here's my version of this patch:

diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 22bf563..7dd8eeb 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -416,6 +416,7 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa

    /////////////////// Instance System /////////////////////

+    m_HasTabard = false;
    m_HomebindTimer = 0;
    m_InstanceValid = true;
    m_dungeonDifficulty = DIFFICULTY_NORMAL;
@@ -5761,15 +5762,32 @@ void Player::RewardReputation(Unit *pVictim, float rate)
        return;

    ReputationOnKillEntry const* Rep = objmgr.GetReputationOnKilEntry(((Creature*)pVictim)->GetCreatureInfo()->Entry);
+    uint32 tabardFactionID = 0;

    if(!Rep)
        return;

+    // Championing System
+    if (m_HasTabard)
+    {
+        InstanceTemplate const* mInstance = objmgr.GetInstanceTemplate(pVictim->GetMapId());
+        MapEntry const* StoredMap = sMapStore.LookupEntry(pVictim->GetMapId());
+        bool heroic = pVictim->GetMap()->IsHeroic();
+
+        // All reputation gains while in level 80 dungeons will be applied to your standing with <faction>.
+        if (mInstance->levelMin == 80 || (StoredMap->Expansion() == 2 && heroic))
+        {
+            Item* tabard = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_TABARD);
+            if (tabard)
+                tabardFactionID = tabard->GetProto()->RequiredReputationFaction;
+        }
+    }
+
    if(Rep->repfaction1 && (!Rep->team_dependent || GetTeam()==ALLIANCE))
    {
-        int32 donerep1 = CalculateReputationGain(pVictim->getLevel(), Rep->repvalue1, Rep->repfaction1, false);
+        int32 donerep1 = CalculateReputationGain(pVictim->getLevel(), Rep->repvalue1, (tabardFactionID) ? tabardFactionID : Rep->repfaction1, false);
        donerep1 = int32(donerep1*rate);
-        FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(Rep->repfaction1);
+        FactionEntry const *factionEntry1 = sFactionStore.LookupEntry((tabardFactionID) ? tabardFactionID : Rep->repfaction1);
        uint32 current_reputation_rank1 = GetReputationMgr().GetRank(factionEntry1);
        if (factionEntry1 && current_reputation_rank1 <= Rep->reputation_max_cap1)
            GetReputationMgr().ModifyReputation(factionEntry1, donerep1);
@@ -5785,9 +5803,9 @@ void Player::RewardReputation(Unit *pVictim, float rate)

    if(Rep->repfaction2 && (!Rep->team_dependent || GetTeam()==HORDE))
    {
-        int32 donerep2 = CalculateReputationGain(pVictim->getLevel(), Rep->repvalue2, Rep->repfaction2, false);
+        int32 donerep2 = CalculateReputationGain(pVictim->getLevel(), Rep->repvalue2, (tabardFactionID) ? tabardFactionID : Rep->repfaction2, false);
        donerep2 = int32(donerep2*rate);
-        FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(Rep->repfaction2);
+        FactionEntry const *factionEntry2 = sFactionStore.LookupEntry((tabardFactionID) ? tabardFactionID : Rep->repfaction2);
        uint32 current_reputation_rank2 = GetReputationMgr().GetRank(factionEntry2);
        if (factionEntry2 && current_reputation_rank2 <= Rep->reputation_max_cap2)
            GetReputationMgr().ModifyReputation(factionEntry2, donerep2);
diff --git a/src/game/Player.h b/src/game/Player.h
index ef17815..9182810 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -2034,6 +2034,7 @@ class MANGOS_DLL_SPEC Player : public Unit

        void UpdateHomebindTime(uint32 time);

+        bool m_HasTabard;
        uint32 m_HomebindTimer;
        bool m_InstanceValid;
        // permanent binds and solo binds by difficulty
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index 2c45612..00b8578 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -2276,6 +2276,13 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
                            m_target->PlayDirectSound(14972, (Player *)m_target);
                    }
                    return;
+                // HasTabard (Championing System)
+                case 57818:
+                    if (caster && caster->GetTypeId() == TYPEID_PLAYER)
+                    {
+                        ((Player*)caster)->m_HasTabard = apply;
+                    }
+                    return;
            }
            break;
        }

Link to comment
Share on other sites

And don't forget about pre-heroic reputation gains in some high-level instances(Oculus, Ulduar:Halls of Stone, etc)

that's covered by this check:

if (mInstance->levelMin == 80)

since its minlevel for normal mode is 80, this patch applies to this difficulty mode too

Link to comment
Share on other sites

that's covered by this check:

if (mInstance->levelMin == 80)

since its minlevel for normal mode is 80, this patch applies to this difficulty mode too

Instance - mode - minlevel - recommended level - group size

Halls of Lightning (NORMAL Mode) 75 (80) 5

The Oculus (NORMAL Mode) 75 (80) 5

Caverns of Time: Culling of Stratholme (NORMAL Mode) 75 (80) 5

Utgarde Pinnacle (NORMAL Mode) 75 (80) 5

so, there is something wrong, levelmin should be 75

Link to comment
Share on other sites

hm ok, so level 80 dungeons, in normal mode, doesn't require level 80 to enter.

so I can't think in a way to know that instance is considered "level 80 dungeon" other than creating a new column in instance_template table with some kind of flag indicating that championing tabards are, for example (0 = not avalilable; 1 = available only in heroic; 2 = available in both difficulties), but I don't know it's worth it.

Link to comment
Share on other sites

hm ok, so level 80 dungeons, in normal mode, doesn't require level 80 to enter.

so I can't think in a way to know that instance is considered "level 80 dungeon" other than creating a new column in instance_template table with some kind of flag indicating that championing tabards are, for example (0 = not avalilable; 1 = available only in heroic; 2 = available in both difficulties), but I don't know it's worth it.

or... wait a second... got it! Use already coded db support(with creature_onkill_reputation), and add this new feature to it:P (look at first post of this thread)

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
  • 4 weeks later...
  • 3 weeks later...
What bug does the patch fix? What features does the patch add?

This patch adds reputation tabard "championing" for WOTLK factions

For which repository revision was the patch created?

8001

Is there a thread in the bug report section or at lighthouse? If yes, please add a link to the thread.

Yes, this thread

Who has been writing this patch? Please include either forum user names or email addresses.

Me, Energy.

Patch code(insert it into textfile and rename it to .patch, then apply):

diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 8126abc..9acb0af 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -5731,6 +5731,7 @@ int32 Player::CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, in
//Calculates how many reputation points player gains in victim's enemy factions
void Player::RewardReputation(Unit *pVictim, float rate)
{
+    uint32  tabardFactionID = 0;
    if(!pVictim || pVictim->GetTypeId() == TYPEID_PLAYER)
        return;

@@ -5739,11 +5740,28 @@ void Player::RewardReputation(Unit *pVictim, float rate)
    if(!Rep)
        return;

+    // Northrend tabards reputation bonus
+    if(HasAura(57818) && (Rep->repfaction1 == 1037) && (Rep->repfaction2 == 1052))
+    {
+        Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_TABARD );
+        if(item)
+            tabardFactionID = pItem->GetProto()->RequiredReputationFaction;
+    }
+
    if(Rep->repfaction1 && (!Rep->team_dependent || GetTeam()==ALLIANCE))
    {
-        int32 donerep1 = CalculateReputationGain(pVictim->getLevel(), Rep->repvalue1, Rep->repfaction1, false);
+        int32 donerep1 = CalculateReputationGain(pVictim->getLevel(), Rep->repvalue1, tabardFactionID == 0 ? Rep->repfaction1 : tabardFactionID, false);
        donerep1 = int32(donerep1*rate);
-        FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(Rep->repfaction1);
+        FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(tabardFactionID == 0 ? Rep->repfaction1 : tabardFactionID);
        uint32 current_reputation_rank1 = GetReputationMgr().GetRank(factionEntry1);
        if (factionEntry1 && current_reputation_rank1 <= Rep->reputation_max_cap1)
            GetReputationMgr().ModifyReputation(factionEntry1, donerep1);
@@ -5759,9 +5777,9 @@ void Player::RewardReputation(Unit *pVictim, float rate)

    if(Rep->repfaction2 && (!Rep->team_dependent || GetTeam()==HORDE))
    {
-        int32 donerep2 = CalculateReputationGain(pVictim->getLevel(), Rep->repvalue2, Rep->repfaction2, false);
+        int32 donerep2 = CalculateReputationGain(pVictim->getLevel(), Rep->repvalue2, tabardFactionID == 0 ? Rep->repfaction2 : tabardFactionID, false);
        donerep2 = int32(donerep2*rate);
-        FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(Rep->repfaction2);
+        FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(tabardFactionID == 0 ? Rep->repfaction2 : tabardFactionID);
        uint32 current_reputation_rank2 = GetReputationMgr().GetRank(factionEntry2);
        if (factionEntry2 && current_reputation_rank2 <= Rep->reputation_max_cap2)
            GetReputationMgr().ModifyReputation(factionEntry2, donerep2);

If we have correct values in `creature_onkill_reputation` table(RewOnKillRepFaction1 == 1037(Alliance Vanguard), and RewOnKillRepFaction2 == 1052(Horde Expedition)), it looks for tabard auras on player, and changing faction id if needed(tabard equipped).

Example creature_onkill_reputation data:

-- Loken Heroic
INSERT INTO `creature_onkill_reputation` VALUES
(31538, 1037, 1052, 7, 0, 250, 7, 0, 250, 1);
-- Loken Normal
INSERT INTO `creature_onkill_reputation` VALUES
(28923, 1037, 1052, 7, 0, 50, 7, 0, 50, 1);
-- Keristrasza heroic
INSERT INTO `creature_onkill_reputation` VALUES
(30540, 1037, 1052, 7, 0, 250, 7, 0, 250, 1);
-- Keristrasza normal should not give any reputation
-- INSERT INTO `creature_onkill_reputation` VALUES
(26723, 1037, 1052, 7, 0, 50, 7, 0, 50, 1);

This worked as intended for me, but there is one bug with MaNGOS's reputation system(not this patch): if faction(that we trying to increase reputation with) have child factions (i.e. Alliance Vanguard has sub-factions:Explorers' League, The Frostborn, The Silver Covenant, Valiance Expedition), that faction doesn't receive any rep, but all of child factions' reputation is being increased by same amount(250 on heroic and 50 on normal in this case).

Works fine, but u have change

+ // Northrend tabards reputation bonus

+ if(HasAura(57818) && (Rep->repfaction1 == 1037) && (Rep->repfaction2 == 1052))

+ {

+ Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_TABARD );

+ if(item)

+ tabardFactionID = pItem->GetProto()->RequiredReputationFaction;

+ }

+

for

+ // Northrend tabards reputation bonus

+ if(HasAura(57818) && (Rep->repfaction1 == 1037) && (Rep->repfaction2 == 1052))

+ {

+ Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_TABARD );

+ if(pItem)

+ tabardFactionID = pItem->GetProto()->RequiredReputationFaction;

+ }

+

And Works pefect ;)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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