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
+16 -16
View File
@@ -1465,23 +1465,23 @@ namespace Game.Entities
SetHealth(health);
ResetPlayerDamageReq();
// mana
uint mana = stats.GenerateMana(cInfo);
SetCreateMana(mana);
switch (GetClass())
{
case Class.Paladin:
case Class.Mage:
SetMaxPower(PowerType.Mana, (int)mana);
SetPower(PowerType.Mana, (int)mana);
break;
default: // We don't set max power here, 0 makes power bar hidden
break;
}
SetStatFlatModifier(UnitMods.Health, UnitModifierFlatType.Base, health);
// mana
PowerType powerType = CalculateDisplayPowerType();
SetCreateMana(stats.BaseMana);
SetStatPctModifier(UnitMods.PowerStart + (int)powerType, UnitModifierPctType.Base, cInfo.ModMana * cInfo.ModManaExtra);
SetPowerType(powerType);
PowerTypeRecord powerTypeEntry = Global.DB2Mgr.GetPowerTypeEntry(powerType);
if (powerTypeEntry != null)
{
if (powerTypeEntry.GetFlags().HasFlag(PowerTypeFlags.UnitsUseDefaultPowerOnInit))
SetPower(powerType, powerTypeEntry.DefaultPower);
else
SetFullPower(powerType);
}
//Damage
float basedamage = GetBaseDamageForLevel(level);
float weaponBaseMinDamage = basedamage;
@@ -1499,7 +1499,7 @@ namespace Game.Entities
SetStatFlatModifier(UnitMods.AttackPower, UnitModifierFlatType.Base, stats.AttackPower);
SetStatFlatModifier(UnitMods.AttackPowerRanged, UnitModifierFlatType.Base, stats.RangedAttackPower);
float armor = GetBaseArmorForLevel(level); /// @todo Why is this treated as uint32 when it's a float?
float armor = GetBaseArmorForLevel(level);
SetStatFlatModifier(UnitMods.Armor, UnitModifierFlatType.Base, armor);
}
@@ -271,16 +271,6 @@ namespace Game.Entities
public uint BaseMana;
public uint AttackPower;
public uint RangedAttackPower;
// Helpers
public uint GenerateMana(CreatureTemplate info)
{
// Mana can be 0.
if (BaseMana == 0)
return 0;
return (uint)Math.Ceiling(BaseMana * info.ModMana * info.ModManaExtra);
}
}
public class CreatureLocale