Kobiesan

Rest exp modifiers not affecting rest xp bar visuals?

I'm trying to recreate the Pandaren racial on 3.3.5a TrinityCore to give double rested experience and I made these edits to player.cpp but the rest bar is not increasing anymore than a normal character without the spell. I'm inclined to believe there's an interface limitation for rest exp growth on the bar. Can anyone help?

OmunFlp.png

Red indicates what I've changed

From Player::Update in player.cpp - https://pastebin.com/CE8pU0Ft

  1. if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING))
  2.     {
  3.         if (roll_chance_i(3) && _restTime > 0)      // freeze update
  4.         {
  5.             time_t currTime = GameTime::GetGameTime();
  6.             time_t timeDiff = currTime - _restTime;
  7.             if (timeDiff >= 10)                             // freeze update
  8.             {
  9.                 _restTime = currTime;
  10.  
  11.                 float bubble;
  12.                 if (HasSpell(90168)) // If has Inner Peace give double rest exp.
  13.                 {
  14.                     bubble = 0.125f * sWorld->getRate(RATE_REST_INGAME) * 2;
  15.                 }
  16.                 else
  17.                 {
  18.                     bubble = 0.125f * sWorld->getRate(RATE_REST_INGAME);
  19.                 }
  20.                 float extraPerSec = ((float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP) / 72000.0f) * bubble;
  21.  
  22.                 // speed collect rest bonus (section/in hour)
  23.                 float currRestBonus = GetRestBonus();
  24.                 SetRestBonus(currRestBonus + timeDiff * extraPerSec);
  25.             }
  26.         }
  27.     }

From Player::LoadFromDB in player.cpp - https://pastebin.com/Ac72z4b8

  1. if (time_diff > 0)
  2.     {
  3.         //speed collect rest bonus in offline, in logout, far from tavern, city (section/in hour)
  4.         float bubble0;
  5.         //speed collect rest bonus in offline, in logout, in tavern, city (section/in hour)
  6.         float bubble1;
  7.         // If has Inner Peace give double rest exp.
  8.         if (HasSpell(90168))
  9.         {
  10.             bubble0 = .062f;
  11.             bubble1 = .25f;
  12.         }
  13.         else
  14.         {
  15.             bubble0 = 0.031f;
  16.             bubble1 = 0.125f;
  17.         }
  18.         float bubble = fields[28].GetUInt8() > 0
  19.             ? bubble1*sWorld->getRate(RATE_REST_OFFLINE_IN_TAVERN_OR_CITY)
  20.             : bubble0*sWorld->getRate(RATE_REST_OFFLINE_IN_WILDERNESS);
  21.  
  22.         SetRestBonus(GetRestBonus() + time_diff*((float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP) / 72000)*bubble);
  23.     }

From Player::GetXPRestBonus in player.cpp - https://pastebin.com/KC0KKKDC

  1. uint32 Player::GetXPRestBonus(uint32 xp)
  2. {
  3.    uint32 rested_bonus = (uint32)GetRestBonus();           // xp for each rested bonus
  4.  
  5.     if (rested_bonus > xp)                                   // max rested_bonus == xp or (r+x) = 200% xp
  6.         rested_bonus = xp;
  7.  
  8.     SetRestBonus(GetRestBonus() - rested_bonus);
  9.  
  10.     TC_LOG_DEBUG("entities.player", "Player::GetXPRestBonus: Player '%s' (%s) gain %u xp (+%u Rested Bonus). Rested points=%f", GetGUID().ToString().c_str(), GetName().c_str(), xp + rested_bonus, rested_bonus, GetRestBonus());
  11.     return HasSpell(90168) ? rested_bonus * 2 : rested_bonus;
  12. }

 

Additionally, I've tried making direct edits to the bubble variable by removing the rate.rest variables from the equations and putting in exactly the rate that I want and still there is no difference between a player who has the spell and who doesn't.

Share this post


Link to post
Share on other sites

Try HasAura instead of HasSpell :)

EDIT:

It is a passive and I never toyed with passives so I am not sure how they work... Well try it just in case. The only think I can promise you is that there is no interface limitation for xp rate : it's all server-side. 

Share this post


Link to post
Share on other sites
19 hours ago, Roarl said:

Try HasAura instead of HasSpell :)

EDIT:

It is a passive and I never toyed with passives so I am not sure how they work... Well try it just in case. The only think I can promise you is that there is no interface limitation for xp rate : it's all server-side. 

Unfortunately, that did not fix it.

Share this post


Link to post
Share on other sites
5 hours ago, Roarl said:

Could you also post your modification in spell.dbc ?

zIW6nES.png

I just changed it into an aura (effect 6) so that HasAura would work.

Share this post


Link to post
Share on other sites

Have you tried to make sure it is the buff being the issue by changing the condition to something else, like your name or “true”? Are you sure that at the time of that calculation, auras are actually applied?

Share this post


Link to post
Share on other sites

Maybe give the player the spell but don't script anything linked with it. Like if you are giving that buff to race = RACE_TAUREN, just check for race == RACE_TAUREN instead of HasAura... Maybe that's kind of hackish though I don't know... And if you want this to be some spell you can learn, then, yeah, it also defeats the purpose.

Share this post


Link to post
Share on other sites
On 1/21/2019 at 8:55 AM, Roarl said:

Maybe give the player the spell but don't script anything linked with it. Like if you are giving that buff to race = RACE_TAUREN, just check for race == RACE_TAUREN instead of HasAura... Maybe that's kind of hackish though I don't know... And if you want this to be some spell you can learn, then, yeah, it also defeats the purpose.

It's for a racial switcher so it needs to be available to all races.

Share this post


Link to post
Share on other sites
On 1/21/2019 at 8:47 AM, wungasaurus said:

Have you tried to make sure it is the buff being the issue by changing the condition to something else, like your name or “true”? Are you sure that at the time of that calculation, auras are actually applied?

Did you try what he said ? :) Like both forcing the check to true and outputting something in the error or debug log if the HasSpell (easiest one to check) condition is true ?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now