Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ScriptMgr.h"
- #include "Player.h"
- #include "GameObject.h"
- #include "GameObjectAI.h"
- //#include "EventMap.h"
- enum events
- {
- TONK_EVENT_CHECK = 1,
- BLASTENHEIMER_EVENT_CHECK = 2,
- };
- //Blastenheimer 5000 Ultra Cannon
- class Blastenheimer : public GameObjectScript
- {
- public:
- Blastenheimer() : GameObjectScript("Blastenheimer") { }
- struct BlastenheimerAI : public GameObjectAI
- {
- BlastenheimerAI(GameObject* go) : GameObjectAI(go) { }
- bool GossipHello(Player* player) override
- {
- plr = player;
- player->CastSpell(player, 24832);
- player->SetMovement(MOVE_ROOT);
- plr->NearTeleportTo(-10785.190430f, 785.208557f, 32.695553f, 1.458903f);
- _events.ScheduleEvent(BLASTENHEIMER_EVENT_CHECK, 2200);
- return true;
- }
- void UpdateAI(uint32 diff) override
- {
- if (_events.Empty())
- return;
- _events.Update(diff);
- while (uint32 eventId = _events.ExecuteEvent())
- {
- switch (eventId)
- {
- case BLASTENHEIMER_EVENT_CHECK:
- if (!plr)
- return;
- if (!plr->IsAlive())
- return;
- plr->SetMovement(MOVE_UNROOT);
- plr->CastSpell(plr, 42867);
- plr->RemoveAura(24832);
- plr = NULL; //reset the pointer
- break;
- }
- }
- }
- Player* plr;
- EventMap _events;
- };
- GameObjectAI* GetAI(GameObject* go) const override
- {
- return new BlastenheimerAI(go);
- }
- };
- // Tonk Controller
- class TonkControlConsole : public GameObjectScript
- {
- public:
- TonkControlConsole() : GameObjectScript("TonkControlConsole") { }
- struct TonkControlConsoleAI : public GameObjectAI
- {
- TonkControlConsoleAI(GameObject* go) : GameObjectAI(go) { }
- bool GossipHello(Player* player) override
- {
- tonkConsole = NULL;
- tonk = NULL;
- plr = player;
- tonkConsole = player->FindNearestGameObject(180524, 1000.0f);
- // Open and disable the Tonk Console
- tonkConsole->SetUInt32Value(GAMEOBJECT_FLAGS, 1);
- tonkConsole->SetGoState(GO_STATE_ACTIVE);
- // Spawn Steam Tonk
- player->SummonCreature(19405, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 1000);
- // Store the tonk just spawned
- tonk = NULL;
- tonk = player->FindNearestCreature(19405, 100.0f);
- if (!tonk || !tonk->IsAlive())
- return false;
- player->CastSpell(tonk, 33849);
- _events.ScheduleEvent(TONK_EVENT_CHECK, 500);
- return true;
- }
- void UpdateAI(uint32 diff) override
- {
- if (_events.Empty())
- return;
- _events.Update(diff);
- while (uint32 eventId = _events.ExecuteEvent())
- {
- switch (eventId)
- {
- case TONK_EVENT_CHECK:
- if (!plr || !tonk)
- return;
- if (!plr->HasAura(33849) || !tonk->IsAlive())
- {
- // Kill then Despawn Tonk
- plr->Kill(tonk, false);
- plr->CastSpell(plr, 2880);
- plr->RemoveAura(33849);
- tonk->DespawnOrUnsummon(1000);
- // Close the console so others can access it
- tonkConsole->SetUInt32Value(GAMEOBJECT_FLAGS, 0);
- tonkConsole->SetGoState(GO_STATE_READY);
- }
- else
- _events.ScheduleEvent(TONK_EVENT_CHECK, 100);
- break;
- }
- }
- }
- EventMap _events;
- Creature* tonk = NULL;
- Player* plr = NULL;
- GameObject* tonkConsole = NULL;
- };
- GameObjectAI* GetAI(GameObject* go) const override
- {
- return new TonkControlConsoleAI(go);
- }
- };
- void AddSC_darkmoonfaire()
- {
- new TonkControlConsole();
- new Blastenheimer();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement