Core/Misc: Added helper function Unit::SetFullPower * Also renamed Unit::getPowerType and Unit::setPowerType to follow style guidelines

This commit is contained in:
hondacrx
2018-01-03 13:57:16 -05:00
parent 8b43b08f6f
commit 9d3e87fd87
30 changed files with 106 additions and 124 deletions
@@ -357,7 +357,7 @@ namespace Game.Entities
SendActionButtons(1);
UpdateDisplayPower();
PowerType pw = getPowerType();
PowerType pw = GetPowerType();
if (pw != PowerType.Mana)
SetPower(PowerType.Mana, 0); // Mana must be 0 even if it isn't the active power type.
+20 -27
View File
@@ -345,8 +345,8 @@ namespace Game.Entities
// apply original stats mods before spell loading or item equipment that call before equip _RemoveStatsMods()
UpdateMaxHealth(); // Update max Health (for add bonus from stamina)
SetFullHealth();
if (getPowerType() == PowerType.Mana)
SetPower(PowerType.Mana, GetMaxPower(PowerType.Mana));
if (GetPowerType() == PowerType.Mana)
SetFullPower(PowerType.Mana);
// original spells
LearnDefaultSkills();
@@ -3573,19 +3573,12 @@ namespace Game.Entities
{
ResurrectPlayer(0.0f, false);
if (GetMaxHealth() > _resurrectionData.Health)
SetHealth(_resurrectionData.Health);
else
SetFullHealth();
if (GetMaxPower(PowerType.Mana) > _resurrectionData.Mana)
SetPower(PowerType.Mana, (int)_resurrectionData.Mana);
else
SetPower(PowerType.Mana, GetMaxPower(PowerType.Mana));
SetHealth(_resurrectionData.Health);
SetPower(PowerType.Mana, (int)_resurrectionData.Mana);
SetPower(PowerType.Rage, 0);
SetPower(PowerType.Energy, GetMaxPower(PowerType.Energy));
SetPower(PowerType.Focus, GetMaxPower(PowerType.Focus));
SetFullPower(PowerType.Energy);
SetFullPower(PowerType.Focus);
SetPower(PowerType.LunarPower, 0);
uint aura = _resurrectionData.Aura;
@@ -3921,17 +3914,17 @@ namespace Game.Entities
}
public void ResetAllPowers()
{
SetHealth(GetMaxHealth());
switch (getPowerType())
SetFullHealth();
switch (GetPowerType())
{
case PowerType.Mana:
SetPower(PowerType.Mana, GetMaxPower(PowerType.Mana));
SetFullPower(PowerType.Mana);
break;
case PowerType.Rage:
SetPower(PowerType.Rage, 0);
break;
case PowerType.Energy:
SetPower(PowerType.Energy, GetMaxPower(PowerType.Energy));
SetFullPower(PowerType.Energy);
break;
case PowerType.RunicPower:
SetPower(PowerType.RunicPower, 0);
@@ -4484,7 +4477,7 @@ namespace Game.Entities
// set health/powers (0- will be set in caller)
if (restore_percent > 0.0f)
{
SetHealth((uint)(GetMaxHealth() * restore_percent));
SetHealth((ulong)(GetMaxHealth() * restore_percent));
SetPower(PowerType.Mana, (int)(GetMaxPower(PowerType.Mana) * restore_percent));
SetPower(PowerType.Rage, 0);
SetPower(PowerType.Energy, (int)(GetMaxPower(PowerType.Energy) * restore_percent));
@@ -4842,7 +4835,7 @@ namespace Game.Entities
pet.SetCreatorGUID(GetGUID());
pet.SetUInt32Value(UnitFields.FactionTemplate, getFaction());
pet.setPowerType(PowerType.Mana);
pet.SetPowerType(PowerType.Mana);
pet.SetUInt64Value(UnitFields.NpcFlags, (uint)NPCFlags.None);
pet.SetUInt32Value(UnitFields.Bytes1, 0);
pet.InitStatsForLevel(getLevel());
@@ -4858,7 +4851,7 @@ namespace Game.Entities
pet.SetUInt32Value(UnitFields.PetExperience, 0);
pet.SetUInt32Value(UnitFields.PetNextLevelExp, 1000);
pet.SetFullHealth();
pet.SetPower(PowerType.Mana, pet.GetMaxPower(PowerType.Mana));
pet.SetFullPower(PowerType.Mana);
pet.SetUInt32Value(UnitFields.PetNameTimestamp, (uint)Time.UnixTime); // cast can't be helped in this case
break;
default:
@@ -5332,10 +5325,10 @@ namespace Game.Entities
// set current level health and mana/energy to maximum after applying all mods.
SetFullHealth();
SetPower(PowerType.Mana, GetMaxPower(PowerType.Mana));
SetPower(PowerType.Energy, GetMaxPower(PowerType.Energy));
SetFullPower(PowerType.Mana);
SetFullPower(PowerType.Energy);
if (GetPower(PowerType.Rage) > GetMaxPower(PowerType.Rage))
SetPower(PowerType.Rage, GetMaxPower(PowerType.Rage));
SetFullPower(PowerType.Rage);
SetPower(PowerType.Focus, 0);
// update level to hunter/summon pet
@@ -5914,11 +5907,11 @@ namespace Game.Entities
// set current level health and mana/energy to maximum after applying all mods.
SetFullHealth();
SetPower(PowerType.Mana, GetMaxPower(PowerType.Mana));
SetPower(PowerType.Energy, GetMaxPower(PowerType.Energy));
SetFullPower(PowerType.Mana);
SetFullPower(PowerType.Energy);
if (GetPower(PowerType.Rage) > GetMaxPower(PowerType.Rage))
SetPower(PowerType.Rage, GetMaxPower(PowerType.Rage));
SetPower(PowerType.Focus, GetMaxPower(PowerType.Focus));
SetFullPower(PowerType.Rage);
SetFullPower(PowerType.Focus);
SetPower(PowerType.RunicPower, 0);
// update level to hunter/summon pet