Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum WardenGame
- {
- NPC_WARDEN_PAWN = 46344,
- NPC_WARDEN_CONTROLLER = 46339,
- SPELL_TELEPORT_EFFECT = 86368,
- SPELL_DESPAWN_ALL_SUMMONS = 86394,
- SPELL_SUMMON_PAWN = 86342,
- SPELL_SUMMON_CONTROLLER = 86343,
- QUEST_THE_WARDEN_GAME_A = 27693,
- QUEST_THE_WARDEN_GAME_H = 27885,
- CREDIT_THE_WARDEN_GAME = 46339
- };
- const Position pawnPositions[3][3] =
- {
- {
- { -6962.4f, -3443.251f, 200.8954f, 0.7602509f },
- { -6962.451f, -3445.25f, 200.8954f, -0.02514732f },
- { -6962.501f, -3447.25f, 200.8954f, -0.810486f },
- },
- {
- { -6964.4f, -3443.201f, 200.8954f, 1.545646f },
- { -6964.4f, -3445.15f, 200.8954f, 0.0f },
- { -6964.5f, -3447.199f, 200.8954f, -1.595947f },
- },
- {
- { -6966.399f, -3443.15f, 200.8954f, 2.331107f },
- { -6966.45f, -3445.15f, 200.8954f, 3.116445f },
- { -6966.5f, -3447.149f, 200.8954f, -2.381342f },
- },
- };
- const float correctOrientations[3][3] =
- {
- { 0.7602509f, -0.02514732f, -0.810486f },
- { 1.545646f, 0.0f, -1.595947f },
- { 2.331107f, 3.116445f, -2.381342f },
- };
- class npc_warden_controller : public CreatureScript
- {
- public:
- npc_warden_controller() : CreatureScript("npc_warden_controller") { }
- struct npc_warden_controllerAI : public ScriptedAI
- {
- npc_warden_controllerAI(Creature* creature) : ScriptedAI(creature)
- {
- }
- void IsSummonedBy(Unit* summoner) override
- {
- _playerGUID = summoner->GetGUID();
- for (_x = 0; _x < 3; _x++)
- {
- for (_y = 0; _y < 3; _y++)
- {
- if (_x == 1 && _y == 1)
- continue;
- me->CastSpell(pawnPositions[_y][_x].GetPositionX(), pawnPositions[_y][_x].GetPositionY(), pawnPositions[_y][_x].GetPositionZ(), SPELL_SUMMON_PAWN, true);
- }
- }
- _x = 1;
- _y = 1;
- }
- void JustSummoned(Creature* summon) override
- {
- _pawnsGUID[_y][_x] = summon->GetGUID();
- summon->SetFacingTo(pawnPositions[_y][_x].GetOrientation());
- summon->AI()->SetData(_x, _y);
- summon->AI()->SetGUID(_playerGUID);
- }
- void SetData(uint32 x, uint32 y) override
- {
- if (CheckPosition(x, y))
- {
- if (Creature* pawn = sObjectAccessor->GetCreature(*me, _pawnsGUID[y][x]))
- {
- pawn->CastSpell(pawnPositions[_y][_x].GetPositionX(), pawnPositions[_y][_x].GetPositionY(), pawnPositions[_y][_x].GetPositionZ(), SPELL_TELEPORT_EFFECT, true);
- pawn->NearTeleportTo(pawnPositions[_y][_x].GetPositionX(), pawnPositions[_y][_x].GetPositionY(), pawnPositions[_y][_x].GetPositionZ(), pawn->GetOrientation());
- pawn->AI()->SetData(_x, _y);
- _pawnsGUID[_y][_x] = pawn->GetGUID();
- _pawnsGUID[y][x] = 0;
- _y = y;
- _x = x;
- if (CheckOrientations())
- {
- if (Player* player = sObjectAccessor->GetPlayer(*me, _playerGUID))
- player->KilledMonsterCredit(CREDIT_THE_WARDEN_GAME);
- DoCast(SPELL_DESPAWN_ALL_SUMMONS);
- }
- }
- }
- }
- void SpellHitTarget(Unit* target, SpellInfo const* spell) override
- {
- if (target->GetTypeId() == TYPEID_UNIT)
- target->ToCreature()->DespawnOrUnsummon(1);
- }
- bool CheckPosition(uint32 x, uint32 y)
- {
- if (x == _x && y == _y - 1)
- return true;
- if (x == _x && y == _y + 1)
- return true;
- if (x == _x - 1 && y == _y)
- return true;
- if (x == _x + 1 && y == _y)
- return true;
- return false;
- }
- bool CheckOrientations()
- {
- for (uint8 x = 0; x < 3; x++)
- {
- for (uint8 y = 0; y < 3; y++)
- {
- if (x == 1 && y == 1)
- continue;
- if (Creature* pawn = sObjectAccessor->GetCreature(*me, _pawnsGUID[y][x]))
- {
- float orientation = pawn->GetOrientation() - M_PI;
- if (!Approximate(orientation, correctOrientations[y][x]))
- return false;
- }
- else
- return false;
- }
- }
- return true;
- }
- bool Approximate(float orientation, float correctOrientation)
- {
- if (orientation > (correctOrientation - 0.1f) && orientation < (correctOrientation + 0.1f))
- return true;
- return false;
- }
- void UpdateAI(uint32 /*diff*/) override { }
- private:
- uint8 _x, _y;
- uint64 _playerGUID;
- uint64 _pawnsGUID[3][3];
- };
- CreatureAI* GetAI(Creature* creature) const override
- {
- return new npc_warden_controllerAI(creature);
- }
- };
- class npc_warden_pawn : public CreatureScript
- {
- public:
- npc_warden_pawn() : CreatureScript("npc_warden_pawn") { }
- struct npc_warden_pawnAI : public ScriptedAI
- {
- npc_warden_pawnAI(Creature* creature) : ScriptedAI(creature)
- {
- }
- void IsSummonedBy(Unit* summoner)
- {
- _controllerGUID = summoner->GetGUID();
- me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
- }
- void SetData(uint32 x, uint32 y) override
- {
- _x = x;
- _y = y;
- }
- void SetGUID(uint64 guid, int32 id)
- {
- _playerGUID = guid;
- }
- void OnSpellClick(Unit* clicker, bool& result) override
- {
- if (clicker->GetGUID() != _playerGUID)
- {
- result = false;
- return;
- }
- if (Creature* controller = sObjectAccessor->GetCreature(*me, _controllerGUID))
- controller->AI()->SetData(_x, _y);
- result = true;
- }
- void UpdateAI(uint32 /*diff*/) override { }
- private:
- uint64 _controllerGUID;
- uint64 _playerGUID;
- uint32 _x, _y;
- };
- CreatureAI* GetAI(Creature* creature) const override
- {
- return new npc_warden_pawnAI(creature);
- }
- };
- void AddSC_badlands_custom()
- {
- new npc_warden_controller();
- new npc_warden_pawn();
- }
- -- The Warden's Game
- UPDATE `creature_template` SET `ScriptName` = 'npc_warden_controller' WHERE `entry` = 46339;
- UPDATE `creature_template` SET `ScriptName` = 'npc_warden_pawn' WHERE `entry` = 46344;
- SET @GOENTRY := 206335;
- DELETE FROM `smart_scripts` WHERE `entryorguid` = @ENTRY AND `source_type` = 0;
- DELETE FROM `smart_scripts` WHERE `entryorguid` = @ENTRY*100 AND `source_type` = 9;
- INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
- (@GOENTRY, 1, 0, 0, 19, 0, 100, 0, 27885, 0, 0, 0, 85, 86343, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 'Stone Slab - On Quest Accept - Player cast spell'),
- (@GOENTRY, 1, 1, 0, 19, 0, 100, 0, 27693, 0, 0, 0, 85, 86343, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 'Stone Slab - On Quest Accept - Player cast spell');
- UPDATE `gameobject_template` SET `AIName` = 'SmartGameObjectAI' WHERE `entry` = @GOENTRY;
- SET @SPELL := 80528;
- DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId` = 13 AND `SourceEntry` = @SPELL;
- INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `ErrorTextId`, `ScriptName`, `Comment`) VALUES
- (13, 1, @SPELL, 0, 31, 3, 46344, 0, 0, '', NULL),
- (13, 1, @SPELL, 1, 31, 3, 46339, 0, 0, '', NULL);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement