Advertisement
Guest User

Zombie Event

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