Core/Misc: Added helper function Unit::SetFullPower * Also renamed Unit::getPowerType and Unit::setPowerType to follow style guidelines
This commit is contained in:
@@ -79,9 +79,9 @@ namespace Game.Entities
|
||||
case UnitMods.Runes:
|
||||
case UnitMods.RunicPower:
|
||||
case UnitMods.SoulShards:
|
||||
case UnitMods.Eclipse:
|
||||
case UnitMods.LunarPower:
|
||||
case UnitMods.HolyPower:
|
||||
case UnitMods.Alternative:
|
||||
case UnitMods.Alternate:
|
||||
case UnitMods.Maelstrom:
|
||||
case UnitMods.Chi:
|
||||
case UnitMods.Insanity:
|
||||
@@ -413,16 +413,16 @@ namespace Game.Entities
|
||||
public virtual float GetArmorMultiplierForTarget(WorldObject target) { return 1.0f; }
|
||||
|
||||
//Powers
|
||||
public PowerType getPowerType()
|
||||
public PowerType GetPowerType()
|
||||
{
|
||||
return (PowerType)GetUInt32Value(UnitFields.DisplayPower);
|
||||
}
|
||||
public void setPowerType(PowerType newPowerType)
|
||||
public void SetPowerType(PowerType powerType)
|
||||
{
|
||||
if (getPowerType() == newPowerType)
|
||||
if (GetPowerType() == powerType)
|
||||
return;
|
||||
|
||||
SetUInt32Value(UnitFields.DisplayPower, (uint)newPowerType);
|
||||
SetUInt32Value(UnitFields.DisplayPower, (uint)powerType);
|
||||
|
||||
if (IsTypeId(TypeId.Player))
|
||||
{
|
||||
@@ -444,7 +444,7 @@ namespace Game.Entities
|
||||
powerMultiplier = creature.GetCreatureTemplate().ModMana;
|
||||
}
|
||||
|
||||
switch (newPowerType)
|
||||
switch (powerType)
|
||||
{
|
||||
default:
|
||||
case PowerType.Mana:
|
||||
@@ -462,13 +462,13 @@ namespace Game.Entities
|
||||
break;
|
||||
}
|
||||
}
|
||||
public void SetMaxPower(PowerType power, int val)
|
||||
public void SetMaxPower(PowerType powerType, int val)
|
||||
{
|
||||
uint powerIndex = GetPowerIndex(power);
|
||||
uint powerIndex = GetPowerIndex(powerType);
|
||||
if (powerIndex == (int)PowerType.Max || powerIndex >= (int)PowerType.MaxPerClass)
|
||||
return;
|
||||
|
||||
int cur_power = GetPower(power);
|
||||
int cur_power = GetPower(powerType);
|
||||
SetInt32Value(UnitFields.MaxPower + (int)powerIndex, val);
|
||||
|
||||
// group update
|
||||
@@ -485,7 +485,7 @@ namespace Game.Entities
|
||||
}*/
|
||||
|
||||
if (val < cur_power)
|
||||
SetPower(power, val);
|
||||
SetPower(powerType, val);
|
||||
}
|
||||
public void SetPower(PowerType powerType, int val)
|
||||
{
|
||||
@@ -521,30 +521,31 @@ namespace Game.Entities
|
||||
pet.SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_CUR_POWER);
|
||||
}*/
|
||||
}
|
||||
public int GetPower(PowerType power)
|
||||
public void SetFullPower(PowerType powerType) { SetPower(powerType, GetMaxPower(powerType)); }
|
||||
public int GetPower(PowerType powerType)
|
||||
{
|
||||
uint powerIndex = GetPowerIndex(power);
|
||||
uint powerIndex = GetPowerIndex(powerType);
|
||||
if (powerIndex == (int)PowerType.Max || powerIndex >= (int)PowerType.MaxPerClass)
|
||||
return 0;
|
||||
|
||||
return GetInt32Value(UnitFields.Power + (int)powerIndex);
|
||||
}
|
||||
public int GetMaxPower(PowerType power)
|
||||
public int GetMaxPower(PowerType powerType)
|
||||
{
|
||||
uint powerIndex = GetPowerIndex(power);
|
||||
uint powerIndex = GetPowerIndex(powerType);
|
||||
if (powerIndex == (int)PowerType.Max || powerIndex >= (int)PowerType.MaxPerClass)
|
||||
return 0;
|
||||
|
||||
return GetInt32Value(UnitFields.MaxPower + (int)powerIndex);
|
||||
}
|
||||
public int GetCreatePowers(PowerType power)
|
||||
public int GetCreatePowers(PowerType powerType)
|
||||
{
|
||||
if (power == PowerType.Mana)
|
||||
if (powerType == PowerType.Mana)
|
||||
return (int)GetCreateMana();
|
||||
|
||||
PowerTypeRecord powerType = Global.DB2Mgr.GetPowerTypeEntry(power);
|
||||
if (powerType != null)
|
||||
return powerType.MaxPower;
|
||||
PowerTypeRecord powerTypeEntry = Global.DB2Mgr.GetPowerTypeEntry(powerType);
|
||||
if (powerTypeEntry != null)
|
||||
return powerTypeEntry.MaxPower;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -560,6 +561,7 @@ namespace Game.Entities
|
||||
|
||||
return Global.DB2Mgr.GetPowerIndexByClass(powerType, _class);
|
||||
}
|
||||
public float GetPowerPct(PowerType powerType) { return GetMaxPower(powerType) != 0 ? 100.0f* GetPower(powerType) / GetMaxPower(powerType) : 0.0f; }
|
||||
|
||||
public void ApplyResilience(Unit victim, ref uint damage)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user