Jump to content

[Fix][8477] regenerate power


Auntie Mangos

Recommended Posts

Description of the bug?

Whenever my mana / energy is exausted and is rebuilding , although the spell icon lights up , meaning i have enough mana / energy , i can\\'t use the spell because i get the message that i don;t have enough mana / energy.

For example i can only use an ability requiring 30 energy when i have about 45 - 50 energy. same goes for mana type spells and abilities.

I emphasize that this only happens after i use up my mana or energy and it is recharging. Up to that point it works fine.

For which repository revision was the patch created?

8029

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

http://getmangos.eu/community/viewtopic.php?id=6982

Who has been writing this patch?

Myself + nos4r2zod

Fix:

Update the regenerate mechanism so that it is time-based and no longer only "2 seconds based".

The rune cooldown was also based on 5 ticks of 2 seconds. moved to a more fine time-based cooldown (in msec).

In the normal case, the regenerate is still called every 2sec. However, when a spell requires some power (energy, mana, ...), RegenerateAll is called to have up to date value. Well, almost. To avoid to much regenerate computation, there is a minimum of 400msec between regenerate.

Finally, the unit_flag2 UNIT_FLAG2_REGENERATE_POWER is set/unset to notify the client to display correctly the regen in the mana bar.

Test OK for Mana (with a priest) and Energy (with a rogue). need a test for DK.

latest patch with corrections for [8029] (posted by nos4r2zod) :

http://paste2.org/p/268341

Link to comment
Share on other sites

  • Replies 66
  • Created
  • Last Reply

Top Posters In This Topic

As for this patch: it fixed most of the problem. However when using Life Tap it mana still behaves erratic.

Life Tap triggers this spell, which is spell effect energize, so it's not related to this patch. I think I've fixed it here, same with potions.

Edit: There seems to be a bug with druids when they cast cat form. When you use it, energy "ticks" (in increments of 20) for a while before it begins to regen smoothly. I think it's because the "five second rule" is being applied after casting cat form, causing the server to remove the regenerate flag incorrectly.

Link to comment
Share on other sites

  • 39 years later...
mana.txt:16: trailing whitespace.
       // if no longer casting, set regen power as soon as it is up.
mana.txt:17: trailing whitespace.
       if (!IsUnderLastManaUseEffect())
mana.txt:18: trailing whitespace.
       {
mana.txt:19: trailing whitespace.
           SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER);
mana.txt:20: trailing whitespace.
       }
error: patch failed: src/game/Player.cpp:1266
error: src/game/Player.cpp: patch does not apply
error: patch failed: src/game/Player.h:239
error: src/game/Player.h: patch does not apply
error: patch failed: src/game/Spell.cpp:4851
error: src/game/Spell.cpp: patch does not apply
error: patch failed: src/game/Unit.h:1350
error: src/game/Unit.h: patch does not apply

Link to comment
Share on other sites

mana.txt:16: trailing whitespace.
       // if no longer casting, set regen power as soon as it is up.
mana.txt:17: trailing whitespace.
       if (!IsUnderLastManaUseEffect())
mana.txt:18: trailing whitespace.
       {
mana.txt:19: trailing whitespace.
           SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER);
mana.txt:20: trailing whitespace.
       }
error: patch failed: src/game/Player.cpp:1266
error: src/game/Player.cpp: patch does not apply
error: patch failed: src/game/Player.h:239
error: src/game/Player.h: patch does not apply
error: patch failed: src/game/Spell.cpp:4851
error: src/game/Spell.cpp: patch does not apply
error: patch failed: src/game/Unit.h:1350
error: src/game/Unit.h: patch does not apply

I just applied it without problem on a clean pull of master (rev 7673).

Check your revision. Or may be you have custom patch?

Link to comment
Share on other sites

Ok, I had to manually alter the source content. As you say it probably because of some other patch that changed Player.cpp and I didn't know it :)

As for this patch: it fixed most of the problem. However when using Life Tap it mana still behaves erratic.

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 weeks later...

I think this fixes some shapeshifting quirks:

diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp

index a5a7917..fb5d319 100644

--- a/src/game/Unit.cpp

+++ b/src/game/Unit.cpp

@@ -6924,10 +6924,14 @@ void Unit::setPowerType(Powers new_powertype)

{

default:

case POWER_MANA:

+ if(GetTypeId() == TYPEID_PLAYER && IsUnderLastManaUseEffect())

+ RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER);

break;

case POWER_RAGE:

SetMaxPower(POWER_RAGE,GetCreatePowers(POWER_RAGE));

SetPower( POWER_RAGE,0);

+ if(GetTypeId() == TYPEID_PLAYER)

+ SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER);

break;

case POWER_FOCUS:

SetMaxPower(POWER_FOCUS,GetCreatePowers(POWER_FOCUS));

@@ -6936,6 +6940,8 @@ void Unit::setPowerType(Powers new_powertype)

case POWER_ENERGY:

SetMaxPower(POWER_ENERGY,GetCreatePowers(POWER_ENERGY));

SetPower( POWER_ENERGY,0);

+ if(GetTypeId() == TYPEID_PLAYER)

+ SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER);

break;

case POWER_HAPPINESS:

SetMaxPower(POWER_HAPPINESS,GetCreatePowers(POWER_HAPPINESS));

This allows energy to start ticking immediately after casting cat form, while preventing mana regeneration if you shapeshift out within 5 seconds.

Full patch, applied on [7897].

Link to comment
Share on other sites

Tested and in some special cases it makes players no realy die, they die and regen 1 life than states on a dead can cast state...

Life..? Unrelated I think, this patch deals with power (mana/energy/rage) regeneration. Health "ticks" are still calculated in the same places.

But there was a duel bug with this I believe.

Link to comment
Share on other sites

There also needs to be an update to m_lastRegenerate time after a dead player is resurrected (in Player::ResurrectPlayer), or else it counts the time spent dead as time spent regenerating and returns the player to life with more life/power than intended.

Link to comment
Share on other sites

no, in my addition the timer is updated before the alive check. i considered the case you told and i can assure that the timers are beeing updated correctly (also tested this specific case to be sure)

This isn't related to the bug that GuruRD discovered. RegenerateAll() isn't called at all when the player the player is dead, so the timer never gets updated when dead. So if someone casts a resurrect spell on you, or you have reincarnate, you can wait 5 minutes before clicking accept and immediately come back to life with +5minutes worth of regenerating health and mana.

Link to comment
Share on other sites

  • 2 weeks later...
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