Advertisement
Guest User

Untitled

a guest
May 19th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 23.20 KB | None | 0 0
  1. #include "ScriptedPch.h"
  2. #include "violet_hold.h"
  3.  
  4. #define MAX_ENCOUNTER          3
  5.  
  6. /* Violet Hold encounters:
  7. 0 - First boss
  8. 1 - Second boss
  9. 2 - Cyanigosa*/
  10.  
  11. /* Violet hold bosses:
  12. 1 - Moragg
  13. 2 - Erekem
  14. 3 - Ichoron
  15. 4 - Lavanthor
  16. 5 - Xevozz
  17. 6 - Zuramat
  18. 7 - Cyanigosa */
  19.  
  20. enum GameObjects
  21. {
  22.     GO_MAIN_DOOR                                    = 191723,
  23.     GO_XEVOZZ_DOOR                                  = 191556,
  24.     GO_LAVANTHOR_DOOR                               = 191566,
  25.     GO_ICHORON_DOOR                                 = 191722,
  26.     GO_ZURAMAT_DOOR                                 = 191565,
  27.     GO_EREKEM_DOOR                                  = 191564,
  28.     GO_EREKEM_GUARD_1_DOOR                          = 191563,
  29.     GO_EREKEM_GUARD_2_DOOR                          = 191562,
  30.     GO_MORAGG_DOOR                                  = 191606,
  31.     GO_INTRO_ACTIVATION_CRYSTAL                     = 193615,
  32.     GO_ACTIVATION_CRYSTAL                           = 193611
  33. };
  34.  
  35. enum Yells
  36. {
  37.      CYANIGOSA_SAY_SPAWN        = -1608005
  38. };
  39.  
  40. enum Spells
  41. {
  42.     CYANIGOSA_SPELL_TRANSFORM                       = 58668,
  43.     CYANIGOSA_BLUE_AURA                             = 47759, // visual workaround
  44.     SABOTEUR_SHIELD_DISRUPTION                      = 58291,
  45.     SABOTEUR_SHIELD_EFFECT                          = 45775
  46. };
  47.  
  48. const Position PortalLocation[] =
  49. {
  50.     {1936.07, 803.198, 53.3749, 3.12414},
  51.     {1877.51, 850.104, 44.6599, 4.7822 },
  52.     {1890.64, 753.471, 48.7224, 1.71042}
  53. };
  54.  
  55. const Position MiddleRoomLocation = {1892.291260,805.696838,38.438862};
  56.  
  57. const float SaboteurFinalPos[12][5] =
  58. {
  59.     //x, y, z, expected time to go there, next step (index of this array)  
  60.     {1892.117065,751.497437,47.666885, 6000,6},
  61.     {1877.473877, 856.597351, 43.3336, 6000,7},
  62.     {1914.059082,779.421082,36.159550, 6000,8},
  63.     {1860.548706,771.716797,38.653461, 6000,9},
  64.     {1905.577393,840.393005,38.667526, 6000,10},
  65.     {1925.489624,852.441406,47.187416, 6000,11},
  66.     // 2 wp
  67.     {1925.489624,852.441406,47.187416, 6000,0},
  68.     {1905.577393,840.393005,38.667526, 6000,0},
  69.     {1860.548706,771.716797,38.653461, 6000,0},
  70.     {1925.489624,852.441406,47.187416, 6000,0},
  71.     {1925.489624,852.441406,47.187416, 6000,0},
  72.     {1860.548706,771.716797,38.653461, 6000,0}
  73. };
  74.  
  75. struct instance_violet_hold : public ScriptedInstance
  76. {
  77.     instance_violet_hold(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
  78.  
  79.     uint64 uiMoragg;
  80.     uint64 uiErekem;
  81.     uint64 uiErekemGuard[2];
  82.     uint64 uiIchoron;
  83.     uint64 uiLavanthor;
  84.     uint64 uiXevozz;
  85.     uint64 uiZuramat;
  86.     uint64 uiCyanigosa;
  87.     uint64 uiSinclari;
  88.     uint64 uiSaboteour;
  89.  
  90.     uint64 uiMoraggCell;
  91.     uint64 uiErekemCell;
  92.     uint64 uiErekemLeftGuardCell;
  93.     uint64 uiErekemRightGuardCell;
  94.     uint64 uiIchoronCell;
  95.     uint64 uiLavanthorCell;
  96.     uint64 uiXevozzCell;
  97.     uint64 uiZuramatCell;
  98.     uint64 uiMainDoor;
  99.  
  100.     uint64 uiActivationCrystal[3];
  101.  
  102.     uint32 uiActivationTimer;
  103.  
  104.     uint8 uiWaveCount;
  105.     uint8 uiLocation;
  106.     uint8 uiFirstBoss;
  107.     uint8 uiSecondBoss;
  108.     uint8 uiRemoveNpc;
  109.     uint8 uiPhase;
  110.     uint32 uiTimer;
  111.     uint8 uiLastMove;
  112.     uint8 m_auiEncounter[MAX_ENCOUNTER];
  113.     uint8 uiCountErekemGuards;
  114.     uint8 uiCountActivationCrystals;
  115.  
  116.     bool bActive;
  117.     bool bWiped;
  118.  
  119.     std::string str_data;
  120.  
  121.     void Initialize()
  122.     {
  123.         uiMoragg = 0;
  124.         uiErekem = 0;
  125.         uiIchoron = 0;
  126.         uiLavanthor = 0;
  127.         uiXevozz = 0;
  128.         uiZuramat = 0;
  129.         uiCyanigosa = 0;
  130.         uiSinclari = 0;
  131.         uiSaboteour = 0;
  132.  
  133.         uiMoraggCell = 0;
  134.         uiErekemCell = 0;
  135.         uiErekemGuard[0] = 0;
  136.         uiErekemGuard[1] = 0;
  137.         uiIchoronCell = 0;
  138.         uiLavanthorCell = 0;
  139.         uiXevozzCell = 0;
  140.         uiZuramatCell = 0;
  141.         uiMainDoor = 0;
  142.         uiRemoveNpc = 0;
  143.  
  144.         uiWaveCount = 0;
  145.         uiLocation = urand(0,2);
  146.         uiFirstBoss = 0;
  147.         uiSecondBoss = 0;
  148.         uiPhase = 0;
  149.         uiTimer = 3000;
  150.         uiCountErekemGuards = 0;
  151.         uiCountActivationCrystals = 0;
  152.         uiLastMove = -1;
  153.  
  154.         uiActivationTimer = 5000;
  155.  
  156.         bActive = false;
  157.         bWiped  = false;
  158.  
  159.         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
  160.     }
  161.  
  162.     bool IsEncounterInProgress() const
  163.     {
  164.         for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
  165.             if (m_auiEncounter[i] == IN_PROGRESS) return true;
  166.  
  167.         return false;
  168.     }
  169.  
  170.     void OnCreatureCreate(Creature* pCreature, bool add)
  171.     {
  172.         switch(pCreature->GetEntry())
  173.         {
  174.             case CREATURE_XEVOZZ:
  175.                 uiXevozz = pCreature->GetGUID();
  176.                 break;
  177.             case CREATURE_LAVANTHOR:
  178.                 uiLavanthor = pCreature->GetGUID();
  179.                 break;
  180.             case CREATURE_ICHORON:
  181.                 uiIchoron = pCreature->GetGUID();
  182.                 break;
  183.             case CREATURE_ZURAMAT:
  184.                 uiZuramat = pCreature->GetGUID();
  185.                 break;
  186.             case CREATURE_EREKEM:
  187.                 uiErekem = pCreature->GetGUID();
  188.                 break;
  189.             case CREATURE_EREKEM_GUARD:
  190.                 if (uiCountErekemGuards < 2)
  191.                 {
  192.                     uiErekemGuard[uiCountErekemGuards++] = pCreature->GetGUID();
  193.                     pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
  194.                 }
  195.                 break;
  196.             case CREATURE_MORAGG:
  197.                 uiMoragg = pCreature->GetGUID();
  198.                 break;
  199.             case CREATURE_CYANIGOSA:
  200.                 uiCyanigosa = pCreature->GetGUID();
  201.                 break;
  202.             case CREATURE_SINCLARI:
  203.                 uiSinclari = pCreature->GetGUID();
  204.                 break;
  205.             case CREATURE_SABOTEOUR:
  206.                 uiSaboteour = pCreature->GetGUID();
  207.                 pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
  208.                 pCreature->SetReactState(REACT_PASSIVE);
  209.                 break;
  210.         }
  211.  
  212.         if (add && (pCreature->GetGUID() == uiFirstBoss || pCreature->GetGUID() == uiSecondBoss))
  213.         {
  214.             pCreature->AllLootRemovedFromCorpse();
  215.             pCreature->RemoveLootMode(1);
  216.         }
  217.     }
  218.  
  219.     void OnGameObjectCreate(GameObject* pGo, bool add)
  220.     {
  221.         switch(pGo->GetEntry())
  222.         {
  223.             case GO_EREKEM_GUARD_1_DOOR:
  224.                 uiErekemLeftGuardCell = pGo->GetGUID();
  225.                 break;
  226.             case GO_EREKEM_GUARD_2_DOOR:
  227.                 uiErekemRightGuardCell = pGo->GetGUID();
  228.                 break;
  229.             case GO_EREKEM_DOOR:
  230.                 uiErekemCell = pGo->GetGUID();
  231.                 break;
  232.             case GO_ZURAMAT_DOOR:
  233.                 uiZuramatCell = pGo->GetGUID();
  234.                 break;
  235.             case GO_LAVANTHOR_DOOR:
  236.                 uiLavanthorCell = pGo->GetGUID();
  237.                 break;
  238.             case GO_MORAGG_DOOR:
  239.                 uiMoraggCell = pGo->GetGUID();
  240.                 break;
  241.             case GO_ICHORON_DOOR:
  242.                 uiIchoronCell = pGo->GetGUID();
  243.                 break;
  244.             case GO_XEVOZZ_DOOR:
  245.                 uiXevozzCell = pGo->GetGUID();
  246.                 break;
  247.             case GO_MAIN_DOOR:
  248.                 uiMainDoor = pGo->GetGUID();
  249.                 break;
  250.             case GO_ACTIVATION_CRYSTAL:
  251.                 if (uiCountActivationCrystals < 3)
  252.                     uiActivationCrystal[uiCountActivationCrystals++] = pGo->GetGUID();
  253.                 break;
  254.         }
  255.     }
  256.  
  257.     void SetData(uint32 type, uint32 data)
  258.     {
  259.         switch(type)
  260.         {
  261.             case DATA_1ST_BOSS_EVENT:
  262.                 m_auiEncounter[0] = data;
  263.                 if (data == DONE)
  264.                     SaveToDB();
  265.                 break;
  266.             case DATA_2ND_BOSS_EVENT:
  267.                 m_auiEncounter[1] = data;
  268.                 if (data == DONE)
  269.                     SaveToDB();
  270.                 break;
  271.             case DATA_CYANIGOSA_EVENT:
  272.                 m_auiEncounter[2] = data;
  273.                 if (data == DONE)
  274.                 {
  275.                     SaveToDB();
  276.                     if (GameObject* pMainDoor = instance->GetGameObject(uiMainDoor))
  277.                         pMainDoor->SetGoState(GO_STATE_ACTIVE);
  278.                 }
  279.                 break;
  280.             case DATA_WAVE_COUNT:
  281.                 uiWaveCount = data;
  282.                 bActive = true;
  283.                 break;
  284.             case DATA_REMOVE_NPC:
  285.                 uiRemoveNpc = data;
  286.                 break;
  287.         }
  288.     }
  289.  
  290.     uint32 GetData(uint32 type)
  291.     {
  292.         switch(type)
  293.         {
  294.             case DATA_1ST_BOSS_EVENT:           return m_auiEncounter[0];
  295.             case DATA_2ND_BOSS_EVENT:           return m_auiEncounter[1];
  296.             case DATA_CYANIGOSA_EVENT:          return m_auiEncounter[2];
  297.             case DATA_WAVE_COUNT:               return uiWaveCount;
  298.             case DATA_REMOVE_NPC:               return uiRemoveNpc;
  299.         }
  300.  
  301.         return 0;
  302.     }
  303.  
  304.     void SpawnPortal()
  305.     {
  306.         if (Creature *pSinclari = instance->GetCreature(uiSinclari))
  307.             if (Creature *pPortal = pSinclari->SummonCreature(CREATURE_TELEPORTATION_PORTAL,PortalLocation[uiLocation],TEMPSUMMON_CORPSE_DESPAWN))
  308.                 uiLocation = (uiLocation+urand(1,2))%3;
  309.     }
  310.  
  311.     void StartBossEncounter(uint8 uiBoss, bool bForceRespawn = true)
  312.     {
  313.         Creature* pBoss = NULL;
  314.  
  315.         switch(uiBoss)
  316.         {
  317.             case BOSS_MORAGG:
  318.                 HandleGameObject(uiMoraggCell,bForceRespawn);
  319.                 if (pBoss = instance->GetCreature(uiMoragg))
  320.                     pBoss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
  321.                 break;
  322.             case BOSS_EREKEM:
  323.                 HandleGameObject(uiErekemCell, bForceRespawn);
  324.                 HandleGameObject(uiErekemRightGuardCell, bForceRespawn);
  325.                 HandleGameObject(uiErekemLeftGuardCell, bForceRespawn);
  326.  
  327.                 if (pBoss = instance->GetCreature(uiErekem))
  328.                     pBoss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
  329.  
  330.                 if (Creature* pGuard1 = instance->GetCreature(uiErekemGuard[0]))
  331.                 {
  332.                     if (bForceRespawn)
  333.                         pGuard1->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
  334.                     else
  335.                         pGuard1->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
  336.                 }
  337.  
  338.                 if (Creature* pGuard2 = instance->GetCreature(uiErekemGuard[1]))
  339.                 {
  340.                     if (bForceRespawn)
  341.                         pGuard2->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
  342.                     else
  343.                         pGuard2->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
  344.                 }
  345.                 break;
  346.             case BOSS_ICHORON:
  347.                 HandleGameObject(uiIchoronCell,bForceRespawn);
  348.                 if (pBoss = instance->GetCreature(uiIchoron))
  349.                     pBoss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
  350.                 break;
  351.             case BOSS_LAVANTHOR:
  352.                 HandleGameObject(uiLavanthorCell,bForceRespawn);
  353.                 if (pBoss = instance->GetCreature(uiLavanthor))
  354.                     pBoss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
  355.                 break;
  356.             case BOSS_XEVOZZ:
  357.                 HandleGameObject(uiXevozzCell,bForceRespawn);
  358.                 if (pBoss = instance->GetCreature(uiXevozz))
  359.                     pBoss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
  360.                 break;
  361.             case BOSS_ZURAMAT:
  362.                 HandleGameObject(uiZuramatCell,bForceRespawn);
  363.                 if (pBoss = instance->GetCreature(uiZuramat))
  364.                     pBoss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
  365.                 break;
  366.         }
  367.  
  368.         if (bForceRespawn)
  369.             pBoss->GetMotionMaster()->MovePoint(0, SaboteurFinalPos[uiBoss-1][0], SaboteurFinalPos[uiBoss-1][1], SaboteurFinalPos[uiBoss-1][2]);
  370.    
  371.         if (!bForceRespawn && pBoss)
  372.         {
  373.             if (pBoss->isDead())
  374.             {
  375.                 // respawn but avoid to be looted again
  376.                 pBoss->Respawn();
  377.                 pBoss->RemoveLootMode(1);
  378.             }
  379.             pBoss->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
  380.             SetData(DATA_WAVE_COUNT,0);
  381.             uiWaveCount = 0;
  382.         }
  383.     }
  384.  
  385.     void AddWave()
  386.     {
  387.         DoUpdateWorldState(WORLD_STATE_VH, 1);
  388.         DoUpdateWorldState(WORLD_STATE_VH_WAVE_COUNT, uiWaveCount);
  389.         DoUpdateWorldState(WORLD_STATE_VH_PRISON_STATE, 100); // TODO
  390.  
  391.         switch(uiWaveCount)
  392.         {
  393.             case 6:
  394.                 if (uiFirstBoss == 0)
  395.                     uiFirstBoss = urand(1,6);
  396.         if (Creature *pSinclari = instance->GetCreature(uiSinclari))
  397.             pSinclari->SummonCreature(CREATURE_SABOTEOUR, MiddleRoomLocation, TEMPSUMMON_DEAD_DESPAWN);
  398.         uiPhase = 1;
  399.                 break;
  400.             case 12:
  401.                 if (uiSecondBoss == 0)
  402.                     do
  403.                     {
  404.                         uiSecondBoss = urand(1,6);
  405.                     } while (uiSecondBoss == uiFirstBoss);
  406.                 if (Creature *pSinclari = instance->GetCreature(uiSinclari))
  407.                     pSinclari->SummonCreature(CREATURE_SABOTEOUR, MiddleRoomLocation, TEMPSUMMON_DEAD_DESPAWN);
  408.                 uiPhase = 1;
  409.                 break;
  410.             case 18:
  411.             {
  412.                 if (Creature *pSinclari = instance->GetCreature(uiSinclari))
  413.                     pSinclari->SummonCreature(CREATURE_CYANIGOSA, PortalLocation[0], TEMPSUMMON_DEAD_DESPAWN);
  414.                 uiPhase = 1;
  415.                 break;
  416.             }
  417.             case 1:
  418.             {
  419.                 if (GameObject* pMainDoor = instance->GetGameObject(uiMainDoor))
  420.                     pMainDoor->SetGoState(GO_STATE_READY);
  421.             }
  422.             default:
  423.                 if (!bWiped)
  424.                     SpawnPortal();
  425.                 bWiped = false;
  426.                 break;
  427.         }
  428.     }
  429.  
  430.     uint64 GetData64(uint32 identifier)
  431.     {
  432.         switch(identifier)
  433.         {
  434.             case DATA_MORAGG:                   return uiMoragg;
  435.             case DATA_EREKEM:                   return uiErekem;
  436.             case DATA_EREKEM_GUARD_1:           return uiErekemGuard[0];
  437.             case DATA_EREKEM_GUARD_2:           return uiErekemGuard[1];
  438.             case DATA_ICHORON:                  return uiIchoron;
  439.             case DATA_LAVANTHOR:                return uiLavanthor;
  440.             case DATA_XEVOZZ:                   return uiXevozz;
  441.             case DATA_ZURAMAT:                  return uiZuramat;
  442.             case DATA_CYANIGOSA:                return uiCyanigosa;
  443.             case DATA_MORAGG_CELL:              return uiMoraggCell;
  444.             case DATA_EREKEM_CELL:              return uiErekemCell;
  445.             case DATA_EREKEM_RIGHT_GUARD_CELL:  return uiErekemRightGuardCell;
  446.             case DATA_EREKEM_LEFT_GUARD_CELL:   return uiErekemLeftGuardCell;
  447.             case DATA_ICHORON_CELL:             return uiIchoronCell;
  448.             case DATA_LAVANTHOR_CELL:           return uiLavanthorCell;
  449.             case DATA_XEVOZZ_CELL:              return uiXevozzCell;
  450.             case DATA_ZURAMAT_CELL:             return uiZuramatCell;
  451.             case DATA_MAIN_DOOR:                return uiMainDoor;
  452.             case DATA_SINCLARI:                 return uiSinclari;
  453.         }
  454.  
  455.         return 0;
  456.     }
  457.  
  458.     std::string GetSaveData()
  459.     {
  460.         OUT_SAVE_INST_DATA;
  461.  
  462.         std::ostringstream saveStream;
  463.         saveStream << "V H " << (uint16)m_auiEncounter[0]
  464.             << " " << (uint16)m_auiEncounter[1]
  465.             << " " << (uint16)m_auiEncounter[2]
  466.             << " " << (uint16)uiFirstBoss
  467.             << " " << (uint16)uiSecondBoss;
  468.  
  469.         str_data = saveStream.str();
  470.  
  471.         OUT_SAVE_INST_DATA_COMPLETE;
  472.         return str_data;
  473.     }
  474.  
  475.     void Load(const char* in)
  476.     {
  477.         if (!in)
  478.         {
  479.             OUT_LOAD_INST_DATA_FAIL;
  480.             return;
  481.         }
  482.  
  483.         OUT_LOAD_INST_DATA(in);
  484.  
  485.         char dataHead1, dataHead2;
  486.         uint16 data0, data1, data2, data3, data4;
  487.  
  488.         std::istringstream loadStream(in);
  489.         loadStream >> dataHead1 >> dataHead2 >> data0 >> data1 >> data2 >> data3 >> data4;
  490.  
  491.         if (dataHead1 == 'V' && dataHead2 == 'H')
  492.         {
  493.             m_auiEncounter[0] = data0;
  494.             m_auiEncounter[1] = data1;
  495.             m_auiEncounter[2] = data2;
  496.  
  497.             for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
  498.                 if (m_auiEncounter[i] == IN_PROGRESS)
  499.                     m_auiEncounter[i] = NOT_STARTED;
  500.  
  501.             uiFirstBoss = data3;
  502.             uiSecondBoss = data4;
  503.         } else OUT_LOAD_INST_DATA_FAIL;
  504.  
  505.         OUT_LOAD_INST_DATA_COMPLETE;
  506.     }
  507.  
  508.     bool CheckWipe()
  509.     {
  510.         Map::PlayerList const &players = instance->GetPlayers();
  511.         for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
  512.         {
  513.             Player* pPlayer = itr->getSource();
  514.             if (pPlayer->isGameMaster())
  515.                 continue;
  516.  
  517.             if (pPlayer->isAlive())
  518.                 return false;
  519.         }
  520.  
  521.         return true;
  522.     }
  523.  
  524.     void Update(uint32 diff)
  525.     {
  526.         if (!instance->HavePlayers())
  527.             return;
  528.  
  529.         if (bActive)
  530.         {
  531.             if (uiActivationTimer < diff)
  532.             {
  533.                 AddWave();
  534.                 bActive = false;
  535.                 uiActivationTimer = 5000;
  536.             } else uiActivationTimer -= diff;
  537.         }
  538.  
  539.         if (uiTimer <= diff)
  540.         {
  541.             switch(uiWaveCount)
  542.             {
  543.                 case 18:
  544.                     if (Creature *pCyanigosa = instance->GetCreature(uiCyanigosa))
  545.                         if (!pCyanigosa->HasAura(CYANIGOSA_SPELL_TRANSFORM))
  546.                             switch(uiPhase)
  547.                             {
  548.                                 case 1:
  549.                                     pCyanigosa->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
  550.                                     pCyanigosa->CastSpell(pCyanigosa, CYANIGOSA_BLUE_AURA, false);
  551.                                     DoScriptText(CYANIGOSA_SAY_SPAWN, pCyanigosa);
  552.                                     uiTimer = 7000;
  553.                                     ++uiPhase;
  554.                                     break;
  555.                                 case 2:
  556.                                     pCyanigosa->GetMotionMaster()->MoveJump(MiddleRoomLocation.GetPositionX(), MiddleRoomLocation.GetPositionY(), MiddleRoomLocation.GetPositionZ(), 10.0f, 20.0f);
  557.                                     pCyanigosa->CastSpell(pCyanigosa, CYANIGOSA_BLUE_AURA, false);
  558.                                     uiTimer = 7000;                                                
  559.                                     ++uiPhase;
  560.                                     break;
  561.                                 case 3:
  562.                                     pCyanigosa->RemoveAurasDueToSpell(CYANIGOSA_BLUE_AURA);
  563.                                     pCyanigosa->CastSpell(pCyanigosa, CYANIGOSA_SPELL_TRANSFORM, 0);
  564.                                     pCyanigosa->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
  565.                                     uiTimer = 2000;
  566.                                     ++uiPhase;
  567.                                     break;
  568.                                 case 4:                                    
  569.                                     uiPhase = 0;
  570.                                     break;
  571.                             }
  572.                     break;
  573.                 case 6:
  574.                 case 12:
  575.                     if (Creature *pSaboteour = instance->GetCreature(uiSaboteour))
  576.                     {
  577.                         uint8 uiBoss = 0;
  578.                         if (uiFirstBoss && uiWaveCount == 6)
  579.                             uiBoss = uiFirstBoss -1;
  580.                         else if (uiSecondBoss && uiWaveCount == 12)
  581.                             uiBoss = uiSecondBoss -1 ;                     
  582.                         if (uiBoss)
  583.                                 switch(uiPhase)
  584.                                 {                            
  585.                                     case 1:                
  586.                                         if (uiLastMove == -1)
  587.                                             uiLastMove = uiBoss;
  588.                                         pSaboteour->GetMotionMaster()->MovePoint(0, SaboteurFinalPos[uiLastMove][0], SaboteurFinalPos[uiLastMove][1], SaboteurFinalPos[uiLastMove][2]);
  589.                                         pSaboteour->CastSpell(pSaboteour, SABOTEUR_SHIELD_EFFECT, false);
  590.                                         uiTimer = SaboteurFinalPos[uiLastMove][3];
  591.                                         if (SaboteurFinalPos[uiLastMove][4] == 0){
  592.                                             ++uiPhase;
  593.                                             uiLastMove = -1;
  594.                                         }
  595.                                         else
  596.                                             uiLastMove = SaboteurFinalPos[uiLastMove][4];
  597.                                         break;
  598.                                     case 2:
  599.                                     case 3:
  600.                                     case 4:
  601.                                         pSaboteour->CastSpell(pSaboteour, SABOTEUR_SHIELD_DISRUPTION, false);
  602.                                         uiTimer = 3000;
  603.                                         ++uiPhase;
  604.                                         break;
  605.                                     case 5:
  606.                                         StartBossEncounter(uiBoss);
  607.                                         pSaboteour->ForcedDespawn(0);
  608.                                         uiPhase = 0;
  609.                                         break;
  610.                                 }
  611.                         }
  612.                    
  613.                     break;
  614.             }
  615.         } else uiTimer -= diff;
  616.  
  617.         if (GameObject* pMainDoor = instance->GetGameObject(uiMainDoor))
  618.             if (pMainDoor->GetGoState() != GO_STATE_ACTIVE && CheckWipe())
  619.             {
  620.                 SetData(DATA_REMOVE_NPC, 1);
  621.                 StartBossEncounter(uiFirstBoss, false);
  622.                 StartBossEncounter(uiSecondBoss, false);
  623.                 bWiped = true;
  624.                 if (Creature* pSinclari = instance->GetCreature(uiSinclari))
  625.                 {
  626.                     pSinclari->DisappearAndDie();
  627.                     pSinclari->Respawn(true);
  628.                 }
  629.  
  630.                 if (GameObject* pMainDoor = instance->GetGameObject(uiMainDoor))
  631.                     pMainDoor->SetGoState(GO_STATE_ACTIVE);
  632.                 SetData(DATA_WAVE_COUNT, 0);
  633.             }
  634.     }
  635. };
  636.  
  637. InstanceData* GetInstanceData_instance_violet_hold(Map* pMap)
  638. {
  639.     return new instance_violet_hold(pMap);
  640. }
  641.  
  642. void AddSC_instance_violet_hold()
  643. {
  644.     Script *newscript;
  645.     newscript = new Script;
  646.     newscript->Name = "instance_violet_hold";
  647.     newscript->GetInstanceData = &GetInstanceData_instance_violet_hold;
  648.     newscript->RegisterSelf();
  649. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement