mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 08:28:32 +01:00
[7785] Allow regenerate energy for pets if this current power type. Author: Astellar
--HG-- branch : trunk
This commit is contained in:
@@ -565,18 +565,26 @@ void Pet::Update(uint32 diff)
|
||||
}
|
||||
}
|
||||
|
||||
if(getPetType() != HUNTER_PET)
|
||||
break;
|
||||
|
||||
//regenerate Focus
|
||||
//regenerate focus for hunter pets or energy for deathknight's ghoul
|
||||
if(m_regenTimer <= diff)
|
||||
{
|
||||
RegenerateFocus();
|
||||
switch (getPowerType())
|
||||
{
|
||||
case POWER_FOCUS:
|
||||
case POWER_ENERGY:
|
||||
Regenerate(getPowerType());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
m_regenTimer = 4000;
|
||||
}
|
||||
else
|
||||
m_regenTimer -= diff;
|
||||
|
||||
if(getPetType() != HUNTER_PET)
|
||||
break;
|
||||
|
||||
if(m_happinessTimer <= diff)
|
||||
{
|
||||
LooseHappiness();
|
||||
@@ -593,22 +601,41 @@ void Pet::Update(uint32 diff)
|
||||
Creature::Update(diff);
|
||||
}
|
||||
|
||||
void Pet::RegenerateFocus()
|
||||
void Pet::Regenerate(Powers power)
|
||||
{
|
||||
uint32 curValue = GetPower(POWER_FOCUS);
|
||||
uint32 maxValue = GetMaxPower(POWER_FOCUS);
|
||||
uint32 curValue = GetPower(power);
|
||||
uint32 maxValue = GetMaxPower(power);
|
||||
|
||||
if (curValue >= maxValue)
|
||||
return;
|
||||
|
||||
float addvalue = 24 * sWorld.getRate(RATE_POWER_FOCUS);
|
||||
float addvalue = 0.0f;
|
||||
|
||||
switch (power)
|
||||
{
|
||||
case POWER_FOCUS:
|
||||
{
|
||||
// For hunter pets.
|
||||
addvalue = 24 * sWorld.getRate(RATE_POWER_FOCUS);
|
||||
break;
|
||||
}
|
||||
case POWER_ENERGY:
|
||||
{
|
||||
// For deathknight's ghoul.
|
||||
addvalue = 20;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply modifiers (if any).
|
||||
AuraEffectList const& ModPowerRegenPCTAuras = GetAurasByType(SPELL_AURA_MOD_POWER_REGEN_PERCENT);
|
||||
for(AuraEffectList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i)
|
||||
if ((*i)->GetMiscValue() == POWER_FOCUS)
|
||||
if ((*i)->GetMiscValue() == power)
|
||||
addvalue *= ((*i)->GetAmount() + 100) / 100.0f;
|
||||
|
||||
ModifyPower(POWER_FOCUS, (int32)addvalue);
|
||||
ModifyPower(power, (int32)addvalue);
|
||||
}
|
||||
|
||||
void Pet::LooseHappiness()
|
||||
|
||||
@@ -159,7 +159,7 @@ class Pet : public Guardian
|
||||
return m_autospells[pos];
|
||||
}
|
||||
|
||||
void RegenerateFocus();
|
||||
void Regenerate(Powers power);
|
||||
void LooseHappiness();
|
||||
HappinessState GetHappinessState();
|
||||
void GivePetXP(uint32 xp);
|
||||
|
||||
Reference in New Issue
Block a user