mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Scripts/Events: Fix achievement in Love is in the air: "Lonely?" (#26083)
* Scripts/Events: Fix achievement in Love is in the air: "Lonely?" * apply @keader feedback ;) * apply @jackpoz feedback ;) * @jackpoz feedback
This commit is contained in:
@@ -42,75 +42,75 @@ enum SpellsPicnic
|
||||
SPELL_ROMANTIC_PICNIC_ACHIEV = 45123, // Romantic Picnic periodic = 5000
|
||||
};
|
||||
|
||||
class spell_love_is_in_the_air_romantic_picnic : public SpellScriptLoader
|
||||
class spell_love_is_in_the_air_romantic_picnic : public AuraScript
|
||||
{
|
||||
public:
|
||||
spell_love_is_in_the_air_romantic_picnic() : SpellScriptLoader("spell_love_is_in_the_air_romantic_picnic") { }
|
||||
PrepareAuraScript(spell_love_is_in_the_air_romantic_picnic);
|
||||
|
||||
class spell_love_is_in_the_air_romantic_picnic_AuraScript : public AuraScript
|
||||
bool Validate(SpellInfo const* /*spellInfo*/) override
|
||||
{
|
||||
return ValidateSpellInfo(
|
||||
{
|
||||
PrepareAuraScript(spell_love_is_in_the_air_romantic_picnic_AuraScript);
|
||||
SPELL_BASKET_CHECK,
|
||||
SPELL_MEAL_PERIODIC,
|
||||
SPELL_MEAL_EAT_VISUAL,
|
||||
SPELL_DRINK_VISUAL,
|
||||
SPELL_ROMANTIC_PICNIC_ACHIEV
|
||||
});
|
||||
}
|
||||
|
||||
void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
|
||||
{
|
||||
Unit* target = GetTarget();
|
||||
target->SetStandState(UNIT_STAND_STATE_SIT);
|
||||
target->CastSpell(target, SPELL_MEAL_PERIODIC, false);
|
||||
}
|
||||
void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
|
||||
{
|
||||
Unit* target = GetTarget();
|
||||
target->SetStandState(UNIT_STAND_STATE_SIT);
|
||||
target->CastSpell(target, SPELL_MEAL_PERIODIC);
|
||||
}
|
||||
|
||||
void OnPeriodic(AuraEffect const* /*aurEff*/)
|
||||
{
|
||||
// Every 5 seconds
|
||||
Unit* target = GetTarget();
|
||||
Unit* caster = GetCaster();
|
||||
void OnPeriodic(AuraEffect const* /*aurEff*/)
|
||||
{
|
||||
// Every 5 seconds
|
||||
Unit* target = GetTarget();
|
||||
|
||||
// If our player is no longer sit, remove all auras
|
||||
if (target->GetStandState() != UNIT_STAND_STATE_SIT)
|
||||
{
|
||||
target->RemoveAura(SPELL_ROMANTIC_PICNIC_ACHIEV);
|
||||
target->RemoveAura(GetAura());
|
||||
return;
|
||||
}
|
||||
|
||||
target->CastSpell(target, SPELL_BASKET_CHECK, false); // unknown use, it targets Romantic Basket
|
||||
target->CastSpell(target, RAND(SPELL_MEAL_EAT_VISUAL, SPELL_DRINK_VISUAL), false);
|
||||
|
||||
bool foundSomeone = false;
|
||||
// For nearby players, check if they have the same aura. If so, cast Romantic Picnic (45123)
|
||||
// required by achievement and "hearts" visual
|
||||
std::list<Player*> playerList;
|
||||
Trinity::AnyPlayerInObjectRangeCheck checker(target, INTERACTION_DISTANCE*2);
|
||||
Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(target, playerList, checker);
|
||||
Cell::VisitWorldObjects(target, searcher, INTERACTION_DISTANCE * 2);
|
||||
for (std::list<Player*>::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
|
||||
{
|
||||
if ((*itr) != target && (*itr)->HasAura(GetId())) // && (*itr)->GetStandState() == UNIT_STAND_STATE_SIT)
|
||||
{
|
||||
if (caster)
|
||||
{
|
||||
caster->CastSpell(*itr, SPELL_ROMANTIC_PICNIC_ACHIEV, true);
|
||||
caster->CastSpell(target, SPELL_ROMANTIC_PICNIC_ACHIEV, true);
|
||||
}
|
||||
foundSomeone = true;
|
||||
// break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundSomeone && target->HasAura(SPELL_ROMANTIC_PICNIC_ACHIEV))
|
||||
target->RemoveAura(SPELL_ROMANTIC_PICNIC_ACHIEV);
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
AfterEffectApply += AuraEffectApplyFn(spell_love_is_in_the_air_romantic_picnic_AuraScript::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL);
|
||||
OnEffectPeriodic += AuraEffectPeriodicFn(spell_love_is_in_the_air_romantic_picnic_AuraScript::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
|
||||
}
|
||||
};
|
||||
|
||||
AuraScript* GetAuraScript() const override
|
||||
// If our player is no longer sit, remove all auras
|
||||
if (target->GetStandState() != UNIT_STAND_STATE_SIT)
|
||||
{
|
||||
return new spell_love_is_in_the_air_romantic_picnic_AuraScript();
|
||||
target->RemoveAurasDueToSpell(SPELL_ROMANTIC_PICNIC_ACHIEV);
|
||||
target->RemoveAura(GetAura());
|
||||
return;
|
||||
}
|
||||
|
||||
target->CastSpell(target, SPELL_BASKET_CHECK); // unknown use, it targets Romantic Basket
|
||||
target->CastSpell(target, RAND(SPELL_MEAL_EAT_VISUAL, SPELL_DRINK_VISUAL));
|
||||
|
||||
bool foundSomeone = false;
|
||||
// For nearby players, check if they have the same aura. If so, cast Romantic Picnic (45123)
|
||||
// required by achievement and "hearts" visual
|
||||
std::list<Player*> playerList;
|
||||
Trinity::AnyPlayerInObjectRangeCheck checker(target, INTERACTION_DISTANCE*2);
|
||||
Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(target, playerList, checker);
|
||||
Cell::VisitWorldObjects(target, searcher, INTERACTION_DISTANCE * 2);
|
||||
for (std::list<Player*>::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
|
||||
{
|
||||
if (Player* playerFound = (*itr))
|
||||
{
|
||||
if (target != playerFound && playerFound->HasAura(GetId()))
|
||||
{
|
||||
playerFound->CastSpell(playerFound, SPELL_ROMANTIC_PICNIC_ACHIEV, true);
|
||||
target->CastSpell(target, SPELL_ROMANTIC_PICNIC_ACHIEV, true);
|
||||
foundSomeone = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundSomeone && target->HasAura(SPELL_ROMANTIC_PICNIC_ACHIEV))
|
||||
target->RemoveAurasDueToSpell(SPELL_ROMANTIC_PICNIC_ACHIEV);
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
AfterEffectApply += AuraEffectApplyFn(spell_love_is_in_the_air_romantic_picnic::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL);
|
||||
OnEffectPeriodic += AuraEffectPeriodicFn(spell_love_is_in_the_air_romantic_picnic::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
|
||||
}
|
||||
};
|
||||
|
||||
enum HallowEndCandysSpells
|
||||
@@ -1918,7 +1918,7 @@ class spell_midsummer_fling_torch_missed : public SpellScript
|
||||
void AddSC_holiday_spell_scripts()
|
||||
{
|
||||
// Love is in the Air
|
||||
new spell_love_is_in_the_air_romantic_picnic();
|
||||
RegisterSpellScript(spell_love_is_in_the_air_romantic_picnic);
|
||||
// Hallow's End
|
||||
new spell_hallow_end_candy();
|
||||
new spell_hallow_end_candy_pirate();
|
||||
|
||||
Reference in New Issue
Block a user