Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.60 KB | None | 0 0
  1. /* ScriptData
  2. SDName: NPC ARENA 1V1
  3. SD%Complete: 100
  4. SDComment: By Evrial
  5. SDCategory: NPC
  6. EndScriptData */
  7.  
  8. #include "WorldPacket.h"
  9. #include "WorldSession.h"
  10. #include "ObjectMgr.h"
  11. #include "ArenaTeam.h"
  12. #include "ScriptPCH.h"
  13. #include "BattlegroundMgr.h"
  14. #include <cstring>
  15.  
  16. bool GossipHello_npc_arena_1v1(Player* pPlayer, Creature* pCreature)
  17. {
  18. pPlayer->ADD_GOSSIP_ITEM(9, "Create 1v1 Team", GOSSIP_SENDER_MAIN, 1000);
  19. pPlayer->ADD_GOSSIP_ITEM(9, "Delete 1v1 Team", GOSSIP_SENDER_MAIN, 2000);
  20. pPlayer->ADD_GOSSIP_ITEM(9, "Join 1v1 Battle", GOSSIP_SENDER_MAIN, 3000);
  21.  
  22. pPlayer->SEND_GOSSIP_MENU(pPlayer->GetGossipTextId(pCreature), pCreature->GetGUID());
  23. return true;
  24. }
  25.  
  26. void SendDefaultMenu_npc_arena_1v1(Player* player, Creature* creature, uint32 action)
  27. {
  28. // Not allowed if in combat.
  29. if (player->IsInCombat())
  30. {
  31. player->CLOSE_GOSSIP_MENU();
  32. creature->MonsterWhisper("You are in combat.", player->GetGUID());
  33. return;
  34. }
  35.  
  36. if (!sWorld.getConfig(CONFIG_ARENA_SINGLE))
  37. {
  38. player->CLOSE_GOSSIP_MENU();
  39. creature->MonsterWhisper("Arena 1v1 not allowed server administrator.", player->GetGUID());
  40. return;
  41. }
  42.  
  43. /*if (player->GetInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS) > sWorld.getConfig(CONFIG_ARENA_SINGLE_MAX_BH))
  44. {
  45. player->CLOSE_GOSSIP_MENU();
  46. creature->MonsterWhisper("You are HEALER! Change your equipment!", player->GetGUID());
  47. return;
  48. }*/
  49.  
  50. if (sWorld.getConfig(CONFIG_ARENA_SINGLE_NOHEAL_SPELLS))
  51. if (player->HasSpell(31842) ||
  52. player->HasSpell(5420) ||
  53. player->HasSpell(33891) ||
  54. player->HasSpell(34123) ||
  55. player->HasSpell(33886) ||
  56. player->HasSpell(33887) ||
  57. player->HasSpell(33888) ||
  58. player->HasSpell(33889) ||
  59. player->HasSpell(33890) ||
  60. player->HasSpell(32593) ||
  61. player->HasSpell(32594) ||
  62. player->HasSpell(16190) ||
  63. player->HasSpell(20711) ||
  64. player->HasSpell(15354) ||
  65. player->HasSpell(15355) ||
  66. player->HasSpell(15356)
  67. )
  68. {
  69. player->CLOSE_GOSSIP_MENU();
  70. creature->MonsterWhisper("You are HEALER! Change your tallents!", player->GetGUID());
  71. return;
  72. }
  73.  
  74. std::string teamname = player->GetName();
  75. uint32 type = 5;
  76. switch (action)
  77. {
  78. case 1000:
  79. {
  80. uint32 oldatid = player->GetArenaTeamId(2);
  81. ArenaTeam* oldat = sObjectMgr.GetArenaTeamById(oldatid);
  82. if (oldat)
  83. {
  84. player->CLOSE_GOSSIP_MENU();
  85. creature->MonsterWhisper("You have a 1v1 team.", player->GetGUID());
  86. return;
  87. }
  88. if (sObjectMgr.GetArenaTeamByName(teamname))
  89. {
  90. player->CLOSE_GOSSIP_MENU();
  91. creature->MonsterWhisper("Arena Team with YOUR name is EXIST. You can create team in Arena Organizer. Create 5v5 team. No petition sings needed!", player->GetGUID());
  92. return;
  93. }
  94.  
  95. ArenaTeam* at = new ArenaTeam;
  96. if (!at->Create(player->GetGUID(), type, teamname))
  97. {
  98. sLog.outError("Npc_arena_1v1: arena team create failed.");
  99. delete at;
  100. return;
  101. }
  102.  
  103. uint32 icon, iconcolor, border, bordercolor, backgroud;
  104. icon = 69;
  105. iconcolor = 4294705169;
  106. border = 4;
  107. bordercolor = 4294903296;
  108. backgroud = 4278190080;
  109.  
  110. at->SetEmblem(backgroud, icon, iconcolor, border, bordercolor);
  111.  
  112. // register team and add captain
  113. sObjectMgr.AddArenaTeam(at);
  114. sLog.outDebug("Npc_arena_1v1: arena team added to objmrg");
  115.  
  116. player->CLOSE_GOSSIP_MENU();
  117. creature->MonsterWhisper("Your Arena 1v1 team is created.", player->GetGUID());
  118. }
  119. break;
  120. case 2000:
  121. {
  122. uint32 atid = player->GetArenaTeamId(2);
  123. ArenaTeam* at = sObjectMgr.GetArenaTeamById(atid);
  124. if (!atid || !at)
  125. {
  126. player->CLOSE_GOSSIP_MENU();
  127. creature->MonsterWhisper("You have not arena 1v1 team.", player->GetGUID());
  128. return;
  129. }
  130. player->CLOSE_GOSSIP_MENU();
  131. at->DelMember(player->GetGUID());
  132. at->Disband(player->GetSession());
  133. creature->MonsterWhisper("Your Arena 1v1 team is deleted.", player->GetGUID());
  134. }
  135. break;
  136. case 3000:
  137. {
  138. uint32 atid = player->GetArenaTeamId(2);
  139. ArenaTeam* at = sObjectMgr.GetArenaTeamById(atid);
  140. if (!atid || !at)
  141. {
  142. player->CLOSE_GOSSIP_MENU();
  143. creature->MonsterWhisper("You have not arena 1v1 team.", player->GetGUID());
  144. return;
  145. }
  146. uint8 arenaslot = 2;
  147. uint8 asGroup = 0;
  148. uint8 isRated = 1;
  149.  
  150. uint8 arenatype = ARENA_TYPE_5v5;
  151. uint32 arenaRating = 0;
  152.  
  153. Battleground* bg = NULL;
  154. if (!(bg = sBattlegroundMgr.GetBattlegroundTemplate(BATTLEGROUND_AA)))
  155. {
  156. player->CLOSE_GOSSIP_MENU();
  157. sLog.outError("Npc_arena_1v1: template bg (all arenas) not found");
  158. return;
  159. }
  160. bg = sBattlegroundMgr.GetBattlegroundTemplate(BATTLEGROUND_AA);
  161. uint8 bgTypeId = bg->GetTypeID();
  162. uint32 bgQueueTypeId = sBattlegroundMgr.BGQueueTypeId(bgTypeId, arenatype);
  163.  
  164. if (player->GetBattlegroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES)
  165. return;
  166. if (!player->HasFreeBattlegroundQueueId())
  167. return;
  168.  
  169. arenaRating = at->GetRating();
  170.  
  171. uint32 queueSlot = player->AddBattlegroundQueueId(bgQueueTypeId);
  172. player->SetBattlegroundEntryPoint(player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation());
  173.  
  174. WorldPacket data;
  175. sBattlegroundMgr.BuildBattlegroundStatusPacket(&data, bg, player->GetTeam(), queueSlot, STATUS_WAIT_QUEUE, 0, 0, arenatype, isRated);
  176. player->GetSession()->SendPacket(&data);
  177. sBattlegroundMgr.BuildGroupJoinedBattlegroundPacket(&data, bgTypeId);
  178. player->GetSession()->SendPacket(&data);
  179. GroupQueueInfo * ginfo = sBattlegroundMgr.m_BattlegroundQueues[bgQueueTypeId].AddGroup(player, bgTypeId, arenatype, isRated, arenaRating);
  180. sBattlegroundMgr.m_BattlegroundQueues[bgQueueTypeId].AddPlayer(player, ginfo);
  181. sLog.outDebug("Npc_arena_1v1: player joined queue for arena as group bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, player->GetGUIDLow(), player->GetName());
  182.  
  183. sLog.outDebug("Npc_arena_1v1: arena join end");
  184. sBattlegroundMgr.m_BattlegroundQueues[bgQueueTypeId].Update(bgTypeId, player->GetBattlegroundQueueIdFromLevel(), arenatype, isRated, arenaRating);
  185.  
  186. player->CLOSE_GOSSIP_MENU();
  187. creature->MonsterWhisper("Your Arena 1v1 team is in queue now.", player->GetGUID());
  188. }
  189. break;
  190. }
  191. }
  192.  
  193. bool GossipSelect_npc_arena_1v1(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
  194. {
  195. // Show menu
  196. if (uiSender == GOSSIP_SENDER_MAIN)
  197. SendDefaultMenu_npc_arena_1v1(pPlayer, pCreature, uiAction);
  198. return true;
  199. }
  200.  
  201. void AddSC_npc_arena_1v1()
  202. {
  203. Script *newscript;
  204. newscript = new Script;
  205. newscript->Name = "npc_arena_1v1";
  206. newscript->pGossipHello = &GossipHello_npc_arena_1v1;
  207. newscript->pGossipSelect = &GossipSelect_npc_arena_1v1;
  208. newscript->RegisterSelf();
  209. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement