Advertisement
julienanid

[Trinity] Zombie Event

Oct 14th, 2013
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 24.26 KB | None | 0 0
  1. /*
  2. <--------------------------------------------------------------------------->
  3. - Updated by: Synth
  4. - Complete: %100
  5. - ScriptName: 'zombie_event'
  6. <--------------------------------------------------------------------------->
  7. */
  8.  
  9. #include "ScriptPCH.h"
  10. #include "ScriptedCreature.h"
  11. #include "ObjectMgr.h"
  12. #include "Group.h"
  13.  
  14. enum ZOMBIE_DATA
  15. {
  16. NPC_START_GAME = 125,
  17. NPC_START_NEXT_WAVE = 126,
  18. NPC_START_NEXT_ROUND = 127,
  19. NPC_WAIT_FOR_END_ROUND = 128,
  20. NPC_WAIT_FOR_CHEST_LOOT = 151,
  21. NPC_END_GAME = 152,
  22. NPC_END_GAME_INUSE = 154,
  23. NPC_END_GAME_GOSSIP = 157,
  24.  
  25. TIME_BTW_EACH_WAVE = -1000350,
  26. TIME_TO = -1000350,
  27. ZOMBIE_NPC_3_SPELL = -1000350,
  28. ZOMBIE_NPC_4_SPELL = -1000350,
  29. ZOMBIE_NPC_5_SPELL = -1000350,
  30. };
  31.  
  32. uint32 ZOMBIE_NPCS [7] = {0, 434,435,436,437,440,441};
  33. uint32 TREASURE_CHEST [7] = {0, 510000,520000,530000,540000,550000,560000};
  34.  
  35. const Position Spawn_C1 ={-10953.3662f, -1997.1374f, 79.9735f, 3.0059f};
  36. const Position Spawn_C2 ={-10974.728516f, -1972.700073f, 79.973518f, 5.158750f};
  37. const Position Spawn_C3 ={-10957.954102f, -1973.366821f, 79.973518f, 3.991647f};
  38. const Position Spawn_C4 ={-10985.388672f, -1992.934814f, 79.973984f, 6.138140f};
  39. const Position Spawn_C5 ={-10980.184570f, -2016.144897f, 79.973984f, 0.798218f};
  40. const Position Spawn_C6 ={-10962.931641f, -2019.476074f, 79.974602f, 2.163240f};
  41.  
  42. bool zombie_inUse = false;
  43.  
  44. bool closeGossipNotify(Player *player, std::string message)
  45. {
  46. player->PlayerTalkClass->SendCloseGossip();
  47. player->GetSession()->SendNotification(message.c_str());
  48. return true;
  49. }
  50.  
  51. class zombie_bg_master : public CreatureScript
  52. {
  53. public:
  54.     zombie_bg_master() : CreatureScript("zombie_bg_master") { }
  55.  
  56. bool OnGossipHello(Player* player, Creature* creature)
  57. {
  58. if(player->IsInCombat())
  59. {
  60. return closeGossipNotify(player, "You can't start the zombie event while being in combat.");
  61. }
  62.  
  63. if(!player->GetGroup() || player->GetGroup() == NULL)
  64. {
  65. return closeGossipNotify(player, "You must be the group leader in a party/raid with 5-10 players.");
  66. }
  67.  
  68. Group* grp = player->GetGroup();
  69.  
  70. if(grp->GetMembersCount() > 10 || grp->GetMembersCount() < 5)
  71. {
  72. return closeGossipNotify(player, "You must be the group leader in a party/raid with 5-10 players.");
  73. }
  74.  
  75. if(grp->GetLeaderGUID() != player->GetGUID())
  76. {
  77. return closeGossipNotify(player, "Only the party leader can activate the Zombie Event!");
  78. }
  79.  
  80. player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Teleport me to the Zombie Attack event!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
  81. player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "No thanks.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
  82. player->PlayerTalkClass->SendGossipMenu(1, creature->GetGUID());
  83. return true;
  84. }
  85.  
  86.     bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 uiAction)
  87.     {
  88. player->PlayerTalkClass->ClearMenus();
  89. Group* grp = player->GetGroup();
  90. switch(uiAction)
  91. {
  92. case GOSSIP_ACTION_INFO_DEF+1:
  93. grp->ConvertToRaid();
  94. player->TeleportTo(532, -10966.888f, -2011.3127f, 79.98f, 1.37f);
  95. zombie_inUse = true;
  96. break;
  97.  
  98. case GOSSIP_ACTION_INFO_DEF+2:
  99. player->PlayerTalkClass->SendCloseGossip();
  100. break;
  101. }
  102. return true;
  103. }
  104.  
  105.  
  106. };
  107.  
  108.  
  109. class zombie_bg_master_endgame : public CreatureScript
  110. {
  111. public:
  112.     zombie_bg_master_endgame() : CreatureScript("zombie_bg_master_endgame") { }
  113.  
  114. bool OnGossipHello(Player* player, Creature* creature)
  115. {
  116. //if(player->isInCombat())
  117. // return false;
  118. //if(player->GetGroup()->GetLeaderGUID() == player->GetGUID()){
  119. // player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "End the Zombie Event!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
  120. // player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Nevermind.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
  121. // player->PlayerTalkClass->SendGossipMenu(1, creature->GetGUID());
  122. //}
  123. return true;
  124. }
  125.  
  126.     bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 uiAction)
  127.     {
  128. //player->PlayerTalkClass->ClearMenus();
  129. //Group* grp = player->GetGroup();
  130. //switch(uiAction)
  131. //{
  132. //case GOSSIP_ACTION_INFO_DEF+1:
  133. // creature->MonsterYell("The group leader ended the zombie event!", 0, 0);
  134. // creature->SummonCreature(NPC_END_GAME, -10989.9003f, -1940.1300f, 93.9107f, 4.8345f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1*1000);
  135. // creature->DespawnOrUnsummon();
  136. // break;
  137.  
  138. //case GOSSIP_ACTION_INFO_DEF+2:
  139. // player->PlayerTalkClass->SendCloseGossip();
  140. // break;
  141. //}
  142. return true;
  143. }
  144.  
  145.  
  146. };
  147.  
  148. class zombie_bg_master_final : public CreatureScript
  149. {
  150. public:
  151.     zombie_bg_master_final() : CreatureScript("zombie_bg_master_final") { }
  152.  
  153. bool OnGossipHello(Player* player, Creature* creature)
  154. {
  155. if(!player->GetGroup())
  156. return false;
  157. if(player->GetGroup() == NULL)
  158. return false;
  159. if((player->GetGroup()->GetMembersCount() <= 10 && player->GetGroup()->GetMembersCount() >= 5) && player->GetGroup()->GetLeaderGUID() == player->GetGUID())
  160. {
  161. player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "Summon group to the Zombie Attack event!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
  162. if(player->GetGroup()->GetLeaderGUID() == player->GetGUID())
  163. player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Start the event!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
  164. player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Nevermind", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4);
  165. player->PlayerTalkClass->SendGossipMenu(1, creature->GetGUID());
  166. } else
  167. {
  168. ChatHandler(player->GetSession()).PSendSysMessage("You must be the group leader in a party/raid with 5-10 players");
  169. while(creature->SelectNearestPlayer(280.0f) != NULL)
  170. {
  171. Player* plr = creature->SelectNearestPlayer(280.0f);
  172. if(plr)
  173. {
  174. plr->ResurrectPlayer(60, false);
  175. plr->TeleportTo(534, 5541.770020f, -3783.469971f, 1594.910034f, 2.883010f);
  176. }
  177. }
  178. }
  179.  
  180. return true;
  181. }
  182.  
  183.     bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 uiAction)
  184.     {
  185.  
  186. player->PlayerTalkClass->ClearMenus();
  187. Group* grp = player->GetGroup();
  188. zombie_inUse = true;
  189. if(grp){
  190. GroupReference* grpRef = grp->GetFirstMember();
  191. if(grp->GetLeaderGUID() == player->GetGUID())
  192. GroupReference grpRef = player->GetGroupRef(); 
  193.  
  194. switch(uiAction)
  195. {
  196. case GOSSIP_ACTION_INFO_DEF+1:
  197.  
  198. for (grpRef; grpRef != NULL; grpRef = grpRef->next())
  199. {
  200. Player* groupMember = grpRef->GetSource();
  201. ChatHandler(player->GetSession()).PSendSysMessage("Sending summon request to...");
  202. if(!groupMember)
  203. continue;  
  204. if(groupMember->GetGUID() == player->GetGUID())
  205. break;
  206. player->SetSelection(groupMember->GetGUID());
  207. player->CastSpell(groupMember, 7720, true);
  208. ChatHandler(player->GetSession()).PSendSysMessage("%s", groupMember->GetName());
  209. }
  210. break;
  211.  
  212. case GOSSIP_ACTION_INFO_DEF+2:
  213. creature->MonsterYell("Round 1 starts in 30 seconds!", 0, 0);
  214.  
  215. /* spawn NPC_START_GAME to despawn after 30 seconds and start the game */
  216. creature->SummonCreature(NPC_START_GAME, -10989.9003f, -1940.1300f, 93.9107f, 4.8345f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30*1000);
  217. /* the main NPC will not be seen again by the group so teleport him away */
  218. creature->UpdatePosition(-10989.9003f, -1940.1300f, 93.9107f, 4.8345f, true);
  219. break;
  220.  
  221. case GOSSIP_ACTION_INFO_DEF+3:
  222. creature->MonsterYell("The group leader ended the zombie event!", 0, 0);
  223. creature->SummonCreature(NPC_END_GAME, -10989.9003f, -1940.1300f, 93.9107f, 4.8345f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 500);
  224. break;
  225.  
  226. case GOSSIP_ACTION_INFO_DEF+4:
  227. //NPC_END_GAME
  228.  
  229. break;
  230. }
  231. }
  232. player->PlayerTalkClass->SendCloseGossip();
  233. return true;
  234. }
  235.  
  236. struct zombie_bg_master_finalAI : public ScriptedAI
  237.     {
  238. zombie_bg_master_finalAI(Creature* c) : ScriptedAI(c), Summons(me) {}
  239.  
  240. SummonList Summons;
  241. //total number of zombies to spawn
  242. uint8 zombieCount;
  243. //current number of zombies spawned so far
  244. uint8 zombiesSpawned;
  245. //how many zombies have died in this round
  246. uint8 zombieDeathCount;
  247. //what round in the game you are on
  248. uint8 zombieRound;
  249. //how many waves of zombies per round
  250. uint8 zombieWaves;
  251. //the number of waves already spawned
  252. uint8 zombieWavesCount;
  253. //the number of zombies to be spawned per wave
  254. uint32 zombieSpawnPerWave;
  255. //stores how many players are in the group
  256. uint32 zombieGroupMembers;
  257. //stores number of zombies spawn per each person
  258. uint8 ZOMBIES_PER_PERSON;
  259.  
  260. bool inZombieGame;
  261.  
  262. Player* zombieLeader;
  263. Group* playerGroup;
  264. GameObject *zombie_chest_loot;
  265.  
  266. void JustSummoned(Creature* summon)
  267. {  
  268. if(summon) {
  269. uint32 entry = summon->GetEntry();
  270. Summons.Summon(summon);
  271. if(entry >= 125 && entry <= 128 || entry == 151 || entry == 152)
  272. {
  273.  
  274. } else {
  275. Player* selPlr = summon->SelectNearestPlayer(200);
  276. if(selPlr)
  277. summon->Attack(selPlr, false);
  278. else
  279. {
  280. /* cant find a player to select */
  281. }
  282. }
  283. }
  284. }
  285.  
  286. void SummonedCreatureDespawn(Creature* summon)
  287. {
  288. uint32 summonID = summon->GetEntry();
  289.  
  290. if(summonID == NPC_START_GAME)
  291. {
  292. /* called at the beg of the game */
  293. /* reset all vars because this is new instance of game */
  294. resetZombieEvent();
  295.  
  296. Player* selPlr = me->SelectNearestPlayer(280.0f);
  297. if(!selPlr)
  298. { reviveAndTeleportOut(); resetZombieEvent(); me->MonsterYell("!selPlr return", 0, 0);return; }
  299. if(selPlr == NULL)
  300. {   reviveAndTeleportOut(); resetZombieEvent(); me->MonsterYell("selPlr == NULL return", 0, 0);return; }
  301. if(!selPlr->GetGroup())
  302. {   reviveAndTeleportOut(); resetZombieEvent(); me->MonsterYell("!Group return", 0, 0);return; }
  303. if(selPlr->GetGroup() == NULL)
  304. {   reviveAndTeleportOut(); resetZombieEvent(); me->MonsterYell("Group == NULL return", 0, 0);return; }
  305. if(playerGroup = selPlr->GetGroup())
  306. {
  307. zombieGroupMembers = playerGroup->GetMembersCount();
  308. if(zombieLeader = sObjectAccessor->FindPlayer(playerGroup->GetLeaderGUID()))
  309. {
  310. } else {
  311. reviveAndTeleportOut(); resetZombieEvent(); me->MonsterYell("LeaderGUID == NULL return", 0, 0);return;
  312. }
  313. }
  314. else
  315. {
  316. reviveAndTeleportOut(); resetZombieEvent(); me->MonsterYell("playerGroup == NULL return", 0, 0);return;
  317. }
  318.  
  319. /* Set the ZombieGame to true so they cant keep starting the game */
  320. inZombieGame = true;
  321.  
  322. me->MonsterYell("Round 1 is starting now!", 0, 0);
  323. sendMessageToGroup("Round 1 is starting now!");
  324. me->MonsterYell("If you die anytime during the event you will respawned at the end of the round!", 0, 0);
  325. me->SetVisible(false);
  326.  
  327. /* calc how many waves of zombies to send */
  328. zombieWaves = getNumberOfWaves();  
  329. /* calc how many zombies per wave */
  330. zombieSpawnPerWave = getZombieSpawnCountPerWave(); 
  331. /* spawn */
  332. spawnZombies(me, zombieSpawnPerWave);  
  333.  
  334. /* NPC_START_NEXT_WAVE is despanwed when the next wave of zombies is to be sent */
  335. me->SummonCreature(NPC_START_NEXT_WAVE, -10989.9003f, -1940.1300f, 93.9107f, 4.8345f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30*1000);
  336. }
  337.  
  338. if(inZombieGame == false){ return; }
  339. char buffer [150];
  340. switch(summonID)
  341. {
  342. case NPC_START_GAME:
  343. /* called at the beg of the game */
  344. break;
  345.  
  346. /* called when a wave of zombies needs to be spawned */
  347. case NPC_START_NEXT_WAVE:
  348. if(zombieWavesCount == zombieWaves){    /* spawned all waves */
  349. if(isRoundOver()){  /* check if all zombies are dead */
  350. /* reset wave count to 1 for next round */
  351. zombieWavesCount = 1;  
  352. /* add addtional zombies for next round */
  353. ZOMBIES_PER_PERSON = ZOMBIES_PER_PERSON + 2;   
  354.  
  355. /* spawn treasure loot */
  356. spawnGoDrop(me);
  357.  
  358. /* remove all add. zombies that are somehow left */
  359. Summons.RemoveNotExisting();
  360.  
  361. /* revive the group for the next round */
  362. reviveGroup();
  363. me->SetVisible(true);
  364.  
  365. sprintf (buffer, "You have finished round %u, you now have 1 minute to loot the chest in the middle before it dissapears and next round begins!", zombieRound);
  366. me->MonsterYell(buffer, 0 , 0);
  367. sendMessageToGroup(buffer);
  368. sprintf (buffer, "If you want to stop the event and exit, disband your group and you will be teleported out in 30 seconds.");
  369. me->MonsterYell(buffer, 0 , 0);
  370. sendMessageToGroup(buffer);
  371.  
  372. /* NPC_START_NEXT_ROUND is spawned when all waves of zombies have been killed */
  373. me->SummonCreature(NPC_START_NEXT_ROUND, -10989.9003f, -1940.1300f, 93.9107f, 4.8345f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60*1000);
  374. /* NPC_END_GAME_GOSSIP is spawned after every round incase players want to exit the game */
  375. me->SummonCreature(NPC_END_GAME_GOSSIP, -10969.819336f, -1995.319580f, 79.973022f, 1.467133f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60*1000);
  376. zombieRound++;
  377.  
  378. } else {    /* not all zombies are dead wait for * sec and check again */
  379. if(isGroupDead())
  380. {
  381. reviveAndTeleportOut();
  382. me->SetVisible(true);
  383. Summons.DespawnAll();
  384. Summons.RemoveNotExisting();
  385. resetZombieEvent();
  386. }
  387. else {
  388. /* not all members are dead but there is still zombies left, respawn and check again in * sec */
  389. me->SummonCreature(NPC_WAIT_FOR_END_ROUND, -10989.9003f, -1940.1300f, 93.9107f, 4.8345f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30*1000);
  390. }
  391. }
  392. }
  393. else{   /* not all waves spawned continue spawning zombies */
  394. if(!isGroupDead()) {
  395. spawnZombies(me, zombieSpawnPerWave);
  396. me->SummonCreature(NPC_START_NEXT_WAVE, -10989.9003f, -1940.1300f, 93.9107f, 4.8345f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30*1000);
  397. zombieWavesCount++;
  398. } else {
  399. reviveAndTeleportOut();
  400. me->SetVisible(true);
  401. Summons.DespawnAll();
  402. resetZombieEvent();
  403. TC_LOG_INFO(LOG_FILTER_GENERAL, "Everyone is dead. Stopping....2");
  404. }
  405. }
  406. break;
  407.  
  408. case NPC_START_NEXT_ROUND: /* called when the all waves are spawned and next round needs to begin */
  409. if(zombieRound != 15) {
  410. sprintf (buffer, "Round %u is starting now!", zombieRound);
  411. me->MonsterYell(buffer, 0 , 0);
  412. sendMessageToGroup(buffer);
  413. me->SetVisible(false);
  414. zombieWaves = getNumberOfWaves();   /* calc how many waves of zombies to send */
  415. zombieSpawnPerWave = getZombieSpawnCountPerWave();  /* calc how many zombies per wave */
  416. spawnZombies(me, zombieSpawnPerWave);
  417. me->SummonCreature(NPC_START_NEXT_WAVE, -10989.9003f, -1940.1300f, 93.9107f, 4.8345f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30*1000);
  418. }
  419. else
  420. {
  421. me->MonsterYell("You have completed all 15 rounds!", 0 , 0);   
  422. sendMessageToGroup("You have completed all 15 rounds!");
  423. resetZombieEvent();
  424. Summons.RemoveNotExisting();
  425. }
  426. break;
  427.  
  428. case NPC_WAIT_FOR_END_ROUND: /* called when the all waves are spawned but zombies are still left */
  429. if(isGroupDead())   /* check if the zombies killed all the players */
  430. {
  431. reviveAndTeleportOut();
  432. me->SetVisible(true);
  433. Summons.DespawnAll();
  434. resetZombieEvent();
  435. TC_LOG_INFO(LOG_FILTER_GENERAL, "Everyone is dead. Stopping....3");
  436. } else {   
  437. if(isRoundOver()){  /* check if all zombies have been killed if not, wait another * secs*/ 
  438. sprintf (buffer, "You have finished round %u, you now have 1 minute to loot the chest in the middle before it dissapears and next round begins!", zombieRound);
  439. me->SetVisible(true);
  440. me->MonsterYell(buffer, 0 , 0);
  441. sendMessageToGroup(buffer);
  442. sprintf (buffer, "If you want to stop the event and exit, disband your group and you will be teleported out in 30 seconds.");
  443. me->MonsterYell(buffer, 0 , 0);
  444. sendMessageToGroup(buffer);
  445.  
  446. zombieWavesCount = 1;
  447. ZOMBIES_PER_PERSON = ZOMBIES_PER_PERSON + 2;
  448.  
  449. reviveGroup();
  450. Summons.RemoveNotExisting();
  451. spawnGoDrop(me);
  452.  
  453. me->SummonCreature(NPC_START_NEXT_ROUND, -10989.9003f, -1940.1300f, 93.9107f, 4.8345f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60*1000);
  454. me->SummonCreature(NPC_END_GAME_GOSSIP, -10969.819336f, -1995.319580f, 79.973022f, 1.467133f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60*1000);
  455. zombieRound++;
  456. } else {
  457. me->SummonCreature(NPC_WAIT_FOR_END_ROUND, -10989.9003f, -1940.1300f, 93.9107f, 4.8345f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30*1000);
  458. }
  459. }
  460. break;
  461.  
  462. case NPC_WAIT_FOR_CHEST_LOOT:
  463. if(zombie_chest_loot)
  464. {
  465. zombie_chest_loot->SetRespawnTime(0);
  466. zombie_chest_loot->Delete();
  467. zombie_chest_loot->DeleteFromDB();
  468. }
  469. break;
  470.  
  471. case NPC_END_GAME:
  472. reviveAndTeleportOut();
  473. resetZombieEvent();
  474. me->UpdatePosition(-10989.9003f, -1940.1300f, 93.9107f, 4.8345f, true);
  475. break;
  476. case NPC_END_GAME_INUSE:
  477. zombie_inUse = false;
  478. break;
  479. case NPC_END_GAME_GOSSIP:
  480.  
  481. break;
  482. default:
  483. if(summonID == 434 || summonID == 435 || summonID == 436 || summonID == 437 || summonID == 440 || summonID == 441)
  484. zombieDeathCount++;
  485. break;
  486. }
  487. }
  488.  
  489. bool isGroupDead()
  490. {
  491. if(!zombieLeader->GetGroup())
  492. return true;
  493. if(zombieLeader->GetGroup() == NULL)
  494. return true;
  495. if(!playerGroup)
  496. return true;
  497. if(playerGroup == NULL)
  498. return true;
  499. if(playerGroup->GetMembersCount() > 10 || playerGroup->GetMembersCount() < 5)
  500. return true;
  501.  
  502. uint32 playersDead = 0;
  503. Player* GroupMember;
  504. const Group::MemberSlotList members = playerGroup->GetMemberSlots();
  505. for (Group::member_citerator itr = members.begin(); itr!= members.end(); ++itr)
  506. {
  507. GroupMember = (Unit::GetPlayer(*me, itr->guid));
  508. if (!GroupMember || !GroupMember->GetSession()) { playersDead++; continue; }
  509. //if (!GroupMember->IsWithinDistInMap(me, 100)){ playersDead++; continue; }
  510. if (GroupMember->isDead()){ playersDead++; continue; }
  511.  
  512. }
  513.  
  514. if(playersDead >= playerGroup->GetMembersCount())
  515. return true;
  516.  
  517. if(zombieRound == 15)
  518. return true;   
  519. return false;
  520. }
  521.  
  522. bool sendMessageToGroup(const char *message)
  523. {
  524. if(!zombieLeader->GetGroup())
  525. return true;
  526. if(zombieLeader->GetGroup() == NULL)
  527. return true;
  528. if(!playerGroup)
  529. return true;
  530.  
  531. Player* GroupMember;
  532. const Group::MemberSlotList members = playerGroup->GetMemberSlots();
  533. for (Group::member_citerator itr = members.begin(); itr!= members.end(); ++itr)
  534. {
  535. GroupMember = (Unit::GetPlayer(*me, itr->guid));
  536. if (GroupMember && GroupMember->GetSession())
  537. {
  538. if(!GroupMember)
  539. continue;
  540. GroupMember->GetSession()->SendAreaTriggerMessage(message);
  541. }
  542. }
  543. return true;
  544. }
  545.  
  546. void reviveAndTeleportOut()
  547. {
  548. if(!zombieLeader || zombieLeader == NULL)
  549. {
  550. teleportPlayersOut();
  551. return;
  552. }
  553.  
  554. if(!zombieLeader->GetGroup())
  555. {
  556. teleportPlayersOut();
  557. return;
  558. }
  559. if(zombieLeader->GetGroup() == NULL)
  560. {
  561. teleportPlayersOut();
  562. return;
  563. }
  564. if(!playerGroup)
  565. {
  566. teleportPlayersOut();
  567. return;
  568. }
  569.  
  570. if(playerGroup){
  571. Player* GroupMember;
  572. const Group::MemberSlotList members = playerGroup->GetMemberSlots();
  573. for (Group::member_citerator itr = members.begin(); itr!= members.end(); ++itr)
  574. {
  575. GroupMember = (Unit::GetPlayer(*me, itr->guid));
  576. if (GroupMember && GroupMember->GetSession())
  577. {
  578. //if (!GroupMember->IsWithinDistInMap(me, 100))
  579. //{
  580. if(GroupMember->isDead())
  581. GroupMember->ResurrectPlayer(60, false);
  582. GroupMember->TeleportTo(534, 5541.770020f, -3783.469971f, 1594.910034f, 2.883010f);
  583. //}
  584. }
  585. }
  586. }
  587. }
  588.  
  589. bool teleportPlayersOut()
  590. {
  591. TC_LOG_INFO(LOG_FILTER_GENERAL, "teleportPlrsOut");
  592. while(me->SelectNearestPlayer(280.0f) != NULL)
  593. {
  594. Player* plr = me->SelectNearestPlayer(280.0f);
  595. if(plr)
  596. {
  597. plr->ResurrectPlayer(60, false);
  598. plr->TeleportTo(534, 5541.770020f, -3783.469971f, 1594.910034f, 2.883010f);
  599. }
  600. }
  601. return true;
  602. }
  603.  
  604. void spawnZombies(Creature* creature, uint32 count)
  605. {
  606. zombiesSpawned = zombiesSpawned + count;
  607. for(uint32 i = 1; i <= count; i++){
  608. ACE_Based::Thread::Sleep(10);
  609. uint32 NPC_ID = rand() % 6 + 1;
  610. switch((rand() % 6 + 1))
  611. {
  612. case 1:
  613. creature->SummonCreature(ZOMBIE_NPCS[NPC_ID], Spawn_C1);   
  614. break;
  615. case 2:
  616. creature->SummonCreature(ZOMBIE_NPCS[NPC_ID], Spawn_C2);   
  617. break;
  618. case 3:
  619. creature->SummonCreature(ZOMBIE_NPCS[NPC_ID], Spawn_C3);   
  620. break;
  621. case 4:
  622. creature->SummonCreature(ZOMBIE_NPCS[NPC_ID], Spawn_C4);   
  623. break;
  624. case 5:
  625. creature->SummonCreature(ZOMBIE_NPCS[NPC_ID], Spawn_C5);   
  626. break;
  627. case 6:
  628. creature->SummonCreature(ZOMBIE_NPCS[NPC_ID], Spawn_C6);   
  629. break;
  630. default: TC_LOG_INFO(LOG_FILTER_GENERAL, "spawn default");break;
  631. }
  632. }
  633. }
  634.  
  635. int getZombieSpawnCountPerWave()
  636. {
  637. return ((zombieGroupMembers * ZOMBIES_PER_PERSON) - 1 ) / zombieWaves + 1;
  638. }
  639.  
  640. int getNumberOfWaves()
  641. {
  642. if(zombieRound <= 3)
  643. return 3;
  644. if(zombieRound > 4 && zombieRound <= 8)
  645. return 4;
  646. if(zombieRound > 8 && zombieRound <= 12)
  647. return 5;
  648. if(zombieRound > 12 && zombieRound <= 18)
  649. return 6;
  650. if(zombieRound >18 && zombieRound < 50)
  651. return 7;
  652. return 3;
  653. }
  654.  
  655. int getZombieSpawnCount(Creature* creature)
  656. {
  657. return ((zombieGroupMembers * ZOMBIES_PER_PERSON) - 1 ) / 3 + 1;
  658.  
  659. }
  660.  
  661. bool spawnGoDrop(Creature* creature)
  662. {
  663. switch(zombieRound)
  664. {
  665. case 1: creature->SummonCreature(510000, -10970.494141f, -2001.188354f, 79.973495f, 1.433620f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90*1000); break;
  666. case 2: creature->SummonCreature(510000, -10970.494141f, -2001.188354f, 79.973495f, 1.433620f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90*1000); break;
  667. case 3: creature->SummonCreature(520000, -10970.494141f, -2001.188354f, 79.973495f, 1.433620f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90*1000); break;
  668. case 4: creature->SummonCreature(520000, -10970.494141f, -2001.188354f, 79.973495f, 1.433620f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90*1000); break;
  669. case 5: creature->SummonCreature(530000, -10970.494141f, -2001.188354f, 79.973495f, 1.433620f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90*1000); break;
  670. case 6: creature->SummonCreature(530000, -10970.494141f, -2001.188354f, 79.973495f, 1.433620f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90*1000); break;
  671. case 7: creature->SummonCreature(540000, -10970.494141f, -2001.188354f, 79.973495f, 1.433620f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90*1000); break;
  672. case 8: creature->SummonCreature(540000, -10970.494141f, -2001.188354f, 79.973495f, 1.433620f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90*1000); break;
  673. case 9: creature->SummonCreature(550000, -10970.494141f, -2001.188354f, 79.973495f, 1.433620f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90*1000); break;
  674. case 10: creature->SummonCreature(550000, -10970.494141f, -2001.188354f, 79.973495f, 1.433620f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90*1000); break;
  675. case 11: creature->SummonCreature(560000, -10970.494141f, -2001.188354f, 79.973495f, 1.433620f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90*1000); break;
  676. case 12: creature->SummonCreature(560000, -10970.494141f, -2001.188354f, 79.973495f, 1.433620f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90*1000); break;
  677. case 13: creature->SummonCreature(560000, -10970.494141f, -2001.188354f, 79.973495f, 1.433620f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90*1000); break;
  678. case 14: creature->SummonCreature(560000, -10970.494141f, -2001.188354f, 79.973495f, 1.433620f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90*1000); break;
  679. case 15: creature->SummonCreature(560000, -10970.494141f, -2001.188354f, 79.973495f, 1.433620f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90*1000); break;
  680. }
  681.  
  682. //creature->SummonCreature(NPC_WAIT_FOR_CHEST_LOOT, -10989.9003f, -1940.1300f, 93.9107f, 4.8345f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 100*1000);
  683. return true;
  684. }
  685.  
  686. bool isRoundOver()
  687. {
  688. if((zombiesSpawned - zombieDeathCount) <= 0) {
  689. zombiesSpawned = 0;
  690. zombieDeathCount = 0;
  691. return true;
  692. }
  693.  
  694. return false;
  695. }
  696.  
  697. bool resetZombieEvent()
  698. {
  699. zombieCount = 0;
  700. zombiesSpawned = 0;
  701. zombieDeathCount = 0;
  702. zombieRound = 1;
  703. zombieWaves = 3;
  704. zombieWavesCount = 1;
  705. zombieSpawnPerWave = 0;
  706. zombieGroupMembers = 0;
  707. ZOMBIES_PER_PERSON = 3;
  708.  
  709. playerGroup = NULL;
  710. zombieLeader = NULL;
  711.  
  712. inZombieGame = false;
  713. me->UpdatePosition(-10989.9003f, -1940.1300f, 93.9107f, 4.8345f, true);
  714. return true;
  715. }
  716.  
  717. void reviveGroup()
  718. {
  719. GroupReference* grpRef = playerGroup->GetFirstMember();
  720. for (grpRef; grpRef != NULL; grpRef = grpRef->next())
  721. {
  722. Player* groupMember = grpRef->GetSource();
  723. if(!groupMember)
  724. continue;
  725.  
  726. if(!groupMember->IsInFlight() && !groupMember->IsFlying())
  727. {
  728. if(!groupMember->IsAlive() && groupMember->IsInWorld())
  729. {
  730. if(!groupMember->InBattleground() && !groupMember->InArena())
  731. {
  732. groupMember->ResurrectPlayer(60, false);
  733. }
  734. }
  735. groupMember->TeleportTo(532, -10966.888f, -2011.3127f, 79.98f, 1.37f); 
  736. }
  737. }
  738. }
  739.  
  740.  
  741. };
  742.  
  743. CreatureAI* GetAI(Creature* creature) const
  744.     {
  745.         return new zombie_bg_master_finalAI(creature);
  746.     }
  747. };
  748.  
  749. /*
  750. ---------------
  751. Zombie Creatures AI
  752. ---------------
  753. */
  754.  
  755. class mobs_normal_zombie : public CreatureScript
  756. {
  757. public:
  758.     mobs_normal_zombie() : CreatureScript("mobs_normal_zombie") { }
  759.  
  760.     struct mobs_normal_zombieAI : public ScriptedAI
  761.     {
  762. mobs_normal_zombieAI(Creature* c) : ScriptedAI(c) {}
  763.  
  764. void JustDied(Unit* killer)
  765. {
  766. //zombieDeathCount++;
  767. if(me)
  768. me->DespawnOrUnsummon();
  769. }  
  770. };
  771.  
  772. CreatureAI* GetAI(Creature* creature) const
  773.     {
  774.         return new mobs_normal_zombieAI (creature);
  775.     }
  776. };
  777.  
  778. class go_zombie_treasure : public GameObjectScript
  779. {
  780. public:
  781.     go_zombie_treasure() : GameObjectScript("go_zombie_treasure") { }
  782.  
  783.     bool OnGossipHello(Player* player, GameObject* go)
  784.     {
  785. TC_LOG_INFO(LOG_FILTER_GENERAL, "OnGossipHello");
  786. //player->SendLoot(go->GetGUID(), LOOT_CORPSE);
  787. return true;
  788.     }
  789. };
  790.  
  791. void AddSC_zombie_event()
  792. {
  793.    new zombie_bg_master();
  794.    new zombie_bg_master_endgame();
  795.    new zombie_bg_master_final();
  796.    new mobs_normal_zombie();
  797.    new go_zombie_treasure();
  798. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement