Skip to content

Commit

Permalink
Brewfest: Script Belbi Quikswitch 23710
Browse files Browse the repository at this point in the history
  • Loading branch information
MantisLord committed Sep 22, 2021
1 parent 1cc9414 commit 74d9820
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sql/scriptdev2/scriptdev2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,9 @@ INSERT INTO scripted_event_id VALUES
(8428,'event_spells_warlock_dreadsteed');

/* DUN MOROGH */
UPDATE creature_template SET ScriptName='npc_belbi_quikswitch' WHERE entry=23710;
INSERT INTO scripted_areatrigger VALUES
(4718,'at_belbi_quikswitch');

/* DUROTAR */
UPDATE creature_template SET ScriptName='npc_lazy_peon' WHERE entry=10556;
Expand Down
75 changes: 75 additions & 0 deletions src/game/AI/ScriptDevAI/scripts/eastern_kingdoms/dun_morogh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,82 @@ EndScriptData */
EndContentData */

#include "AI/ScriptDevAI/include/sc_common.h"
#include "world_eastern_kingdoms.h"

std::vector<uint32> belbiTexts = { 22170, 22171, 22172, 22173, 22174, 22175 };

struct npc_belbi_quikswitch : public ScriptedAI
{
npc_belbi_quikswitch(Creature* creature) : ScriptedAI(creature) { Reset(); }

bool m_bCanStartScript;
uint32 m_uiScriptCooldownTimer;
uint32 m_uiShyTimer;

void Reset() override
{
m_uiScriptCooldownTimer = 0;
m_uiShyTimer = 0;
m_bCanStartScript = true;
}

void StartScript(Player* player)
{
m_bCanStartScript = false;
m_uiScriptCooldownTimer = 30000;
m_uiShyTimer = 3000;
m_creature->HandleEmote(EMOTE_ONESHOT_EXCLAMATION);
DoBroadcastText(belbiTexts[urand(0, belbiTexts.size() - 1)], m_creature, player);
}

void UpdateAI(const uint32 diff) override
{
if (m_uiScriptCooldownTimer)
{
if (m_uiScriptCooldownTimer < diff)
{
m_uiScriptCooldownTimer = 0;
m_bCanStartScript = true;
}
else
m_uiScriptCooldownTimer -= diff;
}

if (m_uiShyTimer)
{
if (m_uiShyTimer < diff)
{
m_creature->HandleEmote(EMOTE_ONESHOT_SHY);
m_uiShyTimer = 0;
}
else
m_uiShyTimer -= diff;
}
}
};

bool AreaTrigger_at_belbi_quikswitch(Player* player, AreaTriggerEntry const* /*pAt*/)
{
if (player->IsGameMaster() || !player->IsAlive())
return false;

if (Creature* belbi = static_cast<ScriptedInstance*>(player->GetInstanceData())->GetSingleCreatureFromStorage(NPC_BELBI_QUIKSWITCH))
if (npc_belbi_quikswitch* belbiAI = dynamic_cast<npc_belbi_quikswitch*>(belbi->AI()))
if (belbiAI->m_bCanStartScript)
belbiAI->StartScript(player);

return true;
}

void AddSC_dun_morogh()
{
Script* pNewScript = new Script;
pNewScript->Name = "npc_belbi_quikswitch";
pNewScript->GetAI = &GetNewAIInstance<npc_belbi_quikswitch>;
pNewScript->RegisterSelf();

pNewScript = new Script;
pNewScript->Name = "at_belbi_quikswitch";
pNewScript->pAreaTrigger = &AreaTrigger_at_belbi_quikswitch;
pNewScript->RegisterSelf();
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ struct world_map_eastern_kingdoms : public ScriptedMap, public TimerManager
case NPC_AGENT_PROUDWELL:
case NPC_FALSTAD_WILDHAMMER:
case NPC_SHORT_JOHN_MITHRIL:
case NPC_BELBI_QUIKSWITCH:
m_npcEntryGuidStore[pCreature->GetEntry()] = pCreature->GetObjectGuid();
break;
case NPC_DREADKNIGHT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ enum
NPC_FALSTAD_WILDHAMMER = 5635,

NPC_SHORT_JOHN_MITHRIL = 14508,

NPC_BELBI_QUIKSWITCH = 23710,
};

enum BFTDP_NPCs
Expand Down

0 comments on commit 74d9820

Please sign in to comment.