Fix(Core/Player): fix periodic eating and drinking emotes (#1602)

This commit is contained in:
Viste(Кирилл)
2019-03-23 11:35:04 +03:00
committed by GitHub
parent 980f4cff99
commit 03bfbf4f7e
4 changed files with 41 additions and 1 deletions

View File

@@ -709,6 +709,7 @@ Player::Player(WorldSession* session): Unit(true), m_mover(this)
m_regenTimer = 0;
m_regenTimerCount = 0;
m_foodEmoteTimerCount = 0;
m_weaponChangeTimer = 0;
m_zoneUpdateId = uint32(-1);
@@ -2579,6 +2580,7 @@ void Player::RegenerateAll()
// return;
m_regenTimerCount += m_regenTimer;
m_foodEmoteTimerCount += m_regenTimer;
Regenerate(POWER_ENERGY);
@@ -2623,6 +2625,37 @@ void Player::RegenerateAll()
}
m_regenTimer = 0;
// Handles the emotes for drinking and eating.
// According to sniffs there is a background timer going on that repeats independed from the time window where the aura applies.
// That's why we dont need to reset the timer on apply. In sniffs I have seen that the first call for the spell visual is totally random, then after
// 5 seconds over and over again which confirms my theory that we have a independed timer.
if (m_foodEmoteTimerCount >= 5000)
{
std::vector<AuraEffect*> auraList;
AuraEffectList const& ModRegenAuras = GetAuraEffectsByType(SPELL_AURA_MOD_REGEN);
AuraEffectList const& ModPowerRegenAuras = GetAuraEffectsByType(SPELL_AURA_MOD_POWER_REGEN);
auraList.reserve(ModRegenAuras.size() + ModPowerRegenAuras.size());
auraList.insert(auraList.end(), ModRegenAuras.begin(), ModRegenAuras.end());
auraList.insert(auraList.end(), ModPowerRegenAuras.begin(), ModPowerRegenAuras.end());
for (auto itr = auraList.begin(); itr != auraList.end(); ++itr)
{
// Food emote comes above drinking emote if we have to decide (mage regen food for example)
if ((*itr)->GetBase()->HasEffectType(SPELL_AURA_MOD_REGEN) && (*itr)->GetSpellInfo()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED)
{
SendPlaySpellVisual(SPELL_VISUAL_KIT_FOOD);
break;
}
else if ((*itr)->GetBase()->HasEffectType(SPELL_AURA_MOD_POWER_REGEN) && (*itr)->GetSpellInfo()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED)
{
SendPlaySpellVisual(SPELL_VISUAL_KIT_DRINK);
break;
}
}
m_foodEmoteTimerCount -= 5000;
}
}
void Player::Regenerate(Powers power)