本文整理汇总了C++中BattleGround::AddPlayer方法的典型用法代码示例。如果您正苦于以下问题:C++ BattleGround::AddPlayer方法的具体用法?C++ BattleGround::AddPlayer怎么用?C++ BattleGround::AddPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BattleGround
的用法示例。
在下文中一共展示了BattleGround::AddPlayer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddPlayerToBattleGround
void BattleGroundMgr::AddPlayerToBattleGround(Player *pl, uint32 bgId)
{
sLog.outDetail("BATTLEGROUND: Added %s to BattleGround.", pl->GetName());
BattleGround *bg = GetBattleGround(bgId);
bg->AddPlayer(pl);
}
示例2: HandleBattleGroundPlayerPortOpcode
void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data )
{
CHECK_PACKET_SIZE(recv_data, 1+1+4+2+1);
sLog.outDebug( "WORLD: Recvd CMSG_BATTLEFIELD_PORT Message");
uint8 unk1;
uint8 unk2; // unk, can be 0x0 (may be if was invited?) and 0x1
uint32 bgTypeId; // type id from dbc
uint16 unk; // 0x1F90 constant?
uint8 action; // enter battle 0x1, leave queue 0x0
recv_data >> unk1 >> unk2 >> bgTypeId >> unk >> action;
BattleGround *bg = sBattleGroundMgr.GetBattleGround(bgTypeId);
if(bg)
{
if(_player->InBattleGroundQueue())
{
uint32 queueSlot = 0;
WorldPacket data;
switch(action)
{
case 1: // port to battleground
_player->RemoveFromGroup();
queueSlot = _player->GetBattleGroundQueueIndex(bgTypeId);
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, _player->GetTeam(), queueSlot, STATUS_IN_PROGRESS, 0, bg->GetStartTime());
_player->GetSession()->SendPacket(&data);
// remove battleground queue status from BGmgr
sBattleGroundMgr.m_BattleGroundQueues[bgTypeId].RemovePlayer(_player->GetGUID(), false);
// check if player is not deserter
if( !_player->CanJoinToBattleground() )
{
WorldPacket data2;
data2.Initialize(SMSG_GROUP_JOINED_BATTLEGROUND, 4);
data2 << (uint32) 0xFFFFFFFE;
SendPacket(&data2);
return;
}
_player->SetBattleGroundId(bg->GetTypeID());
sBattleGroundMgr.SendToBattleGround(_player, bgTypeId);
bg->AddPlayer(_player);
break;
case 0: // leave queue
queueSlot = _player->GetBattleGroundQueueIndex(bgTypeId);
_player->RemoveBattleGroundQueueId(bgTypeId); // must be called this way, because if you move this call to queue->removeplayer, it causes bugs
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, _player->GetTeam(), queueSlot, STATUS_NONE, 0, 0);
sBattleGroundMgr.m_BattleGroundQueues[bgTypeId].RemovePlayer(_player->GetGUID(), true);
SendPacket(&data);
break;
default:
sLog.outError("Battleground port: unknown action %u", action);
break;
}
}
}
}
示例3: HandleBattleGroundJoinOpcode
void WorldSession::HandleBattleGroundJoinOpcode( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8);
uint64 guid;
recv_data >> guid; // >> MapID >> Instance;
sLog.outDebug( "WORLD: Recvd CMSG_BATTLEMASTER_JOIN Message from: " I64FMT, guid);
// ignore if we already in BG
if(GetPlayer()->InBattleGround())
return;
// TODO: select bg ID base at bg map_id or use map id as bg ID
uint8 bgID = 1;
// check existance
BattleGround *bg = sBattleGroundMgr.GetBattleGround(bgID);
if(!bg)
return;
// We're in BG.
GetPlayer()->SetBattleGroundId(bgID);
//sBattleGroundMgr.SendBattleGroundStatusPacket(GetPlayer(), sBattleGroundMgr.GetBattleGround(1)->GetMapId(), sBattleGroundMgr.GetBattleGround(1)->GetID(),3);
GetPlayer()->SetBattleGroundEntryPointMap(GetPlayer()->GetMapId());
GetPlayer()->SetBattleGroundEntryPointO(GetPlayer()->GetOrientation());
GetPlayer()->SetBattleGroundEntryPointX(GetPlayer()->GetPositionX());
GetPlayer()->SetBattleGroundEntryPointY(GetPlayer()->GetPositionY());
GetPlayer()->SetBattleGroundEntryPointZ(GetPlayer()->GetPositionZ());
sBattleGroundMgr.SendToBattleGround(GetPlayer(),bgID);
//sBattleGroundMgr.SendBattleGroundStatusPacket(GetPlayer(), sBattleGroundMgr.GetBattleGround(1)->GetMapId(), sBattleGroundMgr.GetBattleGround(1)->GetID(), 0x03, 0x001D2A00);
sBattleGroundMgr.SendBattleGroundStatusPacket(GetPlayer(), sBattleGroundMgr.GetBattleGround(1)->GetMapId(), sBattleGroundMgr.GetBattleGround(bgID)->GetID(), 0x03, 0x00);
// Adding Player to BattleGround id = 0
sLog.outDetail("BATTLEGROUND: Added %s to BattleGround.", GetPlayer()->GetName());
bg->AddPlayer(GetPlayer());
// Bur: Not sure if we would have to send a position/score update.. maybe the client requests this automatically we'll have to see
}
示例4: HandleMoveWorldportAckOpcode
//.........这里部分代码省略.........
// relocate the player to the teleport destination
GetPlayer()->SetMap(MapManager::Instance().CreateMap(loc.mapid, GetPlayer()));
GetPlayer()->Relocate(loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation);
// check this before Map::Add(player), because that will create the instance save!
bool reset_notify = (GetPlayer()->GetBoundInstance(GetPlayer()->GetMapId()) == NULL);
GetPlayer()->SendInitialPacketsBeforeAddToMap();
// the CanEnter checks are done in TeleporTo but conditions may change
// while the player is in transit, for example the map may get full
if(!GetPlayer()->GetMap()->Add(GetPlayer()))
{
//if player wasn't added to map, reset his map pointer!
GetPlayer()->ResetMap();
DEBUG_LOG("WORLD: teleport of player %s (%d) to location %d, %f, %f, %f, %f failed", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation);
// teleport the player home
GetPlayer()->TeleportToHomebind();
return;
}
GetPlayer()->SendInitialPacketsAfterAddToMap();
// flight fast teleport case
if(GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE)
{
if(!_player->InBattleGround())
{
// short preparations to continue flight
FlightPathMovementGenerator* flight = (FlightPathMovementGenerator*)(GetPlayer()->GetMotionMaster()->top());
flight->Reset(*GetPlayer());
return;
}
// battleground state prepare, stop flight
GetPlayer()->GetMotionMaster()->MovementExpired();
GetPlayer()->m_taxi.ClearTaxiDestinations();
}
// resurrect character at enter into instance where his corpse exist after add to map
Corpse *corpse = GetPlayer()->GetCorpse();
if (corpse && corpse->GetType() != CORPSE_BONES && corpse->GetMapId() == GetPlayer()->GetMapId())
{
if( mEntry->IsDungeon() )
{
GetPlayer()->ResurrectPlayer(0.5f);
GetPlayer()->SpawnCorpseBones();
}
}
if(mEntry->IsRaid() && mInstance)
{
if(reset_notify)
{
uint32 timeleft = sInstanceSaveMgr.GetResetTimeFor(GetPlayer()->GetMapId()) - time(NULL);
GetPlayer()->SendInstanceResetWarning(GetPlayer()->GetMapId(), timeleft); // greeting at the entrance of the resort raid instance
}
}
// mount allow check
if(!mEntry->IsMountAllowed())
_player->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED);
// battleground state prepare
// only add to bg group and object, if the player was invited (else he entered through command)
if(_player->InBattleGround() && _player->IsInvitedForBattleGroundInstance(_player->GetBattleGroundId()))
{
BattleGround *bg = _player->GetBattleGround();
if(bg)
{
bg->AddPlayer(_player);
if(bg->GetMapId() == _player->GetMapId()) // we teleported to bg
{
// get the team this way, because arenas might 'override' the teams.
uint32 team = bg->GetPlayerTeam(_player->GetGUID());
if(!team)
team = _player->GetTeam();
if(!bg->GetBgRaid(team)) // first player joined
{
Group *group = new Group;
bg->SetBgRaid(team, group);
group->Create(_player->GetGUIDLow(), _player->GetName());
}
else // raid already exist
{
bg->GetBgRaid(team)->AddMember(_player->GetGUID(), _player->GetName());
}
}
}
}
// honorless target
if(GetPlayer()->pvpInfo.inHostileArea)
GetPlayer()->CastSpell(GetPlayer(), 2479, true);
// resummon pet
GetPlayer()->ResummonPetTemporaryUnSummonedIfAny();
//lets process all delayed operations on successful teleport
GetPlayer()->ProcessDelayedOperations();
}
示例5: HandleMoveWorldportAckOpcode
//.........这里部分代码省略.........
{
sLog.outDebug("WORLD: teleport of player %s (%d) to location %d,%f,%f,%f,%f failed", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.mapid, loc.x, loc.y, loc.z, loc.o);
// teleport the player home
GetPlayer()->SetDontMove(false);
if(!GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation()))
{
// the player must always be able to teleport home
sLog.outError("WORLD: failed to teleport player %s (%d) to homebind location %d,%f,%f,%f,%f!", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation());
assert(false);
}
return;
}
GetPlayer()->SendInitialPacketsAfterAddToMap();
// flight fast teleport case
if(GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType()==FLIGHT_MOTION_TYPE)
{
if(!_player->InBattleGround())
{
// short preparations to continue flight
GetPlayer()->SetDontMove(false);
FlightPathMovementGenerator* flight = (FlightPathMovementGenerator*)(GetPlayer()->GetMotionMaster()->top());
flight->Initialize(*GetPlayer());
return;
}
// battleground state prepare, stop flight
GetPlayer()->GetMotionMaster()->MovementExpired();
GetPlayer()->m_taxi.ClearTaxiDestinations();
}
// resurrect character at enter into instance where his corpse exist after add to map
Corpse *corpse = GetPlayer()->GetCorpse();
if (corpse && corpse->GetType() != CORPSE_BONES && corpse->GetMapId() == GetPlayer()->GetMapId())
{
if( mEntry->IsDungeon() )
{
GetPlayer()->ResurrectPlayer(0.5f);
GetPlayer()->SpawnCorpseBones();
GetPlayer()->SaveToDB();
}
}
if(mEntry->IsRaid() && mInstance)
{
if(reset_notify)
{
uint32 timeleft = sInstanceSaveManager.GetResetTimeFor(GetPlayer()->GetMapId()) - time(NULL);
GetPlayer()->SendInstanceResetWarning(GetPlayer()->GetMapId(), timeleft); // greeting at the entrance of the resort raid instance
}
}
// mount allow check
if(!mEntry->IsMountAllowed())
_player->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED);
// battleground state prepare
// only add to bg group and object, if the player was invited (else he entered through command)
if(_player->InBattleGround() && _player->IsInvitedForBattleGroundInstance(_player->GetBattleGroundId()))
{
BattleGround *bg = _player->GetBattleGround();
if(bg)
{
bg->AddPlayer(_player);
if(bg->GetMapId() == _player->GetMapId()) // we teleported to bg
{
// get the team this way, because arenas might 'override' the teams.
uint32 team = bg->GetPlayerTeam(_player->GetGUID());
if(!team)
team = _player->GetTeam();
if(!bg->GetBgRaid(team)) // first player joined
{
Group *group = new Group;
bg->SetBgRaid(team, group);
group->Create(_player->GetGUIDLow(), _player->GetName());
}
else // raid already exist
{
bg->GetBgRaid(team)->AddMember(_player->GetGUID(), _player->GetName());
}
}
}
}
// honorless target
if(GetPlayer()->pvpInfo.inHostileArea)
GetPlayer()->CastSpell(GetPlayer(), 2479, true);
// resummon pet
if(GetPlayer()->m_temporaryUnsummonedPetNumber)
{
Pet* NewPet = new Pet;
if(!NewPet->LoadPetFromDB(GetPlayer(), 0, GetPlayer()->m_temporaryUnsummonedPetNumber, true))
delete NewPet;
GetPlayer()->m_temporaryUnsummonedPetNumber = 0;
}
GetPlayer()->SetDontMove(false);
}