Jump to content

[patch] PLAYER_FLAGS_NO_XP_GAIN


Auntie Mangos

Recommended Posts

All of my spare time is tied up in studying C++ and trying to patch together my own server's update from 3.2.2a to 3.3.3a. I hope I get to test this "No XP" patch soon enough to give timely feedback.

I'm nearly sick to death of staring at side-by-side sources as I work out merge errors!

Link to comment
Share on other sites

I tried it as well and on mangos core 10051 the player keeps the flag whether he relogs or not.

Simpli tested with:

diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 53706be..eb63ea2 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -2514,6 +2514,9 @@ void Player::GiveXP(uint32 xp, Unit* victim)
    if(!isAlive())
        return;

+    if(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_XP_USER_DISABLED))
+        return;
+
    uint32 level = getLevel();

    // XP to money conversion processed in Player::RewardQuest
@@ -17627,6 +17630,13 @@ void Player::BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string

void Player::Say(const std::string& text, const uint32 language)
{
+    // [only for test]
+    if(text == "xp 0" && !HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_XP_USER_DISABLED))
+        SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_XP_USER_DISABLED);
+    else if (text == "xp 1" && HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_XP_USER_DISABLED))
+        RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_XP_USER_DISABLED);
+    // [/only for test]
+
    WorldPacket data(SMSG_MESSAGECHAT, 200);
    BuildPlayerChat(&data, CHAT_MSG_SAY, text, language);
    SendMessageToSetInRange(&data,sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_SAY),true);

Link to comment
Share on other sites

  • 2 weeks later...

Okay, I'm still lost on this one. Can some kind soul alleviate my confusion and actually post a single, clean patch?

All this pasting together from different sources is making me pull out my gray hairs I've gotten from this and other patches that seem to be scattered all over the place in pieces.

I know many custom repos have No-XP implemented. So where are their devs and why aren't they giving back by offering up some code so this can progress?

Link to comment
Share on other sites

  • 1 month later...

The final version is

diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 08aed8a..92179f9 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -2432,6 +2432,9 @@ void Player::GiveXP(uint32 xp, Unit* victim)
    if(level >= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL))
        return;

+    if(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_XP_USER_DISABLED))
+        return;
+
    if(victim)
    {
        // handle SPELL_AURA_MOD_KILL_XP_PCT auras

Link to comment
Share on other sites

Very simple structure. Good work you've done there, TGM. :)

It's such a small patch that I have difficulty believing this is the entire code, after the previous patches. lol

This last version solves the issue of the flag being reset?

Should that be the case, I hope this will make it into the core soon.

Link to comment
Share on other sites

I finally managed to find a bug with this patch. Warlocks can no longer receive a Soulshard while using Drain Soul.

I didn't find the link with this patch.

SpellAuras.cpp, function HandleChannelDeathItem :

       // Soul Shard (target req.)
       if (spellInfo->EffectItemType[m_effIndex] == 6265)
       {
           // Only from non-grey units
           if (!((Player*)caster)->isHonorOrXPTarget(victim) ||
               victim->GetTypeId() == TYPEID_UNIT && !((Player*)caster)->isAllowedToLoot((Creature*)victim))
               return;
       }

Player.cpp :

bool Player::isHonorOrXPTarget(Unit* pVictim) const
{
   uint32 v_level = pVictim->getLevel();
   uint32 k_grey  = MaNGOS::XP::GetGrayLevel(getLevel());

   // Victim level less gray level
   if(v_level<=k_grey)
       return false;

   if(pVictim->GetTypeId() == TYPEID_UNIT)
   {
       if (((Creature*)pVictim)->isTotem() ||
           ((Creature*)pVictim)->isPet() ||
           ((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL)
               return false;
   }
   return true;
}

No link with PLAYER_FLAGS_XP_USER_DISABLED...did you test the spell with exactly the same victim but without the patch?

Link to comment
Share on other sites

  • 10 months later...

Bumping, I've researched this a little

the flag "randomly" being dropped for some and not for others at relogin seems to be because the flag is dropped for players on GM accounts

I'm using this and it seems to work for all players even after a relogin

https://github.com/antiroot/mangos/commit/bffe7293eb44ca9471f04a80442561f9c0aea13e

wowwiki states

Players who have turned off their experience gains by visiting Behsten or Slahtz do not get any money in compensation for the XP they would otherwise gain.

Players at max level should still receive money reward. I haven't tested, but it doesn't look like these changes will affect that feature

Patch 3.2.0 Notes state

Players with experience gains turned off who compete in Battlegrounds will face off only against other players with experience gains turned off.

I did not attempt to write that part because I cannot test this on my server thoroughly enough

Link to comment
Share on other sites

  • 7 months later...

Bumping and giving an update

I've been using my proposed patch for 8 months, and haven't experienced any issues with it.

I have a GM account that is "XP Locked" and is able to login/logout without loosing the flag.

Would love to not have to manually/remember to patch it every time I do a fresh clone

To clarify why some users loose the flag after relogin:

If PLAYER_FLAGS_XP_USER_DISABLED is not added to the old_safe_flags variable then

if( HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM) )

SetUInt32Value(PLAYER_FLAGS, 0 | old_safe_flags);

Those 2 lines unset the flag for GMs

https://github.com/antiroot/mangos/commit/bffe7293eb44ca9471f04a80442561f9c0aea13e

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