Core/Units: Power handling improvements

* Don't include creature_template power multipliers in CreateMana updatefield
* Allow NPCs to have power types other than mana
* Add missing Essence config regeneration rate
* Fixed demon hunter powers not decaying immediately after combat
* Fixed some powers decaying immediately out of combat after energizing (for example holy power)
* Replace hardcoded list of powers to set to full on levelup with a db2 flag check
* Updated Creature::GetPowerIndex for 10.1 new power types
Port From (https://github.com/TrinityCore/TrinityCore/commit/1325e0c4b279d590acbcbb05d6abdf5fdb66a882)
This commit is contained in:
hondacrx
2023-05-23 05:44:42 -04:00
parent 06f99fda8b
commit d55f4f836f
13 changed files with 191 additions and 62 deletions
+1 -1
View File
@@ -331,7 +331,7 @@ namespace Game.Entities
{
base.AtExitCombat();
UpdatePotionCooldown();
m_combatExitTime = Time.GetMSTime();
m_regenInterruptTimestamp = GameTime.Now();
}
public override float GetBlockPercent(uint attackerLevel)
+2 -1
View File
@@ -14,6 +14,7 @@ using Game.Maps;
using Game.Misc;
using Game.Networking.Packets;
using Game.Spells;
using System;
using System.Collections;
using System.Collections.Generic;
@@ -142,7 +143,7 @@ namespace Game.Entities
uint m_deathTimer;
long m_deathExpireTime;
byte m_swingErrorMsg;
uint m_combatExitTime;
DateTime m_regenInterruptTimestamp;
uint m_regenTimerCount;
uint m_foodEmoteTimerCount;
uint m_weaponChangeTimer;
+25 -9
View File
@@ -46,6 +46,8 @@ namespace Game.Entities
if (!GetSession().HasPermission(RBACPermissions.CanFilterWhispers))
SetAcceptWhispers(true);
m_regenInterruptTimestamp = GameTime.Now();
m_zoneUpdateId = 0xffffffff;
m_nextSave = WorldConfig.GetUIntValue(WorldCfg.IntervalSave);
m_customizationsChanged = false;
@@ -3342,7 +3344,7 @@ namespace Game.Entities
if (!IsInCombat())
{
if (powerType.RegenInterruptTimeMS != 0 && Time.GetMSTimeDiffToNow(m_combatExitTime) < powerType.RegenInterruptTimeMS)
if (powerType.GetFlags().HasFlag(PowerTypeFlags.UseRegenInterrupt) && m_regenInterruptTimestamp + TimeSpan.FromMicroseconds(powerType.RegenInterruptTimeMS) < GameTime.Now())
return;
addvalue = (powerType.RegenPeace + m_unitData.PowerRegenFlatModifier[(int)powerIndex]) * 0.001f * RegenTimer;
@@ -3371,13 +3373,13 @@ namespace Game.Entities
WorldCfg.RatePowerArcaneCharges,
WorldCfg.RatePowerFury,
WorldCfg.RatePowerPain,
0, // todo add config for Essence power
0,
0,
0,
0,
0,
0
WorldCfg.RatePowerEssence,
0, // runes
0, // runes
0, // runes
0, // alternate
0, // alternate
0, // alternate
};
if (RatesForPower[(int)power] != 0)
@@ -3470,6 +3472,18 @@ namespace Game.Entities
});
}
}
public void InterruptPowerRegen(PowerType power)
{
uint powerIndex = GetPowerIndex(power);
if (powerIndex == (uint)PowerType.Max || powerIndex >= (uint)PowerType.MaxPerClass)
return;
m_regenInterruptTimestamp = GameTime.Now();
m_powerFraction[powerIndex] = 0.0f;
SendPacket(new InterruptPowerRegen(power));
}
void RegenerateHealth()
{
uint curValue = (uint)GetHealth();
@@ -5046,7 +5060,9 @@ namespace Game.Entities
// Only health and mana are set to maximum.
SetFullHealth();
SetFullPower(PowerType.Mana);
foreach (PowerTypeRecord powerType in CliDB.PowerTypeStorage.Values)
if (powerType.GetFlags().HasFlag(PowerTypeFlags.SetToMaxOnLevelUp))
SetFullPower(powerType.PowerTypeEnum);
// update level to hunter/summon pet
Pet pet = GetPet();