Skip to content

Commit

Permalink
Brewfest: Generalize Belbi Quikswitch script so it works for Blix Fix…
Browse files Browse the repository at this point in the history
…widget

Also move to new file
  • Loading branch information
MantisLord authored and killerwife committed Oct 17, 2021
1 parent f089ac3 commit 196ee0f
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 78 deletions.
9 changes: 6 additions & 3 deletions sql/scriptdev2/scriptdev2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ entry IN(15383,15431,15432,15434,15437,15445,15446,15448,15450,15451,15452,15453
UPDATE gameobject_template SET ScriptName='go_midsummer_bonfire' WHERE entry IN(187946,187945,187944,187943,187942,187941,187940,187939,187938,187937,187936,187935,187934,187933,187932,187931,187930,187929,187928,187927,187926,187925,187924,187923,187922,187921,187920,187919,187917,187916,187914,187564,187971,187973,187952,187963,187950,187961,187959,187957,187968,187948,187953,187970,187966,187975,187969,187951,187956,187954,187947,187972,187964,187559,187965,187949,187955,187967,187958,187974,187960,187962,181332,181333,181334,181335,181336,181337,188128,188129);
UPDATE creature_template SET ScriptName='npc_torch_tossing_bunny_controller' WHERE entry IN(25536);

/* Brewfest */
UPDATE creature_template SET ScriptName='npc_ticket_redeemer' WHERE entry IN (23710,24495); -- Belbi Quikswitch, Blix Fixwidget
INSERT INTO scripted_areatrigger VALUES
(4718,'at_ticket_redeemer'),
(4800,'at_ticket_redeemer');

/* */
/* ZONE */
/* */
Expand Down Expand Up @@ -632,9 +638,6 @@ 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: 0 additions & 75 deletions src/game/AI/ScriptDevAI/scripts/eastern_kingdoms/dun_morogh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,82 +25,7 @@ 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 @@ -17,6 +17,7 @@ enum

NPC_SHORT_JOHN_MITHRIL = 14508,

// Brewfest
NPC_BELBI_QUIKSWITCH = 23710,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ struct world_map_kalimdor : public ScriptedMap
case NPC_THE_WINDREAVER:
case NPC_BARON_CHARR:
case NPC_HIGHLORD_KRUUL:
case NPC_BLIX_FIXWIDGET:
m_npcEntryGuidStore[pCreature->GetEntry()] = pCreature->GetObjectGuid();
break;
case NPC_MASKED_ORPHAN_MATRON:
Expand Down
3 changes: 3 additions & 0 deletions src/game/AI/ScriptDevAI/scripts/kalimdor/world_kalimdor.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ enum
NPC_COLOSSUS_RESEARCHER_SOPHIA = 15797,
NPC_COLOSSUS_RESEARCHER_NESTOR = 15798,
NPC_COLOSSUS_RESEARCHER_EAZEL = 15799,

// Brewfest
NPC_BLIX_FIXWIDGET = 24495,
};

enum Encounters
Expand Down
78 changes: 78 additions & 0 deletions src/game/AI/ScriptDevAI/scripts/world/brewfest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/

#include "AI/ScriptDevAI/include/sc_common.h"
#include "AI/ScriptDevAI/scripts/eastern_kingdoms/world_eastern_kingdoms.h"
#include "AI/ScriptDevAI/scripts/kalimdor/world_kalimdor.h"

struct BrewfestMountTransformation : public SpellScript
{
Expand Down Expand Up @@ -86,8 +88,84 @@ struct BrewfestMountTransformationFactionSwap : public SpellScript
}
};

std::vector<uint32> belbiTexts = { 22170, 22171, 22172, 22173, 22174, 22175 };
std::vector<uint32> blixTexts = { 23497, 23498, 23499, 23500, 23501, 23502 };

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

bool m_bCanStartScript;
uint32 m_uiScriptCooldownTimer;
uint32 m_uiEmoteTimer;

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

void StartScript(Player* player)
{
m_bCanStartScript = false;
m_uiScriptCooldownTimer = 30000;
m_uiEmoteTimer = 3000;
m_creature->HandleEmote(m_creature->GetEntry() == NPC_BELBI_QUIKSWITCH ? EMOTE_ONESHOT_EXCLAMATION : EMOTE_ONESHOT_TALK_NOSHEATHE);
DoBroadcastText(m_creature->GetEntry() == NPC_BELBI_QUIKSWITCH ? belbiTexts[urand(0, belbiTexts.size() - 1)] : blixTexts[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_uiEmoteTimer)
{
if (m_uiEmoteTimer < diff)
{
m_creature->HandleEmote(m_creature->GetEntry() == NPC_BELBI_QUIKSWITCH ? EMOTE_ONESHOT_SHY : EMOTE_ONESHOT_YES);
m_uiEmoteTimer = 0;
}
else
m_uiEmoteTimer -= diff;
}
}
};

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

if (Creature* redeemer = static_cast<ScriptedInstance*>(player->GetInstanceData())->GetSingleCreatureFromStorage(player->GetMapId() == 0 ? NPC_BELBI_QUIKSWITCH : NPC_BLIX_FIXWIDGET))
if (npc_ticket_redeemer* ticketRedeemerAI = dynamic_cast<npc_ticket_redeemer*>(redeemer->AI()))
if (ticketRedeemerAI->m_bCanStartScript)
ticketRedeemerAI->StartScript(player);

return true;
}

void AddSC_brewfest()
{
RegisterSpellScript<BrewfestMountTransformation>("spell_brewfest_mount_transformation");
RegisterSpellScript<BrewfestMountTransformationFactionSwap>("spell_brewfest_mount_transformation_faction_swap");

Script* pNewScript = new Script;
pNewScript->Name = "npc_ticket_redeemer";
pNewScript->GetAI = &GetNewAIInstance<npc_ticket_redeemer>;
pNewScript->RegisterSelf();

pNewScript = new Script;
pNewScript->Name = "at_ticket_redeemer";
pNewScript->pAreaTrigger = &AreaTrigger_at_ticket_redeemer;
pNewScript->RegisterSelf();
}

0 comments on commit 196ee0f

Please sign in to comment.