Example #1
1
        void HandleFlightSequence()
        {
            switch (uiFlightCount)
            {
            case 0:
                //me->AttackStop();
                me->GetMotionMaster()->Clear(false);
                me->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF);
                me->StopMoving();
                Talk(YELL_TAKEOFF);
                events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 2000);
                break;
            case 1:
                me->GetMotionMaster()->MovePoint(0, me->GetPositionX()+1, me->GetPositionY(), me->GetPositionZ()+10);
                break;
            case 2:
            {
                Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true);
                if (!target)
                    target = Unit::GetUnit(*me, instance ? instance->GetData64(DATA_PLAYER_GUID) : 0);

                if (!target)
                {
                    EnterEvadeMode();
                    return;
                }

                Creature* Vapor = me->SummonCreature(MOB_VAPOR, target->GetPositionX()-5+rand()%10, target->GetPositionY()-5+rand()%10, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000);
                if (Vapor)
                {
                    Vapor->AI()->AttackStart(target);
                    me->InterruptNonMeleeSpells(false);
                    DoCast(Vapor, SPELL_VAPOR_CHANNEL, false); // core bug
                    Vapor->CastSpell(Vapor, SPELL_VAPOR_TRIGGER, true);
                }

                events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 10000);
                break;
            }
            case 3:
            {
                DespawnSummons(MOB_VAPOR_TRAIL);
                //DoCast(me, SPELL_VAPOR_SELECT); need core support

                Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true);
                if (!target)
                    target = Unit::GetUnit(*me, instance ? instance->GetData64(DATA_PLAYER_GUID) : 0);

                if (!target)
                {
                    EnterEvadeMode();
                    return;
                }

                //target->CastSpell(target, SPELL_VAPOR_SUMMON, true); need core support
                Creature* pVapor = me->SummonCreature(MOB_VAPOR, target->GetPositionX()-5+rand()%10, target->GetPositionY()-5+rand()%10, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000);
                if (pVapor)
                {
                    if (pVapor->AI())
                        pVapor->AI()->AttackStart(target);
                    me->InterruptNonMeleeSpells(false);
                    DoCast(pVapor, SPELL_VAPOR_CHANNEL, false); // core bug
                    pVapor->CastSpell(pVapor, SPELL_VAPOR_TRIGGER, true);
                }

                events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 10000);
                break;
            }
            case 4:
                DespawnSummons(MOB_VAPOR_TRAIL);
                events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 1);
                break;
            case 5:
            {
                Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true);
                if (!target)
                    target = Unit::GetUnit(*me, instance ? instance->GetData64(DATA_PLAYER_GUID) : 0);

                if (!target)
                {
                    EnterEvadeMode();
                    return;
                }

                breathX = target->GetPositionX();
                breathY = target->GetPositionY();
                float x, y, z;
                target->GetContactPoint(me, x, y, z, 70);
                me->GetMotionMaster()->MovePoint(0, x, y, z+10);
                break;
            }
            case 6:
                me->SetOrientation(me->GetAngle(breathX, breathY));
                me->StopMoving();
                //DoTextEmote("takes a deep breath.", NULL);
                events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 10000);
                break;
            case 7:
            {
                DoCast(me, SPELL_FOG_BREATH, true);
                float x, y, z;
                me->GetPosition(x, y, z);
                x = 2 * breathX - x;
                y = 2 * breathY - y;
                me->GetMotionMaster()->MovePoint(0, x, y, z);
                events.ScheduleEvent(EVENT_SUMMON_FOG, 1);
                break;
            }
            case 8:
                me->CastStop(SPELL_FOG_BREATH);
                me->RemoveAurasDueToSpell(SPELL_FOG_BREATH);
                ++uiBreathCount;
                events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 1);
                if (uiBreathCount < 3)
                    uiFlightCount = 4;
                break;
            case 9:
                if (Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO))
                    DoStartMovement(target);
                else
                {
                    EnterEvadeMode();
                    return;
                }
                break;
            case 10:
                me->SetDisableGravity(false);
                me->HandleEmoteCommand(EMOTE_ONESHOT_LAND);
                EnterPhase(PHASE_GROUND);
                AttackStart(SelectTarget(SELECT_TARGET_TOPAGGRO));
                break;
            }
            ++uiFlightCount;
        }
Example #2
1
 void HandleFlightSequence()
 {
     switch(FlightCount)
     {
     case 0:
         //me->AttackStop();
         error_log("prevent fly phase");
         me->GetMotionMaster()->Clear(false);
         me->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF);
         me->SetUnitMovementFlags(MOVEMENTFLAG_LEVITATING);
         me->StopMoving();
         DoScriptText(YELL_TAKEOFF, me);
         Timer[EVENT_FLIGHT_SEQUENCE] = 2000;
         break;
     case 1:
         error_log("Move to Fly point");
         me->GetMotionMaster()->MovePoint(0, me->GetPositionX()+1, me->GetPositionY(), me->GetPositionZ()+10);
         Timer[EVENT_FLIGHT_SEQUENCE] = 0;
         break;
     case 2: {
         error_log("Summon Vapor case 2");
         Unit *pTarget;
         pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true);
         if (!pTarget) pTarget = Unit::GetUnit(*me, pInstance ? pInstance->GetData64(DATA_PLAYER_GUID) : 0);
         if (pTarget)
         {
             Creature* Vapor = me->SummonCreature(MOB_VAPOR, pTarget->GetPositionX()-5+rand()%10, pTarget->GetPositionY()-5+rand()%10, pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000);
             if (Vapor)
             {
                 Vapor->AI()->AttackStart(pTarget);
                 me->InterruptNonMeleeSpells(false);
                 DoCast(Vapor, SPELL_VAPOR_CHANNEL, false); // core bug
                 Vapor->CastSpell(Vapor, SPELL_VAPOR_TRIGGER, true);
             }
         }
         else
         {
             EnterEvadeMode();
             return;
         }
         Timer[EVENT_FLIGHT_SEQUENCE] = 10000;
         break;
     }
     case 3: {
         DespawnSummons(MOB_VAPOR_TRAIL);
         error_log("Summon Vapor case3");
         //DoCast(me, SPELL_VAPOR_SELECT); need core support
         Unit *pTarget;
         pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true);
         if (!pTarget) pTarget = Unit::GetUnit(*me, pInstance ? pInstance->GetData64(DATA_PLAYER_GUID) : 0);
         if (pTarget)
         {
             //pTarget->CastSpell(pTarget, SPELL_VAPOR_SUMMON, true); need core support
             Creature* Vapor = me->SummonCreature(MOB_VAPOR, pTarget->GetPositionX()-5+rand()%10, pTarget->GetPositionY()-5+rand()%10, pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000);
             if (Vapor)
             {
                 Vapor->AI()->AttackStart(pTarget);
                 me->InterruptNonMeleeSpells(false);
                 DoCast(Vapor, SPELL_VAPOR_CHANNEL, false); // core bug
                 Vapor->CastSpell(Vapor, SPELL_VAPOR_TRIGGER, true);
             }
         }
         else
         {
             EnterEvadeMode();
             return;
         }
         Timer[EVENT_FLIGHT_SEQUENCE] = 10000;
         break;
     }
     case 4:
         DespawnSummons(MOB_VAPOR_TRAIL);
         Timer[EVENT_FLIGHT_SEQUENCE] = 1;
         break;
     case 5: {
         Unit *pTarget;
         pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true);
         if (!pTarget) pTarget = Unit::GetUnit(*me, pInstance ? pInstance->GetData64(DATA_PLAYER_GUID) : 0);
         if (pTarget)
         {
             BreathX = pTarget->GetPositionX();
             BreathY = pTarget->GetPositionY();
             float x, y, z;
             pTarget->GetContactPoint(me, x, y, z, 70);
             me->GetMotionMaster()->MovePoint(0, x, y, z+10);
         } else
         {
             EnterEvadeMode();
             return;
         }
         Timer[EVENT_FLIGHT_SEQUENCE] = 0;
         break;
     }
     case 6:
         me->SetOrientation(me->GetAngle(BreathX, BreathY));
         me->StopMoving();
         //DoTextEmote("takes a deep breath.", NULL);
         Timer[EVENT_FLIGHT_SEQUENCE] = 10000;
         break;
     case 7:
         DoCast(me, SPELL_FOG_BREATH, true);
         {
             float x, y, z;
             me->GetPosition(x, y, z);
             x = 2 * BreathX - x;
             y = 2 * BreathY - y;
             me->GetMotionMaster()->MovePoint(0, x, y, z);
         }
         Timer[EVENT_SUMMON_FOG] = 1;
         Timer[EVENT_FLIGHT_SEQUENCE] = 0;
         break;
     case 8:
         me->RemoveAurasDueToSpell(SPELL_FOG_BREATH);
         ++BreathCount;
         Timer[EVENT_SUMMON_FOG] = 0;
         Timer[EVENT_FLIGHT_SEQUENCE] = 1;
         if (BreathCount < 3) FlightCount = 4;
         break;
     case 9:
         if (Unit *pTarget = SelectUnit(SELECT_TARGET_TOPAGGRO, 0))
         {
             float x, y, z;
             pTarget->GetContactPoint(me, x, y, z);
             me->GetMotionMaster()->MovePoint(0, x, y, z);
         }
         else
         {
             EnterEvadeMode();
             return;
         }
         Timer[EVENT_FLIGHT_SEQUENCE] = 0;
         break;
     case 10:
         me->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
         me->StopMoving();
         me->HandleEmoteCommand(EMOTE_ONESHOT_LAND);
         EnterPhase(PHASE_GROUND);
         me->AI()->AttackStart(SelectUnit(SELECT_TARGET_TOPAGGRO, 0));
         break;
     default:
         break;
     }
     ++FlightCount;
 }
Example #3
0
void WorldSession::HandleTalentWipeConfirmOpcode( WorldPacket & recv_data )
{
    DETAIL_LOG("MSG_TALENT_WIPE_CONFIRM");
    ObjectGuid guid;
    recv_data >> guid;

    Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TRAINER);
    if (!unit)
    {
        DEBUG_LOG( "WORLD: HandleTalentWipeConfirmOpcode - %s not found or you can't interact with him.", guid.GetString().c_str());
        return;
    }

    // remove fake death
    if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
        GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);

    if (!(_player->resetTalents()))
    {
        WorldPacket data( MSG_TALENT_WIPE_CONFIRM, 8+4);    //you have not any talent
        data << uint64(0);
        data << uint32(0);
        SendPacket( &data );
        return;
    }

    unit->CastSpell(_player, 14867, true);                  //spell: "Untalent Visual Effect"
}
Example #4
0
void WorldSession::HandleTalentWipeConfirmOpcode(WorldPacket & recv_data)
{
    sLog->outDebug(LOG_FILTER_NETWORKIO, "MSG_TALENT_WIPE_CONFIRM");
    uint64 guid;
    recv_data >> guid;

    Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_TRAINER);
    if (!unit)
    {
        sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleTalentWipeConfirmOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)));
        return;
    }

    // remove fake death
    if (GetPlayer()->HasUnitState(UNIT_STAT_DIED))
        GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);

    if (!(_player->resetTalents()))
    {
        WorldPacket data(MSG_TALENT_WIPE_CONFIRM, 8+4);    //you have not any talent
        data << uint64(0);
        data << uint32(0);
        SendPacket(&data);
        return;
    }

    _player->SendTalentsInfoData(false);
    unit->CastSpell(_player, 14867, true);                  //spell: "Untalent Visual Effect"
}
void WorldSession::HandleConfirmRespecWipe(WorldPacket& recvData)
{
    TC_LOG_DEBUG("network", "CMSG_CONFIRM_RESPEC_WIPE");

    ObjectGuid respecMasterGUID;
    RespecType respecType;

    respecType = (RespecType)recvData.read<uint8>();
    respecMasterGUID[7] = recvData.ReadBit();  // 23
    respecMasterGUID[2] = recvData.ReadBit();  // 18
    respecMasterGUID[6] = recvData.ReadBit();  // 22
    respecMasterGUID[1] = recvData.ReadBit();  // 17
    respecMasterGUID[4] = recvData.ReadBit();  // 20
    respecMasterGUID[0] = recvData.ReadBit();  // 16
    respecMasterGUID[3] = recvData.ReadBit();  // 19
    respecMasterGUID[5] = recvData.ReadBit();  // 21

    recvData.ReadByteSeq(respecMasterGUID[2]);  // 18
    recvData.ReadByteSeq(respecMasterGUID[4]);  // 20
    recvData.ReadByteSeq(respecMasterGUID[1]);  // 17
    recvData.ReadByteSeq(respecMasterGUID[3]);  // 19
    recvData.ReadByteSeq(respecMasterGUID[0]);  // 16
    recvData.ReadByteSeq(respecMasterGUID[5]);  // 21
    recvData.ReadByteSeq(respecMasterGUID[7]);  // 23
    recvData.ReadByteSeq(respecMasterGUID[6]);  // 22

    Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(respecMasterGUID, UNIT_NPC_FLAG_TRAINER);
    if (!unit)
    {
        TC_LOG_DEBUG("network", "WORLD: HandleTalentWipeConfirmOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(respecMasterGUID)));
        return;
    }

    // remove fake death
    if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
        GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);

    if (respecType == RESPEC_TYPE_TALENT)
    {
        if (!_player->ResetTalents(false, true))
        {
            WorldPacket data(SMSG_RESPEC_WIPE_CONFIRM, 8+4);    //you have not any talent
            data << uint8(0);
            data << uint8(0);
            data << uint32(0);
            SendPacket(&data);
            return;
        }
    }
    else
    {
        _player->ResetTalents(false, false, true);
    }

    _player->SendTalentsInfoData();
    unit->CastSpell(_player, 14867, true);                  //spell: "Untalent Visual Effect"
}
 void SummonBeams()
 {
     Creature* beamer = me->SummonCreature(ENTRY_BEAM_DUMMY,-258.333,-356.34,22.0499,5.90835,TEMPSUMMON_CORPSE_DESPAWN,0);
     if (beamer)
     {
         beamer->CastSpell(me,SPELL_BLUE_BEAM,true);
         beamer->SetDisplayId(11686);  //invisible
         beamer->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         beams[0]=beamer->GetGUID();
     }
     beamer = beamer = me->SummonCreature(ENTRY_BEAM_DUMMY,-219.918,-371.308,22.0042,2.73072,TEMPSUMMON_CORPSE_DESPAWN,0);
     if (beamer)
     {
         beamer->CastSpell(me,SPELL_BLUE_BEAM,true);
         beamer->SetDisplayId(11686);  //invisible
         beamer->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         beams[1]=beamer->GetGUID();
     }
 }
Example #7
0
bool GOHello_go_scourge_enclosure(Player *pPlayer, GameObject *pGO)
{
    Creature *pGymerDummy;
    if (pPlayer->GetQuestStatus(QUEST_OUR_ONLY_HOPE) == QUEST_STATUS_INCOMPLETE &&
            (pGymerDummy = pGO->FindNearestCreature(NPC_GYMER_DUMMY,20.0f)))
    {
        pGO->UseDoorOrButton();
        pPlayer->KilledMonsterCredit(pGymerDummy->GetEntry(),pGymerDummy->GetGUID());
        pGymerDummy->CastSpell(pGymerDummy, 55529, true);
        pGymerDummy->DisappearAndDie();
    }
    return true;
}
Example #8
0
        void UpdateAI(const uint32 diff)
        {
            if (!UpdateVictim())
                return;

            //always decrease BerserkTimer
            if (BerserkTimer <= diff)
            {
                //if evocate, then break evocate
                if (Evocating)
                {
                    if (me->HasAura(SPELL_EVOCATION))
                        me->RemoveAurasDueToSpell(SPELL_EVOCATION);

                    Evocating = false;
                }

                //may not be correct SAY (generic hard enrage)
                DoScriptText(SAY_ENRAGE, me);

                me->InterruptNonMeleeSpells(true);
                DoCast(me, SPELL_BERSERK);

                //don't know if he's supposed to do summon/evocate after hard enrage (probably not)
                Enraged = true;
            } else BerserkTimer -= diff;

            if (Evocating)
            {
                //not supposed to do anything while evocate
                if (me->HasAura(SPELL_EVOCATION))
                    return;
                else
                    Evocating = false;
            }

            if (!Enraged)
            {
                if (AddTimer <= diff)
                {
                    //Summon Astral Flare
                    Creature* AstralFlare = DoSpawnCreature(17096, float(rand()%37), float(rand()%37), 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    Unit* target = NULL;
                    target = SelectTarget(SELECT_TARGET_RANDOM, 0);

                    if (AstralFlare && target)
                    {
                        AstralFlare->CastSpell(AstralFlare, SPELL_ASTRAL_FLARE_PASSIVE, false);
                        AstralFlare->AI()->AttackStart(target);
                    }

                    //Reduce Mana by 10% of max health
                    if (int32 mana = me->GetMaxPower(POWER_MANA))
                    {
                        mana /= 10;
                        me->ModifyPower(POWER_MANA, -mana);

                        //if this get's us below 10%, then we evocate (the 10th should be summoned now)
                        if (me->GetPower(POWER_MANA)*100 / me->GetMaxPower(POWER_MANA) < 10)
                        {
                            DoScriptText(SAY_EVOCATE, me);
                            me->InterruptNonMeleeSpells(false);
                            DoCast(me, SPELL_EVOCATION);
                            Evocating = true;
                            //no AddTimer cooldown, this will make first flare appear instantly after evocate end, like expected
                            return;
                        }
                        else
                        {
                            if (urand(0, 1) == 0)
                            {
                                DoScriptText(RAND(SAY_SUMMON1, SAY_SUMMON2), me);
                            }
                        }
                    }

                    AddTimer = 10000;
                } else AddTimer -= diff;

                if (!HealthAbovePct(15))
                {
                    Enraged = true;
                    DoCast(me, SPELL_ENRAGE);
                    DoScriptText(SAY_ENRAGE, me);
                }
            }

            if (HatefulBoltTimer <= diff)
            {
                if (Enraged)
                    HatefulBoltTimer = 7000;
                else
                    HatefulBoltTimer = 15000;

                if (Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO, 1))
                    DoCast(target, SPELL_HATEFUL_BOLT);
            } else HatefulBoltTimer -= diff;

            DoMeleeAttackIfReady();
        }
        void DoIntro()
        {
            Creature* Madrigosa = Unit::GetCreature(*me, instance ? instance->GetData64(DATA_MADRIGOSA) : 0);
            if (!Madrigosa)
                return;

            switch (IntroPhase)
            {
            case 0:
                Madrigosa->AI()->Talk(YELL_MADR_ICE_BARRIER);
                IntroPhaseTimer = 7000;
                ++IntroPhase;
                break;
            case 1:
                me->SetInFront(Madrigosa);
                Madrigosa->SetInFront(me);
                Madrigosa->AI()->Talk(YELL_MADR_INTRO, me);
                IntroPhaseTimer = 9000;
                ++IntroPhase;
                break;
            case 2:
                Talk(YELL_INTRO, Madrigosa);
                IntroPhaseTimer = 13000;
                ++IntroPhase;
                break;
            case 3:
                DoCast(me, SPELL_INTRO_FROST_BLAST);
                Madrigosa->SetDisableGravity(true);
                me->AttackStop();
                Madrigosa->AttackStop();
                IntroFrostBoltTimer = 3000;
                IntroPhaseTimer = 28000;
                ++IntroPhase;
                break;
            case 4:
                Talk(YELL_INTRO_BREAK_ICE);
                IntroPhaseTimer = 6000;
                ++IntroPhase;
                break;
            case 5:
                Madrigosa->CastSpell(me, SPELL_INTRO_ENCAPSULATE_CHANELLING, false);
                Madrigosa->AI()->Talk(YELL_MADR_TRAP);
                DoCast(me, SPELL_INTRO_ENCAPSULATE);
                IntroPhaseTimer = 11000;
                ++IntroPhase;
                break;
            case 6:
                Talk(YELL_INTRO_CHARGE);
                IntroPhaseTimer = 5000;
                ++IntroPhase;
                break;
            case 7:
                me->Kill(Madrigosa);
                Madrigosa->AI()->Talk(YELL_MADR_DEATH);
                me->SetFullHealth();
                me->AttackStop();
                IntroPhaseTimer = 4000;
                ++IntroPhase;
                break;
            case 8:
                Talk(YELL_INTRO_KILL_MADRIGOSA);
                me->SetOrientation(0.14f);
                me->StopMoving();
                Madrigosa->setDeathState(CORPSE);
                IntroPhaseTimer = 8000;
                ++IntroPhase;
                break;
            case 9:
                Talk(YELL_INTRO_TAUNT);
                IntroPhaseTimer = 5000;
                ++IntroPhase;
                break;
            case 10:
                EndIntro();
                break;
            }
        }
void BattlegroundEY::EventTeamCapturedPoint(Player* player, uint32 Point)
{
    if (GetStatus() != STATUS_IN_PROGRESS)
        return;

    uint32 Team = player->GetTeam();

    SpawnBGObject(m_CapturingPointTypes[Point].DespawnNeutralObjectType, RESPAWN_ONE_DAY);
    SpawnBGObject(m_CapturingPointTypes[Point].DespawnNeutralObjectType + 1, RESPAWN_ONE_DAY);
    SpawnBGObject(m_CapturingPointTypes[Point].DespawnNeutralObjectType + 2, RESPAWN_ONE_DAY);

    if (Team == ALLIANCE)
    {
        m_TeamPointsCount[TEAM_ALLIANCE]++;
        SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeAlliance, RESPAWN_IMMEDIATELY);
        SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeAlliance + 1, RESPAWN_IMMEDIATELY);
        SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeAlliance + 2, RESPAWN_IMMEDIATELY);
    }
    else
    {
        m_TeamPointsCount[TEAM_HORDE]++;
        SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeHorde, RESPAWN_IMMEDIATELY);
        SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeHorde + 1, RESPAWN_IMMEDIATELY);
        SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeHorde + 2, RESPAWN_IMMEDIATELY);
    }

    //buff isn't respawned

    m_PointOwnedByTeam[Point] = Team;
    m_PointState[Point] = EY_POINT_UNDER_CONTROL;

    if (Team == ALLIANCE)
        SendMessageToAll(m_CapturingPointTypes[Point].MessageIdAlliance, CHAT_MSG_BG_SYSTEM_ALLIANCE, player);
    else
        SendMessageToAll(m_CapturingPointTypes[Point].MessageIdHorde, CHAT_MSG_BG_SYSTEM_HORDE, player);

    if (BgCreatures[Point])
        DelCreature(Point);

    WorldSafeLocsEntry const* sg = NULL;
    sg = sWorldSafeLocsStore.LookupEntry(m_CapturingPointTypes[Point].GraveYardId);
    if (!sg || !AddSpiritGuide(Point, sg->x, sg->y, sg->z, 3.124139f, Team))
        TC_LOG_ERROR("bg.battleground", "BatteGroundEY: Failed to spawn spirit guide! point: %u, team: %u, graveyard_id: %u",
                     Point, Team, m_CapturingPointTypes[Point].GraveYardId);

//    SpawnBGCreature(Point, RESPAWN_IMMEDIATELY);

    UpdatePointsIcons(Team, Point);
    UpdatePointsCount(Team);

    if (Point >= EY_POINTS_MAX)
        return;

    Creature* trigger = GetBGCreature(Point + 6, false);//0-5 spirit guides
    if (!trigger)
        trigger = AddCreature(WORLD_TRIGGER, Point+6, Team, BG_EY_TriggerPositions[Point][0], BG_EY_TriggerPositions[Point][1], BG_EY_TriggerPositions[Point][2], BG_EY_TriggerPositions[Point][3]);

    //add bonus honor aura trigger creature when node is accupied
    //cast bonus aura (+50% honor in 25yards)
    //aura should only apply to players who have accupied the node, set correct faction for trigger
    if (trigger)
    {
        trigger->setFaction(Team == ALLIANCE ? 84 : 83);
        trigger->CastSpell(trigger, SPELL_HONORABLE_DEFENDER_25Y, false);
    }
}
Example #11
0
    void UpdateAI(const uint32 diff)
    {
        if (!m_creature->SelectHostilTarget() || !m_creature->getVictim())
            return;

        if (CloseDoorTimer)
        {
            if (CloseDoorTimer <= diff)
            {
                if (pInstance)
                {
                    if (GameObject* pDoor = pInstance->instance->GetGameObject(pInstance->GetData64(DATA_GAMEOBJECT_LIBRARY_DOOR)))
                        pDoor->SetGoState(GO_STATE_READY);

                    CloseDoorTimer = 0;
                }
            } else CloseDoorTimer -= diff;
        }

        //Cooldowns for casts
        if (ArcaneCooldown)
        {
            if (ArcaneCooldown >= diff)
                ArcaneCooldown -= diff;
            else ArcaneCooldown = 0;
        }

        if (FireCooldown)
        {
            if (FireCooldown >= diff)
                FireCooldown -= diff;
            else FireCooldown = 0;
        }

        if (FrostCooldown)
        {
            if (FrostCooldown >= diff)
                FrostCooldown -= diff;
            else FrostCooldown = 0;
        }

        if (!Drinking && m_creature->GetMaxPower(POWER_MANA) && (m_creature->GetPower(POWER_MANA)*100 / m_creature->GetMaxPower(POWER_MANA)) < 20)
        {
            Drinking = true;
            m_creature->InterruptNonMeleeSpells(false);

            DoScriptText(SAY_DRINK, m_creature);

            if (!DrinkInturrupted)
            {
                m_creature->CastSpell(m_creature, SPELL_MASS_POLY, true);
                m_creature->CastSpell(m_creature, SPELL_CONJURE, false);
                m_creature->CastSpell(m_creature, SPELL_DRINK, false);
                m_creature->SetStandState(UNIT_STAND_STATE_SIT);
                DrinkInturruptTimer = 10000;
            }
        }

        //Drink Inturrupt
        if (Drinking && DrinkInturrupted)
        {
            Drinking = false;
            m_creature->RemoveAurasDueToSpell(SPELL_DRINK);
            m_creature->SetStandState(UNIT_STAND_STATE_STAND);
            m_creature->SetPower(POWER_MANA, m_creature->GetMaxPower(POWER_MANA)-32000);
            m_creature->CastSpell(m_creature, SPELL_POTION, false);
        }

        //Drink Inturrupt Timer
        if (Drinking && !DrinkInturrupted)
        {
            if (DrinkInturruptTimer >= diff)
                DrinkInturruptTimer -= diff;
            else
            {
                m_creature->SetStandState(UNIT_STAND_STATE_STAND);
                m_creature->CastSpell(m_creature, SPELL_POTION, true);
                m_creature->CastSpell(m_creature, SPELL_AOE_PYROBLAST, false);
                DrinkInturrupted = true;
                Drinking = false;
            }
        }

        //Don't execute any more code if we are drinking
        if (Drinking)
            return;

        //Normal casts
        if (NormalCastTimer < diff)
        {
            if (!m_creature->IsNonMeleeSpellCasted(false))
            {
                Unit* target = NULL;
                target = SelectUnit(SELECT_TARGET_RANDOM, 0);
                if (!target)
                    return;

                uint32 Spells[3];
                uint8 AvailableSpells = 0;

                //Check for what spells are not on cooldown
                if (!ArcaneCooldown)
                {
                    Spells[AvailableSpells] = SPELL_ARCMISSLE;
                    AvailableSpells++;
                }
                if (!FireCooldown)
                {
                    Spells[AvailableSpells] = SPELL_FIREBALL;
                    AvailableSpells++;
                }
                if (!FrostCooldown)
                {
                    Spells[AvailableSpells] = SPELL_FROSTBOLT;
                    AvailableSpells++;
                }

                //If no available spells wait 1 second and try again
                if (AvailableSpells)
                {
                    CurrentNormalSpell = Spells[rand() % AvailableSpells];
                    DoCast(target, CurrentNormalSpell);
                }
            }
            NormalCastTimer = 1000;
        } else NormalCastTimer -= diff;

        if (SecondarySpellTimer < diff)
        {
            switch (rand()%2)
            {
            case 0:
                DoCast(m_creature, SPELL_AOE_CS);
                break;
            case 1:
                if (Unit* pUnit = SelectUnit(SELECT_TARGET_RANDOM, 0))
                    DoCast(pUnit, SPELL_CHAINSOFICE);
                break;
            }
            SecondarySpellTimer = 5000 + (rand()%15000);
        } else SecondarySpellTimer -= diff;

        if (SuperCastTimer < diff)
        {
            uint8 Available[2];

            switch (LastSuperSpell)
            {
            case SUPER_AE:
                Available[0] = SUPER_FLAME;
                Available[1] = SUPER_BLIZZARD;
                break;
            case SUPER_FLAME:
                Available[0] = SUPER_AE;
                Available[1] = SUPER_BLIZZARD;
                break;
            case SUPER_BLIZZARD:
                Available[0] = SUPER_FLAME;
                Available[1] = SUPER_AE;
                break;
            }

            LastSuperSpell = Available[rand()%2];

            switch (LastSuperSpell)
            {
            case SUPER_AE:
                if (rand()%2)
                    DoScriptText(SAY_EXPLOSION1, m_creature);
                else
                    DoScriptText(SAY_EXPLOSION2, m_creature);

                m_creature->CastSpell(m_creature, SPELL_BLINK_CENTER, true);
                m_creature->CastSpell(m_creature, SPELL_PLAYERPULL, true);
                m_creature->CastSpell(m_creature, SPELL_MASSSLOW, true);
                m_creature->CastSpell(m_creature, SPELL_AEXPLOSION, false);
                break;

            case SUPER_FLAME:
                if (rand()%2)
                    DoScriptText(SAY_FLAMEWREATH1, m_creature);
                else
                    DoScriptText(SAY_FLAMEWREATH2, m_creature);

                FlameWreathTimer = 20000;
                FlameWreathCheckTime = 500;

                FlameWreathTarget[0] = 0;
                FlameWreathTarget[1] = 0;
                FlameWreathTarget[2] = 0;

                FlameWreathEffect();
                break;

            case SUPER_BLIZZARD:
                if (rand()%2)
                    DoScriptText(SAY_BLIZZARD1, m_creature);
                else
                    DoScriptText(SAY_BLIZZARD2, m_creature);

                Creature* Spawn = NULL;
                Spawn = DoSpawnCreature(CREATURE_ARAN_BLIZZARD, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 25000);
                if (Spawn)
                {
                    Spawn->setFaction(m_creature->getFaction());
                    Spawn->CastSpell(Spawn, SPELL_CIRCULAR_BLIZZARD, false);
                }
                break;
            }

            SuperCastTimer = 35000 + (rand()%5000);
        } else SuperCastTimer -= diff;

        if (!ElementalsSpawned && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 40)
        {
            ElementalsSpawned = true;

            for (uint32 i = 0; i < 4; i++)
            {
                Creature* pUnit = DoSpawnCreature(CREATURE_WATER_ELEMENTAL, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 90000);
                if (pUnit)
                {
                    pUnit->Attack(m_creature->getVictim(), true);
                    pUnit->setFaction(m_creature->getFaction());
                }
            }

            DoScriptText(SAY_ELEMENTALS, m_creature);
        }

        if (BerserkTimer < diff)
        {
            for (uint32 i = 0; i < 5; i++)
            {
                Creature* pUnit = DoSpawnCreature(CREATURE_SHADOW_OF_ARAN, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                if (pUnit)
                {
                    pUnit->Attack(m_creature->getVictim(), true);
                    pUnit->setFaction(m_creature->getFaction());
                }
            }

            DoScriptText(SAY_TIMEOVER, m_creature);

            BerserkTimer = 60000;
        } else BerserkTimer -= diff;

        //Flame Wreath check
        if (FlameWreathTimer)
        {
            if (FlameWreathTimer >= diff)
                FlameWreathTimer -= diff;
            else FlameWreathTimer = 0;

            if (FlameWreathCheckTime < diff)
            {
                for (uint32 i = 0; i < 3; i++)
                {
                    if (!FlameWreathTarget[i])
                        continue;

                    Unit* pUnit = Unit::GetUnit(*m_creature, FlameWreathTarget[i]);
                    if (pUnit && pUnit->GetDistance2d(FWTargPosX[i], FWTargPosY[i]) > 3)
                    {
                        pUnit->CastSpell(pUnit, 20476, true, 0, 0, m_creature->GetGUID());
                        pUnit->CastSpell(pUnit, 11027, true);
                        FlameWreathTarget[i] = 0;
                    }
                }
                FlameWreathCheckTime = 500;
            } else FlameWreathCheckTime -= diff;
        }

        if (ArcaneCooldown && FireCooldown && FrostCooldown)
            DoMeleeAttackIfReady();
    }