From 2af6e0ee20999dcbfdd41e2316fb778f9114efae Mon Sep 17 00:00:00 2001 From: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Date: Mon, 13 Dec 2021 09:22:16 +0100 Subject: [PATCH] refactor(Scripts/Events): convert love_in_air to new system (#9609) --- src/server/scripts/Events/love_in_air.cpp | 1076 +++++++++------------ 1 file changed, 476 insertions(+), 600 deletions(-) diff --git a/src/server/scripts/Events/love_in_air.cpp b/src/server/scripts/Events/love_in_air.cpp index 4db3d1f50..7ef1a1814 100644 --- a/src/server/scripts/Events/love_in_air.cpp +++ b/src/server/scripts/Events/love_in_air.cpp @@ -53,55 +53,44 @@ enum SupplySentrySay SAY_SUPPLY_SENTRY_0 = 0 }; -class npc_love_in_air_supply_sentry : public CreatureScript +struct npc_love_in_air_supply_sentry : public ScriptedAI { -public: - npc_love_in_air_supply_sentry() : CreatureScript("npc_love_in_air_supply_sentry") { } - - struct npc_love_in_air_supply_sentryAI : public ScriptedAI + npc_love_in_air_supply_sentry(Creature* creature) : ScriptedAI(creature), lock(0) { - npc_love_in_air_supply_sentryAI(Creature* creature) : ScriptedAI(creature), lock(0) - { - } + } - uint32 lock; + uint32 lock; - void MoveInLineOfSight(Unit* who) override + void MoveInLineOfSight(Unit* who) override + { + if (lock > 1000 && me->GetDistance(who) < 10.0f && who->GetTypeId() == TYPEID_PLAYER && who->HasAura(SPELL_GOBLIN_DISGUISE) && !who->HasAura(SPELL_GOBLIN_CARRY_CRATE)) { - if (lock > 1000 && me->GetDistance(who) < 10.0f && who->GetTypeId() == TYPEID_PLAYER && who->HasAura(SPELL_GOBLIN_DISGUISE) && !who->HasAura(SPELL_GOBLIN_CARRY_CRATE)) + lock = 0; + if (urand(0, 1)) { - lock = 0; - if (urand(0, 1)) - { - me->AI()->Talk(SAY_SUPPLY_SENTRY_0, who->ToPlayer()); - } - else - { - me->AI()->Talk(SAY_SUPPLY_SENTRY_0, who->ToPlayer()); - } - - if (who->ToPlayer()->GetTeamId() == TEAM_ALLIANCE) - { - who->ToPlayer()->CompleteQuest(QUEST_PILGRIM_ALLIANCE); - } - else - { - who->ToPlayer()->CompleteQuest(QUEST_PILGRIM_HORDE); - } - - me->CastSpell(who, SPELL_GOBLIN_CARRY_CRATE, true); + me->AI()->Talk(SAY_SUPPLY_SENTRY_0, who->ToPlayer()); + } + else + { + me->AI()->Talk(SAY_SUPPLY_SENTRY_0, who->ToPlayer()); } - } - void UpdateAI(uint32 diff) override - { - lock += diff; - } - }; + if (who->ToPlayer()->GetTeamId() == TEAM_ALLIANCE) + { + who->ToPlayer()->CompleteQuest(QUEST_PILGRIM_ALLIANCE); + } + else + { + who->ToPlayer()->CompleteQuest(QUEST_PILGRIM_HORDE); + } - CreatureAI* GetAI(Creature* creature) const override + me->CastSpell(who, SPELL_GOBLIN_CARRY_CRATE, true); + } + } + + void UpdateAI(uint32 diff) override { - return new npc_love_in_air_supply_sentryAI(creature); + lock += diff; } }; @@ -120,62 +109,49 @@ enum hotOnTrail const uint32 spellTable[6] = {71713, 71745, 71752, 71759, 71760, 71758}; -class npc_love_in_air_snivel : public CreatureScript +struct npc_love_in_air_snivel : public NullCreatureAI { -public: - npc_love_in_air_snivel() : CreatureScript("npc_love_in_air_snivel") { } + npc_love_in_air_snivel(Creature* creature) : NullCreatureAI(creature) { } - struct npc_love_in_air_snivelAI : public NullCreatureAI + int32 delay; + + void Reset() override { - npc_love_in_air_snivelAI(Creature* creature) : NullCreatureAI(creature) - { - } - - int32 delay; - - void Reset() override - { - delay = 0; - me->SetReactState(REACT_AGGRESSIVE); - } - - bool AllowAction(Player* player) - { - uint16 slot = player->FindQuestSlot(player->GetTeamId() == TEAM_ALLIANCE ? QUEST_HOT_ON_TRAIL_ALLY : QUEST_HOT_ON_TRAIL_HORDE); - if (slot >= MAX_QUEST_LOG_SIZE) - return false; - - QuestStatusData& qData = player->getQuestStatusMap()[(player->GetTeamId() == TEAM_ALLIANCE ? QUEST_HOT_ON_TRAIL_ALLY : QUEST_HOT_ON_TRAIL_HORDE)]; - if (qData.CreatureOrGOCount[me->GetEntry() - NPC_SNIVEL_COUNTER] == 0) - return true; + delay = 0; + me->SetReactState(REACT_AGGRESSIVE); + } + bool AllowAction(Player* player) + { + uint16 slot = player->FindQuestSlot(player->GetTeamId() == TEAM_ALLIANCE ? QUEST_HOT_ON_TRAIL_ALLY : QUEST_HOT_ON_TRAIL_HORDE); + if (slot >= MAX_QUEST_LOG_SIZE) return false; - } - void MoveInLineOfSight(Unit* who) override + QuestStatusData& qData = player->getQuestStatusMap()[(player->GetTeamId() == TEAM_ALLIANCE ? QUEST_HOT_ON_TRAIL_ALLY : QUEST_HOT_ON_TRAIL_HORDE)]; + if (qData.CreatureOrGOCount[me->GetEntry() - NPC_SNIVEL_COUNTER] == 0) + return true; + + return false; + } + + void MoveInLineOfSight(Unit* who) override + { + if (delay == 0 && me->GetDistance(who) < 7.0f && who->GetTypeId() == TYPEID_PLAYER) { - if (delay == 0 && me->GetDistance(who) < 7.0f && who->GetTypeId() == TYPEID_PLAYER) + Player* plr = who->ToPlayer(); + if (AllowAction(plr)) { - Player* plr = who->ToPlayer(); - if (AllowAction(plr)) - { - delay = 25000; - uint8 index = plr->GetTeamId() * 3 + (me->GetEntry() - NPC_SNIVEL_COUNTER); - plr->CastSpell(plr, spellTable[index], true); - } + delay = 25000; + uint8 index = plr->GetTeamId() * 3 + (me->GetEntry() - NPC_SNIVEL_COUNTER); + plr->CastSpell(plr, spellTable[index], true); } } + } - void UpdateAI(uint32 diff) override - { - if (delay > 0) - delay -= std::min(delay, diff); - } - }; - - CreatureAI* GetAI(Creature* creature) const override + void UpdateAI(uint32 diff) override { - return new npc_love_in_air_snivelAI(creature); + if (delay > 0) + delay -= std::min(delay, diff); } }; @@ -187,105 +163,94 @@ enum SnivelRealSay SAY_SNIVEL_REAL_3 = 3 }; -class npc_love_in_air_snivel_real : public CreatureScript +struct npc_love_in_air_snivel_real : public ScriptedAI { -public: - npc_love_in_air_snivel_real() : CreatureScript("npc_love_in_air_snivel_real") { } - - struct npc_love_in_air_snivel_realAI : public ScriptedAI + npc_love_in_air_snivel_real(Creature* creature) : ScriptedAI(creature) { - npc_love_in_air_snivel_realAI(Creature* creature) : ScriptedAI(creature) + actionTimer = 7000; + actionCounter = 0; + } + + uint32 actionTimer; + uint32 actionCounter; + + bool Talk(uint32 time) + { + switch (me->GetEntry()) { - actionTimer = 7000; - actionCounter = 0; - } - - uint32 actionTimer; - uint32 actionCounter; - - bool Talk(uint32 time) - { - switch (me->GetEntry()) - { - case NPC_SNIVEL_ALLY: - case NPC_SNIVEL_HORDE: - { - switch (time) - { - case 1: - me->AI()->Talk(SAY_SNIVEL_REAL_0); - return false; - case 2: - me->AI()->Talk(SAY_SNIVEL_REAL_1); - return true; - } - break; - } - case NPC_SNIVEL_ALLY+1: - case NPC_SNIVEL_HORDE+1: - { - switch (time) - { - case 1: - me->AI()->Talk(SAY_SNIVEL_REAL_0); - return false; - case 2: - me->AI()->Talk(SAY_SNIVEL_REAL_1); - return false; - case 3: - me->AI()->Talk(SAY_SNIVEL_REAL_2); - return true; - } - break; - } - - case NPC_SNIVEL_ALLY+2: - case NPC_SNIVEL_HORDE+2: - { - switch (time) - { - case 1: - me->AI()->Talk(SAY_SNIVEL_REAL_0); - return false; - case 2: - me->AI()->Talk(SAY_SNIVEL_REAL_1); - return false; - case 3: - me->AI()->Talk(SAY_SNIVEL_REAL_2); - return false; - case 4: - me->AI()->Talk(SAY_SNIVEL_REAL_3); - return true; - } - break; - } - } - - return true; - } - - void UpdateAI(uint32 diff) override - { - actionTimer += diff; - if (actionTimer >= 7000) - { - actionTimer = 0; - actionCounter++; - if (Talk(actionCounter)) + case NPC_SNIVEL_ALLY: + case NPC_SNIVEL_HORDE: { - if (me->ToTempSummon()) - if (Unit* owner = me->ToTempSummon()->GetSummonerUnit()) - me->CastSpell(owner, SPELL_SNIVEL_GUN, true); - - me->DespawnOrUnsummon(1000); + switch (time) + { + case 1: + me->AI()->Talk(SAY_SNIVEL_REAL_0); + return false; + case 2: + me->AI()->Talk(SAY_SNIVEL_REAL_1); + return true; + } + break; } + case NPC_SNIVEL_ALLY+1: + case NPC_SNIVEL_HORDE+1: + { + switch (time) + { + case 1: + me->AI()->Talk(SAY_SNIVEL_REAL_0); + return false; + case 2: + me->AI()->Talk(SAY_SNIVEL_REAL_1); + return false; + case 3: + me->AI()->Talk(SAY_SNIVEL_REAL_2); + return true; + } + break; + } + + case NPC_SNIVEL_ALLY+2: + case NPC_SNIVEL_HORDE+2: + { + switch (time) + { + case 1: + me->AI()->Talk(SAY_SNIVEL_REAL_0); + return false; + case 2: + me->AI()->Talk(SAY_SNIVEL_REAL_1); + return false; + case 3: + me->AI()->Talk(SAY_SNIVEL_REAL_2); + return false; + case 4: + me->AI()->Talk(SAY_SNIVEL_REAL_3); + return true; + } + break; + } + } + + return true; + } + + void UpdateAI(uint32 diff) override + { + actionTimer += diff; + if (actionTimer >= 7000) + { + actionTimer = 0; + actionCounter++; + if (Talk(actionCounter)) + { + if (me->ToTempSummon()) + if (Unit* owner = me->ToTempSummon()->GetSummonerUnit()) + me->CastSpell(owner, SPELL_SNIVEL_GUN, true); + + me->DespawnOrUnsummon(1000); } } - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return new npc_love_in_air_snivel_realAI(creature); } }; @@ -330,147 +295,126 @@ enum HummelSay SAY_HUMMEL_5 = 5 }; -class npc_love_in_air_hummel : public CreatureScript +struct npc_love_in_air_hummel : public ScriptedAI { -public: - npc_love_in_air_hummel() : CreatureScript("npc_love_in_air_hummel") { } + npc_love_in_air_hummel(Creature* creature) : ScriptedAI(creature), summons(me) { } - struct npc_love_in_air_hummelAI : public ScriptedAI + SummonList summons; + EventMap events; + uint32 speachTimer; + + bool CanBeSeen(Player const* player) override { - npc_love_in_air_hummelAI(Creature* creature) : ScriptedAI(creature), summons(me) + if (player->IsGameMaster()) { + return true; } - SummonList summons; - EventMap events; - uint32 speachTimer; - - bool CanBeSeen(Player const* player) override - { - if (player->IsGameMaster()) - { - return true; - } - - Group const* group = player->GetGroup(); - return group && sLFGMgr->GetDungeon(group->GetGUID()) == lfg::LFG_DUNGEON_CROWN_CHEMICAL_CO; - } - - void Reset() override - { - speachTimer = 0; - me->SetFaction(FACTION_FRIENDLY); - summons.DespawnAll(); - events.Reset(); - me->SummonCreature(NPC_APOTHECARY_FRYE, -205.449f, 2219.56f, 79.7633f, 0.7f); - me->SummonCreature(NPC_APOTHECARY_BAXTER, -209.602f, 2215.42f, 79.7633f, 0.723503f); - } - - void DoAction(int32 param) override - { - if (param == ACTION_START_EVENT) - speachTimer = 1; - } - - void JustDied(Unit* ) override - { - me->AI()->Talk(SAY_HUMMEL_5); - Map::PlayerList const& players = me->GetMap()->GetPlayers(); - if (!players.isEmpty() && players.begin()->GetSource() && players.begin()->GetSource()->GetGroup()) - sLFGMgr->FinishDungeon(players.begin()->GetSource()->GetGroup()->GetGUID(), lfg::LFG_DUNGEON_CROWN_CHEMICAL_CO, me->FindMap()); - } - - void JustSummoned(Creature* cr) override - { - summons.Summon(cr); - cr->SetFaction(FACTION_FRIENDLY); - cr->SetControlled(true, UNIT_STATE_STUNNED); - cr->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - } - - void UpdateAI(uint32 diff) override - { - if (speachTimer) - { - speachTimer += diff; - if (speachTimer < 10000) - { - me->AI()->Talk(SAY_HUMMEL_0); - speachTimer = 10000; - } - else if (speachTimer >= 16000 && speachTimer < 20000) - { - me->AI()->Talk(SAY_HUMMEL_1); - speachTimer = 20000; - } - else if (speachTimer >= 26000 && speachTimer < 30000) - { - me->AI()->Talk(SAY_HUMMEL_2); - speachTimer = 0; - me->SetFaction(FACTION_MONSTER_2); - me->SetInCombatWithZone(); - if (Unit* target = SelectTargetFromPlayerList(40.0f)) - { - AttackStart(target); - events.ScheduleEvent(EVENT_CALL_BAXTER, 10000); - events.ScheduleEvent(EVENT_CALL_FRYE, 20000); - events.ScheduleEvent(EVENT_SPELL_PERFUME_SPRAY, 7000); - events.ScheduleEvent(EVENT_SPELL_CHAIN_REACTION, 12000); - } - else - EnterEvadeMode(); - } - return; - } - - if (!UpdateVictim()) - return; - - events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; - - switch (events.ExecuteEvent()) - { - case EVENT_CALL_BAXTER: - { - EntryCheckPredicate pred(NPC_APOTHECARY_BAXTER); - summons.DoAction(ACTION_RELEASE_HELPER, pred); - - break; - } - case EVENT_CALL_FRYE: - { - EntryCheckPredicate pred(NPC_APOTHECARY_FRYE); - summons.DoAction(ACTION_RELEASE_HELPER, pred); - - break; - } - case EVENT_SPELL_PERFUME_SPRAY: - me->CastSpell(me->GetVictim(), SPELL_ALLURING_PERFUME_SPRAY, false); - events.RepeatEvent(6000); - break; - case EVENT_SPELL_CHAIN_REACTION: - me->CastSpell(me->GetVictim(), SPELL_CHAIN_REACTION, false); - events.RepeatEvent(12000); - break; - } - - DoMeleeAttackIfReady(); - } - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return new npc_love_in_air_hummelAI(creature); + Group const* group = player->GetGroup(); + return group && sLFGMgr->GetDungeon(group->GetGUID()) == lfg::LFG_DUNGEON_CROWN_CHEMICAL_CO; } - bool OnQuestReward(Player* /*player*/, Creature* creature, const Quest* _Quest, uint32 /*slot*/) override + void Reset() override { - if (_Quest->GetQuestId() == QUEST_YOUVE_BEEN_SERVED) - creature->AI()->DoAction(ACTION_START_EVENT); + speachTimer = 0; + me->SetFaction(FACTION_FRIENDLY); + summons.DespawnAll(); + events.Reset(); + me->SummonCreature(NPC_APOTHECARY_FRYE, -205.449f, 2219.56f, 79.7633f, 0.7f); + me->SummonCreature(NPC_APOTHECARY_BAXTER, -209.602f, 2215.42f, 79.7633f, 0.723503f); + } - return true; + void DoAction(int32 param) override + { + if (param == ACTION_START_EVENT) + speachTimer = 1; + } + + void JustDied(Unit* ) override + { + me->AI()->Talk(SAY_HUMMEL_5); + Map::PlayerList const& players = me->GetMap()->GetPlayers(); + if (!players.isEmpty() && players.begin()->GetSource() && players.begin()->GetSource()->GetGroup()) + sLFGMgr->FinishDungeon(players.begin()->GetSource()->GetGroup()->GetGUID(), lfg::LFG_DUNGEON_CROWN_CHEMICAL_CO, me->FindMap()); + } + + void JustSummoned(Creature* cr) override + { + summons.Summon(cr); + cr->SetFaction(FACTION_FRIENDLY); + cr->SetControlled(true, UNIT_STATE_STUNNED); + cr->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + } + + void UpdateAI(uint32 diff) override + { + if (speachTimer) + { + speachTimer += diff; + if (speachTimer < 10000) + { + me->AI()->Talk(SAY_HUMMEL_0); + speachTimer = 10000; + } + else if (speachTimer >= 16000 && speachTimer < 20000) + { + me->AI()->Talk(SAY_HUMMEL_1); + speachTimer = 20000; + } + else if (speachTimer >= 26000 && speachTimer < 30000) + { + me->AI()->Talk(SAY_HUMMEL_2); + speachTimer = 0; + me->SetFaction(FACTION_MONSTER_2); + me->SetInCombatWithZone(); + if (Unit* target = SelectTargetFromPlayerList(40.0f)) + { + AttackStart(target); + events.ScheduleEvent(EVENT_CALL_BAXTER, 10000); + events.ScheduleEvent(EVENT_CALL_FRYE, 20000); + events.ScheduleEvent(EVENT_SPELL_PERFUME_SPRAY, 7000); + events.ScheduleEvent(EVENT_SPELL_CHAIN_REACTION, 12000); + } + else + EnterEvadeMode(); + } + return; + } + + if (!UpdateVictim()) + return; + + events.Update(diff); + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; + + switch (events.ExecuteEvent()) + { + case EVENT_CALL_BAXTER: + { + EntryCheckPredicate pred(NPC_APOTHECARY_BAXTER); + summons.DoAction(ACTION_RELEASE_HELPER, pred); + + break; + } + case EVENT_CALL_FRYE: + { + EntryCheckPredicate pred(NPC_APOTHECARY_FRYE); + summons.DoAction(ACTION_RELEASE_HELPER, pred); + + break; + } + case EVENT_SPELL_PERFUME_SPRAY: + me->CastSpell(me->GetVictim(), SPELL_ALLURING_PERFUME_SPRAY, false); + events.RepeatEvent(6000); + break; + case EVENT_SPELL_CHAIN_REACTION: + me->CastSpell(me->GetVictim(), SPELL_CHAIN_REACTION, false); + events.RepeatEvent(12000); + break; + } + + DoMeleeAttackIfReady(); } }; @@ -479,188 +423,85 @@ enum HummelHelperSay SAY_HUMMEL_HELPER_SAY_5 = 5, }; -class npc_love_in_air_hummel_helper : public CreatureScript +struct npc_love_in_air_hummel_helper : public ScriptedAI { -public: - npc_love_in_air_hummel_helper() : CreatureScript("npc_love_in_air_hummel_helper") { } + npc_love_in_air_hummel_helper(Creature* creature) : ScriptedAI(creature) { } - struct npc_love_in_air_hummel_helperAI : public ScriptedAI + EventMap events; + + bool CanBeSeen(Player const* player) override { - npc_love_in_air_hummel_helperAI(Creature* creature) : ScriptedAI(creature) + if (player->IsGameMaster()) { + return true; } - EventMap events; + Group const* group = player->GetGroup(); + return group && sLFGMgr->GetDungeon(group->GetGUID()) == lfg::LFG_DUNGEON_CROWN_CHEMICAL_CO; + } - bool CanBeSeen(Player const* player) override + void Reset() override + { + } + + void DoAction(int32 param) override + { + if (param == ACTION_RELEASE_HELPER) { - if (player->IsGameMaster()) + me->SetControlled(false, UNIT_STATE_STUNNED); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + me->SetFaction(FACTION_MONSTER_2); + me->SetInCombatWithZone(); + if (Unit* target = SelectTargetFromPlayerList(40.0f)) + AttackStart(target); + + if (me->GetEntry() == NPC_APOTHECARY_BAXTER) { - return true; + events.ScheduleEvent(EVENT_SPELL_PERFUME_SPRAY, 7000); + events.ScheduleEvent(EVENT_SPELL_CHAIN_REACTION, 12000); } - - Group const* group = player->GetGroup(); - return group && sLFGMgr->GetDungeon(group->GetGUID()) == lfg::LFG_DUNGEON_CROWN_CHEMICAL_CO; + else + events.ScheduleEvent(EVENT_SPELL_THROW, 5000); } + } - void Reset() override + void JustDied(Unit* ) override + { + me->AI()->Talk(SAY_HUMMEL_HELPER_SAY_5); + } + + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; + + events.Update(diff); + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; + + switch (events.ExecuteEvent()) { - } - - void DoAction(int32 param) override - { - if (param == ACTION_RELEASE_HELPER) - { - me->SetControlled(false, UNIT_STATE_STUNNED); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - me->SetFaction(FACTION_MONSTER_2); - me->SetInCombatWithZone(); - if (Unit* target = SelectTargetFromPlayerList(40.0f)) - AttackStart(target); - - if (me->GetEntry() == NPC_APOTHECARY_BAXTER) + case EVENT_SPELL_PERFUME_SPRAY: + me->CastSpell(me->GetVictim(), SPELL_COLOGNE_SPRAY, false); + events.RepeatEvent(6000); + break; + case EVENT_SPELL_CHAIN_REACTION: + me->CastSpell(me->GetVictim(), SPELL_CHAIN_REACTION, false); + events.RepeatEvent(12000); + break; + case EVENT_SPELL_THROW: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM)) { - events.ScheduleEvent(EVENT_SPELL_PERFUME_SPRAY, 7000); - events.ScheduleEvent(EVENT_SPELL_CHAIN_REACTION, 12000); + Position pos(*me); + me->Relocate(target); + me->CastSpell(me, RAND(SPELL_THROW_COLOGNE, SPELL_THROW_PERFUME), true, nullptr, nullptr, me->GetGUID()); + me->Relocate(pos); } - else - events.ScheduleEvent(EVENT_SPELL_THROW, 5000); - } + events.RepeatEvent(10000); + break; } - void JustDied(Unit* ) override - { - me->AI()->Talk(SAY_HUMMEL_HELPER_SAY_5); - } - - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; - - events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; - - switch (events.ExecuteEvent()) - { - case EVENT_SPELL_PERFUME_SPRAY: - me->CastSpell(me->GetVictim(), SPELL_COLOGNE_SPRAY, false); - events.RepeatEvent(6000); - break; - case EVENT_SPELL_CHAIN_REACTION: - me->CastSpell(me->GetVictim(), SPELL_CHAIN_REACTION, false); - events.RepeatEvent(12000); - break; - case EVENT_SPELL_THROW: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM)) - { - Position pos(*me); - me->Relocate(target); - me->CastSpell(me, RAND(SPELL_THROW_COLOGNE, SPELL_THROW_PERFUME), true, nullptr, nullptr, me->GetGUID()); - me->Relocate(pos); - } - events.RepeatEvent(10000); - break; - } - - DoMeleeAttackIfReady(); - } - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return new npc_love_in_air_hummel_helperAI(creature); - } -}; - -class spell_love_in_air_perfume_immune : public SpellScriptLoader -{ -public: - spell_love_in_air_perfume_immune() : SpellScriptLoader("spell_love_in_air_perfume_immune") { } - - class spell_love_in_air_perfume_immune_AuraScript : public AuraScript - { - PrepareAuraScript(spell_love_in_air_perfume_immune_AuraScript); - - void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - Unit* target = GetTarget(); - if (GetId() == SPELL_COLOGNE_IMMUNE) - { - target->ApplySpellImmune(SPELL_COLOGNE_PASSIVE_DAMAGE, IMMUNITY_ID, SPELL_COLOGNE_PASSIVE_DAMAGE, true); - target->ApplySpellImmune(SPELL_COLOGNE_PASSIVE_DAMAGE, IMMUNITY_ID, SPELL_COLOGNE_SPRAY, true); - target->ApplySpellImmune(68934, IMMUNITY_ID, 68934, true); - } - else - { - target->ApplySpellImmune(SPELL_PERFUME_PASSIVE_DAMAGE, IMMUNITY_ID, SPELL_PERFUME_PASSIVE_DAMAGE, true); - target->ApplySpellImmune(SPELL_ALLURING_PERFUME_SPRAY, IMMUNITY_ID, SPELL_ALLURING_PERFUME_SPRAY, true); - target->ApplySpellImmune(68927, IMMUNITY_ID, 68927, true); - } - } - - void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - Unit* target = GetTarget(); - if (GetId() == SPELL_COLOGNE_IMMUNE) - { - target->ApplySpellImmune(SPELL_COLOGNE_PASSIVE_DAMAGE, IMMUNITY_ID, SPELL_COLOGNE_PASSIVE_DAMAGE, false); - target->ApplySpellImmune(SPELL_COLOGNE_PASSIVE_DAMAGE, IMMUNITY_ID, SPELL_COLOGNE_SPRAY, false); - target->ApplySpellImmune(68934, IMMUNITY_ID, 68934, false); - } - else - { - target->ApplySpellImmune(SPELL_PERFUME_PASSIVE_DAMAGE, IMMUNITY_ID, SPELL_PERFUME_PASSIVE_DAMAGE, false); - target->ApplySpellImmune(SPELL_PERFUME_PASSIVE_DAMAGE, IMMUNITY_ID, SPELL_ALLURING_PERFUME_SPRAY, false); - target->ApplySpellImmune(68927, IMMUNITY_ID, 68927, false); - } - } - - void Register() override - { - OnEffectApply += AuraEffectApplyFn(spell_love_in_air_perfume_immune_AuraScript::HandleEffectApply, EFFECT_2, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - OnEffectRemove += AuraEffectRemoveFn(spell_love_in_air_perfume_immune_AuraScript::HandleEffectRemove, EFFECT_2, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_love_in_air_perfume_immune_AuraScript(); - } -}; - -class spell_love_in_air_periodic_perfumes : public SpellScriptLoader -{ -public: - spell_love_in_air_periodic_perfumes() : SpellScriptLoader("spell_love_in_air_periodic_perfumes") { } - - class spell_love_in_air_periodic_perfumes_AuraScript : public AuraScript - { - PrepareAuraScript(spell_love_in_air_periodic_perfumes_AuraScript); - - void PeriodicTick(AuraEffect const* /*aurEff*/) - { - ObjectGuid guid = GetCaster() ? GetCaster()->GetGUID() : ObjectGuid::Empty; - if (Unit* target = GetTarget()) - { - uint32 spellId = (GetId() == SPELL_THROW_COLOGNE ? 68934 : 68927); - if (target->IsImmunedToSpell(sSpellMgr->GetSpellInfo(spellId))) - return; - - target->CastSpell(target, spellId, true, nullptr, nullptr, guid); - } - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_love_in_air_periodic_perfumes_AuraScript::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_love_in_air_periodic_perfumes_AuraScript(); + DoMeleeAttackIfReady(); } }; @@ -668,6 +509,74 @@ public: ////// SPELLS /////////////////////////////////////// +class spell_love_in_air_perfume_immune : public AuraScript +{ + PrepareAuraScript(spell_love_in_air_perfume_immune); + + void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* target = GetTarget(); + if (GetId() == SPELL_COLOGNE_IMMUNE) + { + target->ApplySpellImmune(SPELL_COLOGNE_PASSIVE_DAMAGE, IMMUNITY_ID, SPELL_COLOGNE_PASSIVE_DAMAGE, true); + target->ApplySpellImmune(SPELL_COLOGNE_PASSIVE_DAMAGE, IMMUNITY_ID, SPELL_COLOGNE_SPRAY, true); + target->ApplySpellImmune(68934, IMMUNITY_ID, 68934, true); + } + else + { + target->ApplySpellImmune(SPELL_PERFUME_PASSIVE_DAMAGE, IMMUNITY_ID, SPELL_PERFUME_PASSIVE_DAMAGE, true); + target->ApplySpellImmune(SPELL_ALLURING_PERFUME_SPRAY, IMMUNITY_ID, SPELL_ALLURING_PERFUME_SPRAY, true); + target->ApplySpellImmune(68927, IMMUNITY_ID, 68927, true); + } + } + + void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* target = GetTarget(); + if (GetId() == SPELL_COLOGNE_IMMUNE) + { + target->ApplySpellImmune(SPELL_COLOGNE_PASSIVE_DAMAGE, IMMUNITY_ID, SPELL_COLOGNE_PASSIVE_DAMAGE, false); + target->ApplySpellImmune(SPELL_COLOGNE_PASSIVE_DAMAGE, IMMUNITY_ID, SPELL_COLOGNE_SPRAY, false); + target->ApplySpellImmune(68934, IMMUNITY_ID, 68934, false); + } + else + { + target->ApplySpellImmune(SPELL_PERFUME_PASSIVE_DAMAGE, IMMUNITY_ID, SPELL_PERFUME_PASSIVE_DAMAGE, false); + target->ApplySpellImmune(SPELL_PERFUME_PASSIVE_DAMAGE, IMMUNITY_ID, SPELL_ALLURING_PERFUME_SPRAY, false); + target->ApplySpellImmune(68927, IMMUNITY_ID, 68927, false); + } + } + + void Register() override + { + OnEffectApply += AuraEffectApplyFn(spell_love_in_air_perfume_immune::HandleEffectApply, EFFECT_2, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + OnEffectRemove += AuraEffectRemoveFn(spell_love_in_air_perfume_immune::HandleEffectRemove, EFFECT_2, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + } +}; + +class spell_love_in_air_periodic_perfumes : public AuraScript +{ + PrepareAuraScript(spell_love_in_air_periodic_perfumes); + + void PeriodicTick(AuraEffect const* /*aurEff*/) + { + ObjectGuid guid = GetCaster() ? GetCaster()->GetGUID() : ObjectGuid::Empty; + if (Unit* target = GetTarget()) + { + uint32 spellId = (GetId() == SPELL_THROW_COLOGNE ? 68934 : 68927); + if (target->IsImmunedToSpell(sSpellMgr->GetSpellInfo(spellId))) + return; + + target->CastSpell(target, spellId, true, nullptr, nullptr, guid); + } + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_love_in_air_periodic_perfumes::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); + } +}; + enum CreateHeartCandy { SPELL_CREATE_HEART_CANDY_1 = 26668, @@ -688,39 +597,28 @@ std::array constexpr CreateHeartCandySpells = }; // 26678 - Create Heart Candy -class spell_item_create_heart_candy : public SpellScriptLoader +class spell_item_create_heart_candy : public SpellScript { -public: - spell_item_create_heart_candy() : SpellScriptLoader("spell_item_create_heart_candy") { } + PrepareSpellScript(spell_item_create_heart_candy); - class spell_item_create_heart_candy_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareSpellScript(spell_item_create_heart_candy_SpellScript); + return ValidateSpellInfo(CreateHeartCandySpells); + } - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo(CreateHeartCandySpells); - } - - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - if (Player* target = GetHitUnit()->ToPlayer()) - { - target->CastSpell(target, Acore::Containers::SelectRandomContainerElement(CreateHeartCandySpells), true); - } - - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_item_create_heart_candy_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void HandleScript(SpellEffIndex effIndex) { - return new spell_item_create_heart_candy_SpellScript(); + PreventHitDefaultEffect(effIndex); + if (Player* target = GetHitUnit()->ToPlayer()) + { + target->CastSpell(target, Acore::Containers::SelectRandomContainerElement(CreateHeartCandySpells), true); + } + + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_item_create_heart_candy::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; @@ -735,74 +633,63 @@ 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 + void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - PrepareAuraScript(spell_love_is_in_the_air_romantic_picnic_AuraScript); + Unit* target = GetTarget(); + target->SetStandState(UNIT_STAND_STATE_SIT); + target->CastSpell(target, SPELL_MEAL_PERIODIC, false); + } - void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + void OnPeriodic(AuraEffect const* /*aurEff*/) + { + // Every 5 seconds + Unit* target = GetTarget(); + Unit* caster = GetCaster(); + + // If our player is no longer sit, remove all auras + if (target->getStandState() != UNIT_STAND_STATE_SIT) { - Unit* target = GetTarget(); - target->SetStandState(UNIT_STAND_STATE_SIT); - target->CastSpell(target, SPELL_MEAL_PERIODIC, false); + target->RemoveAura(SPELL_ROMANTIC_PICNIC_ACHIEV); + target->RemoveAura(GetAura()); + return; } - void OnPeriodic(AuraEffect const* /*aurEff*/) + 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 playerList; + Acore::AnyPlayerInObjectRangeCheck checker(target, INTERACTION_DISTANCE * 2); + Acore::PlayerListSearcher searcher(target, playerList, checker); + Cell::VisitWorldObjects(target, searcher, INTERACTION_DISTANCE * 2); + for (std::list::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr) { - // Every 5 seconds - Unit* target = GetTarget(); - Unit* caster = GetCaster(); - - // If our player is no longer sit, remove all auras - if (target->getStandState() != UNIT_STAND_STATE_SIT) + if ((*itr) != target && (*itr)->HasAura(GetId())) // && (*itr)->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 playerList; - Acore::AnyPlayerInObjectRangeCheck checker(target, INTERACTION_DISTANCE * 2); - Acore::PlayerListSearcher searcher(target, playerList, checker); - Cell::VisitWorldObjects(target, searcher, INTERACTION_DISTANCE * 2); - for (std::list::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr) - { - if ((*itr) != target && (*itr)->HasAura(GetId())) // && (*itr)->getStandState() == UNIT_STAND_STATE_SIT) + if (caster) { - if (caster) - { - caster->CastSpell(*itr, SPELL_ROMANTIC_PICNIC_ACHIEV, true); - caster->CastSpell(target, SPELL_ROMANTIC_PICNIC_ACHIEV, true); - } - foundSomeone = true; - // break; + 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); - } - }; + if (!foundSomeone && target->HasAura(SPELL_ROMANTIC_PICNIC_ACHIEV)) + target->RemoveAura(SPELL_ROMANTIC_PICNIC_ACHIEV); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_love_is_in_the_air_romantic_picnic_AuraScript(); + 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); } }; @@ -814,68 +701,57 @@ enum ServiceUniform MODEL_GOBLIN_FEMALE = 31003 }; -class spell_gen_aura_service_uniform : public SpellScriptLoader +class spell_gen_aura_service_uniform : public AuraScript { -public: - spell_gen_aura_service_uniform() : SpellScriptLoader("spell_gen_aura_service_uniform") { } + PrepareAuraScript(spell_gen_aura_service_uniform); - class spell_gen_aura_service_uniform_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spell*/) override { - PrepareAuraScript(spell_gen_aura_service_uniform_AuraScript); + return ValidateSpellInfo({ SPELL_SERVICE_UNIFORM }); + } - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_SERVICE_UNIFORM }); - } - - void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - // Apply model goblin - Unit* target = GetTarget(); - if (target->GetTypeId() == TYPEID_PLAYER) - { - if (target->getGender() == GENDER_MALE) - target->SetDisplayId(MODEL_GOBLIN_MALE); - else - target->SetDisplayId(MODEL_GOBLIN_FEMALE); - } - } - - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - Unit* target = GetTarget(); - if (target->GetTypeId() == TYPEID_PLAYER) - target->RestoreDisplayId(); - } - - void Register() override - { - AfterEffectApply += AuraEffectApplyFn(spell_gen_aura_service_uniform_AuraScript::OnApply, EFFECT_0, SPELL_AURA_TRANSFORM, AURA_EFFECT_HANDLE_REAL); - AfterEffectRemove += AuraEffectRemoveFn(spell_gen_aura_service_uniform_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_TRANSFORM, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override + void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - return new spell_gen_aura_service_uniform_AuraScript(); + // Apply model goblin + Unit* target = GetTarget(); + if (target->GetTypeId() == TYPEID_PLAYER) + { + if (target->getGender() == GENDER_MALE) + target->SetDisplayId(MODEL_GOBLIN_MALE); + else + target->SetDisplayId(MODEL_GOBLIN_FEMALE); + } + } + + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* target = GetTarget(); + if (target->GetTypeId() == TYPEID_PLAYER) + target->RestoreDisplayId(); + } + + void Register() override + { + AfterEffectApply += AuraEffectApplyFn(spell_gen_aura_service_uniform::OnApply, EFFECT_0, SPELL_AURA_TRANSFORM, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove += AuraEffectRemoveFn(spell_gen_aura_service_uniform::OnRemove, EFFECT_0, SPELL_AURA_TRANSFORM, AURA_EFFECT_HANDLE_REAL); } }; void AddSC_event_love_in_the_air() { // Npcs - new npc_love_in_air_supply_sentry(); - new npc_love_in_air_snivel(); - new npc_love_in_air_snivel_real(); + RegisterCreatureAI(npc_love_in_air_supply_sentry); + RegisterCreatureAI(npc_love_in_air_snivel); + RegisterCreatureAI(npc_love_in_air_snivel_real); // Boss - new npc_love_in_air_hummel(); - new npc_love_in_air_hummel_helper(); - new spell_love_in_air_perfume_immune(); - new spell_love_in_air_periodic_perfumes(); + RegisterCreatureAI(npc_love_in_air_hummel); + RegisterCreatureAI(npc_love_in_air_hummel_helper); // Spells - new spell_item_create_heart_candy(); - new spell_love_is_in_the_air_romantic_picnic(); - new spell_gen_aura_service_uniform(); + RegisterSpellScript(spell_love_in_air_perfume_immune); + RegisterSpellScript(spell_love_in_air_periodic_perfumes); + RegisterSpellScript(spell_item_create_heart_candy); + RegisterSpellScript(spell_love_is_in_the_air_romantic_picnic); + RegisterSpellScript(spell_gen_aura_service_uniform); }