diff options
-rw-r--r-- | sql/updates/world/3.3.5/2021_10_08_02_world.sql | 3 | ||||
-rw-r--r-- | src/server/scripts/World/npcs_special.cpp | 110 |
2 files changed, 113 insertions, 0 deletions
diff --git a/sql/updates/world/3.3.5/2021_10_08_02_world.sql b/sql/updates/world/3.3.5/2021_10_08_02_world.sql new file mode 100644 index 00000000000..59b306e96ea --- /dev/null +++ b/sql/updates/world/3.3.5/2021_10_08_02_world.sql @@ -0,0 +1,3 @@ +-- Add script to 3 revealers outside Ironforge +UPDATE `creature` SET `ScriptName` = "npc_brewfest_reveler_2" WHERE `guid` IN (47648,86731,84899); +UPDATE `creature_addon` SET `emote` = 0 WHERE `guid` IN (47648,86731); diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index 6de9cb8ba8d..ff622f58201 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -1438,6 +1438,115 @@ class npc_brewfest_reveler : public CreatureScript } }; +/*###### +# npc_brewfest_reveler_2 +######*/ + +Emote const BrewfestRandomEmote[] = +{ + EMOTE_ONESHOT_QUESTION, + EMOTE_ONESHOT_APPLAUD, + EMOTE_ONESHOT_SHOUT, + EMOTE_ONESHOT_EAT_NO_SHEATHE, + EMOTE_ONESHOT_LAUGH_NO_SHEATHE +}; + +struct npc_brewfest_reveler_2 : ScriptedAI +{ + enum BrewfestReveler2 + { + NPC_BREWFEST_REVELER = 24484, + + EVENT_FILL_LIST = 1, + EVENT_FACE_TO = 2, + EVENT_EMOTE = 3, + EVENT_NEXT = 4 + }; + + npc_brewfest_reveler_2(Creature* creature) : ScriptedAI(creature) { } + + void Reset() override + { + _events.Reset(); + _events.ScheduleEvent(EVENT_FILL_LIST, 1s, 2s); + } + + // Copied from old script. I don't know if this is 100% correct. + void ReceiveEmote(Player* player, uint32 emote) override + { + if (!IsHolidayActive(HOLIDAY_BREWFEST)) + return; + + if (emote == TEXT_EMOTE_DANCE) + me->CastSpell(player, SPELL_BREWFEST_TOAST, false); + } + + void UpdateAI(uint32 diff) override + { + UpdateVictim(); + + _events.Update(diff); + + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_FILL_LIST: + { + std::list<Creature*> creatureList; + GetCreatureListWithEntryInGrid(creatureList, me, NPC_BREWFEST_REVELER, 5.0f); + for (Creature* creature : creatureList) + if (creature != me) + _revelerGuids.push_back(creature->GetGUID()); + + _events.ScheduleEvent(EVENT_FACE_TO, 1s, 2s); + break; + } + case EVENT_FACE_TO: + { + // Turn to random brewfest reveler within set range + if (!_revelerGuids.empty()) + if (Creature* creature = ObjectAccessor::GetCreature(*me, Trinity::Containers::SelectRandomContainerElement(_revelerGuids))) + me->SetFacingToObject(creature); + + _events.ScheduleEvent(EVENT_EMOTE, 2s, 6s); + break; + } + case EVENT_EMOTE: + // Play random emote or dance + if (roll_chance_i(50)) + { + me->HandleEmoteCommand(Trinity::Containers::SelectRandomContainerElement(BrewfestRandomEmote)); + _events.ScheduleEvent(EVENT_NEXT, 4s, 6s); + } + else + { + me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_DANCE); + _events.ScheduleEvent(EVENT_NEXT, 8s, 12s); + } + break; + case EVENT_NEXT: + // If dancing stop before next random state + if (me->GetUInt32Value(UNIT_NPC_EMOTESTATE) == EMOTE_STATE_DANCE) + me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); + + // Random EVENT_EMOTE or EVENT_FACETO + if (roll_chance_i(50)) + _events.ScheduleEvent(EVENT_FACE_TO, 1s); + else + _events.ScheduleEvent(EVENT_EMOTE, 1s); + break; + default: + break; + } + } + } + +private: + EventMap _events; + GuidVector _revelerGuids; +}; + struct npc_training_dummy : NullCreatureAI { npc_training_dummy(Creature* creature) : NullCreatureAI(creature) { } @@ -2599,6 +2708,7 @@ void AddSC_npcs_special() new npc_steam_tonk(); new npc_tournament_mount(); new npc_brewfest_reveler(); + RegisterCreatureAI(npc_brewfest_reveler_2); RegisterCreatureAI(npc_training_dummy); new npc_wormhole(); new npc_pet_trainer(); |