Core/Creatures: Updated power type handling

This commit is contained in:
hondacrx
2018-03-04 23:40:51 -05:00
parent 17d3836438
commit b067976678
7 changed files with 119 additions and 82 deletions
+49 -25
View File
@@ -346,10 +346,20 @@ namespace Game.Entities
public void SetFollowAngle(float angle) { m_followAngle = angle; }
public bool IsPetGhoul() { return GetEntry() == 26125; } // Ghoul may be guardian or pet
// Warlock pets
public bool IsPetImp() { return GetEntry() == (uint)PetEntry.Imp; }
public bool IsPetFelhunter() { return GetEntry() == (uint)PetEntry.FelHunter; }
public bool IsPetVoidwalker() { return GetEntry() == (uint)PetEntry.VoidWalker; }
public bool IsPetSuccubus() { return GetEntry() == (uint)PetEntry.Succubus; }
public bool IsPetDoomguard() { return GetEntry() == (uint)PetEntry.Doomguard; }
public bool IsPetFelguard() { return GetEntry() == (uint)PetEntry.Felguard; }
public bool IsSpiritWolf() { return GetEntry() == 29264; } // Spirit wolf from feral spirits
// Death Knight pets
public bool IsPetGhoul() { return GetEntry() == (uint)PetEntry.Ghoul; } // Ghoul may be guardian or pet
public bool IsPetAbomination() { return GetEntry() == (uint)PetEntry.Abomination; } // Sludge Belcher dk talent
// Shaman pet
public bool IsSpiritWolf() { return GetEntry() == (uint)PetEntry.SpiritWolf; } // Spirit wolf from feral spirits
Unit m_owner;
float m_followAngle;
@@ -454,13 +464,12 @@ namespace Game.Entities
for (int i = (int)SpellSchools.Holy; i < (int)SpellSchools.Max; ++i)
SetModifierValue(UnitMods.ResistanceStart + i, UnitModifierType.BaseValue, cinfo.Resistance[i]);
//health, mana, armor and resistance
// Health, Mana or Power, Armor
PetLevelInfo pInfo = Global.ObjectMgr.GetPetLevelInfo(creature_ID, petlevel);
if (pInfo != null) // exist in DB
{
SetCreateHealth(pInfo.health);
if (petType != PetType.Hunter) //hunter pet use focus
SetCreateMana(pInfo.mana);
SetCreateMana(pInfo.mana);
if (pInfo.armor > 0)
SetModifierValue(UnitMods.Armor, UnitModifierType.BaseValue, pInfo.armor);
@@ -481,6 +490,17 @@ namespace Game.Entities
SetCreateStat(Stats.Intellect, 28);
}
// Power
if (petType == PetType.Hunter) // Hunter pets have focus
SetPowerType(PowerType.Focus);
else if (IsPetGhoul() || IsPetAbomination()) // DK pets have energy
SetPowerType(PowerType.Energy);
else if (IsPetImp() || IsPetFelhunter() || IsPetVoidwalker() || IsPetSuccubus() || IsPetDoomguard() || IsPetFelguard()) // Warlock pets have energy (since 5.x)
SetPowerType(PowerType.Energy);
else
SetPowerType(PowerType.Mana);
// Damage
SetBonusDamage(0);
switch (petType)
{
@@ -711,6 +731,8 @@ namespace Game.Entities
public override bool UpdateAllStats()
{
UpdateMaxHealth();
for (var i = Stats.Strength; i < Stats.Max; ++i)
UpdateStats(i);
@@ -799,30 +821,14 @@ namespace Game.Entities
public override void UpdateMaxPower(PowerType power)
{
if (GetPowerIndex(power) == (uint)PowerType.Max)
return;
UnitMods unitMod = UnitMods.PowerStart + (int)power;
float addValue = (power == PowerType.Mana) ? GetStat(Stats.Intellect) - GetCreateStat(Stats.Intellect) : 0.0f;
float multiplicator = 15.0f;
switch (GetEntry())
{
case ENTRY_IMP:
multiplicator = 4.95f;
break;
case ENTRY_VOIDWALKER:
case ENTRY_SUCCUBUS:
case ENTRY_FELHUNTER:
case ENTRY_FELGUARD:
multiplicator = 11.5f;
break;
default:
multiplicator = 15.0f;
break;
}
float value = GetModifierValue(unitMod, UnitModifierType.BaseValue) + GetCreatePowers(power);
value *= GetModifierValue(unitMod, UnitModifierType.BasePCT);
value += GetModifierValue(unitMod, UnitModifierType.TotalValue) + addValue * multiplicator;
value += GetModifierValue(unitMod, UnitModifierType.TotalValue);
value *= GetModifierValue(unitMod, UnitModifierType.TotalPCT);
SetMaxPower(power, (int)value);
@@ -1024,4 +1030,22 @@ namespace Game.Entities
public TempSummonType type; // Summon type, see TempSummonType for available types
public uint time; // Despawn time, usable only with certain temp summon types
}
enum PetEntry
{
// Warlock pets
Imp = 416,
FelHunter = 691,
VoidWalker = 1860,
Succubus = 1863,
Doomguard = 18540,
Felguard = 30146,
// Death Knight pets
Ghoul = 26125,
Abomination = 106848,
// Shaman pet
SpiritWolf = 29264
}
}