Advertisement
Guest User

Untitled

a guest
May 20th, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.42 KB | None | 0 0
  1. enum WardenGame
  2. {
  3. NPC_WARDEN_PAWN = 46344,
  4. NPC_WARDEN_CONTROLLER = 46339,
  5. SPELL_TELEPORT_EFFECT = 86368,
  6. SPELL_DESPAWN_ALL_SUMMONS = 86394,
  7. SPELL_SUMMON_PAWN = 86342,
  8. SPELL_SUMMON_CONTROLLER = 86343,
  9. QUEST_THE_WARDEN_GAME_A = 27693,
  10. QUEST_THE_WARDEN_GAME_H = 27885,
  11. CREDIT_THE_WARDEN_GAME = 46339
  12. };
  13.  
  14. const Position pawnPositions[3][3] =
  15. {
  16. {
  17. { -6962.4f, -3443.251f, 200.8954f, 0.7602509f },
  18. { -6962.451f, -3445.25f, 200.8954f, -0.02514732f },
  19. { -6962.501f, -3447.25f, 200.8954f, -0.810486f },
  20. },
  21. {
  22. { -6964.4f, -3443.201f, 200.8954f, 1.545646f },
  23. { -6964.4f, -3445.15f, 200.8954f, 0.0f },
  24. { -6964.5f, -3447.199f, 200.8954f, -1.595947f },
  25. },
  26. {
  27. { -6966.399f, -3443.15f, 200.8954f, 2.331107f },
  28. { -6966.45f, -3445.15f, 200.8954f, 3.116445f },
  29. { -6966.5f, -3447.149f, 200.8954f, -2.381342f },
  30. },
  31. };
  32.  
  33. const float correctOrientations[3][3] =
  34. {
  35. { 0.7602509f, -0.02514732f, -0.810486f },
  36. { 1.545646f, 0.0f, -1.595947f },
  37. { 2.331107f, 3.116445f, -2.381342f },
  38. };
  39.  
  40.  
  41. class npc_warden_controller : public CreatureScript
  42. {
  43. public:
  44. npc_warden_controller() : CreatureScript("npc_warden_controller") { }
  45.  
  46. struct npc_warden_controllerAI : public ScriptedAI
  47. {
  48. npc_warden_controllerAI(Creature* creature) : ScriptedAI(creature)
  49. {
  50. }
  51.  
  52. void IsSummonedBy(Unit* summoner) override
  53. {
  54. _playerGUID = summoner->GetGUID();
  55. for (_x = 0; _x < 3; _x++)
  56. {
  57. for (_y = 0; _y < 3; _y++)
  58. {
  59. if (_x == 1 && _y == 1)
  60. continue;
  61. me->CastSpell(pawnPositions[_y][_x].GetPositionX(), pawnPositions[_y][_x].GetPositionY(), pawnPositions[_y][_x].GetPositionZ(), SPELL_SUMMON_PAWN, true);
  62. }
  63. }
  64. _x = 1;
  65. _y = 1;
  66. }
  67.  
  68. void JustSummoned(Creature* summon) override
  69. {
  70. _pawnsGUID[_y][_x] = summon->GetGUID();
  71. summon->SetFacingTo(pawnPositions[_y][_x].GetOrientation());
  72. summon->AI()->SetData(_x, _y);
  73. summon->AI()->SetGUID(_playerGUID);
  74. }
  75.  
  76. void SetData(uint32 x, uint32 y) override
  77. {
  78. if (CheckPosition(x, y))
  79. {
  80. if (Creature* pawn = sObjectAccessor->GetCreature(*me, _pawnsGUID[y][x]))
  81. {
  82. pawn->CastSpell(pawnPositions[_y][_x].GetPositionX(), pawnPositions[_y][_x].GetPositionY(), pawnPositions[_y][_x].GetPositionZ(), SPELL_TELEPORT_EFFECT, true);
  83. pawn->NearTeleportTo(pawnPositions[_y][_x].GetPositionX(), pawnPositions[_y][_x].GetPositionY(), pawnPositions[_y][_x].GetPositionZ(), pawn->GetOrientation());
  84. pawn->AI()->SetData(_x, _y);
  85. _pawnsGUID[_y][_x] = pawn->GetGUID();
  86. _pawnsGUID[y][x] = 0;
  87. _y = y;
  88. _x = x;
  89. if (CheckOrientations())
  90. {
  91. if (Player* player = sObjectAccessor->GetPlayer(*me, _playerGUID))
  92. player->KilledMonsterCredit(CREDIT_THE_WARDEN_GAME);
  93. DoCast(SPELL_DESPAWN_ALL_SUMMONS);
  94. }
  95. }
  96. }
  97. }
  98.  
  99. void SpellHitTarget(Unit* target, SpellInfo const* spell) override
  100. {
  101. if (target->GetTypeId() == TYPEID_UNIT)
  102. target->ToCreature()->DespawnOrUnsummon(1);
  103. }
  104.  
  105. bool CheckPosition(uint32 x, uint32 y)
  106. {
  107. if (x == _x && y == _y - 1)
  108. return true;
  109. if (x == _x && y == _y + 1)
  110. return true;
  111. if (x == _x - 1 && y == _y)
  112. return true;
  113. if (x == _x + 1 && y == _y)
  114. return true;
  115. return false;
  116. }
  117.  
  118. bool CheckOrientations()
  119. {
  120. for (uint8 x = 0; x < 3; x++)
  121. {
  122. for (uint8 y = 0; y < 3; y++)
  123. {
  124. if (x == 1 && y == 1)
  125. continue;
  126. if (Creature* pawn = sObjectAccessor->GetCreature(*me, _pawnsGUID[y][x]))
  127. {
  128. float orientation = pawn->GetOrientation() - M_PI;
  129. if (!Approximate(orientation, correctOrientations[y][x]))
  130. return false;
  131. }
  132. else
  133. return false;
  134. }
  135. }
  136. return true;
  137. }
  138.  
  139. bool Approximate(float orientation, float correctOrientation)
  140. {
  141. if (orientation > (correctOrientation - 0.1f) && orientation < (correctOrientation + 0.1f))
  142. return true;
  143. return false;
  144. }
  145.  
  146. void UpdateAI(uint32 /*diff*/) override { }
  147.  
  148. private:
  149. uint8 _x, _y;
  150. uint64 _playerGUID;
  151. uint64 _pawnsGUID[3][3];
  152. };
  153.  
  154. CreatureAI* GetAI(Creature* creature) const override
  155. {
  156. return new npc_warden_controllerAI(creature);
  157. }
  158. };
  159.  
  160. class npc_warden_pawn : public CreatureScript
  161. {
  162. public:
  163. npc_warden_pawn() : CreatureScript("npc_warden_pawn") { }
  164.  
  165. struct npc_warden_pawnAI : public ScriptedAI
  166. {
  167. npc_warden_pawnAI(Creature* creature) : ScriptedAI(creature)
  168. {
  169. }
  170.  
  171. void IsSummonedBy(Unit* summoner)
  172. {
  173. _controllerGUID = summoner->GetGUID();
  174. me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
  175. }
  176.  
  177. void SetData(uint32 x, uint32 y) override
  178. {
  179. _x = x;
  180. _y = y;
  181. }
  182.  
  183. void SetGUID(uint64 guid, int32 id)
  184. {
  185. _playerGUID = guid;
  186. }
  187.  
  188. void OnSpellClick(Unit* clicker, bool& result) override
  189. {
  190. if (clicker->GetGUID() != _playerGUID)
  191. {
  192. result = false;
  193. return;
  194. }
  195. if (Creature* controller = sObjectAccessor->GetCreature(*me, _controllerGUID))
  196. controller->AI()->SetData(_x, _y);
  197. result = true;
  198. }
  199.  
  200. void UpdateAI(uint32 /*diff*/) override { }
  201.  
  202. private:
  203. uint64 _controllerGUID;
  204. uint64 _playerGUID;
  205. uint32 _x, _y;
  206. };
  207.  
  208. CreatureAI* GetAI(Creature* creature) const override
  209. {
  210. return new npc_warden_pawnAI(creature);
  211. }
  212. };
  213.  
  214. void AddSC_badlands_custom()
  215. {
  216. new npc_warden_controller();
  217. new npc_warden_pawn();
  218. }
  219.  
  220.  
  221. -- The Warden's Game
  222. UPDATE `creature_template` SET `ScriptName` = 'npc_warden_controller' WHERE `entry` = 46339;
  223. UPDATE `creature_template` SET `ScriptName` = 'npc_warden_pawn' WHERE `entry` = 46344;
  224. SET @GOENTRY := 206335;
  225. DELETE FROM `smart_scripts` WHERE `entryorguid` = @ENTRY AND `source_type` = 0;
  226. DELETE FROM `smart_scripts` WHERE `entryorguid` = @ENTRY*100 AND `source_type` = 9;
  227. 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
  228. (@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'),
  229. (@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');
  230. UPDATE `gameobject_template` SET `AIName` = 'SmartGameObjectAI' WHERE `entry` = @GOENTRY;
  231. SET @SPELL := 80528;
  232. DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId` = 13 AND `SourceEntry` = @SPELL;
  233. INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `ErrorTextId`, `ScriptName`, `Comment`) VALUES
  234. (13, 1, @SPELL, 0, 31, 3, 46344, 0, 0, '', NULL),
  235. (13, 1, @SPELL, 1, 31, 3, 46339, 0, 0, '', NULL);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement