Example #1
0
void BattleGroundSA::FillInitialWorldStates()
{
    for (uint8 i = 0; i < BG_SA_GRY_MAX; ++i)
    {
        if (m_Gyd[i] == BG_SA_GRAVE_STATUS_HORDE_OCCUPIED || m_Gyd[i] == BG_SA_GRAVE_STATUS_HORDE_CONTESTED)
            _GydOccupied(i, HORDE);
        else if (m_Gyd[i] == BG_SA_GRAVE_STATUS_ALLY_OCCUPIED || m_Gyd[i] == BG_SA_GRAVE_STATUS_ALLY_CONTESTED)
            _GydOccupied(i, ALLIANCE);
    }

    for (uint8 i = 0; i < BG_SA_MAX_WS; ++i)
    {
        FillInitialWorldState(BG_SA_WorldStatusA[i], (GetDefender() == HORDE) ? 1 : 0);
        FillInitialWorldState(BG_SA_WorldStatusH[i], (GetDefender() == HORDE) ? 0 : 1);
    }

    for (uint32 z = 0; z < BG_SA_GATE_MAX; ++z)
    {
        FillInitialWorldState(BG_SA_GateStatus[z], GateStatus[z]);
        if ((z == 0) && (GetDefender() == HORDE))                                               // Ancient gate changes color depending on the defender
            FillInitialWorldState(BG_SA_GateStatus[z], (GateStatus[z] + 3));
    }

    //Time will be sent on first update...
    FillInitialWorldState(BG_SA_ENABLE_TIMER, TimerEnabled ? uint32(1) : uint32(0));
    FillInitialWorldState(BG_SA_TIMER_MINUTES, uint32(0));
    FillInitialWorldState(BG_SA_TIMER_10SEC, uint32(0));
    FillInitialWorldState(BG_SA_TIMER_SEC, uint32(0));
}
Example #2
0
void BattleGroundSA::ResetWorldStates()
{
    for (uint8 i = 0; i < BG_SA_GRY_MAX; ++i)
    {
        if (m_Gyd[i] == BG_SA_GRAVE_STATUS_HORDE_OCCUPIED || m_Gyd[i] == BG_SA_GRAVE_STATUS_HORDE_CONTESTED)
            _GydOccupied(i, HORDE);
        else if (m_Gyd[i] == BG_SA_GRAVE_STATUS_ALLY_OCCUPIED || m_Gyd[i] == BG_SA_GRAVE_STATUS_ALLY_CONTESTED)
            _GydOccupied(i, ALLIANCE);
    }

    // beach graveyard
    _GydOccupied(SA_EVENT_ADD_GRAVE_B, (GetDefender() == HORDE) ? ALLIANCE : HORDE);

    // Reset world-state of gates
    for (uint32 z = 0; z < BG_SA_GATE_MAX; ++z)
    {
        UpdateWorldState(BG_SA_GateStatus[z], GateStatus[z]);
        if ((z == 0) && (GetDefender() == HORDE))
            UpdateWorldState(BG_SA_GateStatus[z], (GateStatus[z] + 3));
    }

    for (uint8 i = 0; i < BG_SA_MAX_WS; ++i)
    {
        UpdateWorldState(BG_SA_WorldStatusA[i], (GetDefender() == HORDE) ? 1 : 0);
        UpdateWorldState(BG_SA_WorldStatusH[i], (GetDefender() == HORDE) ? 0 : 1);
    }
}
Example #3
0
void BattleGroundSA::UpdatePhase()
{
    ResetWorldStates();

    if (Phase == SA_ROUND_TWO)
    {
        SpawnEvent(SA_EVENT_ADD_VECH_E, 0, false);
        SpawnEvent(SA_EVENT_ADD_VECH_W, 0, false);
        SpawnEvent(SA_EVENT_ADD_BOMB, 0, false);
        SpawnEvent(SA_EVENT_ADD_BOMB, 1, false);
        SpawnEvent(SA_EVENT_ADD_NPC, 0, false);
        OpenDoorEvent(SA_EVENT_OP_DOOR, 0);
        SpawnEvent(SA_EVENT_ADD_BOMB, 0, true);
    }

    _GydOccupied(3,GetDefender());

    if(Phase == SA_ROUND_ONE)
    {
        SpawnEvent(SA_EVENT_ADD_SPIR, BG_SA_GARVE_STATUS_HORDE_OCCUPIED, false);
        SpawnEvent(SA_EVENT_ADD_SPIR, BG_SA_GARVE_STATUS_ALLY_OCCUPIED, true);

        m_ActiveEvents[5] = GetDefender() == ALLIANCE ? BG_SA_GARVE_STATUS_ALLY_OCCUPIED : BG_SA_GARVE_STATUS_HORDE_OCCUPIED;

        for (uint8 i = 0; i < BG_SA_GRY_MAX; ++i)
        {
            for (uint8 z = 1; z < 5; ++z)
                SpawnEvent(i, z, false);

            m_prevGyd[i] = 0;
            m_GydTimers[i] = 0;
            m_BannerTimers[i].timer = 0;
            SpawnEvent(i, 3, true); 
            m_Gyd[i] = GetDefender() == ALLIANCE ? BG_SA_GARVE_STATUS_ALLY_OCCUPIED : BG_SA_GARVE_STATUS_HORDE_OCCUPIED;
            m_ActiveEvents[i] = GetDefender() == ALLIANCE ? BG_SA_GARVE_STATUS_ALLY_OCCUPIED : BG_SA_GARVE_STATUS_HORDE_OCCUPIED;
            _GydOccupied(i,GetDefender());
        }

        SpawnEvent(SA_EVENT_ADD_BOMB, 1, true);
        //SpawnEvent(SA_EVENT_ADD_NPC, 0, true);
    }
    // We already do it at ResetWorldStates
    /*for (uint32 z = 0; z <= BG_SA_GATE_MAX; ++z)
        UpdateWorldState(BG_SA_GateStatus[z], GateStatus[z]);*/

    if (Phase == SA_ROUND_TWO)
    {
        Round_timer = 0;
        SetStatus(STATUS_WAIT_JOIN);
        SendMessageToAll(LANG_BG_SA_START_TWO_MINUTE, CHAT_MSG_BG_SYSTEM_NEUTRAL, NULL);
    }

    SpawnEvent(SA_EVENT_ADD_GO, 0, false);
    SpawnEvent(SA_EVENT_ADD_GO, 0, true);
}
Example #4
0
void BattleGroundSA::UpdatePhase()
{
    if (Phase == SA_ROUND_TWO)
    {
        SpawnEvent(SA_EVENT_ADD_VECH_E, 0, false);
        SpawnEvent(SA_EVENT_ADD_VECH_W, 0, false);
        SpawnEvent(SA_EVENT_ADD_BOMB, 0, false);
        SpawnEvent(SA_EVENT_ADD_BOMB, 1, false);
        SpawnEvent(SA_EVENT_ADD_BOMB1, 0, false);
        SpawnEvent(SA_EVENT_ADD_BOMB1, 1, false);
        SpawnEvent(SA_EVENT_ADD_BOMB2, 0, false);
        SpawnEvent(SA_EVENT_ADD_BOMB2, 1, false);
        SpawnEvent(SA_EVENT_ADD_BOMB3, 0, false);
        SpawnEvent(SA_EVENT_ADD_BOMB3, 1, false);
        SpawnEvent(SA_EVENT_ADD_NPC, 0, false);
        SpawnEvent(BG_EVENT_DOOR, 0, true);

        Round_timer = 0;
        SetStatus(STATUS_WAIT_JOIN);
        SendMessageToAll(LANG_BG_SA_START_TWO_MINUTE, CHAT_MSG_BG_SYSTEM_NEUTRAL, NULL);
    }

    _GydOccupied(3, GetDefender() == HORDE ? ALLIANCE : HORDE);

    SpawnEvent(SA_EVENT_ADD_SPIR, BG_SA_GARVE_STATUS_HORDE_OCCUPIED, GetDefender() == ALLIANCE ? false : true);
    SpawnEvent(SA_EVENT_ADD_SPIR, BG_SA_GARVE_STATUS_ALLY_OCCUPIED, GetDefender() == ALLIANCE ? true : false);

    m_ActiveEvents[5] = GetDefender() == ALLIANCE ? BG_SA_GARVE_STATUS_ALLY_OCCUPIED : BG_SA_GARVE_STATUS_HORDE_OCCUPIED;

    for (uint8 i = 0; i < BG_SA_GRY_MAX; ++i)
    {
        for (uint8 z = 1; z < 5; ++z)
        {
            SpawnEvent(i, z, false);
        }
        m_prevGyd[i] = 0;
        m_GydTimers[i] = 0;
        m_BannerTimers[i].timer = 0;
        SpawnEvent(i, GetDefender() == ALLIANCE ? 3 : 4, true);
        m_Gyd[i] = GetDefender() == ALLIANCE ? BG_SA_GARVE_STATUS_ALLY_OCCUPIED : BG_SA_GARVE_STATUS_HORDE_OCCUPIED;
        m_ActiveEvents[i] = GetDefender() == ALLIANCE ? BG_SA_GARVE_STATUS_ALLY_OCCUPIED : BG_SA_GARVE_STATUS_HORDE_OCCUPIED;
        _GydOccupied(i,GetDefender() == ALLIANCE ? ALLIANCE : HORDE);
    }

    for (uint32 z = 0; z <= BG_SA_GATE_MAX; ++z)
        UpdateWorldState(BG_SA_GateStatus[z], GateStatus[z]);

    SpawnEvent(SA_EVENT_ADD_GO, 0, false);
    SpawnEvent(SA_EVENT_ADD_GO, 0, true);
}
Example #5
0
void BattleGroundSA::EventPlayerClickedOnFlag(Player *source, GameObject* target_obj)
{
    if (GetStatus() != STATUS_IN_PROGRESS)
        return;

    uint8 objectEvent = (sBattleGroundMgr.GetGameObjectEventIndex(target_obj->GetGUIDLow())).event1;
    if (objectEvent >= BG_SA_GRY_MAX)                           // not a node
        return;

    BG_SA_Events gyd = BG_SA_Events(objectEvent);

    TeamIndex teamIndex = GetTeamIndex(source->GetTeam());

    //make the new banner not capturable by defenders
    m_Gyd[gyd] = BG_SA_GRAVE_STATUS_OCCUPIED + teamIndex;
    // create new occupied banner
    _CreateBanner(gyd, (GetDefender() == ALLIANCE ? BG_SA_GRAVE_STATUS_HORDE_OCCUPIED : BG_SA_GRAVE_STATUS_ALLY_OCCUPIED), teamIndex, true);
    // make the new occupied banner not clickable by anyone
    MakeInteractive(gyd, (GetDefender() == ALLIANCE) ? BG_SA_GRAVE_STATUS_HORDE_OCCUPIED : BG_SA_GRAVE_STATUS_ALLY_OCCUPIED, false);
    _GydOccupied(gyd, (teamIndex == 0) ? ALLIANCE : HORDE);

    RewardHonorToTeam(85, (teamIndex == 0) ? ALLIANCE : HORDE);
    RewardXpToTeam(0, 0.6f, (teamIndex == 0) ? ALLIANCE : HORDE);

    if (teamIndex == TEAM_INDEX_ALLIANCE)
    {
        SendWarningToAllSA(gyd, ALLIANCE);
        PlaySoundToAll(BG_SA_SOUND_GYD_CAPTURED_ALLIANCE);
    }
    else
    {
        SendWarningToAllSA(gyd, HORDE);
        PlaySoundToAll(BG_SA_SOUND_GYD_CAPTURED_HORDE);
    }
    switch(gyd)
    {
        // east base
        case SA_EVENT_ADD_GRAVE_E:
            SpawnEvent(SA_EVENT_ADD_VECH_E, 0, true);
            SpawnEvent(SA_EVENT_ADD_BOMB_E, (GetDefender() == ALLIANCE) ? BG_SA_GRAVE_STATUS_HORDE_OCCUPIED : BG_SA_GRAVE_STATUS_ALLY_OCCUPIED, true);
            break;
        // west base
        case SA_EVENT_ADD_GRAVE_W:
            SpawnEvent(SA_EVENT_ADD_VECH_W, 0, true);
            SpawnEvent(SA_EVENT_ADD_BOMB_W, (GetDefender() == ALLIANCE) ? BG_SA_GRAVE_STATUS_HORDE_OCCUPIED : BG_SA_GRAVE_STATUS_ALLY_OCCUPIED, true);
            break;
        // central base
        case SA_EVENT_ADD_GRAVE_C:
            SpawnEvent(SA_EVENT_ADD_BOMB_C, (GetDefender() == ALLIANCE) ? BG_SA_GRAVE_STATUS_HORDE_OCCUPIED : BG_SA_GRAVE_STATUS_ALLY_OCCUPIED, true);
            break;
        default:
            break;
    }
}
Example #6
0
void BattleGroundSA::FillInitialWorldStates(WorldPacket& data, uint32& count)
{
    for (uint8 i = 0; i < BG_SA_GRY_MAX; ++i)
    {
        if (m_Gyd[i] == BG_SA_GARVE_STATUS_HORDE_OCCUPIED)
            _GydOccupied(i,HORDE);
        else if (m_Gyd[i] == BG_SA_GARVE_STATUS_ALLY_OCCUPIED)
            _GydOccupied(i,ALLIANCE);
    }
    if (GetDefender() == HORDE)
        _GydOccupied(3,HORDE);
    else
        _GydOccupied(3,ALLIANCE);

    for (uint32 z = 0; z <= BG_SA_GATE_MAX; ++z)
        FillInitialWorldState(data, count, BG_SA_GateStatus[z], GateStatus[z]);

    //Time will be sent on first update...
    FillInitialWorldState(data, count, BG_SA_ENABLE_TIMER, TimerEnabled ? uint32(1) : uint32(0));
    FillInitialWorldState(data, count, BG_SA_TIMER_MINUTES, uint32(0));
    FillInitialWorldState(data, count, BG_SA_TIMER_10SEC, uint32(0));
    FillInitialWorldState(data, count, BG_SA_TIMER_SEC, uint32(0));
}
Example #7
0
void BattleGroundSA::Update(uint32 diff)
{
    BattleGround::Update(diff);

    if (GetStatus() == STATUS_WAIT_JOIN && !shipsStarted)
        if (Phase == SA_ROUND_ONE) // Round one not started yet
            if (shipsTimer <= diff)
                StartShips();
            else
                shipsTimer -= diff;

    if (GetStatus() == STATUS_IN_PROGRESS) // Battleground already in progress
    {
        if (Round_timer >= BG_SA_ROUNDLENGTH)
        {
            if(Phase == SA_ROUND_ONE) // Timeout of second round
            {
                PlaySoundToAll(BG_SA_SOUND_GYD_VICTORY);
                SendMessageToAll(defender == ALLIANCE ? LANG_BG_SA_ALLIANCE_TIMEOUT_END_1ROUND : LANG_BG_SA_HORDE_TIMEOUT_END_1ROUND, CHAT_MSG_BG_SYSTEM_NEUTRAL, NULL);
                RoundScores[0].winner = GetDefender();
                RoundScores[0].time = Round_timer;
				ResetBattle(0, defender);
            }
            else // Timeout of second round
            {
                SendMessageToAll(defender == ALLIANCE ? LANG_BG_SA_ALLIANCE_TIMEOUT_END_2ROUND : LANG_BG_SA_HORDE_TIMEOUT_END_2ROUND, CHAT_MSG_BG_SYSTEM_NEUTRAL, NULL);
                RoundScores[1].winner = GetDefender();
                RoundScores[1].time = Round_timer;
				EndBattleGround(TEAM_NONE);
                return;
            }
        } 
        else
            Round_timer += diff;

        for (int gyd = 0; gyd < BG_SA_GRY_MAX; ++gyd)
        {
            // 3 sec delay to spawn new banner instead previous despawned one
            if (m_BannerTimers[gyd].timer)
            {
                if (m_BannerTimers[gyd].timer > diff)
                    m_BannerTimers[gyd].timer -= diff;
                else
                {
                    m_BannerTimers[gyd].timer = 0;
                    _CreateBanner(gyd, m_BannerTimers[gyd].type, m_BannerTimers[gyd].teamIndex, false);
                }
            }
            // 1-minute to occupy a node from contested state
            if (m_GydTimers[gyd])
            {
                if (m_GydTimers[gyd] > diff)
                    m_GydTimers[gyd] -= diff;
                else
                {
                    m_GydTimers[gyd] = 0;
                    // Change from contested to occupied !
                    uint8 teamIndex = m_Gyd[gyd]-1;
                    m_prevGyd[gyd] = m_Gyd[gyd];
                    m_Gyd[gyd] += 2;
                    // create new occupied banner
                    _CreateBanner(gyd, BG_SA_GARVE_TYPE_OCCUPIED, teamIndex, true);
                    //_SendNodeUpdate(node);
                    _GydOccupied(gyd,(teamIndex == 0) ? ALLIANCE:HORDE);
                    // Message to chatlog
                    RewardHonorToTeam(85, (teamIndex == 0) ? ALLIANCE:HORDE);
                    RewardXpToTeam(0, 0.6f, (teamIndex == 0) ? ALLIANCE:HORDE);
                    RewardReputationToTeam((teamIndex == 0) ? 1050:1085, 65, (teamIndex == 0) ? ALLIANCE:HORDE);
                    switch(gyd)
                    {
                        case 0: SpawnEvent(SA_EVENT_ADD_VECH_W, 0, true);break;
                        case 1: SpawnEvent(SA_EVENT_ADD_VECH_E, 0, true);break;
                    }
                    if (teamIndex == 0)
                    {
                        // SendMessage2ToAll(LANG_BG_SA_AH_SEIZES_GRAVEYARD,CHAT_MSG_BG_SYSTEM_ALLIANCE,NULL,LANG_BG_ALLY,_GydName(gyd));
                        PlaySoundToAll(BG_SA_SOUND_GYD_CAPTURED_ALLIANCE);
                        SendWarningToAllSA(gyd, STATUS_CONQUESTED, ALLIANCE);
                    }
                    else
                    {
                        // SendMessage2ToAll(LANG_BG_SA_AH_SEIZES_GRAVEYARD,CHAT_MSG_BG_SYSTEM_HORDE,NULL,LANG_BG_HORDE,_GydName(gyd));
                        PlaySoundToAll(BG_SA_SOUND_GYD_CAPTURED_HORDE);
                        SendWarningToAllSA(gyd, STATUS_CONQUESTED, HORDE);
                    }
                }
            }
        }
        UpdateTimer();
    }
    if (GetStatus() == STATUS_WAIT_JOIN && Phase == SA_ROUND_TWO) // Round two, not yet started
    {
        if (!shipsStarted)
            if (shipsTimer <= diff)
            {
                SendMessageToAll(LANG_BG_SA_START_ONE_MINUTE, CHAT_MSG_BG_SYSTEM_NEUTRAL, NULL);
                StartShips();
            }
            else
                shipsTimer -= diff;
        if (TimeST2Round < diff)
        {
            Phase = 2;
            OpenDoorEvent(SA_EVENT_OP_DOOR, 0);
			SpawnEvent(SA_EVENT_ADD_NPC, 0, true);
            ToggleTimer();
            SetStatus(STATUS_IN_PROGRESS); // Start round two
            PlaySoundToAll(SOUND_BG_START);
            SendMessageToAll(LANG_BG_SA_HAS_BEGUN, CHAT_MSG_BG_SYSTEM_NEUTRAL, NULL);
            SendWarningToAll(LANG_BG_SA_HAS_BEGUN);
        }
        else
            TimeST2Round -= diff;
    }
}