Beispiel #1
0
void BattleGroundMgr::SendToBattleGround(Player *pl, uint32 teamId, uint32 bgId)
{
    uint32 mapid = GetBattleGround(bgId)->GetMapId();
    float x = GetBattleGround(bgId)->GetTeamStartLocX(teamId);
    float y = GetBattleGround(bgId)->GetTeamStartLocY(teamId);
    float z = GetBattleGround(bgId)->GetTeamStartLocZ(teamId);
    float O = GetBattleGround(bgId)->GetTeamStartLocO(teamId);

    sLog.outDetail("BATTLEGROUND: Sending %s to %f,%f,%f,%f", pl->GetName(), x,y,z,O);
    pl->TeleportTo(mapid, x, y, z, O);
    pl->SendInitWorldStates(mapid);
}
Beispiel #2
0
bool CPlayer::SendBattleGroundChat(ChatMsg msgtype, std::string message)
{
    // Select distance to broadcast to.
    float distance = sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_SAY);

    if (msgtype == CHAT_MSG_YELL)
        sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_YELL);
    else if (msgtype == CHAT_MSG_EMOTE)
        sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_TEXTEMOTE);

    BattleGround* pBattleGround = GetBattleGround();

    if (!pBattleGround || pBattleGround->isArena()) // Only fake chat in BG's. CFBG should not interfere with arenas.
        return false;

    for (auto& itr : pBattleGround->GetPlayers())
    {
        if (Player* pPlayer = sObjectMgr.GetPlayer(itr.first))
        {
            if (GetDistance2d(pPlayer->GetPositionX(), pPlayer->GetPositionY()) <= distance)
            {
                WorldPacket data(SMSG_MESSAGECHAT, 200);

                if (GetTeam() == pPlayer->GetTeam())
                    ChatHandler::BuildChatPacket(data, msgtype, message.c_str(), LANG_UNIVERSAL, GetChatTag(), GetObjectGuid(), GetName());
                else if (msgtype != CHAT_MSG_EMOTE)
                    ChatHandler::BuildChatPacket(data, msgtype, message.c_str(), pPlayer->GetOTeam() == ALLIANCE ? LANG_ORCISH : LANG_COMMON, GetChatTag(), GetObjectGuid(), GetName());

                pPlayer->GetSession()->SendPacket(&data);
            }
        }
    }
    return true;
}
Beispiel #3
0
void BattleGroundMgr::AddPlayerToBattleGround(Player *pl, uint32 bgId)
{
    sLog.outDetail("BATTLEGROUND: Added %s to BattleGround.", pl->GetName());
    BattleGround *bg = GetBattleGround(bgId);
    bg->AddPlayer(pl);

}
void BattleGroundMgr::InvitePlayer(Player* plr, uint32 bgInstanceGUID, uint32 team)
{
    // set invited player counters:
    BattleGround* bg = GetBattleGround(bgInstanceGUID);
    if(!bg)
        return;
    bg->IncreaseInvitedCount(team);

    plr->SetInviteForBattleGroundQueueType(BGQueueTypeId(bg->GetTypeID()), bgInstanceGUID);

    // create invite events:
    //add events to player's counters ---- this is not good way - there should be something like global event processor, where we should add those events
    BGQueueInviteEvent* inviteEvent = new BGQueueInviteEvent(plr->GetGUID(), bgInstanceGUID);
    plr->m_Events.AddEvent(inviteEvent, plr->m_Events.CalculateTime(INVITE_ACCEPT_WAIT_TIME/2));
    BGQueueRemoveEvent* removeEvent = new BGQueueRemoveEvent(plr->GetGUID(), bgInstanceGUID, team);
    plr->m_Events.AddEvent(removeEvent, plr->m_Events.CalculateTime(INVITE_ACCEPT_WAIT_TIME));
}
Beispiel #5
0
void CPlayer::RecachePlayersFromBG()
{
    BattleGround* bg = GetBattleGround();

    if (!bg)
        return;

    for (auto& itr : bg->GetPlayers())
    {
        if (Player* player = sObjectMgr.GetPlayer(itr.first))
        {
            if (!player->ToCPlayer()->NativeTeam())
            {
                // Erase bg players from source player cache
                WorldPacket data(SMSG_INVALIDATE_PLAYER, 8);
                data << player->GetObjectGuid();
                GetSession()->SendPacket(&data);
                // Send bg player data to source player
                data = player->ToCPlayer()->BuildNameQuery();
                GetSession()->SendPacket(&data);
            }

            if (!NativeTeam())
            {
                // Erase source player from bg players cache
                WorldPacket data(SMSG_INVALIDATE_PLAYER, 8);
                data << GetObjectGuid();
                player->GetSession()->SendPacket(&data);
                // Send new source data to bg players
                data = BuildNameQuery();
                player->GetSession()->SendPacket(&data);
            }
        }
        else
        {
            // Couldn't find bgplayer, recache him for source player in case he logs in again.
            WorldPacket data(SMSG_INVALIDATE_PLAYER, 8);
            data << itr.first;
            GetSession()->SendPacket(&data);
        }
    }
}
void BattleGroundMgr::SendToBattleGround(Player *pl, uint32 instanceId)
{
    BattleGround *bg = GetBattleGround(instanceId);
    if(bg)
    {
        uint32 mapid = bg->GetMapId();
        float x, y, z, O;
        uint32 team = pl->GetBGTeam();
        if(team==0)
            team = pl->GetTeam();
        bg->GetTeamStartLoc(team, x, y, z, O);

        sLog.outDetail("BATTLEGROUND: Sending %s to map %u, X %f, Y %f, Z %f, O %f", pl->GetName(), mapid, x, y, z, O);
        pl->TeleportTo(mapid, x, y, z, O);
    }
    else
    {
        sLog.outError("player %u trying to port to non-existent bg instance %u",pl->GetGUIDLow(), instanceId);
    }
}