fix(Script/Item): Deviate Fish effects (#9163)

* fix(Script/Item): Deviate Fish effects

* cherry-pick commit (a9db8a9b9a)
This commit is contained in:
Kitzunu
2021-11-20 18:13:42 +01:00
committed by GitHub
parent c8466fa218
commit 0f7091c7e1
2 changed files with 60 additions and 5 deletions

View File

@@ -1497,6 +1497,7 @@ enum DeviateFishSpells
SPELL_SHRINK = 8066,
SPELL_PARTY_TIME = 8067,
SPELL_HEALTHY_SPIRIT = 8068,
SPELL_REJUVENATION = 8070
};
class spell_item_deviate_fish : public SpellScript
@@ -1510,16 +1511,13 @@ class spell_item_deviate_fish : public SpellScript
bool Validate(SpellInfo const* /*spellInfo*/) override
{
for (uint32 spellId = SPELL_SLEEPY; spellId <= SPELL_HEALTHY_SPIRIT; ++spellId)
if (!sSpellMgr->GetSpellInfo(spellId))
return false;
return true;
return ValidateSpellInfo({ SPELL_SLEEPY, SPELL_INVIGORATE, SPELL_SHRINK, SPELL_PARTY_TIME, SPELL_HEALTHY_SPIRIT, SPELL_REJUVENATION });
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
Unit* caster = GetCaster();
uint32 spellId = urand(SPELL_SLEEPY, SPELL_HEALTHY_SPIRIT);
uint32 spellId = RAND(SPELL_SLEEPY, SPELL_INVIGORATE, SPELL_SHRINK, SPELL_PARTY_TIME, SPELL_HEALTHY_SPIRIT, SPELL_REJUVENATION);
caster->CastSpell(caster, spellId, true, nullptr);
}
@@ -1529,6 +1527,57 @@ class spell_item_deviate_fish : public SpellScript
}
};
class PartyTimeEmoteEvent : public BasicEvent
{
public:
PartyTimeEmoteEvent(Player* player) : _player(player) { }
bool Execute(uint64 /*time*/, uint32 /*diff*/) override
{
if (!_player->HasAura(SPELL_PARTY_TIME))
{
return true;
}
if (_player->isMoving())
{
_player->HandleEmoteCommand(RAND(EMOTE_ONESHOT_APPLAUD, EMOTE_ONESHOT_LAUGH, EMOTE_ONESHOT_CHEER, EMOTE_ONESHOT_CHICKEN));
}
else
{
_player->HandleEmoteCommand(RAND(EMOTE_ONESHOT_APPLAUD, EMOTE_ONESHOT_DANCESPECIAL, EMOTE_ONESHOT_LAUGH, EMOTE_ONESHOT_CHEER, EMOTE_ONESHOT_CHICKEN));
}
_player->m_Events.AddEvent(this, RAND(_player->m_Events.CalculateTime(5000), _player->m_Events.CalculateTime(10000), _player->m_Events.CalculateTime(15000)));
return false; // do not delete re-added event in EventProcessor::Update
}
private:
Player* _player;
};
class spell_item_party_time : public AuraScript
{
PrepareAuraScript(spell_item_party_time);
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Player* player = GetOwner()->ToPlayer();
if (!player)
{
return;
}
player->m_Events.AddEvent(new PartyTimeEmoteEvent(player), RAND(player->m_Events.CalculateTime(5000), player->m_Events.CalculateTime(10000), player->m_Events.CalculateTime(15000)));
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_item_party_time::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
// 71610, 71641 - Echoes of Light (Althor's Abacus)
class spell_item_echoes_of_light : public SpellScript
{
@@ -3497,6 +3546,7 @@ void AddSC_item_spell_scripts()
RegisterSpellScriptWithArgs(spell_item_defibrillate, "spell_item_gnomish_army_knife", 33);
RegisterSpellScript(spell_item_desperate_defense);
RegisterSpellScript(spell_item_deviate_fish);
RegisterSpellScript(spell_item_party_time);
RegisterSpellScript(spell_item_echoes_of_light);
RegisterSpellScript(spell_item_fate_rune_of_unsurpassed_vigor);
RegisterSpellScript(spell_item_flask_of_the_north);